Annotation of linux/kernel/sys.c, revision 1.1.1.8

1.1.1.2   root        1: /*
                      2:  *  linux/kernel/sys.c
                      3:  *
                      4:  *  (C) 1991  Linus Torvalds
                      5:  */
                      6: 
1.1       root        7: #include <errno.h>
                      8: 
                      9: #include <linux/sched.h>
                     10: #include <linux/tty.h>
                     11: #include <linux/kernel.h>
1.1.1.3   root       12: #include <linux/config.h>
1.1       root       13: #include <asm/segment.h>
                     14: #include <sys/times.h>
1.1.1.7   root       15: #include <linux/utsname.h>
1.1.1.3   root       16: #include <sys/param.h>
                     17: #include <sys/resource.h>
1.1.1.6   root       18: #include <linux/string.h>
1.1.1.3   root       19: 
1.1.1.4   root       20: /*
                     21:  * this indicates wether you can reboot with ctrl-alt-del: the deault is yes
                     22:  */
                     23: static int C_A_D = 1;
                     24: 
1.1.1.3   root       25: /* 
                     26:  * The timezone where the local system is located.  Used as a default by some
                     27:  * programs who obtain this value by using gettimeofday.
                     28:  */
                     29: struct timezone sys_tz = { 0, 0};
                     30: 
                     31: extern int session_of_pgrp(int pgrp);
1.1       root       32: 
1.1.1.6   root       33: #define        PZERO   15
                     34: 
                     35: static int proc_sel(struct task_struct *p, int which, int who)
                     36: {
                     37:        switch (which) {
                     38:                case PRIO_PROCESS:
                     39:                        if (!who && p == current)
                     40:                                return 1;
                     41:                        return(p->pid == who);
                     42:                case PRIO_PGRP:
                     43:                        if (!who)
                     44:                                who = current->pgrp;
                     45:                        return(p->pgrp == who);
                     46:                case PRIO_USER:
                     47:                        if (!who)
                     48:                                who = current->uid;
                     49:                        return(p->uid == who);
                     50:        }
                     51:        return 0;
                     52: }
                     53: 
                     54: int sys_setpriority(int which, int who, int niceval)
                     55: {
                     56:        struct task_struct **p;
                     57:        int error = ESRCH;
                     58:        int priority;
                     59: 
                     60:        if (which > 2 || which < 0)
                     61:                return -EINVAL;
                     62: 
                     63:        if ((priority = PZERO - niceval) <= 0)
                     64:                priority = 1;
                     65: 
                     66:        for(p = &LAST_TASK; p > &FIRST_TASK; --p) {
                     67:                if (!*p || !proc_sel(*p, which, who))
                     68:                        continue;
                     69:                if ((*p)->uid != current->euid &&
                     70:                        (*p)->uid != current->uid && !suser()) {
                     71:                        error = EPERM;
                     72:                        continue;
                     73:                }
                     74:                if (error == ESRCH)
                     75:                        error = 0;
                     76:                if (priority > (*p)->priority && !suser())
                     77:                        error = EACCES;
                     78:                else
                     79:                        (*p)->priority = priority;
                     80:        }
                     81:        return -error;
                     82: }
                     83: 
                     84: int sys_getpriority(int which, int who)
                     85: {
                     86:        struct task_struct **p;
                     87:        int max_prio = 0;
                     88: 
                     89:        if (which > 2 || which < 0)
                     90:                return -EINVAL;
                     91: 
                     92:        for(p = &LAST_TASK; p > &FIRST_TASK; --p) {
                     93:                if (!*p || !proc_sel(*p, which, who))
                     94:                        continue;
                     95:                if ((*p)->priority > max_prio)
                     96:                        max_prio = (*p)->priority;
                     97:        }
                     98:        return(max_prio ? max_prio : -ESRCH);
                     99: }
                    100: 
                    101: int sys_profil()
                    102: {
                    103:        return -ENOSYS;
                    104: }
                    105: 
