s3: Pass smb_filename through the is_offline vfs op
authorVolker Lendecke <vl@samba.org>
Fri, 25 Feb 2011 13:37:34 +0000 (06:37 -0700)
committerVolker Lendecke <vlendec@samba.org>
Wed, 2 Mar 2011 17:39:21 +0000 (18:39 +0100)
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_default.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_onefs_shadow_copy.c
source3/modules/vfs_tsmsm.c
source3/smbd/dosmode.c
source3/smbd/vfs.c

index 7e5b87a4185853d08a04460dccf5694d4a03cfa5..304f04356c475295ff68cf1a9cb37301159da672 100644 (file)
@@ -401,7 +401,9 @@ struct vfs_fn_pointers {
        bool (*aio_force)(struct vfs_handle_struct *handle, struct files_struct *fsp);
 
        /* offline operations */
-       bool (*is_offline)(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf);
+       bool (*is_offline)(struct vfs_handle_struct *handle,
+                          const struct smb_filename *fname,
+                          SMB_STRUCT_STAT *sbuf);
        int (*set_offline)(struct vfs_handle_struct *handle, const char *path);
 };
 
@@ -815,7 +817,8 @@ int smb_vfs_call_aio_suspend(struct vfs_handle_struct *handle,
 bool smb_vfs_call_aio_force(struct vfs_handle_struct *handle,
                            struct files_struct *fsp);
 bool smb_vfs_call_is_offline(struct vfs_handle_struct *handle,
-                            const char *path, SMB_STRUCT_STAT *sbuf);
+                            const struct smb_filename *fname,
+                            SMB_STRUCT_STAT *sbuf);
 int smb_vfs_call_set_offline(struct vfs_handle_struct *handle,
                             const char *path);
 
index 7c26529385a7e39e4750386333fe8cb884413f1f..029806d33564987d0a650f7ccb207cd1981f9d55 100644 (file)
 #define SMB_VFS_NEXT_AIO_FORCE(handle,fsp) \
        smb_vfs_call_aio_force((handle)->next,(fsp))
 
-#define SMB_VFS_IS_OFFLINE(conn,path,sbuf) \
-       smb_vfs_call_is_offline((conn)->vfs_handles,(path),(sbuf))
-#define SMB_VFS_NEXT_IS_OFFLINE(handle,path,sbuf) \
-       smb_vfs_call_is_offline((handle)->next,(path),(sbuf))
+#define SMB_VFS_IS_OFFLINE(conn,fname,sbuf) \
+       smb_vfs_call_is_offline((conn)->vfs_handles,(fname),(sbuf))
+#define SMB_VFS_NEXT_IS_OFFLINE(handle,fname,sbuf) \
+       smb_vfs_call_is_offline((handle)->next,(fname),(sbuf))
 
 #define SMB_VFS_SET_OFFLINE(conn,path) \
        smb_vfs_call_set_offline((conn)->vfs_handles,(path))
index 5448db8ee016505da243ad762cd81a66b670e61f..6ad538149a899984d67fa552f4498125aab71d79 100644 (file)
@@ -1607,9 +1607,14 @@ static bool vfswrap_aio_force(struct vfs_handle_struct *handle, struct files_str
        return false;
 }
 
-static bool vfswrap_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
+static bool vfswrap_is_offline(struct vfs_handle_struct *handle,
+                              const struct smb_filename *fname,
+                              SMB_STRUCT_STAT *sbuf)
 {
-       if (ISDOT(path) || ISDOTDOT(path)) {
+       NTSTATUS status;
+       char *path;
+
+        if (ISDOT(fname->base_name) || ISDOTDOT(fname->base_name)) {
                return false;
        }
 
@@ -1620,6 +1625,12 @@ static bool vfswrap_is_offline(struct vfs_handle_struct *handle, const char *pat
                return false;
        }
 
+        status = get_full_smb_filename(talloc_tos(), fname, &path);
+        if (!NT_STATUS_IS_OK(status)) {
+                errno = map_errno_from_nt_status(status);
+                return false;
+        }
+
        return (dmapi_file_flags(path) & FILE_ATTRIBUTE_OFFLINE) != 0;
 }
 
index a9a4a0664e001ff64924e59b1131d0aadee10779..e5c375ad95bee7196b055df37152bb39eaefb809 100644 (file)
@@ -2203,6 +2203,18 @@ static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
        return result;
 }
 
