diff options
-rw-r--r-- | fs/fcntl.c | 12 | ||||
-rw-r--r-- | include/linux/fcntl.h | 15 |
2 files changed, 18 insertions, 9 deletions
diff --git a/fs/fcntl.c b/fs/fcntl.c index 78b2ff044054..c9db73fc5e3d 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -110,7 +110,7 @@ out: | |||
110 | return error; | 110 | return error; |
111 | } | 111 | } |
112 | 112 | ||
113 | static int dupfd(struct file *file, unsigned int start) | 113 | static int dupfd(struct file *file, unsigned int start, int cloexec) |
114 | { | 114 | { |
115 | struct files_struct * files = current->files; | 115 | struct files_struct * files = current->files; |
116 | struct fdtable *fdt; | 116 | struct fdtable *fdt; |
@@ -122,7 +122,10 @@ static int dupfd(struct file *file, unsigned int start) | |||
122 | /* locate_fd() may have expanded fdtable, load the ptr */ | 122 | /* locate_fd() may have expanded fdtable, load the ptr */ |
123 | fdt = files_fdtable(files); | 123 | fdt = files_fdtable(files); |
124 | FD_SET(fd, fdt->open_fds); | 124 | FD_SET(fd, fdt->open_fds); |
125 | FD_CLR(fd, fdt->close_on_exec); | 125 | if (cloexec) |
126 | FD_SET(fd, fdt->close_on_exec); | ||
127 | else | ||
128 | FD_CLR(fd, fdt->close_on_exec); | ||
126 | spin_unlock(&files->file_lock); | 129 | spin_unlock(&files->file_lock); |
127 | fd_install(fd, file); | 130 | fd_install(fd, file); |
128 | } else { | 131 | } else { |
@@ -195,7 +198,7 @@ asmlinkage long sys_dup(unsigned int fildes) | |||
195 | struct file * file = fget(fildes); | 198 | struct file * file = fget(fildes); |
196 | 199 | ||
197 | if (file) | 200 | if (file) |
198 | ret = dupfd(file, 0); | 201 | ret = dupfd(file, 0, 0); |
199 | return ret; | 202 | return ret; |
200 | } | 203 | } |
201 | 204 | ||
@@ -319,8 +322,9 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, | |||
319 | 322 | ||
320 | switch (cmd) { | 323 | switch (cmd) { |
321 | case F_DUPFD: | 324 | case F_DUPFD: |
325 | case F_DUPFD_CLOEXEC: | ||
322 | get_file(filp); | 326 | get_file(filp); |
323 | err = dupfd(filp, arg); | 327 | err = dupfd(filp, arg, cmd == F_DUPFD_CLOEXEC); |
324 | break; | 328 | break; |
325 | case F_GETFD: | 329 | case F_GETFD: |
326 | err = get_close_on_exec(fd) ? FD_CLOEXEC : 0; | 330 | err = get_close_on_exec(fd) ? FD_CLOEXEC : 0; |
diff --git a/include/linux/fcntl.h b/include/linux/fcntl.h index 40b93265d4ba..86037400a6e3 100644 --- a/include/linux/fcntl.h +++ b/include/linux/fcntl.h | |||
@@ -3,12 +3,17 @@ | |||
3 | 3 | ||
4 | #include <asm/fcntl.h> | 4 | #include <asm/fcntl.h> |
5 | 5 | ||
6 | /* Cancel a blocking posix lock; internal use only until we expose an | 6 | #define F_SETLEASE (F_LINUX_SPECIFIC_BASE + 0) |
7 | * asynchronous lock api to userspace: */ | 7 | #define F_GETLEASE (F_LINUX_SPECIFIC_BASE + 1) |
8 | #define F_CANCELLK (F_LINUX_SPECIFIC_BASE+5) | ||
9 | 8 | ||
10 | #define F_SETLEASE (F_LINUX_SPECIFIC_BASE+0) | 9 | /* |
11 | #define F_GETLEASE (F_LINUX_SPECIFIC_BASE+1) | 10 | * Cancel a blocking posix lock; internal use only until we expose an |
11 | * asynchronous lock api to userspace: | ||
12 | */ | ||
13 | #define F_CANCELLK (F_LINUX_SPECIFIC_BASE + 5) | ||
14 | |||
15 | /* Create a file descriptor with FD_CLOEXEC set. */ | ||
16 | #define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6) | ||
12 | 17 | ||
13 | /* | 18 | /* |
14 | * Request nofications on a directory. | 19 | * Request nofications on a directory. |