/* Set the current time of day and timezone information. This call is restricted to the super-user. */ int __settimeofday (const struct timeval *tv, const struct timezone *tz) { error_t err; mach_port_t hostpriv; if (tz != NULL) { errno = ENOSYS; return -1; } err = __get_privileged_ports (&hostpriv, NULL); if (err) return __hurd_fail (EPERM); /* `time_value_t' and `struct timeval' are in fact identical with the names changed. */ err = __host_set_time (hostpriv, *(time_value_t *) tv); __mach_port_deallocate (__mach_task_self (), hostpriv); if (err) return __hurd_fail (err); return 0; }
int ioperm (unsigned long int from, unsigned long int num, int turn_on) { #if ! HAVE_I386_IO_PERM_MODIFY return __hurd_fail (ENOSYS); #else error_t err; device_t devmaster; /* With the device master port we get a capability that represents this range of io ports. */ err = __get_privileged_ports (NULL, &devmaster); if (! err) { io_perm_t perm; err = __i386_io_perm_create (devmaster, from, from + num - 1, &perm); __mach_port_deallocate (__mach_task_self (), devmaster); if (! err) { /* Now we add or remove that set from our task's bitmap. */ err = __i386_io_perm_modify (__mach_task_self (), perm, turn_on); __mach_port_deallocate (__mach_task_self (), perm); } if (err == MIG_BAD_ID) /* Old kernels don't have these RPCs. */ err = ENOSYS; } return err ? __hurd_fail (err) : 0; #endif }
int mlock (const void *addr, size_t len) { mach_port_t hostpriv; vm_address_t page; error_t err; err = __get_privileged_ports (&hostpriv, NULL); if (err) return __hurd_fail (EPERM); page = trunc_page ((vm_address_t) addr); len = round_page ((vm_address_t) addr + len) - page; err = __vm_wire (hostpriv, __mach_task_self (), page, len, VM_PROT_READ); __mach_port_deallocate (__mach_task_self (), hostpriv); return err ? __hurd_fail (err) : 0; }