1.1       root      106: int sys_ftime()
                    107: {
                    108:        return -ENOSYS;
                    109: }
                    110: 
                    111: int sys_break()
                    112: {
                    113:        return -ENOSYS;
                    114: }
                    115: 
1.1.1.4   root      116: int sys_stty()
1.1       root      117: {
                    118:        return -ENOSYS;
                    119: }
                    120: 
1.1.1.4   root      121: int sys_gtty()
1.1       root      122: {
                    123:        return -ENOSYS;
                    124: }
                    125: 
1.1.1.4   root      126: int sys_prof()
1.1       root      127: {
                    128:        return -ENOSYS;
                    129: }
                    130: 
1.1.1.4   root      131: extern void hard_reset_now(void);
                    132: 
                    133: /*
                    134:  * Reboot system call: for obvious reasons only root may call it,
                    135:  * and even root needs to set up some magic numbers in the registers
                    136:  * so that some mistake won't make this reboot the whole machine.
                    137:  * You can also set the meaning of the ctrl-alt-del-key here.
                    138:  *
                    139:  * reboot doesn't sync: do that yourself before calling this.
                    140:  */
                    141: int sys_reboot(int magic, int magic_too, int flag)
1.1       root      142: {
1.1.1.4   root      143:        if (!suser())
                    144:                return -EPERM;
                    145:        if (magic != 0xfee1dead || magic_too != 672274793)
                    146:                return -EINVAL;
                    147:        if (flag == 0x01234567)
                    148:                hard_reset_now();
                    149:        else if (flag == 0x89ABCDEF)
                    150:                C_A_D = 1;
                    151:        else if (!flag)
                    152:                C_A_D = 0;
                    153:        else
                    154:                return -EINVAL;
                    155:        return (0);
1.1       root      156: }
                    157: 
1.1.1.4   root      158: /*
                    159:  * This function gets called by ctrl-alt-del - ie the keyboard interrupt.
                    160:  * As it's called within an interrupt, it may NOT sync: the only choice
                    161:  * is wether to reboot at once, or just ignore the ctrl-alt-del.
                    162:  */
                    163: void ctrl_alt_del(void)
1.1       root      164: {
1.1.1.4   root      165:        if (C_A_D)
                    166:                hard_reset_now();
1.1.1.8 ! root      167:        else
        !           168:                if (task[1])
        !           169:                        send_sig(SIGINT,task[1],1);
1.1       root      170: }
1.1.1.4   root      171:        
1.1       root      172: 
1.1.1.3   root      173: /*
                    174:  * This is done BSD-style, with no consideration of the saved gid, except
                    175:  * that if you set the effective gid, it sets the saved gid too.  This 
                    176:  * makes it possible for a setgid program to completely drop its privileges,
                    177:  * which is often a useful assertion to make when you are doing a security
                    178:  * audit over a program.
                    179:  *
                    180:  * The general idea is that a program which uses just setregid() will be
                    181:  * 100% compatible with BSD.  A program which uses just setgid() will be
                    182:  * 100% compatible with POSIX w/ Saved ID's. 
                    183:  */
1.1.1.2   root      184: int sys_setregid(int rgid, int egid)
1.1       root      185: {
1.1.1.7   root      186:        if (rgid >= 0) {
1.1.1.2   root      187:                if ((current->gid == rgid) || 
                    188:                    suser())
                    189:                        current->gid = rgid;
                    190:                else
                    191:                        return(-EPERM);
                    192:        }
1.1.1.7   root      193:        if (egid >= 0) {
1.1.1.2   root      194:                if ((current->gid == egid) ||
                    195:                    (current->egid == egid) ||
1.1.1.3   root      196:                    suser()) {
1.1.1.2   root      197:                        current->egid = egid;
1.1.1.3   root      198:                        current->sgid = egid;
                    199:                } else
1.1.1.2   root      200:                        return(-EPERM);
                    201:        }
1.1       root      202:        return 0;
                    203: }
                    204: 
