The branch, v3-2-test has been updated
       via  14294535512a7f191c5008e622b6708e417854ae (commit)
       via  74ed53a115b2063d4d5c8572af8f1302bc658882 (commit)
       via  d928e6648d61cf2d3c1b77db440efb835b729a84 (commit)
       via  df264bf3e00d7d77afcf55e54d2669b9ffa9af4a (commit)
       via  3cf56b124a2886c6260455bba4bf77d08e9a4f77 (commit)
      from  3acc0d84dc8f29b67ddaa1124224a93cb43b07ad (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 14294535512a7f191c5008e622b6708e417854ae
Author: Michael Adam <[EMAIL PROTECTED]>
Date:   Fri Jan 11 14:19:28 2008 +0100

    Remove redundant parameter fd from SMB_VFS_CLOSE().
    
    Now all those redundant fd's have vanished from the VFS API.
    
    Michael

commit 74ed53a115b2063d4d5c8572af8f1302bc658882
Author: Michael Adam <[EMAIL PROTECTED]>
Date:   Fri Jan 11 13:41:46 2008 +0100

    Slight reformatting of fd_close_posix(), while I'm at it.
    
    Wrap lines and remove trailing space.
    
    Michael

commit d928e6648d61cf2d3c1b77db440efb835b729a84
Author: Michael Adam <[EMAIL PROTECTED]>
Date:   Fri Jan 11 13:28:28 2008 +0100

    Change fd_close_posix() to return int instead of NTSTATUS.
    
    The errno is handed up through the VFS layer to the callers.
    
    Michael

commit df264bf3e00d7d77afcf55e54d2669b9ffa9af4a
Author: Michael Adam <[EMAIL PROTECTED]>
Date:   Fri Jan 11 13:03:16 2008 +0100

    Don't modify the fsp in fd_close_posix() anymore.
    
    Now that it is inside the vfs layer, this function should
    not alter the fsp (i.e. set fsp->fh->fd = -1) anymore.
    That belongs above the vfs layer.
    
    Michael

commit 3cf56b124a2886c6260455bba4bf77d08e9a4f77
Author: Michael Adam <[EMAIL PROTECTED]>
Date:   Fri Jan 11 12:18:33 2008 +0100

    Move the posix pending close functionality down into the VFS layer.
    
    This hides the pending close fds from the outside. Call order
    of SMB_VFS_CLOSE is reversed. Originally, it was:
    
    fd_close -> fd_close_posix -> SMB_VFS_CLOSE -> close
    
    And now it is:
    
    fd_close -> SMB_VFS_CLOSE -> fd_close_posix -> close
    
    This is in preparation of removing the fd parameter
    from the SMB_VFS_CLOSE function. But it is also the right
    place for the pending close calls anyways.
    
    Michael

-----------------------------------------------------------------------

Summary of changes:
 examples/VFS/skel_opaque.c         |    4 ++--
 examples/VFS/skel_transparent.c    |    4 ++--
 source/include/vfs.h               |    3 ++-
 source/include/vfs_macros.h        |    6 +++---
 source/locking/posix.c             |   36 ++++++++++++++----------------------
 source/modules/vfs_audit.c         |    8 ++++----
 source/modules/vfs_commit.c        |    5 ++---
 source/modules/vfs_default.c       |    5 ++---
 source/modules/vfs_extd_audit.c    |   10 +++++-----
 source/modules/vfs_full_audit.c    |    6 +++---
 source/modules/vfs_streams_xattr.c |    2 +-
 source/modules/vfs_syncops.c       |    6 +++---
 source/smbd/open.c                 |   10 +++++++++-
 source/torture/cmd_vfs.c           |    2 +-
 14 files changed, 53 insertions(+), 54 deletions(-)


Changeset truncated at 500 lines:

diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index 4a6e6be..eb49f35 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -125,9 +125,9 @@ static int skel_open(vfs_handle_struct *handle,  const char 
*fname, files_struct
        return vfswrap_open(NULL,  fname, flags, mode);
 }
 
-static int skel_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int skel_close(vfs_handle_struct *handle, files_struct *fsp)
 {
-       return vfswrap_close(NULL, fsp, fd);
+       return vfswrap_close(NULL, fsp);
 }
 
 static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, void 
*data, size_t n)
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index f4cb9b1..7102d4d 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -119,9 +119,9 @@ static int skel_open(vfs_handle_struct *handle,  const char 
*fname, files_struct
        return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
 }
 
