Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
[PATCH] fix sysctl_nr_open bugs
[PATCH] sanitize anon_inode_getfd()
[PATCH] split linux/file.h
[PATCH] make osf_select() use core_sys_select()
[PATCH] remove horrors with irix tty ioctls handling
[PATCH] fix file and descriptor handling in perfmon

+186 -274
+4 -65
arch/alpha/kernel/osf_sys.c
··· 981 981 osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, 982 982 struct timeval32 __user *tvp) 983 983 { 984 - fd_set_bits fds; 985 - char *bits; 986 - size_t size; 987 - long timeout; 988 - int ret = -EINVAL; 989 - struct fdtable *fdt; 990 - int max_fds; 991 - 992 - timeout = MAX_SCHEDULE_TIMEOUT; 984 + s64 timeout = MAX_SCHEDULE_TIMEOUT; 993 985 if (tvp) { 994 986 time_t sec, usec; 995 987 996 988 if (!access_ok(VERIFY_READ, tvp, sizeof(*tvp)) 997 989 || __get_user(sec, &tvp->tv_sec) 998 990 || __get_user(usec, &tvp->tv_usec)) { 999 - ret = -EFAULT; 1000 - goto out_nofds; 991 + return -EFAULT; 1001 992 } 1002 993 1003 994 if (sec < 0 || usec < 0) 1004 - goto out_nofds; 995 + return -EINVAL; 1005 996 1006 997 if ((unsigned long) sec < MAX_SELECT_SECONDS) { 1007 998 timeout = (usec + 1000000/HZ - 1) / (1000000/HZ); ··· 1000 1009 } 1001 1010 } 1002 1011 1003 - rcu_read_lock(); 1004 - fdt = files_fdtable(current->files); 1005 - max_fds = fdt->max_fds; 1006 - rcu_read_unlock(); 1007 - if (n < 0 || n > max_fds) 1008 - goto out_nofds; 1009 - 1010 - /* 1011 - * We need 6 bitmaps (in/out/ex for both incoming and outgoing), 1012 - * since we used fdset we need to allocate memory in units of 1013 - * long-words. 1014 - */ 1015 - ret = -ENOMEM; 1016 - size = FDS_BYTES(n); 1017 - bits = kmalloc(6 * size, GFP_KERNEL); 1018 - if (!bits) 1019 - goto out_nofds; 1020 - fds.in = (unsigned long *) bits; 1021 - fds.out = (unsigned long *) (bits + size); 1022 - fds.ex = (unsigned long *) (bits + 2*size); 1023 - fds.res_in = (unsigned long *) (bits + 3*size); 1024 - fds.res_out = (unsigned long *) (bits + 4*size); 1025 - fds.res_ex = (unsigned long *) (bits + 5*size); 1026 - 1027 - if ((ret = get_fd_set(n, inp->fds_bits, fds.in)) || 1028 - (ret = get_fd_set(n, outp->fds_bits, fds.out)) || 1029 - (ret = get_fd_set(n, exp->fds_bits, fds.ex))) 1030 - goto out; 1031 - zero_fd_set(n, fds.res_in); 1032 - zero_fd_set(n, fds.res_out); 1033 - zero_fd_set(n, fds.res_ex); 1034 - 1035 - ret = do_select(n, &fds, &timeout); 1036 - 1037 1012 /* OSF does not copy back the remaining time. */ 1038 - 1039 - if (ret < 0) 1040 - goto out; 1041 - if (!ret) { 1042 - ret = -ERESTARTNOHAND; 1043 - if (signal_pending(current)) 1044 - goto out; 1045 - ret = 0; 1046 - } 1047 - 1048 - if (set_fd_set(n, inp->fds_bits, fds.res_in) || 1049 - set_fd_set(n, outp->fds_bits, fds.res_out) || 1050 - set_fd_set(n, exp->fds_bits, fds.res_ex)) 1051 - ret = -EFAULT; 1052 - 1053 - out: 1054 - kfree(bits); 1055 - out_nofds: 1056 - return ret; 1013 + return core_sys_select(n, inp, outp, exp, &timeout); 1057 1014 } 1058 1015 1059 1016 struct rusage32 {
+9 -46
arch/mips/kernel/irixioctl.c
··· 27 27 cc_t c_cc[NCCS]; 28 28 }; 29 29 30 - extern void start_tty(struct tty_struct *tty); 31 - static struct tty_struct *get_tty(int fd) 32 - { 33 - struct file *filp; 34 - struct tty_struct *ttyp = NULL; 35 - 36 - rcu_read_lock(); 37 - filp = fcheck(fd); 38 - if(filp && filp->private_data) { 39 - ttyp = (struct tty_struct *) filp->private_data; 40 - 41 - if(ttyp->magic != TTY_MAGIC) 42 - ttyp =NULL; 43 - } 44 - rcu_read_unlock(); 45 - return ttyp; 46 - } 47 - 48 - static struct tty_struct *get_real_tty(struct tty_struct *tp) 49 - { 50 - if (tp->driver->type == TTY_DRIVER_TYPE_PTY && 51 - tp->driver->subtype == PTY_TYPE_MASTER) 52 - return tp->link; 53 - else 54 - return tp; 55 - } 56 - 57 30 asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg) 58 31 { 59 32 struct tty_struct *tp, *rtp; ··· 119 146 error = sys_ioctl(fd, TIOCNOTTY, arg); 120 147 break; 121 148 122 - case 0x00007416: 149 + case 0x00007416: { 150 + pid_t pid; 123 151 #ifdef DEBUG_IOCTLS 124 152 printk("TIOCGSID, %08lx) ", arg); 125 153 #endif 126 - tp = get_tty(fd); 127 - if(!tp) { 128 - error = -EINVAL; 129 - break; 130 - } 131 - rtp = get_real_tty(tp); 132 - #ifdef DEBUG_IOCTLS 133 - printk("rtp->session=%d ", rtp->session); 134 - #endif 135 - error = put_user(rtp->session, (unsigned long __user *) arg); 154 + old_fs = get_fs(); set_fs(get_ds()); 155 + error = sys_ioctl(fd, TIOCGSID, (unsigned long)&pid); 156 + set_fs(old_fs); 157 + if (!error) 158 + error = put_user(pid, (unsigned long __user *) arg); 136 159 break; 137 - 160 + } 138 161 case 0x746e: 139 162 /* TIOCSTART, same effect as hitting ^Q */ 140 163 #ifdef DEBUG_IOCTLS 141 164 printk("TIOCSTART, %08lx) ", arg); 142 165 #endif 143 - tp = get_tty(fd); 144 - if(!tp) { 145 - error = -EINVAL; 146 - break; 147 - } 148 - rtp = get_real_tty(tp); 149 - start_tty(rtp); 166 + error = sys_ioctl(fd, TCXONC, TCOON); 150 167 break; 151 168 152 169 case 0x20006968:
+1
arch/mips/kernel/kspd.c
··· 20 20 #include <linux/sched.h> 21 21 #include <linux/unistd.h> 22 22 #include <linux/file.h> 23 + #include <linux/fdtable.h> 23 24 #include <linux/fs.h> 24 25 #include <linux/syscalls.h> 25 26 #include <linux/workqueue.h>
+1
arch/powerpc/platforms/cell/spufs/coredump.c
··· 22 22 23 23 #include <linux/elf.h> 24 24 #include <linux/file.h> 25 + #include <linux/fdtable.h> 25 26 #include <linux/fs.h> 26 27 #include <linux/list.h> 27 28 #include <linux/module.h>
+1
drivers/char/tty_audit.c
··· 11 11 12 12 #include <linux/audit.h> 13 13 #include <linux/file.h> 14 + #include <linux/fdtable.h> 14 15 #include <linux/tty.h> 15 16 16 17 struct tty_audit_buf {
+1
drivers/char/tty_io.c
··· 78 78 #include <linux/tty_flip.h> 79 79 #include <linux/devpts_fs.h> 80 80 #include <linux/file.h> 81 + #include <linux/fdtable.h> 81 82 #include <linux/console.h> 82 83 #include <linux/timer.h> 83 84 #include <linux/ctype.h>
+3 -10
fs/anon_inodes.c
··· 57 57 * anonymous inode, and a dentry that describe the "class" 58 58 * of the file 59 59 * 60 - * @pfd: [out] pointer to the file descriptor 61 - * @dpinode: [out] pointer to the inode 62 - * @pfile: [out] pointer to the file struct 63 60 * @name: [in] name of the "class" of the new file 64 61 * @fops [in] file operations for the new file 65 62 * @priv [in] private data for the new file (will be file's private_data) ··· 65 68 * that do not need to have a full-fledged inode in order to operate correctly. 66 69 * All the files created with anon_inode_getfd() will share a single inode, 67 70 * hence saving memory and avoiding code duplication for the file/inode/dentry 68 - * setup. 71 + * setup. Returns new descriptor or -error. 69 72 */ 70 - int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile, 71 - const char *name, const struct file_operations *fops, 73 + int anon_inode_getfd(const char *name, const struct file_operations *fops, 72 74 void *priv) 73 75 { 74 76 struct qstr this; ··· 121 125 122 126 fd_install(fd, file); 123 127 124 - *pfd = fd; 125 - *pinode = anon_inode_inode; 126 - *pfile = file; 127 - return 0; 128 + return fd; 128 129 129 130 err_dput: 130 131 dput(dentry);
+1
fs/compat.c
··· 24 24 #include <linux/fcntl.h> 25 25 #include <linux/namei.h> 26 26 #include <linux/file.h> 27 + #include <linux/fdtable.h> 27 28 #include <linux/vfs.h> 28 29 #include <linux/ioctl.h> 29 30 #include <linux/init.h>
+1 -1
fs/dnotify.c
··· 20 20 #include <linux/init.h> 21 21 #include <linux/spinlock.h> 22 22 #include <linux/slab.h> 23 - #include <linux/file.h> 23 + #include <linux/fdtable.h> 24 24 25 25 int dir_notify_enable __read_mostly = 1; 26 26
+5 -10
fs/eventfd.c
··· 200 200 201 201 asmlinkage long sys_eventfd(unsigned int count) 202 202 { 203 - int error, fd; 203 + int fd; 204 204 struct eventfd_ctx *ctx; 205 - struct file *file; 206 - struct inode *inode; 207 205 208 206 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); 209 207 if (!ctx) ··· 214 216 * When we call this, the initialization must be complete, since 215 217 * anon_inode_getfd() will install the fd. 216 218 */ 217 - error = anon_inode_getfd(&fd, &inode, &file, "[eventfd]", 218 - &eventfd_fops, ctx); 219 - if (!error) 220 - return fd; 221 - 222 - kfree(ctx); 223 - return error; 219 + fd = anon_inode_getfd("[eventfd]", &eventfd_fops, ctx); 220 + if (fd < 0) 221 + kfree(ctx); 222 + return fd; 224 223 } 225 224
+8 -15
fs/eventpoll.c
··· 1050 1050 { 1051 1051 int error, fd = -1; 1052 1052 struct eventpoll *ep; 1053 - struct inode *inode; 1054 - struct file *file; 1055 1053 1056 1054 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d)\n", 1057 1055 current, size)); ··· 1059 1061 * structure ( "struct eventpoll" ). 1060 1062 */ 1061 1063 error = -EINVAL; 1062 - if (size <= 0 || (error = ep_alloc(&ep)) != 0) 1064 + if (size <= 0 || (error = ep_alloc(&ep)) < 0) { 1065 + fd = error; 1063 1066 goto error_return; 1067 + } 1064 1068 1065 1069 /* 1066 1070 * Creates all the items needed to setup an eventpoll file. That is, 1067 - * a file structure, and inode and a free file descriptor. 1071 + * a file structure and a free file descriptor. 1068 1072 */ 1069 - error = anon_inode_getfd(&fd, &inode, &file, "[eventpoll]", 1070 - &eventpoll_fops, ep); 1071 - if (error) 1072 - goto error_free; 1073 + fd = anon_inode_getfd("[eventpoll]", &eventpoll_fops, ep); 1074 + if (fd < 0) 1075 + ep_free(ep); 1073 1076 1077 + error_return: 1074 1078 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n", 1075 1079 current, size, fd)); 1076 1080 1077 1081 return fd; 1078 - 1079 - error_free: 1080 - ep_free(ep); 1081 - error_return: 1082 - DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n", 1083 - current, size, error)); 1084 - return error; 1085 1082 } 1086 1083 1087 1084 /*
+1
fs/exec.c
··· 24 24 25 25 #include <linux/slab.h> 26 26 #include <linux/file.h> 27 + #include <linux/fdtable.h> 27 28 #include <linux/mman.h> 28 29 #include <linux/a.out.h> 29 30 #include <linux/stat.h>
+1
fs/fcntl.c
··· 9 9 #include <linux/mm.h> 10 10 #include <linux/fs.h> 11 11 #include <linux/file.h> 12 + #include <linux/fdtable.h> 12 13 #include <linux/capability.h> 13 14 #include <linux/dnotify.h> 14 15 #include <linux/smp_lock.h>
+21 -2
fs/file.c
··· 12 12 #include <linux/slab.h> 13 13 #include <linux/vmalloc.h> 14 14 #include <linux/file.h> 15 + #include <linux/fdtable.h> 15 16 #include <linux/bitops.h> 16 17 #include <linux/interrupt.h> 17 18 #include <linux/spinlock.h> ··· 150 149 nr /= (1024 / sizeof(struct file *)); 151 150 nr = roundup_pow_of_two(nr + 1); 152 151 nr *= (1024 / sizeof(struct file *)); 153 - if (nr > sysctl_nr_open) 154 - nr = sysctl_nr_open; 152 + /* 153 + * Note that this can drive nr *below* what we had passed if sysctl_nr_open 154 + * had been set lower between the check in expand_files() and here. Deal 155 + * with that in caller, it's cheaper that way. 156 + * 157 + * We make sure that nr remains a multiple of BITS_PER_LONG - otherwise 158 + * bitmaps handling below becomes unpleasant, to put it mildly... 159 + */ 160 + if (unlikely(nr > sysctl_nr_open)) 161 + nr = ((sysctl_nr_open - 1) | (BITS_PER_LONG - 1)) + 1; 155 162 156 163 fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL); 157 164 if (!fdt) ··· 207 198 spin_lock(&files->file_lock); 208 199 if (!new_fdt) 209 200 return -ENOMEM; 201 + /* 202 + * extremely unlikely race - sysctl_nr_open decreased between the check in 203 + * caller and alloc_fdtable(). Cheaper to catch it here... 204 + */ 205 + if (unlikely(new_fdt->max_fds <= nr)) { 206 + free_fdarr(new_fdt); 207 + free_fdset(new_fdt); 208 + kfree(new_fdt); 209 + return -EMFILE; 210 + } 210 211 /* 211 212 * Check again since another task may have expanded the fd table while 212 213 * we dropped the lock
+1
fs/file_table.c
··· 8 8 #include <linux/string.h> 9 9 #include <linux/slab.h> 10 10 #include <linux/file.h> 11 + #include <linux/fdtable.h> 11 12 #include <linux/init.h> 12 13 #include <linux/module.h> 13 14 #include <linux/fs.h>
+1
fs/locks.c
··· 116 116 117 117 #include <linux/capability.h> 118 118 #include <linux/file.h> 119 + #include <linux/fdtable.h> 119 120 #include <linux/fs.h> 120 121 #include <linux/init.h> 121 122 #include <linux/module.h>
+1
fs/open.c
··· 7 7 #include <linux/string.h> 8 8 #include <linux/mm.h> 9 9 #include <linux/file.h> 10 + #include <linux/fdtable.h> 10 11 #include <linux/quotaops.h> 11 12 #include <linux/fsnotify.h> 12 13 #include <linux/module.h>
+1
fs/proc/array.c
··· 73 73 #include <linux/signal.h> 74 74 #include <linux/highmem.h> 75 75 #include <linux/file.h> 76 + #include <linux/fdtable.h> 76 77 #include <linux/times.h> 77 78 #include <linux/cpuset.h> 78 79 #include <linux/rcupdate.h>
+1
fs/proc/base.c
··· 56 56 #include <linux/init.h> 57 57 #include <linux/capability.h> 58 58 #include <linux/file.h> 59 + #include <linux/fdtable.h> 59 60 #include <linux/string.h> 60 61 #include <linux/seq_file.h> 61 62 #include <linux/namei.h>
+2 -1
fs/select.c
··· 21 21 #include <linux/poll.h> 22 22 #include <linux/personality.h> /* for STICKY_TIMEOUTS */ 23 23 #include <linux/file.h> 24 + #include <linux/fdtable.h> 24 25 #include <linux/fs.h> 25 26 #include <linux/rcupdate.h> 26 27 ··· 299 298 #define MAX_SELECT_SECONDS \ 300 299 ((unsigned long) (MAX_SCHEDULE_TIMEOUT / HZ)-1) 301 300 302 - static int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, 301 + int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, 303 302 fd_set __user *exp, s64 *timeout) 304 303 { 305 304 fd_set_bits fds;
+4 -13
fs/signalfd.c
··· 207 207 208 208 asmlinkage long sys_signalfd(int ufd, sigset_t __user *user_mask, size_t sizemask) 209 209 { 210 - int error; 211 210 sigset_t sigmask; 212 211 struct signalfd_ctx *ctx; 213 - struct file *file; 214 - struct inode *inode; 215 212 216 213 if (sizemask != sizeof(sigset_t) || 217 214 copy_from_user(&sigmask, user_mask, sizeof(sigmask))) ··· 227 230 * When we call this, the initialization must be complete, since 228 231 * anon_inode_getfd() will install the fd. 229 232 */ 230 - error = anon_inode_getfd(&ufd, &inode, &file, "[signalfd]", 231 - &signalfd_fops, ctx); 232 - if (error) 233 - goto err_fdalloc; 233 + ufd = anon_inode_getfd("[signalfd]", &signalfd_fops, ctx); 234 + if (ufd < 0) 235 + kfree(ctx); 234 236 } else { 235 - file = fget(ufd); 237 + struct file *file = fget(ufd); 236 238 if (!file) 237 239 return -EBADF; 238 240 ctx = file->private_data; ··· 248 252 } 249 253 250 254 return ufd; 251 - 252 - err_fdalloc: 253 - kfree(ctx); 254 - return error; 255 255 } 256 -
+3 -8
fs/timerfd.c
··· 181 181 182 182 asmlinkage long sys_timerfd_create(int clockid, int flags) 183 183 { 184 - int error, ufd; 184 + int ufd; 185 185 struct timerfd_ctx *ctx; 186 - struct file *file; 187 - struct inode *inode; 188 186 189 187 if (flags) 190 188 return -EINVAL; ··· 198 200 ctx->clockid = clockid; 199 201 hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS); 200 202 201 - error = anon_inode_getfd(&ufd, &inode, &file, "[timerfd]", 202 - &timerfd_fops, ctx); 203 - if (error) { 203 + ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx); 204 + if (ufd < 0) 204 205 kfree(ctx); 205 - return error; 206 - } 207 206 208 207 return ufd; 209 208 }
+1 -2
include/linux/anon_inodes.h
··· 8 8 #ifndef _LINUX_ANON_INODES_H 9 9 #define _LINUX_ANON_INODES_H 10 10 11 - int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile, 12 - const char *name, const struct file_operations *fops, 11 + int anon_inode_getfd(const char *name, const struct file_operations *fops, 13 12 void *priv); 14 13 15 14 #endif /* _LINUX_ANON_INODES_H */
+99
include/linux/fdtable.h
··· 1 + /* 2 + * descriptor table internals; you almost certainly want file.h instead. 3 + */ 4 + 5 + #ifndef __LINUX_FDTABLE_H 6 + #define __LINUX_FDTABLE_H 7 + 8 + #include <asm/atomic.h> 9 + #include <linux/posix_types.h> 10 + #include <linux/compiler.h> 11 + #include <linux/spinlock.h> 12 + #include <linux/rcupdate.h> 13 + #include <linux/types.h> 14 + 15 + /* 16 + * The default fd array needs to be at least BITS_PER_LONG, 17 + * as this is the granularity returned by copy_fdset(). 18 + */ 19 + #define NR_OPEN_DEFAULT BITS_PER_LONG 20 + 21 + /* 22 + * The embedded_fd_set is a small fd_set, 23 + * suitable for most tasks (which open <= BITS_PER_LONG files) 24 + */ 25 + struct embedded_fd_set { 26 + unsigned long fds_bits[1]; 27 + }; 28 + 29 + struct fdtable { 30 + unsigned int max_fds; 31 + struct file ** fd; /* current fd array */ 32 + fd_set *close_on_exec; 33 + fd_set *open_fds; 34 + struct rcu_head rcu; 35 + struct fdtable *next; 36 + }; 37 + 38 + /* 39 + * Open file table structure 40 + */ 41 + struct files_struct { 42 + /* 43 + * read mostly part 44 + */ 45 + atomic_t count; 46 + struct fdtable *fdt; 47 + struct fdtable fdtab; 48 + /* 49 + * written part on a separate cache line in SMP 50 + */ 51 + spinlock_t file_lock ____cacheline_aligned_in_smp; 52 + int next_fd; 53 + struct embedded_fd_set close_on_exec_init; 54 + struct embedded_fd_set open_fds_init; 55 + struct file * fd_array[NR_OPEN_DEFAULT]; 56 + }; 57 + 58 + #define files_fdtable(files) (rcu_dereference((files)->fdt)) 59 + 60 + extern struct kmem_cache *filp_cachep; 61 + 62 + struct file_operations; 63 + struct vfsmount; 64 + struct dentry; 65 + 66 + extern int expand_files(struct files_struct *, int nr); 67 + extern void free_fdtable_rcu(struct rcu_head *rcu); 68 + extern void __init files_defer_init(void); 69 + 70 + static inline void free_fdtable(struct fdtable *fdt) 71 + { 72 + call_rcu(&fdt->rcu, free_fdtable_rcu); 73 + } 74 + 75 + static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) 76 + { 77 + struct file * file = NULL; 78 + struct fdtable *fdt = files_fdtable(files); 79 + 80 + if (fd < fdt->max_fds) 81 + file = rcu_dereference(fdt->fd[fd]); 82 + return file; 83 + } 84 + 85 + /* 86 + * Check whether the specified fd has an open file. 87 + */ 88 + #define fcheck(fd) fcheck_files(current->files, fd) 89 + 90 + struct task_struct; 91 + 92 + struct files_struct *get_files_struct(struct task_struct *); 93 + void put_files_struct(struct files_struct *fs); 94 + void reset_files_struct(struct files_struct *); 95 + int unshare_files(struct files_struct **); 96 + 97 + extern struct kmem_cache *files_cachep; 98 + 99 + #endif /* __LINUX_FDTABLE_H */
+2 -84
include/linux/file.h
··· 5 5 #ifndef __LINUX_FILE_H 6 6 #define __LINUX_FILE_H 7 7 8 - #include <asm/atomic.h> 9 - #include <linux/posix_types.h> 10 8 #include <linux/compiler.h> 11 - #include <linux/spinlock.h> 12 - #include <linux/rcupdate.h> 13 9 #include <linux/types.h> 10 + #include <linux/posix_types.h> 14 11 15 - /* 16 - * The default fd array needs to be at least BITS_PER_LONG, 17 - * as this is the granularity returned by copy_fdset(). 18 - */ 19 - #define NR_OPEN_DEFAULT BITS_PER_LONG 20 - 21 - /* 22 - * The embedded_fd_set is a small fd_set, 23 - * suitable for most tasks (which open <= BITS_PER_LONG files) 24 - */ 25 - struct embedded_fd_set { 26 - unsigned long fds_bits[1]; 27 - }; 28 - 29 - struct fdtable { 30 - unsigned int max_fds; 31 - struct file ** fd; /* current fd array */ 32 - fd_set *close_on_exec; 33 - fd_set *open_fds; 34 - struct rcu_head rcu; 35 - struct fdtable *next; 36 - }; 37 - 38 - /* 39 - * Open file table structure 40 - */ 41 - struct files_struct { 42 - /* 43 - * read mostly part 44 - */ 45 - atomic_t count; 46 - struct fdtable *fdt; 47 - struct fdtable fdtab; 48 - /* 49 - * written part on a separate cache line in SMP 50 - */ 51 - spinlock_t file_lock ____cacheline_aligned_in_smp; 52 - int next_fd; 53 - struct embedded_fd_set close_on_exec_init; 54 - struct embedded_fd_set open_fds_init; 55 - struct file * fd_array[NR_OPEN_DEFAULT]; 56 - }; 57 - 58 - #define files_fdtable(files) (rcu_dereference((files)->fdt)) 59 - 60 - extern struct kmem_cache *filp_cachep; 12 + struct file; 61 13 62 14 extern void __fput(struct file *); 63 15 extern void fput(struct file *); ··· 37 85 extern int get_unused_fd(void); 38 86 extern int get_unused_fd_flags(int flags); 39 87 extern void put_unused_fd(unsigned int fd); 40 - struct kmem_cache; 41 - 42 - extern int expand_files(struct files_struct *, int nr); 43 - extern void free_fdtable_rcu(struct rcu_head *rcu); 44 - extern void __init files_defer_init(void); 45 - 46 - static inline void free_fdtable(struct fdtable *fdt) 47 - { 48 - call_rcu(&fdt->rcu, free_fdtable_rcu); 49 - } 50 - 51 - static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) 52 - { 53 - struct file * file = NULL; 54 - struct fdtable *fdt = files_fdtable(files); 55 - 56 - if (fd < fdt->max_fds) 57 - file = rcu_dereference(fdt->fd[fd]); 58 - return file; 59 - } 60 - 61 - /* 62 - * Check whether the specified fd has an open file. 63 - */ 64 - #define fcheck(fd) fcheck_files(current->files, fd) 65 88 66 89 extern void fd_install(unsigned int fd, struct file *file); 67 - 68 - struct task_struct; 69 - 70 - struct files_struct *get_files_struct(struct task_struct *); 71 - void put_files_struct(struct files_struct *fs); 72 - void reset_files_struct(struct files_struct *); 73 - int unshare_files(struct files_struct **); 74 - 75 - extern struct kmem_cache *files_cachep; 76 90 77 91 #endif /* __LINUX_FILE_H */
+1 -1
include/linux/init_task.h
··· 1 1 #ifndef _LINUX__INIT_TASK_H 2 2 #define _LINUX__INIT_TASK_H 3 3 4 - #include <linux/file.h> 4 + #include <linux/fdtable.h> 5 5 #include <linux/rcupdate.h> 6 6 #include <linux/irqflags.h> 7 7 #include <linux/utsname.h>
+2
include/linux/poll.h
··· 117 117 extern int do_select(int n, fd_set_bits *fds, s64 *timeout); 118 118 extern int do_sys_poll(struct pollfd __user * ufds, unsigned int nfds, 119 119 s64 *timeout); 120 + extern int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, 121 + fd_set __user *exp, s64 *timeout); 120 122 121 123 #endif /* KERNEL */ 122 124
+1
kernel/exit.c
··· 19 19 #include <linux/acct.h> 20 20 #include <linux/tsacct_kern.h> 21 21 #include <linux/file.h> 22 + #include <linux/fdtable.h> 22 23 #include <linux/binfmts.h> 23 24 #include <linux/nsproxy.h> 24 25 #include <linux/pid_namespace.h>
+1
kernel/fork.c
··· 22 22 #include <linux/mempolicy.h> 23 23 #include <linux/sem.h> 24 24 #include <linux/file.h> 25 + #include <linux/fdtable.h> 25 26 #include <linux/key.h> 26 27 #include <linux/binfmts.h> 27 28 #include <linux/mman.h>
+1
kernel/kmod.c
··· 27 27 #include <linux/mnt_namespace.h> 28 28 #include <linux/completion.h> 29 29 #include <linux/file.h> 30 + #include <linux/fdtable.h> 30 31 #include <linux/workqueue.h> 31 32 #include <linux/security.h> 32 33 #include <linux/mount.h>
+1
security/selinux/hooks.c
··· 39 39 #include <linux/spinlock.h> 40 40 #include <linux/syscalls.h> 41 41 #include <linux/file.h> 42 + #include <linux/fdtable.h> 42 43 #include <linux/namei.h> 43 44 #include <linux/mount.h> 44 45 #include <linux/ext2_fs.h>
+5 -16
virt/kvm/kvm_main.c
··· 834 834 */ 835 835 static int create_vcpu_fd(struct kvm_vcpu *vcpu) 836 836 { 837 - int fd, r; 838 - struct inode *inode; 839 - struct file *file; 840 - 841 - r = anon_inode_getfd(&fd, &inode, &file, 842 - "kvm-vcpu", &kvm_vcpu_fops, vcpu); 843 - if (r) { 837 + int fd = anon_inode_getfd("kvm-vcpu", &kvm_vcpu_fops, vcpu); 838 + if (fd < 0) 844 839 kvm_put_kvm(vcpu->kvm); 845 - return r; 846 - } 847 840 return fd; 848 841 } 849 842 ··· 1161 1168 1162 1169 static int kvm_dev_ioctl_create_vm(void) 1163 1170 { 1164 - int fd, r; 1165 - struct inode *inode; 1166 - struct file *file; 1171 + int fd; 1167 1172 struct kvm *kvm; 1168 1173 1169 1174 kvm = kvm_create_vm(); 1170 1175 if (IS_ERR(kvm)) 1171 1176 return PTR_ERR(kvm); 1172 - r = anon_inode_getfd(&fd, &inode, &file, "kvm-vm", &kvm_vm_fops, kvm); 1173 - if (r) { 1177 + fd = anon_inode_getfd("kvm-vm", &kvm_vm_fops, kvm); 1178 + if (fd < 0) 1174 1179 kvm_put_kvm(kvm); 1175 - return r; 1176 - } 1177 1180 1178 1181 return fd; 1179 1182 }