1.1.1.3   root      205: /*
                    206:  * setgid() is implemeneted like SysV w/ SAVED_IDS 
                    207:  */
1.1.1.2   root      208: int sys_setgid(int gid)
                    209: {
1.1.1.3   root      210:        if (suser())
                    211:                current->gid = current->egid = current->sgid = gid;
                    212:        else if ((gid == current->gid) || (gid == current->sgid))
                    213:                current->egid = gid;
                    214:        else
                    215:                return -EPERM;
                    216:        return 0;
1.1.1.2   root      217: }
                    218: 
1.1       root      219: int sys_acct()
                    220: {
                    221:        return -ENOSYS;
                    222: }
                    223: 
                    224: int sys_phys()
                    225: {
                    226:        return -ENOSYS;
                    227: }
                    228: 
                    229: int sys_lock()
                    230: {
                    231:        return -ENOSYS;
                    232: }
                    233: 
                    234: int sys_mpx()
                    235: {
                    236:        return -ENOSYS;
                    237: }
                    238: 
                    239: int sys_ulimit()
                    240: {
                    241:        return -ENOSYS;
                    242: }
                    243: 
                    244: int sys_time(long * tloc)
                    245: {
                    246:        int i;
                    247: 
                    248:        i = CURRENT_TIME;
                    249:        if (tloc) {
                    250:                verify_area(tloc,4);
                    251:                put_fs_long(i,(unsigned long *)tloc);
                    252:        }
                    253:        return i;
                    254: }
                    255: 
1.1.1.2   root      256: /*
                    257:  * Unprivileged users may change the real user id to the effective uid
1.1.1.3   root      258:  * or vice versa.  (BSD-style)
                    259:  *
                    260:  * When you set the effective uid, it sets the saved uid too.  This 
                    261:  * makes it possible for a setuid program to completely drop its privileges,
                    262:  * which is often a useful assertion to make when you are doing a security
                    263:  * audit over a program.
                    264:  *
                    265:  * The general idea is that a program which uses just setreuid() will be
                    266:  * 100% compatible with BSD.  A program which uses just setuid() will be
                    267:  * 100% compatible with POSIX w/ Saved ID's. 
1.1.1.2   root      268:  */
                    269: int sys_setreuid(int ruid, int euid)
1.1       root      270: {
1.1.1.2   root      271:        int old_ruid = current->uid;
                    272:        
1.1.1.7   root      273:        if (ruid >= 0) {
1.1.1.2   root      274:                if ((current->euid==ruid) ||
1.1.1.7   root      275:                    (old_ruid == ruid) ||
1.1.1.2   root      276:                    suser())
                    277:                        current->uid = ruid;
1.1       root      278:                else
1.1.1.2   root      279:                        return(-EPERM);
                    280:        }
1.1.1.7   root      281:        if (euid >= 0) {
1.1.1.2   root      282:                if ((old_ruid == euid) ||
1.1.1.7   root      283:                    (current->euid == euid) ||
1.1.1.3   root      284:                    suser()) {
1.1.1.2   root      285:                        current->euid = euid;
1.1.1.3   root      286:                        current->suid = euid;
                    287:                } else {
1.1.1.2   root      288:                        current->uid = old_ruid;
                    289:                        return(-EPERM);
                    290:                }
                    291:        }
1.1       root      292:        return 0;
                    293: }
                    294: 
1.1.1.3   root      295: /*
                    296:  * setuid() is implemeneted like SysV w/ SAVED_IDS 
                    297:  * 
                    298:  * Note that SAVED_ID's is deficient in that a setuid root program
                    299:  * like sendmail, for example, cannot set its uid to be a normal 
                    300:  * user and then switch back, because if you're root, setuid() sets
                    301:  * the saved uid too.  If you don't like this, blame the bright people
                    302:  * in the POSIX commmittee and/or USG.  Note that the BSD-style setreuid()
                    303:  * will allow a root program to temporarily drop privileges and be able to
                    304:  * regain them by swapping the real and effective uid.  
                    305:  */
