diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 8ea6ca5..39354c2 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -43,6 +43,9 @@ #include "cifs_fs_sb.h" #include "fscache.h" +static bool warned_on_bad_open_flags; /* globals init to false automatically */ + + static inline int cifs_convert_flags(unsigned int flags) { if ((flags & O_ACCMODE) == O_RDONLY) @@ -72,10 +75,17 @@ static u32 cifs_posix_convert_flags(unsigned int flags) else if ((flags & O_ACCMODE) == O_RDWR) posix_flags = SMB_O_RDWR; - if (flags & O_CREAT) + if (flags & O_CREAT) { posix_flags |= SMB_O_CREAT; - if (flags & O_EXCL) - posix_flags |= SMB_O_EXCL; + if (flags & O_EXCL) + posix_flags |= SMB_O_EXCL; + } else if (flags & O_EXCL) { + warned_on_bad_open_flags = true; + cERROR(1, "Application has incorrectly set O_EXCL flag but " + "not O_CREAT on file open. Ignoring O_EXCL"); + } + + if (flags & O_TRUNC) posix_flags |= SMB_O_TRUNC; /* be safe and imply O_SYNC for O_DSYNC */