-static int skel_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int skel_close(vfs_handle_struct *handle, files_struct *fsp)
 {
-       return SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
+       return SMB_VFS_NEXT_CLOSE(handle, fsp);
 }
 
 static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, void 
*data, size_t n)
diff --git a/source/include/vfs.h b/source/include/vfs.h
index ca176aa..c839716 100644
--- a/source/include/vfs.h
+++ b/source/include/vfs.h
@@ -105,6 +105,7 @@
 /* Leave at 22 - not yet released. Remove parameter fromfd from recvfile. - 
obnox */
 /* Leave at 22 - not yet released. Additional change: add operations for 
offline files -- ab */
 /* Leave at 22 - not yet released. Add the streaminfo call. -- jpeach, vl */
+/* Leave at 22 - not yet released. Remove parameter fd from close_fn. - obnox 
*/
 
 #define SMB_VFS_INTERFACE_VERSION 22
 
@@ -301,7 +302,7 @@ struct vfs_ops {
                /* File operations */
 
                int (*open)(struct vfs_handle_struct *handle, const char 
*fname, files_struct *fsp, int flags, mode_t mode);
-               int (*close_fn)(struct vfs_handle_struct *handle, struct 
files_struct *fsp, int fd);
+               int (*close_fn)(struct vfs_handle_struct *handle, struct 
files_struct *fsp);
                ssize_t (*read)(struct vfs_handle_struct *handle, struct 
files_struct *fsp, void *data, size_t n);
                ssize_t (*pread)(struct vfs_handle_struct *handle, struct 
files_struct *fsp, void *data, size_t n, SMB_OFF_T offset);
                ssize_t (*write)(struct vfs_handle_struct *handle, struct 
files_struct *fsp, const void *data, size_t n);
diff --git a/source/include/vfs_macros.h b/source/include/vfs_macros.h
index 1e64bd5..f0a9809 100644
--- a/source/include/vfs_macros.h
+++ b/source/include/vfs_macros.h
@@ -48,7 +48,7 @@
 
 /* File operations */
 #define SMB_VFS_OPEN(conn, fname, fsp, flags, mode) 
(((conn)->vfs.ops.open)((conn)->vfs.handles.open, (fname), (fsp), (flags), 
(mode)))
-#define SMB_VFS_CLOSE(fsp, fd) 
((fsp)->conn->vfs.ops.close_fn((fsp)->conn->vfs.handles.close_hnd, (fsp), (fd)))
+#define SMB_VFS_CLOSE(fsp) 
((fsp)->conn->vfs.ops.close_fn((fsp)->conn->vfs.handles.close_hnd, (fsp)))
 #define SMB_VFS_READ(fsp, data, n) 
((fsp)->conn->vfs.ops.read((fsp)->conn->vfs.handles.read, (fsp), (data), (n)))
 #define SMB_VFS_PREAD(fsp, data, n, off) 
((fsp)->conn->vfs.ops.pread((fsp)->conn->vfs.handles.pread, (fsp), (data), (n), 
(off)))
 #define SMB_VFS_WRITE(fsp, data, n) 
((fsp)->conn->vfs.ops.write((fsp)->conn->vfs.handles.write, (fsp), (data), (n)))
@@ -174,7 +174,7 @@
 
 /* File operations */
 #define SMB_VFS_OPAQUE_OPEN(conn, fname, fsp, flags, mode) 
(((conn)->vfs_opaque.ops.open)((conn)->vfs_opaque.handles.open, (fname), (fsp), 
(flags), (mode)))
-#define SMB_VFS_OPAQUE_CLOSE(fsp, fd) 
((fsp)->conn->vfs_opaque.ops.close_fn((fsp)->conn->vfs_opaque.handles.close_hnd,
 (fsp), (fd)))
+#define SMB_VFS_OPAQUE_CLOSE(fsp) 
((fsp)->conn->vfs_opaque.ops.close_fn((fsp)->conn->vfs_opaque.handles.close_hnd,
 (fsp)))
 #define SMB_VFS_OPAQUE_READ(fsp, data, n) 
((fsp)->conn->vfs_opaque.ops.read((fsp)->conn->vfs_opaque.handles.read, (fsp), 
(data), (n)))
 #define SMB_VFS_OPAQUE_PREAD(fsp, data, n, off) 
((fsp)->conn->vfs_opaque.ops.pread((fsp)->conn->vfs_opaque.handles.pread, 
(fsp), (data), (n), (off)))
 #define SMB_VFS_OPAQUE_WRITE(fsp, data, n) 
((fsp)->conn->vfs_opaque.ops.write((fsp)->conn->vfs_opaque.handles.write, 
(fsp), (data), (n)))
@@ -301,7 +301,7 @@
 
 /* File operations */
 #define SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode) 
(((handle)->vfs_next.ops.open)((handle)->vfs_next.handles.open, (fname), (fsp), 
(flags), (mode)))
-#define SMB_VFS_NEXT_CLOSE(handle, fsp, fd) 
((handle)->vfs_next.ops.close_fn((handle)->vfs_next.handles.close_hnd, (fsp), 
(fd)))
+#define SMB_VFS_NEXT_CLOSE(handle, fsp) 
((handle)->vfs_next.ops.close_fn((handle)->vfs_next.handles.close_hnd, (fsp)))
 #define SMB_VFS_NEXT_READ(handle, fsp, data, n) 
((handle)->vfs_next.ops.read((handle)->vfs_next.handles.read, (fsp), (data), 
(n)))
 #define SMB_VFS_NEXT_PREAD(handle, fsp, data, n, off) 
((handle)->vfs_next.ops.pread((handle)->vfs_next.handles.pread, (fsp), (data), 
(n), (off)))
 #define SMB_VFS_NEXT_WRITE(handle, fsp, data, n) 
((handle)->vfs_next.ops.write((handle)->vfs_next.handles.write, (fsp), (data), 
(n)))
diff --git a/source/locking/posix.c b/source/locking/posix.c
index 1b88c47..32e1ee9 100644
--- a/source/locking/posix.c
+++ b/source/locking/posix.c
@@ -607,37 +607,34 @@ static size_t get_posix_pending_close_entries(TALLOC_CTX 
*mem_ctx,
  to delete all locks on this fsp before this function is called.
 ****************************************************************************/
 
-NTSTATUS fd_close_posix(struct files_struct *fsp)
+int fd_close_posix(struct files_struct *fsp)
 {
        int saved_errno = 0;
        int ret;
        int *fd_array = NULL;
        size_t count, i;
 
-       if (!lp_locking(fsp->conn->params) || 
!lp_posix_locking(fsp->conn->params)) {
+       if (!lp_locking(fsp->conn->params) ||
+           !lp_posix_locking(fsp->conn->params))
+       {
                /*
                 * No locking or POSIX to worry about or we want POSIX semantics
                 * which will lose all locks on all fd's open on this dev/inode,
                 * just close.
                 */
-               ret = SMB_VFS_CLOSE(fsp,fsp->fh->fd);
-               fsp->fh->fd = -1;
-               if (ret == -1) {
-                       return map_nt_error_from_unix(errno);
-               }
-               return NT_STATUS_OK;
+               return close(fsp->fh->fd);
        }
 
        if (get_windows_lock_ref_count(fsp)) {
 
                /*
-                * There are outstanding locks on this dev/inode pair on other 
fds.
-                * Add our fd to the pending close tdb and set fsp->fh->fd to 
-1.
+                * There are outstanding locks on this dev/inode pair on
+                * other fds. Add our fd to the pending close tdb and set
+                * fsp->fh->fd to -1.
                 */
 
                add_fd_to_close_entry(fsp);
-               fsp->fh->fd = -1;
-               return NT_STATUS_OK;
+               return 0;
        }
 
        /*
@@ -648,10 +645,11 @@ NTSTATUS fd_close_posix(struct files_struct *fsp)
        count = get_posix_pending_close_entries(talloc_tos(), fsp, &fd_array);
 
        if (count) {
-               DEBUG(10,("fd_close_posix: doing close on %u fd's.\n", 
(unsigned int)count ));
+               DEBUG(10,("fd_close_posix: doing close on %u fd's.\n",
+                         (unsigned int)count));
 
                for(i = 0; i < count; i++) {
-                       if (SMB_VFS_CLOSE(fsp,fd_array[i]) == -1) {
+                       if (close(fd_array[i]) == -1) {
                                saved_errno = errno;
                        }
                }
@@ -673,20 +671,14 @@ NTSTATUS fd_close_posix(struct files_struct *fsp)
         * Finally close the fd associated with this fsp.
         */
 
-       ret = SMB_VFS_CLOSE(fsp,fsp->fh->fd);
+       ret = close(fsp->fh->fd);
 
        if (ret == 0 && saved_errno != 0) {
                errno = saved_errno;
                ret = -1;
-       } 
-
-       fsp->fh->fd = -1;
-
-       if (ret == -1) {
-               return map_nt_error_from_unix(errno);
        }
 
-       return NT_STATUS_OK;
+       return ret;
 }
 
 /****************************************************************************
diff --git a/source/modules/vfs_audit.c b/source/modules/vfs_audit.c
index cfb4ddf..4000580 100644
--- a/source/modules/vfs_audit.c
+++ b/source/modules/vfs_audit.c
@@ -34,7 +34,7 @@ static SMB_STRUCT_DIR *audit_opendir(vfs_handle_struct 
*handle, const char *fnam
 static int audit_mkdir(vfs_handle_struct *handle, const char *path, mode_t 
mode);
 static int audit_rmdir(vfs_handle_struct *handle, const char *path);
 static int audit_open(vfs_handle_struct *handle, const char *fname, 
files_struct *fsp, int flags, mode_t mode);
-static int audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd);
+static int audit_close(vfs_handle_struct *handle, files_struct *fsp);
 static int audit_rename(vfs_handle_struct *handle, const char *oldname, const 
char *newname);
 static int audit_unlink(vfs_handle_struct *handle, const char *path);
 static int audit_chmod(vfs_handle_struct *handle, const char *path, mode_t 
mode);
@@ -202,14 +202,14 @@ static int audit_open(vfs_handle_struct *handle, const 
char *fname, files_struct
        return result;
 }
 
-static int audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int audit_close(vfs_handle_struct *handle, files_struct *fsp)
 {
        int result;
 
-       result = SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
+       result = SMB_VFS_NEXT_CLOSE(handle, fsp);
 
        syslog(audit_syslog_priority(handle), "close fd %d %s%s\n",
-              fd,
+              fsp->fh->fd,
               (result < 0) ? "failed: " : "",
               (result < 0) ? strerror(errno) : "");
 
diff --git a/source/modules/vfs_commit.c b/source/modules/vfs_commit.c
index ac391cf..1cef6d0 100644
--- a/source/modules/vfs_commit.c
+++ b/source/modules/vfs_commit.c
@@ -265,12 +265,11 @@ static ssize_t commit_pwrite(
 
 static int commit_close(
         vfs_handle_struct * handle,
-        files_struct *      fsp,
-        int                 fd)
+        files_struct *      fsp)
 {
         /* Commit errors not checked, close() will find them again */
         commit_all(handle, fsp);
-        return SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
+        return SMB_VFS_NEXT_CLOSE(handle, fsp);
 }
 
 static int commit_ftruncate(
diff --git a/source/modules/vfs_default.c b/source/modules/vfs_default.c
index 31ebb63..de801a2 100644
--- a/source/modules/vfs_default.c
+++ b/source/modules/vfs_default.c
@@ -208,13 +208,12 @@ static int vfswrap_open(vfs_handle_struct *handle,  const 
char *fname,
        return result;
 }
 
-static int vfswrap_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int vfswrap_close(vfs_handle_struct *handle, files_struct *fsp)
 {
        int result;
 
        START_PROFILE(syscall_close);
-
-       result = close(fd);
+       result = fd_close_posix(fsp);
        END_PROFILE(syscall_close);
        return result;
 }
diff --git a/source/modules/vfs_extd_audit.c b/source/modules/vfs_extd_audit.c
index 926ec36..7516cba 100644
--- a/source/modules/vfs_extd_audit.c
+++ b/source/modules/vfs_extd_audit.c
@@ -37,7 +37,7 @@ static SMB_STRUCT_DIR *audit_opendir(vfs_handle_struct 
*handle, const char *fnam
 static int audit_mkdir(vfs_handle_struct *handle, const char *path, mode_t 
mode);
 static int audit_rmdir(vfs_handle_struct *handle, const char *path);
 static int audit_open(vfs_handle_struct *handle, const char *fname, 
files_struct *fsp, int flags, mode_t mode);
-static int audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd);
+static int audit_close(vfs_handle_struct *handle, files_struct *fsp);
 static int audit_rename(vfs_handle_struct *handle, const char *oldname, const 
char *newname);
 static int audit_unlink(vfs_handle_struct *handle, const char *path);
 static int audit_chmod(vfs_handle_struct *handle, const char *path, mode_t 
mode);
@@ -224,18 +224,18 @@ static int audit_open(vfs_handle_struct *handle, const 
char *fname, files_struct
        return result;
 }
 
-static int audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int audit_close(vfs_handle_struct *handle, files_struct *fsp)
 {
        int result;
        
-       result = SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
+       result = SMB_VFS_NEXT_CLOSE(handle, fsp);
 
        syslog(audit_syslog_priority(handle), "close fd %d %s%s\n",
-              fd,
+              fsp->fh->fd,
               (result < 0) ? "failed: " : "",
               (result < 0) ? strerror(errno) : "");
        DEBUG(2, ("vfs_extd_audit: close fd %d %s %s\n",
-              fd,
+              fsp->fh->fd,
               (result < 0) ? "failed: " : "",
               (result < 0) ? strerror(errno) : ""));
 
diff --git a/source/modules/vfs_full_audit.c b/source/modules/vfs_full_audit.c
index 19218cc..2f8098d 100644
--- a/source/modules/vfs_full_audit.c
+++ b/source/modules/vfs_full_audit.c
@@ -111,7 +111,7 @@ static int smb_full_audit_closedir(vfs_handle_struct 
*handle,
                          SMB_STRUCT_DIR *dirp);
 static int smb_full_audit_open(vfs_handle_struct *handle,
                      const char *fname, files_struct *fsp, int flags, mode_t 
mode);
-static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, 
int fd);
+static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp);
 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct 
*fsp,
                          void *data, size_t n);
 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct 
*fsp,
@@ -1083,11 +1083,11 @@ static int smb_full_audit_open(vfs_handle_struct 
*handle,
        return result;
 }
 
-static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, 
int fd)
+static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
 {
        int result;
        
-       result = SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
+       result = SMB_VFS_NEXT_CLOSE(handle, fsp);
 
        do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
 
diff --git a/source/modules/vfs_streams_xattr.c 
b/source/modules/vfs_streams_xattr.c
index 766e7d1..b74c4f7 100644
--- a/source/modules/vfs_streams_xattr.c
+++ b/source/modules/vfs_streams_xattr.c
@@ -345,7 +345,7 @@ static int streams_xattr_open(vfs_handle_struct *handle,  
const char *fname,
                 * BUGBUGBUG -- we would need to call fd_close_posix here, but
                 * we don't have a full fsp yet
                 */
-               SMB_VFS_CLOSE(fsp, hostfd);
+               SMB_VFS_CLOSE(fsp);
        }
 
        TALLOC_FREE(frame);
diff --git a/source/modules/vfs_syncops.c b/source/modules/vfs_syncops.c
index 3aa89b4..d3f7868 100644
--- a/source/modules/vfs_syncops.c
+++ b/source/modules/vfs_syncops.c
@@ -165,14 +165,14 @@ static int syncops_rmdir(vfs_handle_struct *handle,  
const char *fname)
 }
 
 /* close needs to be handled specially */