+static bool smb_full_audit_is_offline(struct vfs_handle_struct *handle,
+                                     const struct smb_filename *fname,
+                                     SMB_STRUCT_STAT *sbuf)
+{
+       bool result;
+
+       result = SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
+       do_log(SMB_VFS_OP_IS_OFFLINE, result, handle, "%s",
+              smb_fname_str_do_log(fname));
+       return result;
+}
+
 static struct vfs_fn_pointers vfs_full_audit_fns = {
 
        /* Disk operations */
@@ -2320,6 +2332,7 @@ static struct vfs_fn_pointers vfs_full_audit_fns = {
        .aio_fsync = smb_full_audit_aio_fsync,
        .aio_suspend = smb_full_audit_aio_suspend,
        .aio_force = smb_full_audit_aio_force,
+       .is_offline = smb_full_audit_is_offline,
 };
 
 NTSTATUS vfs_full_audit_init(void)
index bcc40f0d9fa00c2ce9bfe01df31d911b529b8f6a..a6681c0ab4f2936cfee46cf1ee9670f4111f1adf 100644 (file)
@@ -634,8 +634,10 @@ onefs_shadow_copy_lsetxattr(vfs_handle_struct *handle, const char *path,
 
 static bool
 onefs_shadow_copy_is_offline(struct vfs_handle_struct *handle,
-                            const char *path, SMB_STRUCT_STAT *sbuf)
+                            const struct smb_fname *fname,
+                            SMB_STRUCT_STAT *sbuf)
 {
+#error Isilon, please convert "char *path" to "struct smb_fname *fname"
        SHADOW_NEXT(IS_OFFLINE,
                    (handle, cpath ?: path, sbuf),
                    bool);
index 95c83de08d28b4ec3355c87ac97860b46a42f27c..533fde200307eb481b05f08e74786945853f0596 100644 (file)
@@ -146,8 +146,9 @@ static int tsmsm_connect(struct vfs_handle_struct *handle,
 }
 
 static bool tsmsm_is_offline(struct vfs_handle_struct *handle, 
-                           const char *path,
-                           SMB_STRUCT_STAT *stbuf) {
+                            const struct smb_filename *fname,
+                            SMB_STRUCT_STAT *stbuf)
+{
        struct tsmsm_struct *tsmd = (struct tsmsm_struct *) handle->data;
        const dm_sessid_t *dmsession_id;
        void *dmhandle = NULL;
@@ -158,6 +159,14 @@ static bool tsmsm_is_offline(struct vfs_handle_struct *handle,
        bool offline;
        char *buf = NULL;
        size_t buflen;
+       NTSTATUS status;
+       char *path;
+
+        status = get_full_smb_filename(talloc_tos(), fname, &path);
+        if (!NT_STATUS_IS_OK(status)) {
+                errno = map_errno_from_nt_status(status);
+                return false;
+        }
 
         /* if the file has more than FILE_IS_ONLINE_RATIO of blocks available,
           then assume it is not offline (it may not be 100%, as it could be sparse) */
index c0bf168e5381906c5aad98083342a7a5146db7d3..307da32bc3eeff93c2f93cba669754ea4073009a 100644 (file)
@@ -648,7 +648,7 @@ uint32 dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
                }
        }
 
-       offline = SMB_VFS_IS_OFFLINE(conn, smb_fname->base_name, &smb_fname->st);
+       offline = SMB_VFS_IS_OFFLINE(conn, smb_fname, &smb_fname->st);
        if (S_ISREG(smb_fname->st.st_ex_mode) && offline) {
                result |= FILE_ATTRIBUTE_OFFLINE;
        }
index 40aaf6bb742d55215001691310b9b902e39cea82..71de587d17cab388a4489befe406e84b6c108c08 100644 (file)
@@ -2006,10 +2006,11 @@ bool smb_vfs_call_aio_force(struct vfs_handle_struct *handle,
 }
 
 bool smb_vfs_call_is_offline(struct vfs_handle_struct *handle,
-                            const char *path, SMB_STRUCT_STAT *sbuf)
+                            const struct smb_filename *fname,
+                            SMB_STRUCT_STAT *sbuf)
 {
        VFS_FIND(is_offline);
-       return handle->fns->is_offline(handle, path, sbuf);
+       return handle->fns->is_offline(handle, fname, sbuf);
 }
 
 int smb_vfs_call_set_offline(struct vfs_handle_struct *handle,