Annotation of researchv10no/sys/io/fd.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * file descriptor driver
        !             3:  * open(minor n) -> dup of minor n
        !             4:  */
        !             5: 
        !             6: #include "sys/param.h"
        !             7: #include "sys/file.h"
        !             8: #include "sys/user.h"
        !             9: #include "sys/conf.h"
        !            10: 
        !            11: int fdopen();
        !            12: 
        !            13: struct cdevsw fdcdev = cdinit(fdopen, nodev, nodev, nodev, nodev);
        !            14: 
        !            15: fdopen(dev, flag)
        !            16: {
        !            17:        register struct file *fp;
        !            18:        register int ofd;
        !            19: 
        !            20:        ofd = u.u_r.r_val1;             /* magic knowledge */
        !            21:        if (minor(dev) == ofd || (fp = getf(minor(dev))) == NULL) {
        !            22:                u.u_error = EBADF;
        !            23:                return;
        !            24:        }
        !            25:        /* now for the naughty part */
        !            26:        if ((unsigned)ofd >= NOFILE || u.u_ofile[ofd] == NULL)
        !            27:                panic("fdopen");
        !            28:        closef(u.u_ofile[ofd]);
        !            29:        u.u_ofile[ofd] = fp;
        !            30:        fp->f_count++;
        !            31: }

unix.superglobalmegacorp.com

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