-static int syncops_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int syncops_close(vfs_handle_struct *handle, files_struct *fsp)
 {
        if (fsp->can_write && sync_onclose) {
                /* ideally we'd only do this if we have written some
                 data, but there is no flag for that in fsp yet. */
-               fsync(fd);
+               fsync(fsp->fh->fd);
        }
-       return SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
+       return SMB_VFS_NEXT_CLOSE(handle, fsp);
 }
 
 
diff --git a/source/smbd/open.c b/source/smbd/open.c
index f3ed234..0d1dd31 100644
--- a/source/smbd/open.c
+++ b/source/smbd/open.c
@@ -72,13 +72,21 @@ static NTSTATUS fd_open(struct connection_struct *conn,
 
 NTSTATUS fd_close(files_struct *fsp)
 {
+       int ret;
+
        if (fsp->fh->fd == -1) {
                return NT_STATUS_OK; /* What we used to call a stat open. */
        }
        if (fsp->fh->ref_count > 1) {
                return NT_STATUS_OK; /* Shared handle. Only close last 
reference. */
        }
-       return fd_close_posix(fsp);
+
+       ret = SMB_VFS_CLOSE(fsp);
+       fsp->fh->fd = -1;
+       if (ret == -1) {
+               return map_nt_error_from_unix(errno);
+       }
+       return NT_STATUS_OK;
 }
 
 /****************************************************************************
diff --git a/source/torture/cmd_vfs.c b/source/torture/cmd_vfs.c
index 9359b58..2840088 100644
--- a/source/torture/cmd_vfs.c
+++ b/source/torture/cmd_vfs.c
@@ -355,7 +355,7 @@ static NTSTATUS cmd_close(struct vfs_state *vfs, TALLOC_CTX 
*mem_ctx, int argc,
                return NT_STATUS_OK;
        }
 
-       ret = SMB_VFS_CLOSE(vfs->files[fd], fd);
+       ret = SMB_VFS_CLOSE(vfs->files[fd]);
        if (ret == -1 )
                printf("close: error=%d (%s)\n", errno, strerror(errno));
        else


-- 
Samba Shared Repository

Reply via email to