shithub: riscv

ref: 9c0d74e03620811e9a5c0a697a849f9c3551e9bf
dir: /sys/src/libc/9sys/sysname.c/

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

char*
sysname(void)
{
	int f, n;
	static char b[128];

	if(b[0])
		return b;

	f = open("/dev/sysname", OREAD|OCEXEC);
	if(f >= 0) {
		n = read(f, b, sizeof(b)-1);
		if(n > 0)
			b[n] = 0;
		close(f);
	}
	return b;
}