1.1.1.2   root      306: int sys_setuid(int uid)
                    307: {
1.1.1.3   root      308:        if (suser())
                    309:                current->uid = current->euid = current->suid = uid;
                    310:        else if ((uid == current->uid) || (uid == current->suid))
                    311:                current->euid = uid;
                    312:        else
                    313:                return -EPERM;
                    314:        return(0);
1.1.1.2   root      315: }
                    316: 
1.1       root      317: int sys_stime(long * tptr)
                    318: {
1.1.1.2   root      319:        if (!suser())
                    320:                return -EPERM;
1.1       root      321:        startup_time = get_fs_long((unsigned long *)tptr) - jiffies/HZ;
1.1.1.3   root      322:        jiffies_offset = 0;
1.1       root      323:        return 0;
                    324: }
                    325: 
                    326: int sys_times(struct tms * tbuf)
                    327: {
1.1.1.2   root      328:        if (tbuf) {
                    329:                verify_area(tbuf,sizeof *tbuf);
                    330:                put_fs_long(current->utime,(unsigned long *)&tbuf->tms_utime);
                    331:                put_fs_long(current->stime,(unsigned long *)&tbuf->tms_stime);
                    332:                put_fs_long(current->cutime,(unsigned long *)&tbuf->tms_cutime);
                    333:                put_fs_long(current->cstime,(unsigned long *)&tbuf->tms_cstime);
                    334:        }
1.1       root      335:        return jiffies;
                    336: }
                    337: 
                    338: int sys_brk(unsigned long end_data_seg)
                    339: {
                    340:        if (end_data_seg >= current->end_code &&
                    341:            end_data_seg < current->start_stack - 16384)
                    342:                current->brk = end_data_seg;
                    343:        return current->brk;
                    344: }
                    345: 
                    346: /*
                    347:  * This needs some heave checking ...
                    348:  * I just haven't get the stomach for it. I also don't fully
                    349:  * understand sessions/pgrp etc. Let somebody who does explain it.
1.1.1.3   root      350:  *
                    351:  * OK, I think I have the protection semantics right.... this is really
                    352:  * only important on a multi-user system anyway, to make sure one user
                    353:  * can't send a signal to a process owned by another.  -TYT, 12/12/91
1.1       root      354:  */
                    355: int sys_setpgid(int pid, int pgid)
                    356: {
1.1.1.3   root      357:        int i; 
1.1       root      358: 
                    359:        if (!pid)
                    360:                pid = current->pid;
                    361:        if (!pgid)
1.1.1.2   root      362:                pgid = current->pid;
1.1.1.3   root      363:        if (pgid < 0)
                    364:                return -EINVAL;
1.1       root      365:        for (i=0 ; i<NR_TASKS ; i++)
1.1.1.3   root      366:                if (task[i] && (task[i]->pid == pid) &&
                    367:                    ((task[i]->p_pptr == current) || 
                    368:                     (task[i] == current))) {
1.1       root      369:                        if (task[i]->leader)
                    370:                                return -EPERM;
1.1.1.3   root      371:                        if ((task[i]->session != current->session) ||
                    372:                            ((pgid != pid) && 
                    373:                             (session_of_pgrp(pgid) != current->session)))
1.1       root      374:                                return -EPERM;
                    375:                        task[i]->pgrp = pgid;
                    376:                        return 0;
                    377:                }
                    378:        return -ESRCH;
                    379: }
                    380: 
                    381: int sys_getpgrp(void)
                    382: {
                    383:        return current->pgrp;
                    384: }
                    385: 
                    386: int sys_setsid(void)
                    387: {
1.1.1.2   root      388:        if (current->leader && !suser())
1.1       root      389:                return -EPERM;
                    390:        current->leader = 1;
                    391:        current->session = current->pgrp = current->pid;
                    392:        current->tty = -1;
                    393:        return current->pgrp;
                    394: }
                    395: 
