1: #
   2: /*
   3:  */
   4: 
   5: /*
   6:  * Everything in this file is a routine implementing a system call.
   7:  */
   8: 
   9: #include "../param.h"
  10: #include "../user.h"
  11: #include "../reg.h"
  12: #include "../inode.h"
  13: #include "../systm.h"
  14: #include "../proc.h"
  15: 
  16: getswit()
  17: {
  18: 
  19:     u.u_ar0[R0] = SW->integ;
  20: }
  21: 
  22: gtime()
  23: {
  24: 
  25:     u.u_ar0[R0] = time[0];
  26:     u.u_ar0[R1] = time[1];
  27: }
  28: 
  29: stime()
  30: {
  31: 
  32:     if(suser()) {
  33:         time[0] = u.u_ar0[R0];
  34:         time[1] = u.u_ar0[R1];
  35:         wakeup(tout);
  36:     }
  37: }
  38: 
  39: setuid()
  40: {
  41:     register uid;
  42: 
  43:     uid = u.u_ar0[R0].lobyte;
  44:     if(u.u_ruid == uid.lobyte || suser()) {
  45:         u.u_uid = uid;
  46:         u.u_procp->p_uid = uid;
  47:         u.u_ruid = uid;
  48:     }
  49: }
  50: 
  51: getuid()
  52: {
  53: 
  54:     u.u_ar0[R0].lobyte = u.u_ruid;
  55:     u.u_ar0[R0].hibyte = u.u_uid;
  56: }
  57: 
  58: setgid()
  59: {
  60:     register gid;
  61: 
  62:     gid = u.u_ar0[R0].lobyte;
  63:     if(u.u_rgid == gid.lobyte || suser()) {
  64:         u.u_gid = gid;
  65:         u.u_rgid = gid;
  66:     }
  67: }
  68: 
  69: getgid()
  70: {
  71: 
  72:     u.u_ar0[R0].lobyte = u.u_rgid;
  73:     u.u_ar0[R0].hibyte = u.u_gid;
  74: }
  75: 
  76: getpid()
  77: {
  78:     u.u_ar0[R0] = u.u_procp->p_pid;
  79: }
  80: 
  81: sync()
  82: {
  83: 
  84:     update();
  85: }
  86: 
  87: nice()
  88: {
  89:     register n;
  90: 
  91:     n = u.u_ar0[R0];
  92:     if(n > 20)
  93:         n = 20;
  94:     if(n < 0 && !suser())
  95:         n = 0;
  96:     u.u_procp->p_nice = n;
  97: }
  98: 
  99: /*
 100:  * Unlink system call.
 101:  * panic: unlink -- "cannot happen"
 102:  */
 103: unlink()
 104: {
 105:     register *ip, *pp;
 106:     extern uchar;
 107: 
 108:     pp = namei(&uchar, 2);
 109:     if(pp == NULL)
 110:         return;
 111:     prele(pp);
 112:     ip = iget(pp->i_dev, u.u_dent.u_ino);
 113:     if(ip == NULL)
 114:         panic("unlink -- iget");
 115:     if((ip->i_mode&IFMT)==IFDIR && !suser())
 116:         goto out;
 117:     u.u_offset[1] =- DIRSIZ+2;
 118:     u.u_base = &u.u_dent;
 119:     u.u_count = DIRSIZ+2;
 120:     u.u_dent.u_ino = 0;
 121:     writei(pp);
 122:     ip->i_nlink--;
 123:     ip->i_flag =| IUPD;
 124: 
 125: out:
 126:     iput(pp);
 127:     iput(ip);
 128: }
 129: 
 130: chdir()
 131: {
 132:     register *ip;
 133:     extern uchar;
 134: 
 135:     ip = namei(&uchar, 0);
 136:     if(ip == NULL)
 137:         return;
 138:     if((ip->i_mode&IFMT) != IFDIR) {
 139:         u.u_error = ENOTDIR;
 140:     bad:
 141:         iput(ip);
 142:         return;
 143:     }
 144:     if(access(ip, IEXEC))
 145:         goto bad;
 146:     iput(u.u_cdir);
 147:     u.u_cdir = ip;
 148:     prele(ip);
 149: }
 150: 
 151: chmod()
 152: {
 153:     register *ip;
 154: 
 155:     if ((ip = owner()) == NULL)
 156:         return;
 157:     ip->i_mode =& ~07777;
 158:     if (u.u_uid)
 159:         u.u_arg[1] =& ~ISVTX;
 160:     ip->i_mode =| u.u_arg[1]&07777;
 161:     ip->i_flag =| IUPD;
 162:     iput(ip);
 163: }
 164: 
 165: chown()
 166: {
 167:     register *ip;
 168: 
 169:     if (!suser() || (ip = owner()) == NULL)
 170:         return;
 171:     ip->i_uid = u.u_arg[1].lobyte;
 172:     ip->i_gid = u.u_arg[1].hibyte;
 173:     ip->i_flag =| IUPD;
 174:     iput(ip);
 175: }
 176: 
 177: /*
 178:  * Change modified date of file:
 179:  * time to r0-r1; sys smdate; file
 180:  * This call has been withdrawn because it messes up
 181:  * incremental dumps (pseudo-old files aren't dumped).
 182:  * It works though and you can uncomment it if you like.
 183: 
 184: smdate()
 185: {
 186: 	register struct inode *ip;
 187: 	register int *tp;
 188: 	int tbuf[2];
 189: 
 190: 	if ((ip = owner()) == NULL)
 191: 		return;
 192: 	ip->i_flag =| IUPD;
 193: 	tp = &tbuf[2];
 194: 	*--tp = u.u_ar0[R1];
 195: 	*--tp = u.u_ar0[R0];
 196: 	iupdat(ip, tp);
 197: 	ip->i_flag =& ~IUPD;
 198: 	iput(ip);
 199: }
 200: */
 201: 
 202: ssig()
 203: {
 204:     register a;
 205: 
 206:     a = u.u_arg[0];
 207:     if(a<=0 || a>=NSIG || a ==SIGKIL) {
 208:         u.u_error = EINVAL;
 209:         return;
 210:     }
 211:     u.u_ar0[R0] = u.u_signal[a];
 212:     u.u_signal[a] = u.u_arg[1];
 213:     if(u.u_procp->p_sig == a)
 214:         u.u_procp->p_sig = 0;
 215: }
 216: 
 217: kill()
 218: {
 219:     register struct proc *p, *q;
 220:     register a;
 221:     int f;
 222: 
 223:     f = 0;
 224:     a = u.u_ar0[R0];
 225:     q = u.u_procp;
 226:     for(p = &proc[0]; p < &proc[NPROC]; p++) {
 227:         if(p == q)
 228:             continue;
 229:         if(a != 0 && p->p_pid != a)
 230:             continue;
 231:         if(a == 0 && (p->p_ttyp != q->p_ttyp || p <= &proc[1]))
 232:             continue;
 233:         if(u.u_uid != 0 && u.u_uid != p->p_uid)
 234:             continue;
 235:         f++;
 236:         psignal(p, u.u_arg[0]);
 237:     }
 238:     if(f == 0)
 239:         u.u_error = ESRCH;
 240: }
 241: 
 242: times()
 243: {
 244:     register *p;
 245: 
 246:     for(p = &u.u_utime; p  < &u.u_utime+6;) {
 247:         suword(u.u_arg[0], *p++);
 248:         u.u_arg[0] =+ 2;
 249:     }
 250: }
 251: 
 252: profil()
 253: {
 254: 
 255:     u.u_prof[0] = u.u_arg[0] & ~1;  /* base of sample buf */
 256:     u.u_prof[1] = u.u_arg[1];   /* size of same */
 257:     u.u_prof[2] = u.u_arg[2];   /* pc offset */
 258:     u.u_prof[3] = (u.u_arg[3]>>1) & 077777; /* pc scale */
 259: }

Defined functions

chdir defined in line 130; never used
chmod defined in line 151; never used
chown defined in line 165; never used
getgid defined in line 69; never used
getpid defined in line 76; never used
getswit defined in line 16; never used
getuid defined in line 51; never used
gtime defined in line 22; never used
kill defined in line 217; never used
nice defined in line 87; never used
profil defined in line 252; never used
setgid defined in line 58; never used
setuid defined in line 39; never used
ssig defined in line 202; never used
stime defined in line 29; never used
sync defined in line 81; never used
times defined in line 242; never used
unlink defined in line 103; never used
Last modified: 1975-07-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1462
Valid CSS Valid XHTML 1.0 Strict