X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=fs%2Ffcntl.c;h=dc4a7007f4e742c4e30563db78b34bd21d39ab58;hb=90f0094dc607abe384a412bfb7199fb667ab0735;hp=d0767fe5836247dd68aac8d7f3bd5818984e2790;hpb=9f5974c8734d83d4ab7096ed98136a82f41210d6;p=karo-tx-linux.git diff --git a/fs/fcntl.c b/fs/fcntl.c index d0767fe58362..dc4a7007f4e7 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -36,7 +36,7 @@ void fastcall set_close_on_exec(unsigned int fd, int flag) spin_unlock(&files->file_lock); } -static inline int get_close_on_exec(unsigned int fd) +static int get_close_on_exec(unsigned int fd) { struct files_struct *files = current->files; struct fdtable *fdt; @@ -208,8 +208,11 @@ static int setfl(int fd, struct file * filp, unsigned long arg) struct inode * inode = filp->f_dentry->d_inode; int error = 0; - /* O_APPEND cannot be cleared if the file is marked as append-only */ - if (!(arg & O_APPEND) && IS_APPEND(inode)) + /* + * O_APPEND cannot be cleared if the file is marked as append-only + * and the file is open for write. + */ + if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) return -EPERM; /* O_NOATIME can only be set by the owner or superuser */