1.1.1.3   root      396: /*
                    397:  * Supplementary group ID's
                    398:  */
                    399: int sys_getgroups(int gidsetsize, gid_t *grouplist)
                    400: {
                    401:        int     i;
                    402: 
                    403:        if (gidsetsize)
                    404:                verify_area(grouplist, sizeof(gid_t) * gidsetsize);
                    405: 
                    406:        for (i = 0; (i < NGROUPS) && (current->groups[i] != NOGROUP);
                    407:             i++, grouplist++) {
                    408:                if (gidsetsize) {
                    409:                        if (i >= gidsetsize)
                    410:                                return -EINVAL;
                    411:                        put_fs_word(current->groups[i], (short *) grouplist);
                    412:                }
                    413:        }
                    414:        return(i);
                    415: }
                    416: 
                    417: int sys_setgroups(int gidsetsize, gid_t *grouplist)
                    418: {
                    419:        int     i;
                    420: 
                    421:        if (!suser())
                    422:                return -EPERM;
                    423:        if (gidsetsize > NGROUPS)
                    424:                return -EINVAL;
                    425:        for (i = 0; i < gidsetsize; i++, grouplist++) {
                    426:                current->groups[i] = get_fs_word((unsigned short *) grouplist);
                    427:        }
                    428:        if (i < NGROUPS)
                    429:                current->groups[i] = NOGROUP;
                    430:        return 0;
                    431: }
                    432: 
                    433: int in_group_p(gid_t grp)
                    434: {
                    435:        int     i;
                    436: 
                    437:        if (grp == current->egid)
                    438:                return 1;
                    439: 
                    440:        for (i = 0; i < NGROUPS; i++) {
                    441:                if (current->groups[i] == NOGROUP)
                    442:                        break;
                    443:                if (current->groups[i] == grp)
                    444:                        return 1;
                    445:        }
                    446:        return 0;
                    447: }
                    448: 
1.1.1.7   root      449: static struct new_utsname thisname = {
1.1.1.3   root      450:        UTS_SYSNAME, UTS_NODENAME, UTS_RELEASE, UTS_VERSION, UTS_MACHINE
                    451: };
                    452: 
1.1.1.7   root      453: int sys_newuname(struct new_utsname * name)
1.1       root      454: {
1.1.1.7   root      455:        if (!name)
                    456:                return -EFAULT;
                    457:        verify_area(name, sizeof *name);
                    458:        memcpy_tofs(name,&thisname,sizeof *name);
                    459:        return 0;
                    460: }
1.1       root      461: 
1.1.1.7   root      462: int sys_uname(struct old_utsname * name)
                    463: {
1.1.1.6   root      464:        if (!name)
                    465:                return -EINVAL;
1.1       root      466:        verify_area(name,sizeof *name);
1.1.1.7   root      467:        memcpy_tofs(&name->sysname,&thisname.sysname,__OLD_UTS_LEN);
                    468:        put_fs_byte(0,name->sysname+__OLD_UTS_LEN);
                    469:        memcpy_tofs(&name->nodename,&thisname.nodename,__OLD_UTS_LEN);
                    470:        put_fs_byte(0,name->nodename+__OLD_UTS_LEN);
                    471:        memcpy_tofs(&name->release,&thisname.release,__OLD_UTS_LEN);
                    472:        put_fs_byte(0,name->release+__OLD_UTS_LEN);
                    473:        memcpy_tofs(&name->version,&thisname.version,__OLD_UTS_LEN);
                    474:        put_fs_byte(0,name->version+__OLD_UTS_LEN);
                    475:        memcpy_tofs(&name->machine,&thisname.machine,__OLD_UTS_LEN);
                    476:        put_fs_byte(0,name->machine+__OLD_UTS_LEN);
1.1.1.2   root      477:        return 0;
1.1       root      478: }
                    479: 
