Plan 9 from Bell Labs’s /usr/web/sources/contrib/cinap_lenrek/old/linuxemu.old/sysmisc.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>
#include <ureg.h>
#include "linuxsys.h"
#include "linux.h"

/*
 * Try to set ``personality'', a system-emulation thing.
 * 0 is Linux.
 */
SYSCALL(sys_personality)
{
	ulong p = ARG1;

	DPRINT("personality(%lud)...", p);
	if(p != 0 && p != 0xffffffff)
		RETURN(-EINVAL);
	RETURN(0);
}

struct new_utsname
{
	char sysname[65];
	char nodename[65];
	char release[65];
	char version[65];
	char machine[65];
	char domainname[65];
};

SYSCALL(sys_newuname)
{
	struct new_utsname	*p;

	p = (struct new_utsname*)ARG1;

	DPRINT("newuname(0x%p)...", p);

	strncpy(p->sysname, "Linux", 65);
	strncpy(p->nodename, sysname(), 65);
	strncpy(p->release, "2.6.11", 65);
	strncpy(p->version, "blah", 65);
	strncpy(p->machine, "i386", 65);
	strncpy(p->domainname, sysname(), 65);

	RETURN(0);
}

SYSCALL(sys_sethostname)
{
	RETURN(-EPERM);
}

SYSCALL(sys_setdomainname)
{
	RETURN(-EPERM);
}

SYSCALL(sys_time)
{
	long *p = (long*)ARG1;

	DPRINT("time()...");
	RETURN(time(p));
}

struct timeval
{
	long	tv_sec;
	long	tv_usec;
};

struct timezone
{
	int		tz_minuteswest;
	int		tz_dsttime;
};

SYSCALL(sys_gettimeofday)
{
	struct timeval *tv;
	struct timezone *tz;

	vlong t;

	tv = (struct timeval*)ARG1;
	tz = (struct timezone*)ARG2;

	DPRINT("gettimeofday(0x%p, 0x%p)...", tv, tz);

	t = nsec();
	tv->tv_sec = (long)(t/1000000000LL);
	tv->tv_usec = (long)((t%1000000000LL)/1000);

	if(tz){
		// FIXME: figure out what this is
		tz->tz_minuteswest = 0;
		tz->tz_dsttime = 0;
	}
	RETURN(0);
}

struct timespec
{
	long	tv_sec;
	long	tvnsec;
};

SYSCALL(sys_nanosleep)
{
	struct timespec *req;
	struct timespec *rem;
	vlong t;
	vlong s;
	int r;

	DPRINT("nanosleep()...");

	req = (struct timespec*)ARG1;
	rem = (struct timespec*)ARG2;
	s = nsec();
	t = req->tv_sec*1000000000LL + req->tvnsec;
	r = sleep((long)(t/1000000LL));
	if(r < 0 && rem){
		t = t - (nsec() - s);
		if(t < 0)
			t = 0;
		rem->tv_sec = (long)(t/1000000000LL);
		rem->tvnsec = (long)(t%1000000000LL);
	}
	RETURN(r);
}


SYSCALL(sys_sched_setscheduler)
{
	DPRINT("sched_setscheduler()...");
	RETURN(-EPERM);
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.