r7963: Add aio support to 3.0.
[jra/samba/.git] / source3 / smbd / open.c
index fbe763ab0ac5cc941ed0976ae9530300f4e0c960..9da53a5057a96116e457157010bfbd7cb6ff5c4d 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "includes.h"
 
+extern struct current_user current_user;
 extern userdom_struct current_user_info;
 extern uint16 global_oplock_port;
 extern uint16 global_smbpid;
@@ -172,7 +173,6 @@ Error was %s\n",
 static BOOL open_file(files_struct *fsp,connection_struct *conn,
                      const char *fname,SMB_STRUCT_STAT *psbuf,int flags,mode_t mode, uint32 desired_access)
 {
-       extern struct current_user current_user;
        int accmode = (flags & O_ACCMODE);
        int local_flags = flags;
 
@@ -304,7 +304,6 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn,
        fsp->dev = psbuf->st_dev;
        fsp->vuid = current_user.vuid;
        fsp->file_pid = global_smbpid;
-       fsp->size = psbuf->st_size;
        fsp->can_lock = True;
        fsp->can_read = ((flags & O_WRONLY)==0);
        fsp->can_write = ((flags & (O_WRONLY|O_RDWR))!=0);
@@ -317,6 +316,10 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn,
        fsp->is_directory = False;
        fsp->is_stat = False;
        fsp->directory_delete_on_close = False;
+       if (conn->aio_write_behind_list && is_in_path(fname, conn->aio_write_behind_list, conn->case_sensitive)) {
+               fsp->aio_write_behind = True;
+       }
+
        string_set(&fsp->fsp_name,fname);
        fsp->wcp = NULL; /* Write cache pointer. */
 
@@ -1159,6 +1162,7 @@ files_struct *open_file_shared1(connection_struct *conn,char *fname, SMB_STRUCT_
                append does not mean the same thing under dos and unix */
 
        switch (GET_OPEN_MODE(share_mode)) {
+               case DOS_OPEN_EXEC:
                case DOS_OPEN_RDONLY:
                        flags = O_RDONLY;
                        if (desired_access == 0)
@@ -1176,7 +1180,6 @@ files_struct *open_file_shared1(connection_struct *conn,char *fname, SMB_STRUCT_
                                desired_access = FILE_READ_DATA|FILE_WRITE_DATA;
                        break;
                case DOS_OPEN_RDWR: 
-               case DOS_OPEN_EXEC:
                        flags = O_RDWR; 
                        if (desired_access == 0)
                                desired_access = FILE_READ_DATA|FILE_WRITE_DATA;
@@ -1435,7 +1438,7 @@ flags=0x%X flags2=0x%X mode=0%o returned %d\n",
        DEBUG(10,("open_file_shared : share_mode = %x\n", fsp->share_mode ));
 
        if (Access) {
-               (*Access) = open_mode;
+               (*Access) = (SET_DENY_MODE(deny_mode) | SET_OPEN_MODE(open_mode));
        }
 
        action = 0;
@@ -1606,7 +1609,6 @@ int close_file_fchmod(files_struct *fsp)
 files_struct *open_directory(connection_struct *conn, const char *fname, SMB_STRUCT_STAT *psbuf,
                        uint32 desired_access, int share_mode, int smb_ofun, int *action)
 {
-       extern struct current_user current_user;
        BOOL got_stat = False;
        files_struct *fsp = file_new(conn);
        BOOL delete_on_close = GET_DELETE_ON_CLOSE_FLAG(share_mode);
@@ -1702,7 +1704,6 @@ files_struct *open_directory(connection_struct *conn, const char *fname, SMB_STR
        fsp->mode = psbuf->st_mode;
        fsp->inode = psbuf->st_ino;
        fsp->dev = psbuf->st_dev;
-       fsp->size = psbuf->st_size;
        fsp->vuid = current_user.vuid;
        fsp->file_pid = global_smbpid;
        fsp->can_lock = True;
@@ -1744,7 +1745,6 @@ files_struct *open_directory(connection_struct *conn, const char *fname, SMB_STR
 
 files_struct *open_file_stat(connection_struct *conn, char *fname, SMB_STRUCT_STAT *psbuf)
 {
-       extern struct current_user current_user;
        files_struct *fsp = NULL;
 
        if (!VALID_STAT(*psbuf))
@@ -1767,7 +1767,6 @@ files_struct *open_file_stat(connection_struct *conn, char *fname, SMB_STRUCT_ST
        fsp->mode = psbuf->st_mode;
        fsp->inode = psbuf->st_ino;
        fsp->dev = psbuf->st_dev;
-       fsp->size = psbuf->st_size;
        fsp->vuid = current_user.vuid;
        fsp->file_pid = global_smbpid;
        fsp->can_lock = False;