Annotation of linux/fs/ioctl.c, revision 1.1.1.11

1.1.1.2   root        1: /*
                      2:  *  linux/fs/ioctl.c
                      3:  *
1.1.1.10  root        4:  *  Copyright (C) 1991, 1992  Linus Torvalds
1.1.1.2   root        5:  */
                      6: 
1.1.1.10  root        7: #include <asm/segment.h>
1.1       root        8: 
1.1.1.10  root        9: #include <linux/sched.h>
                     10: #include <linux/errno.h>
1.1.1.9   root       11: #include <linux/string.h>
1.1.1.8   root       12: #include <linux/stat.h>
1.1.1.11! root       13: #include <linux/termios.h>
        !            14: 
        !            15: static int file_ioctl(struct file *filp,unsigned int cmd,unsigned long arg)
        !            16: {
        !            17:        int block;
        !            18: 
        !            19:        switch (cmd) {
        !            20:                case FIBMAP:
        !            21:                        if (filp->f_inode->i_op == NULL)
        !            22:                                return -EBADF;
        !            23:                        if (filp->f_inode->i_op->bmap == NULL)
        !            24:                                return -EINVAL;
        !            25:                        verify_area((void *) arg,4);
        !            26:                        block = get_fs_long((long *) arg);
        !            27:                        block = filp->f_inode->i_op->bmap(filp->f_inode,block);
        !            28:                        put_fs_long(block,(long *) arg);
        !            29:                        return 0;
        !            30:                case FIGETBSZ:
        !            31:                        if (filp->f_inode->i_sb == NULL)
        !            32:                                return -EBADF;
        !            33:                        verify_area((void *) arg,4);
        !            34:                        put_fs_long(filp->f_inode->i_sb->s_blocksize,
        !            35:                            (long *) arg);
        !            36:                        return 0;
        !            37:                case FIONREAD:
        !            38:                        verify_area((void *) arg,4);
        !            39:                        put_fs_long(filp->f_inode->i_size - filp->f_pos,
        !            40:                            (long *) arg);
        !            41:                        return 0;
        !            42:                default:
        !            43:                        return -EINVAL;
        !            44:        }
        !            45: }
        !            46: 
1.1       root       47: 
                     48: int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
                     49: {      
                     50:        struct file * filp;
                     51: 
                     52:        if (fd >= NR_OPEN || !(filp = current->filp[fd]))
                     53:                return -EBADF;
1.1.1.11! root       54:        if (filp->f_inode && S_ISREG(filp->f_inode->i_mode))
        !            55:                return file_ioctl(filp,cmd,arg);
1.1.1.7   root       56:        if (filp->f_op && filp->f_op->ioctl)
                     57:                return filp->f_op->ioctl(filp->f_inode, filp, cmd,arg);
                     58:        return -EINVAL;
1.1       root       59: }

unix.superglobalmegacorp.com

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