X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=fs%2Ffcntl.c;h=dc4a7007f4e742c4e30563db78b34bd21d39ab58;hb=90f0094dc607abe384a412bfb7199fb667ab0735;hp=9903bde475f2ec4877bd0f0f32e76b2939ebf81f;hpb=850d6fbe70c62a9792eac3e8ef34f2f09f209895;p=karo-tx-linux.git diff --git a/fs/fcntl.c b/fs/fcntl.c index 9903bde475f2..dc4a7007f4e7 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -35,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; @@ -207,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 */