fdmap v2 - implement sys_nonseqfd
Subsystems (3)
PATCH 3/8 fdmap v2 - implement sys_nonseqfd
This patch implement a new syscall sys_nonseqfd():
int nonseqfd(int fd, int flags);
The sys_nonseqfd() syscall can be used to map an existing file descriptor inside the non-sequential fd area.
Signed-off-by Davide Libenzi <[email protected]>
- Davide
fs/fcntl.c +19 -0
@@ -81,6 +81,25 @@return fd; } +asmlinkage long sys_nonseqfd (unsigned int fd,unsigned int flags) +{ +struct files_struct *files = current->files; +int nfd = -EBADF ; +struct file *file; + +spin_lock (&files->file_lock); +if (!(file =fcheck (fd))) + goto out_unlock; + nfd =__alloc_nonseq_fd (files, flags); +if (likely (nfd >=0 )) +get_file (file); +out_unlock: +spin_unlock (&files->file_lock); +if (likely (nfd >=0 )) +fd_install (nfd, file); +return nfd; +} +static int dupfd (struct file *file,unsigned int start) {struct files_struct *files = current->files;
include/linux/syscalls.h +1 -0
@@ -302,6 +302,7 @@asmlinkage long sys_fcntl64 (unsigned int fd,unsigned int cmd,unsigned long arg);#endif +asmlinkage long sys_nonseqfd (unsigned int fd,unsigned int flags);asmlinkage long sys_dup (unsigned int fildes);asmlinkage long sys_dup2 (unsigned int oldfd,unsigned int newfd);asmlinkage long sys_ioperm (unsigned long from,unsigned long num,int on);