Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 70714
b: refs/heads/master
c: 22d2b35
h: refs/heads/master
v: v3
  • Loading branch information
Ulrich Drepper authored and Linus Torvalds committed Oct 17, 2007
1 parent 99b93a1 commit 93f041a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 18796aa00243a594a2bd6733f1360aa38c3cd8f4
refs/heads/master: 22d2b35b200f76085c16a2e14ca30b58510fcbe7
12 changes: 8 additions & 4 deletions trunk/fs/fcntl.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static int locate_fd(struct files_struct *files,
return error;
}

static int dupfd(struct file *file, unsigned int start)
static int dupfd(struct file *file, unsigned int start, int cloexec)
{
struct files_struct * files = current->files;
struct fdtable *fdt;
Expand All @@ -122,7 +122,10 @@ static int dupfd(struct file *file, unsigned int start)
/* locate_fd() may have expanded fdtable, load the ptr */
fdt = files_fdtable(files);
FD_SET(fd, fdt->open_fds);
FD_CLR(fd, fdt->close_on_exec);
if (cloexec)
FD_SET(fd, fdt->close_on_exec);
else
FD_CLR(fd, fdt->close_on_exec);
spin_unlock(&files->file_lock);
fd_install(fd, file);
} else {
Expand Down Expand Up @@ -195,7 +198,7 @@ asmlinkage long sys_dup(unsigned int fildes)
struct file * file = fget(fildes);

if (file)
ret = dupfd(file, 0);
ret = dupfd(file, 0, 0);
return ret;
}

Expand Down Expand Up @@ -319,8 +322,9 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,

switch (cmd) {
case F_DUPFD:
case F_DUPFD_CLOEXEC:
get_file(filp);
err = dupfd(filp, arg);
err = dupfd(filp, arg, cmd == F_DUPFD_CLOEXEC);
break;
case F_GETFD:
err = get_close_on_exec(fd) ? FD_CLOEXEC : 0;
Expand Down
15 changes: 10 additions & 5 deletions trunk/include/linux/fcntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@

#include <asm/fcntl.h>

/* Cancel a blocking posix lock; internal use only until we expose an
* asynchronous lock api to userspace: */
#define F_CANCELLK (F_LINUX_SPECIFIC_BASE+5)
#define F_SETLEASE (F_LINUX_SPECIFIC_BASE + 0)
#define F_GETLEASE (F_LINUX_SPECIFIC_BASE + 1)

#define F_SETLEASE (F_LINUX_SPECIFIC_BASE+0)
#define F_GETLEASE (F_LINUX_SPECIFIC_BASE+1)
/*
* Cancel a blocking posix lock; internal use only until we expose an
* asynchronous lock api to userspace:
*/
#define F_CANCELLK (F_LINUX_SPECIFIC_BASE + 5)

/* Create a file descriptor with FD_CLOEXEC set. */
#define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6)

/*
* Request nofications on a directory.
Expand Down

0 comments on commit 93f041a

Please sign in to comment.