Annotation of linux/fs/proc/link.c, revision 1.1

1.1     ! root        1: /*
        !             2:  *  linux/fs/proc/link.c
        !             3:  *
        !             4:  *  Copyright (C) 1991, 1992  Linus Torvalds
        !             5:  *
        !             6:  *  /proc link-file handling code
        !             7:  */
        !             8: 
        !             9: #include <asm/segment.h>
        !            10: 
        !            11: #include <linux/errno.h>
        !            12: #include <linux/sched.h>
        !            13: #include <linux/fs.h>
        !            14: #include <linux/minix_fs.h>
        !            15: #include <linux/stat.h>
        !            16: 
        !            17: static int proc_readlink(struct inode *, char *, int);
        !            18: static int proc_follow_link(struct inode *, struct inode *, int, int, struct inode **);
        !            19: 
        !            20: /*
        !            21:  * links can't do much...
        !            22:  */
        !            23: struct inode_operations proc_link_inode_operations = {
        !            24:        NULL,                   /* no file-operations */
        !            25:        NULL,                   /* create */
        !            26:        NULL,                   /* lookup */
        !            27:        NULL,                   /* link */
        !            28:        NULL,                   /* unlink */
        !            29:        NULL,                   /* symlink */
        !            30:        NULL,                   /* mkdir */
        !            31:        NULL,                   /* rmdir */
        !            32:        NULL,                   /* mknod */
        !            33:        NULL,                   /* rename */
        !            34:        proc_readlink,          /* readlink */
        !            35:        proc_follow_link,       /* follow_link */
        !            36:        NULL,                   /* bmap */
        !            37:        NULL                    /* truncate */
        !            38: };
        !            39: 
        !            40: static int proc_follow_link(struct inode * dir, struct inode * inode,
        !            41:        int flag, int mode, struct inode ** res_inode)
        !            42: {
        !            43:        unsigned int pid, ino;
        !            44:        struct task_struct * p;
        !            45:        int i;
        !            46: 
        !            47:        *res_inode = NULL;
        !            48:        if (dir)
        !            49:                iput(dir);
        !            50:        if (!inode)
        !            51:                return -ENOENT;
        !            52:        ino = inode->i_ino;
        !            53:        pid = ino >> 16;
        !            54:        ino &= 0x0000ffff;
        !            55:        iput(inode);
        !            56:        for (i = 0 ; i < NR_TASKS ; i++)
        !            57:                if ((p = task[i]) && p->pid == pid)
        !            58:                        break;
        !            59:        if (i >= NR_TASKS)
        !            60:                return -ENOENT;
        !            61:        inode = NULL;
        !            62:        switch (ino) {
        !            63:                case 4:
        !            64:                        inode = p->pwd;
        !            65:                        break;
        !            66:                case 5:
        !            67:                        inode = p->root;
        !            68:                        break;
        !            69:                case 6:
        !            70:                        inode = p->executable;
        !            71:                        break;
        !            72:                default:
        !            73:                        switch (ino >> 8) {
        !            74:                                case 1:
        !            75:                                        ino &= 0xff;
        !            76:                                        if (ino < NR_OPEN && p->filp[ino])
        !            77:                                                inode = p->filp[ino]->f_inode;
        !            78:                                        break;
        !            79:                                case 2:
        !            80:                                        ino &= 0xff;
        !            81:                                        if (ino < p->numlibraries)
        !            82:                                                inode = p->libraries[ino].library;
        !            83:                        }
        !            84:        }
        !            85:        if (!inode)
        !            86:                return -ENOENT;
        !            87:        *res_inode = inode;
        !            88:        inode->i_count++;
        !            89:        return 0;
        !            90: }
        !            91: 
        !            92: static int proc_readlink(struct inode * inode, char * buffer, int buflen)
        !            93: {
        !            94:        int i;
        !            95: 
        !            96:        iput(inode);
        !            97:        if (buflen > 3)
        !            98:                buflen = 3;
        !            99:        i = 0;
        !           100:        while (i++ < buflen)
        !           101:                put_fs_byte('-',buffer++);
        !           102:        return i;
        !           103: }

unix.superglobalmegacorp.com

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