1.1.1.3   root      480: /*
                    481:  * Only sethostname; gethostname can be implemented by calling uname()
                    482:  */
                    483: int sys_sethostname(char *name, int len)
                    484: {
                    485:        int     i;
                    486:        
                    487:        if (!suser())
                    488:                return -EPERM;
1.1.1.7   root      489:        if (len > __NEW_UTS_LEN)
1.1.1.3   root      490:                return -EINVAL;
                    491:        for (i=0; i < len; i++) {
                    492:                if ((thisname.nodename[i] = get_fs_byte(name+i)) == 0)
1.1.1.7   root      493:                        return 0;
1.1.1.3   root      494:        }
1.1.1.7   root      495:        thisname.nodename[i] = 0;
1.1.1.3   root      496:        return 0;
                    497: }
                    498: 
                    499: int sys_getrlimit(int resource, struct rlimit *rlim)
                    500: {
                    501:        if (resource >= RLIM_NLIMITS)
                    502:                return -EINVAL;
                    503:        verify_area(rlim,sizeof *rlim);
                    504:        put_fs_long(current->rlim[resource].rlim_cur, 
                    505:                    (unsigned long *) rlim);
                    506:        put_fs_long(current->rlim[resource].rlim_max, 
                    507:                    ((unsigned long *) rlim)+1);
                    508:        return 0;       
                    509: }
                    510: 
                    511: int sys_setrlimit(int resource, struct rlimit *rlim)
                    512: {
                    513:        struct rlimit new, *old;
                    514: 
                    515:        if (resource >= RLIM_NLIMITS)
                    516:                return -EINVAL;
                    517:        old = current->rlim + resource;
                    518:        new.rlim_cur = get_fs_long((unsigned long *) rlim);
                    519:        new.rlim_max = get_fs_long(((unsigned long *) rlim)+1);
                    520:        if (((new.rlim_cur > old->rlim_max) ||
                    521:             (new.rlim_max > old->rlim_max)) &&
                    522:            !suser())
                    523:                return -EPERM;
                    524:        *old = new;
                    525:        return 0;
                    526: }
                    527: 
                    528: /*
                    529:  * It would make sense to put struct rusuage in the task_struct,
                    530:  * except that would make the task_struct be *really big*.  After
                    531:  * task_struct gets moved into malloc'ed memory, it would
                    532:  * make sense to do this.  It will make moving the rest of the information
                    533:  * a lot simpler!  (Which we're not doing right now because we're not
                    534:  * measuring them yet).
                    535:  */
                    536: int sys_getrusage(int who, struct rusage *ru)
                    537: {
                    538:        struct rusage r;
                    539:        unsigned long   *lp, *lpend, *dest;
                    540: 
                    541:        if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
                    542:                return -EINVAL;
                    543:        verify_area(ru, sizeof *ru);
                    544:        memset((char *) &r, 0, sizeof(r));
                    545:        if (who == RUSAGE_SELF) {
                    546:                r.ru_utime.tv_sec = CT_TO_SECS(current->utime);
                    547:                r.ru_utime.tv_usec = CT_TO_USECS(current->utime);
                    548:                r.ru_stime.tv_sec = CT_TO_SECS(current->stime);
                    549:                r.ru_stime.tv_usec = CT_TO_USECS(current->stime);
1.1.1.5   root      550:                r.ru_minflt = current->min_flt;
                    551:                r.ru_majflt = current->maj_flt;
1.1.1.3   root      552:        } else {
                    553:                r.ru_utime.tv_sec = CT_TO_SECS(current->cutime);
                    554:                r.ru_utime.tv_usec = CT_TO_USECS(current->cutime);
                    555:                r.ru_stime.tv_sec = CT_TO_SECS(current->cstime);
                    556:                r.ru_stime.tv_usec = CT_TO_USECS(current->cstime);
1.1.1.5   root      557:                r.ru_minflt = current->cmin_flt;
                    558:                r.ru_majflt = current->cmaj_flt;
1.1.1.3   root      559:        }
                    560:        lp = (unsigned long *) &r;
                    561:        lpend = (unsigned long *) (&r+1);
                    562:        dest = (unsigned long *) ru;
                    563:        for (; lp < lpend; lp++, dest++) 
                    564:                put_fs_long(*lp, dest);
                    565:        return(0);
                    566: }
                    567: 
                    568: int sys_gettimeofday(struct timeval *tv, struct timezone *tz)
                    569: {
                    570:        if (tv) {
                    571:                verify_area(tv, sizeof *tv);
                    572:                put_fs_long(startup_time + CT_TO_SECS(jiffies+jiffies_offset),
                    573:                            (unsigned long *) tv);
                    574:                put_fs_long(CT_TO_USECS(jiffies+jiffies_offset), 
                    575:                            ((unsigned long *) tv)+1);
                    576:        }
                    577:        if (tz) {
                    578:                verify_area(tz, sizeof *tz);
                    579:                put_fs_long(sys_tz.tz_minuteswest, (unsigned long *) tz);
                    580:                put_fs_long(sys_tz.tz_dsttime, ((unsigned long *) tz)+1);
                    581:        }
                    582:        return 0;
                    583: }
                    584: 
                    585: /*
                    586:  * The first time we set the timezone, we will warp the clock so that
                    587:  * it is ticking GMT time instead of local time.  Presumably, 
                    588:  * if someone is setting the timezone then we are running in an
                    589:  * environment where the programs understand about timezones.
                    590:  * This should be done at boot time in the /etc/rc script, as
                    591:  * soon as possible, so that the clock can be set right.  Otherwise,
                    592:  * various programs will get confused when the clock gets warped.
                    593:  */
                    594: int sys_settimeofday(struct timeval *tv, struct timezone *tz)
                    595: {
                    596:        static int      firsttime = 1;
                    597:        void            adjust_clock();
                    598: 
                    599:        if (!suser())
                    600:                return -EPERM;
                    601:        if (tz) {
                    602:                sys_tz.tz_minuteswest = get_fs_long((unsigned long *) tz);
                    603:                sys_tz.tz_dsttime = get_fs_long(((unsigned long *) tz)+1);
                    604:                if (firsttime) {
                    605:                        firsttime = 0;
                    606:                        if (!tv)
                    607:                                adjust_clock();
                    608:                }
                    609:        }
                    610:        if (tv) {
                    611:                int sec, usec;
                    612: 
                    613:                sec = get_fs_long((unsigned long *)tv);
                    614:                usec = get_fs_long(((unsigned long *)tv)+1);
                    615:        
                    616:                startup_time = sec - jiffies/HZ;
                    617:                jiffies_offset = usec * HZ / 1000000 - jiffies%HZ;
                    618:        }
                    619:        return 0;
                    620: }
                    621: 
                    622: /*
                    623:  * Adjust the time obtained from the CMOS to be GMT time instead of
                    624:  * local time.
                    625:  * 
                    626:  * This is ugly, but preferable to the alternatives.  Otherwise we
                    627:  * would either need to write a program to do it in /etc/rc (and risk
                    628:  * confusion if the program gets run more than once; it would also be 
                    629:  * hard to make the program warp the clock precisely n hours)  or
                    630:  * compile in the timezone information into the kernel.  Bad, bad....
                    631:  *
                    632:  * XXX Currently does not adjust for daylight savings time.  May not
                    633:  * need to do anything, depending on how smart (dumb?) the BIOS
                    634:  * is.  Blast it all.... the best thing to do not depend on the CMOS
                    635:  * clock at all, but get the time via NTP or timed if you're on a 
                    636:  * network....                         - TYT, 1/1/92
                    637:  */
                    638: void adjust_clock()
                    639: {
                    640:        startup_time += sys_tz.tz_minuteswest*60;
                    641: }
                    642: 
1.1       root      643: int sys_umask(int mask)
                    644: {
                    645:        int old = current->umask;
                    646: 
                    647:        current->umask = mask & 0777;
                    648:        return (old);
                    649: }
1.1.1.3   root      650: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.