Annotation of xinu/sys/shell/x_mount.c, revision 1.1

1.1     ! root        1: /* x_mount.c - x_mount, mprint */
        !             2: 
        !             3: #include <conf.h>
        !             4: #include <kernel.h>
        !             5: #include <io.h>
        !             6: #include <name.h>
        !             7: 
        !             8: #define        PADTO   24
        !             9: 
        !            10: /*------------------------------------------------------------------------
        !            11:  *  x_mount  -  (command mount) change or display namespace table
        !            12:  *------------------------------------------------------------------------
        !            13:  */
        !            14: COMMAND        x_mount(stdin, stdout, stderr, nargs, args)
        !            15: int    stdin, stdout, stderr, nargs;
        !            16: char   *args[];
        !            17: {
        !            18:        int     dev;
        !            19: 
        !            20:        if (nargs == 1)
        !            21:                return(mprint(stdin, stdout, stderr));
        !            22:        if (nargs != 4) {
        !            23:                fprintf(stderr,"use: mount [prefix device new_prefix]\n");
        !            24:                return(SYSERR);
        !            25:        }
        !            26:        for (dev=0 ; dev<NDEVS ; dev++)
        !            27:                if (strcmp(args[2], devtab[dev].dvname) == 0)
        !            28:                        break;
        !            29:        if (dev >=  NDEVS)
        !            30:                if (strcmp(args[2],"SYSERR") == 0)
        !            31:                        dev = SYSERR;
        !            32:                else {
        !            33:                        fprintf(stderr, "Device %s not found\n", args[2]);
        !            34:                        return(SYSERR);
        !            35:                }
        !            36:        if (mount(args[1], dev, args[3]) == SYSERR) {
        !            37:                fprintf(stderr, "Mount failed\n");
        !            38:                return(SYSERR);
        !            39:        }
        !            40:        return(OK);
        !            41: }
        !            42: 
        !            43: 
        !            44: /*------------------------------------------------------------------------
        !            45:  *  mprint  -  print the current contents of the namespace prefix table
        !            46:  *------------------------------------------------------------------------
        !            47:  */
        !            48: LOCAL  mprint(stdin, stdout, stderr)
        !            49: int    stdin, stdout, stderr;
        !            50: {
        !            51:        struct  nament  *nptr;
        !            52:        int     i, len, dev;
        !            53:        char    str[80];
        !            54:        char    *p;
        !            55: 
        !            56:        for (i=0 ; i<Nam.nnames ; i++) {
        !            57:                nptr = & Nam.nametab[i];
        !            58:                sprintf(str, "\"%-s\"", nptr->npre);
        !            59:                for (len=strlen(str) ; len < PADTO ; len++)
        !            60:                        str[len] = ' ';
        !            61:                write(stdout, str, PADTO);
        !            62:                dev = nptr->ndev;
        !            63:                p = isbaddev(dev) ? "SYSERR" : devtab[dev].dvname;
        !            64:                sprintf(str, " -> (%-9s) \"%s\"\n", p, nptr->nrepl);
        !            65:                write(stdout, str, strlen(str));
        !            66:        }
        !            67:        return(OK);
        !            68: }

unix.superglobalmegacorp.com

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