Annotation of linux/fs/minix/symlink.c, revision 1.1.1.2

1.1       root        1: /*
1.1.1.2 ! root        2:  *  linux/fs/minix/symlink.c
1.1       root        3:  *
1.1.1.2 ! root        4:  *  (C) 1991 Linus Torvalds
        !             5:  *
        !             6:  *  minix symlink handling code
1.1       root        7:  */
                      8: 
                      9: #include <errno.h>
                     10: 
                     11: #include <asm/segment.h>
                     12: 
                     13: #include <linux/sched.h>
                     14: #include <linux/fs.h>
                     15: #include <linux/minix_fs.h>
1.1.1.2 ! root       16: #include <linux/stat.h>
1.1       root       17: 
                     18: static int minix_readlink(struct inode *, char *, int);
                     19: static struct inode * minix_follow_link(struct inode *, struct inode *);
                     20: 
                     21: /*
                     22:  * symlinks can't do much...
                     23:  */
                     24: struct inode_operations minix_symlink_inode_operations = {
                     25:        NULL,                   /* no file-operations */
                     26:        NULL,                   /* create */
                     27:        NULL,                   /* lookup */
                     28:        NULL,                   /* link */
                     29:        NULL,                   /* unlink */
                     30:        NULL,                   /* symlink */
                     31:        NULL,                   /* mkdir */
                     32:        NULL,                   /* rmdir */
                     33:        NULL,                   /* mknod */
                     34:        NULL,                   /* rename */
                     35:        minix_readlink,         /* readlink */
                     36:        minix_follow_link,      /* follow_link */
                     37:        NULL,                   /* bmap */
                     38:        NULL                    /* truncate */
                     39: };
                     40: 
                     41: static struct inode * minix_follow_link(struct inode * dir, struct inode * inode)
                     42: {
                     43:        unsigned short fs;
                     44:        struct buffer_head * bh;
                     45: 
                     46:        if (!dir) {
                     47:                dir = current->root;
                     48:                dir->i_count++;
                     49:        }
                     50:        if (!inode) {
                     51:                iput(dir);
                     52:                return NULL;
                     53:        }
                     54:        if (!S_ISLNK(inode->i_mode)) {
                     55:                iput(dir);
                     56:                return inode;
                     57:        }
                     58:        __asm__("mov %%fs,%0":"=r" (fs));
                     59:        if ((current->link_count > 5) || !inode->i_data[0] ||
                     60:           !(bh = bread(inode->i_dev, inode->i_data[0]))) {
                     61:                iput(dir);
                     62:                iput(inode);
                     63:                return NULL;
                     64:        }
                     65:        iput(inode);
                     66:        __asm__("mov %0,%%fs"::"r" ((unsigned short) 0x10));
                     67:        current->link_count++;
                     68:        inode = _namei(bh->b_data,dir,1);
                     69:        current->link_count--;
                     70:        __asm__("mov %0,%%fs"::"r" (fs));
                     71:        brelse(bh);
                     72:        return inode;
                     73: }
                     74: 
                     75: static int minix_readlink(struct inode * inode, char * buffer, int buflen)
                     76: {
                     77:        struct buffer_head * bh;
                     78:        int i;
                     79:        char c;
                     80: 
                     81:        if (!S_ISLNK(inode->i_mode)) {
                     82:                iput(inode);
                     83:                return -EINVAL;
                     84:        }
                     85:        if (buflen > 1023)
                     86:                buflen = 1023;
                     87:        if (inode->i_data[0])
                     88:                bh = bread(inode->i_dev, inode->i_data[0]);
                     89:        else
                     90:                bh = NULL;
                     91:        iput(inode);
                     92:        if (!bh)
                     93:                return 0;
                     94:        i = 0;
                     95:        while (i<buflen && (c = bh->b_data[i])) {
                     96:                i++;
                     97:                put_fs_byte(c,buffer++);
                     98:        }
                     99:        brelse(bh);
                    100:        return i;
                    101: }

unix.superglobalmegacorp.com

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