Re: [RFC][PATCH] vfs: add closefrom(2) syscall

2014-04-08 Thread Zheng Liu
On Tue, Apr 08, 2014 at 10:21:37AM +0200, Mateusz Guzik wrote: > On Tue, Apr 08, 2014 at 03:12:22PM +0800, Zheng Liu wrote: > > > > +int __close_fds(struct files_struct *files, int lowfd) > > +{ > > + struct file *file; > > + struct fdtable *fdt; > > + int fd; > > + > > + if (lowfd < 0) >

Re: [RFC][PATCH] vfs: add closefrom(2) syscall

2014-04-08 Thread Mateusz Guzik
On Tue, Apr 08, 2014 at 03:12:22PM +0800, Zheng Liu wrote: > > +int __close_fds(struct files_struct *files, int lowfd) > +{ > + struct file *file; > + struct fdtable *fdt; > + int fd; > + > + if (lowfd < 0) > + lowfd = 0; > + spin_lock(&files->file_lock); > + f

[RFC][PATCH] vfs: add closefrom(2) syscall

2014-04-08 Thread Zheng Liu
From: Zheng Liu This commit adds a new syscall called closefrom(2) which is almost the same as closefrom(2) in FreeBSD. This syscall will close all open file descriptors that is greater than or equal to the fd that is indicated by caller. It is really useful for an application that has opened a