]> git.samba.org - mat/samba.git/commitdiff
s3: Factor out calculate_open_access_flags
authorVolker Lendecke <vl@samba.org>
Tue, 4 Sep 2012 07:22:49 +0000 (09:22 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 25 Sep 2012 22:22:56 +0000 (00:22 +0200)
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Sep 26 00:22:56 CEST 2012 on sn-devel-104

source3/smbd/open.c

index e33c4abcc1df51c90109343e272d5b655eab28b2..2785d6f3d1892e71d39a954f32f43f59b72ae7dd 100644 (file)
@@ -1869,6 +1869,35 @@ static int disposition_to_open_flags(uint32_t create_disposition)
        return ret;
 }
 
+static int calculate_open_access_flags(uint32_t access_mask,
+                                      int oplock_request,
+                                      uint32_t private_flags)
+{
+       int flags;
+
+       /*
+        * Note that we ignore the append flag as append does not
+        * mean the same thing under DOS and Unix.
+        */
+
+       if ((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ||
+           (oplock_request & FORCE_OPLOCK_BREAK_TO_NONE)) {
+               /* DENY_DOS opens are always underlying read-write on the
+                  file handle, no matter what the requested access mask
+                   says. */
+               if ((private_flags & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS) ||
+                   access_mask & (FILE_READ_ATTRIBUTES|FILE_READ_DATA|
+                                  FILE_READ_EA|FILE_EXECUTE)) {
+                       flags = O_RDWR;
+               } else {
+                       flags = O_WRONLY;
+               }
+       } else {
+               flags = O_RDONLY;
+       }
+       return flags;
+}
+
 /****************************************************************************
  Open a file with a share mode. Passed in an already created files_struct *.
 ****************************************************************************/
@@ -2123,21 +2152,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
         * mean the same thing under DOS and Unix.
         */
 
-       if ((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ||
-           (oplock_request & FORCE_OPLOCK_BREAK_TO_NONE)) {
-               /* DENY_DOS opens are always underlying read-write on the
-                  file handle, no matter what the requested access mask
-                   says. */
-               if ((private_flags & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS) ||
-                   access_mask & (FILE_READ_ATTRIBUTES|FILE_READ_DATA|
-                                  FILE_READ_EA|FILE_EXECUTE)) {
-                       flags = O_RDWR;
-               } else {
-                       flags = O_WRONLY;
-               }
-       } else {
-               flags = O_RDONLY;
-       }
+       flags = calculate_open_access_flags(access_mask, oplock_request,
+                                           private_flags);
 
        /*
         * Currently we only look at FILE_WRITE_THROUGH for create options.