X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=fs%2Ffcntl.c;h=8685263ccc4a7aa51d6666136c285687393bfabb;hb=d85f50d5e1aa99ab082035f94265847521819e58;hp=4740d35e52cd72849ef18cd1879bc452085f8c7f;hpb=7f3af60e5a444b287d740a84998a8f480645dadf;p=powerpc.git diff --git a/fs/fcntl.c b/fs/fcntl.c index 4740d35e52..8685263ccc 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -77,10 +78,9 @@ repeat: start = files->next_fd; newfd = start; - if (start < fdt->max_fdset) { + if (start < fdt->max_fds) newfd = find_next_zero_bit(fdt->open_fds->fds_bits, - fdt->max_fdset, start); - } + fdt->max_fds, start); error = -EMFILE; if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) @@ -111,7 +111,7 @@ out: 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; @@ -123,7 +123,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 { @@ -196,7 +199,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; } @@ -204,7 +207,7 @@ asmlinkage long sys_dup(unsigned int fildes) static int setfl(int fd, struct file * filp, unsigned long arg) { - struct inode * inode = filp->f_dentry->d_inode; + struct inode * inode = filp->f_path.dentry->d_inode; int error = 0; /* @@ -216,7 +219,7 @@ static int setfl(int fd, struct file * filp, unsigned long arg) /* O_NOATIME can only be set by the owner or superuser */ if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) - if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) + if (!is_owner_or_cap(inode)) return -EPERM; /* required for strict SunOS emulation */ @@ -290,7 +293,7 @@ int f_setown(struct file *filp, unsigned long arg, int force) who = -who; } rcu_read_lock(); - pid = find_pid(who); + pid = find_vpid(who); result = __f_setown(filp, pid, type, force); rcu_read_unlock(); return result; @@ -306,7 +309,7 @@ pid_t f_getown(struct file *filp) { pid_t pid; read_lock(&filp->f_owner.lock); - pid = pid_nr(filp->f_owner.pid); + pid = pid_nr_ns(filp->f_owner.pid, current->nsproxy->pid_ns); if (filp->f_owner.pid_type == PIDTYPE_PGID) pid = -pid; read_unlock(&filp->f_owner.lock); @@ -320,8 +323,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; @@ -639,7 +643,7 @@ EXPORT_SYMBOL(kill_fasync); static int __init fasync_init(void) { fasync_cache = kmem_cache_create("fasync_cache", - sizeof(struct fasync_struct), 0, SLAB_PANIC, NULL, NULL); + sizeof(struct fasync_struct), 0, SLAB_PANIC, NULL); return 0; }