vfs_streams_xattr: remove all uses of fd, use name based functions
authorRalph Boehme <slow@samba.org>
Thu, 11 May 2017 13:05:23 +0000 (15:05 +0200)
committerVolker Lendecke <vl@samba.org>
Wed, 9 Aug 2017 16:41:06 +0000 (18:41 +0200)
We don't really need an fd in this module, all calls to the VFS xattr
API can just use the name based versions.

This paves the way for removing the open of the basefile in
streams_xattr_open() in a later commit.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/modules/vfs_streams_xattr.c

index fc79935788d4ec1d2ca550342aca0ec13f852718..90e9771e5295b5cf7e51925cd2ac3a9cd2211a99 100644 (file)
@@ -232,7 +232,7 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
        struct stream_io *io = (struct stream_io *)
                VFS_FETCH_FSP_EXTENSION(handle, fsp);
 
-       DEBUG(10, ("streams_xattr_fstat called for %d\n", fsp->fh->fd));
+       DBG_DEBUG("streams_xattr_fstat called for %s\n", fsp_str_dbg(io->fsp));
 
        if (io == NULL || fsp->base_fsp == NULL) {
                return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
@@ -506,11 +506,11 @@ static int streams_xattr_open(vfs_handle_struct *handle,
                DEBUG(10, ("creating or truncating attribute %s on file %s\n",
                           xattr_name, smb_fname->base_name));
 
-               fsp->fh->fd = hostfd;
-               ret = SMB_VFS_FSETXATTR(fsp, xattr_name,
-                                       &null, sizeof(null),
-                                       flags & O_EXCL ? XATTR_CREATE : 0);
-               fsp->fh->fd = -1;
+               ret = SMB_VFS_SETXATTR(fsp->conn,
+                                      smb_fname,
+                                      xattr_name,
+                                      &null, sizeof(null),
+                                      flags & O_EXCL ? XATTR_CREATE : 0);
                if (ret != 0) {
                        goto fail;
                }
@@ -844,14 +844,7 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle,
        NTSTATUS status;
        struct streaminfo_state state;
 
-       if ((fsp != NULL) && (fsp->fh->fd != -1)) {
-               ret = SMB_VFS_FSTAT(fsp, &sbuf);
-       } else {
-               ret = vfs_stat_smb_basename(handle->conn,
-                               smb_fname,
-                               &sbuf);
-       }
-
+       ret = vfs_stat_smb_basename(handle->conn, smb_fname, &sbuf);
        if (ret == -1) {
                return map_nt_error_from_unix(errno);
        }
@@ -1003,16 +996,10 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle,
 
         memcpy(ea.value.data + offset, data, n);
 
-       if (fsp->fh->fd != -1) {
-               ret = SMB_VFS_FSETXATTR(fsp,
-                               sio->xattr_name,
-                               ea.value.data, ea.value.length, 0);
-       } else {
-               ret = SMB_VFS_SETXATTR(fsp->conn,
-                                      fsp->fsp_name,
-                               sio->xattr_name,
-                               ea.value.data, ea.value.length, 0);
-       }
+       ret = SMB_VFS_SETXATTR(fsp->conn,
+                              fsp->fsp_name,
+                              sio->xattr_name,
+                              ea.value.data, ea.value.length, 0);
        TALLOC_FREE(ea.value.data);
 
        if (ret == -1) {
@@ -1297,17 +1284,10 @@ static int streams_xattr_ftruncate(struct vfs_handle_struct *handle,
        ea.value.length = offset + 1;
        ea.value.data[offset] = 0;
 
-       if (fsp->fh->fd != -1) {
-               ret = SMB_VFS_FSETXATTR(fsp,
-                               sio->xattr_name,
-                               ea.value.data, ea.value.length, 0);
-       } else {
-               ret = SMB_VFS_SETXATTR(fsp->conn,
-                               fsp->fsp_name,
-                               sio->xattr_name,
-                               ea.value.data, ea.value.length, 0);
-       }
-
+       ret = SMB_VFS_SETXATTR(fsp->conn,
+                              fsp->fsp_name,
+                              sio->xattr_name,
+                              ea.value.data, ea.value.length, 0);
        TALLOC_FREE(ea.value.data);
 
        if (ret == -1) {