Fork me on GitHub

root/kernel/syscalls/setdomainname.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. sys_setdomainname

   1 /*
   2  * fiwix/kernel/syscalls/setdomainname.c
   3  *
   4  * Copyright 2018, Jordi Sanfeliu. All rights reserved.
   5  * Distributed under the terms of the Fiwix License.
   6  */
   7 
   8 #include <fiwix/fs.h>
   9 #include <fiwix/utsname.h>
  10 #include <fiwix/errno.h>
  11 #include <fiwix/string.h>
  12 
  13 #ifdef __DEBUG__
  14 #include <fiwix/stdio.h>
  15 #include <fiwix/process.h>
  16 #endif /*__DEBUG__ */
  17 
  18 int sys_setdomainname(const char *name, int length)
  19 {
  20         int errno;
  21 
  22 #ifdef __DEBUG__
  23         printk("(pid %d) sys_setdomainname('%s', %d)\n", current->pid, name, length);
  24 #endif /*__DEBUG__ */
  25 
  26         if((errno = check_user_area(VERIFY_READ, name, length))) {
  27                 return errno;
  28         }
  29         if(!IS_SUPERUSER) {
  30                 return -EPERM;
  31         }
  32         if(length < 0 || length > _UTSNAME_LENGTH) {
  33                 return -EINVAL;
  34         }
  35         memcpy_b(&sys_utsname.domainname, name, length);
  36         sys_utsname.domainname[length] = NULL;
  37         return 0;
  38 }

/* [previous][next][first][last][top][bottom][index][help] */