shithub: riscv

ref: d9b9e15d6bbdae625b3613bb0a704d269cc83098
dir: /sys/src/libc/port/getuser.c/

View raw version
#include <u.h>
#include <libc.h>

char *
getuser(void)
{
	static char user[64];
	int fd;
	int n;

	fd = open("/dev/user", OREAD);
	if(fd < 0)
		return "none";
	n = read(fd, user, (sizeof user)-1);
	close(fd);
	if(n <= 0)
		strcpy(user, "none");
	else
		user[n] = 0;
	return user;
}