Annotation of researchv10no/cmd/upas/libc/v9sysname.c, revision 1.1

1.1     ! root        1: /* get the system's name -- v10 version*/
        !             2: 
        !             3: #define WHOFILE "/etc/whoami"
        !             4: 
        !             5: extern char *
        !             6: sysname_read()
        !             7: {
        !             8:        register int fd, i, n;
        !             9:        static char sysname[128];
        !            10: 
        !            11:        /* read the system identity */
        !            12:        fd = open(WHOFILE, 0);
        !            13:        if (fd < 0)
        !            14:                return "kremvax";
        !            15:        n = read(fd, sysname, sizeof(sysname)-1);
        !            16:        close(fd);
        !            17:        if (n < 0)
        !            18:                return "kremvax";
        !            19: 
        !            20:        sysname[n] = '\0';
        !            21: 
        !            22:        /* find the trailing \n if any and make it \0 */
        !            23:        for (i = 0; i < n; i++)
        !            24:                if (sysname[i] == '\n')
        !            25:                        sysname[i] = '\0';
        !            26: 
        !            27:        return sysname;
        !            28: }

unix.superglobalmegacorp.com

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