X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Ffcntl.c;h=4cac5ba473adec8cf624f7dd74b766678dd7f7ee;hb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;hp=3fe5cdae376ff88c42328030fbfd6433566a68d2;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/fs/fcntl.c b/fs/fcntl.c index 3fe5cdae3..4cac5ba47 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -142,7 +142,7 @@ static int dupfd(struct file *file, unsigned int start) FD_SET(fd, files->open_fds); FD_CLR(fd, files->close_on_exec); spin_unlock(&files->file_lock); - vx_openfd_inc(fd); + // vx_openfd_inc(fd); fd_install(fd, file); } else { spin_unlock(&files->file_lock); @@ -190,7 +190,7 @@ asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd) FD_SET(newfd, files->open_fds); FD_CLR(newfd, files->close_on_exec); spin_unlock(&files->file_lock); - vx_openfd_inc(newfd); + // vx_openfd_inc(newfd); if (tofree) filp_close(tofree, files); @@ -217,7 +217,7 @@ asmlinkage long sys_dup(unsigned int fildes) return ret; } -#define SETFL_MASK (O_APPEND | O_NONBLOCK | O_NDELAY | FASYNC | O_DIRECT) +#define SETFL_MASK (O_APPEND | O_NONBLOCK | O_NDELAY | FASYNC | O_DIRECT | O_NOATIME) static int setfl(int fd, struct file * filp, unsigned long arg) { @@ -228,6 +228,11 @@ static int setfl(int fd, struct file * filp, unsigned long arg) if (!(arg & O_APPEND) && IS_APPEND(inode)) return -EPERM; + /* 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)) + return -EPERM; + /* required for strict SunOS emulation */ if (O_NONBLOCK != O_NDELAY) if (arg & O_NDELAY) @@ -239,6 +244,11 @@ static int setfl(int fd, struct file * filp, unsigned long arg) return -EINVAL; } + if (filp->f_op && filp->f_op->check_flags) + error = filp->f_op->check_flags(arg); + if (error) + return error; + lock_kernel(); if ((arg ^ filp->f_flags) & FASYNC) { if (filp->f_op && filp->f_op->fasync) { @@ -287,8 +297,8 @@ void f_delown(struct file *filp) EXPORT_SYMBOL(f_delown); -long generic_file_fcntl(int fd, unsigned int cmd, - unsigned long arg, struct file *filp) +static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, + struct file *filp) { long err = -EINVAL; @@ -356,15 +366,6 @@ long generic_file_fcntl(int fd, unsigned int cmd, } return err; } -EXPORT_SYMBOL(generic_file_fcntl); - -static long do_fcntl(int fd, unsigned int cmd, - unsigned long arg, struct file *filp) -{ - if (filp->f_op && filp->f_op->fcntl) - return filp->f_op->fcntl(fd, cmd, arg, filp); - return generic_file_fcntl(fd, cmd, arg, filp); -} asmlinkage long sys_fcntl(int fd, unsigned int cmd, unsigned long arg) { @@ -496,16 +497,14 @@ void send_sigio(struct fown_struct *fown, int fd, int band) read_lock(&tasklist_lock); if (pid > 0) { - p = find_task_by_pid(pid); + p = find_task_by_real_pid(pid); if (p) { send_sigio_to_task(p, fown, fd, band); } } else { - struct list_head *l; - struct pid *pidptr; - for_each_task_pid(-pid, PIDTYPE_PGID, p, l, pidptr) { + do_each_task_pid(-pid, PIDTYPE_PGID, p) { send_sigio_to_task(p, fown, fd, band); - } + } while_each_task_pid(-pid, PIDTYPE_PGID, p); } read_unlock(&tasklist_lock); out_unlock_fown: @@ -533,16 +532,14 @@ int send_sigurg(struct fown_struct *fown) read_lock(&tasklist_lock); if (pid > 0) { - p = find_task_by_pid(pid); + p = find_task_by_real_pid(pid); if (p) { send_sigurg_to_task(p, fown); } } else { - struct list_head *l; - struct pid *pidptr; - for_each_task_pid(-pid, PIDTYPE_PGID, p, l, pidptr) { + do_each_task_pid(-pid, PIDTYPE_PGID, p) { send_sigurg_to_task(p, fown); - } + } while_each_task_pid(-pid, PIDTYPE_PGID, p); } read_unlock(&tasklist_lock); out_unlock_fown: