s3 onefs: Fix a few bugs from the smb_filename migration
authorTim Prouty <tprouty@samba.org>
Mon, 6 Jul 2009 22:44:09 +0000 (15:44 -0700)
committerTim Prouty <tprouty@samba.org>
Wed, 8 Jul 2009 04:33:48 +0000 (21:33 -0700)
source3/modules/onefs.h
source3/modules/onefs_streams.c
source3/modules/vfs_onefs_shadow_copy.c

index 88ba5a93f6afa4e88b632610696ac8e612b25cde..e0e463778ce4938adc8316eae88539d17882bab1 100644 (file)
@@ -72,7 +72,8 @@ int onefs_fstat(vfs_handle_struct *handle, struct files_struct *fsp,
 
 int onefs_lstat(vfs_handle_struct *handle, struct smb_filename *smb_fname);
 
-int onefs_unlink(vfs_handle_struct *handle, const char *path);
+int onefs_unlink(vfs_handle_struct *handle,
+                const struct smb_filename *smb_fname);
 
 NTSTATUS onefs_streaminfo(vfs_handle_struct *handle,
                          struct files_struct *fsp,
@@ -81,7 +82,8 @@ NTSTATUS onefs_streaminfo(vfs_handle_struct *handle,
                          unsigned int *num_streams,
                          struct stream_struct **streams);
 
-int onefs_vtimes_streams(vfs_handle_struct *handle, const char *fname,
+int onefs_vtimes_streams(vfs_handle_struct *handle,
+                        const struct smb_filename *smb_fname,
                         int flags, struct timespec times[3]);
 
 NTSTATUS onefs_brl_lock_windows(vfs_handle_struct *handle,
index 91917eef44de395a15c06aa94d371f98e624fc5c..d33d9f30a2c5f602eef6370dc742084ff18f1850 100644 (file)
@@ -463,14 +463,12 @@ int onefs_lstat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
 }
 
 int onefs_unlink(vfs_handle_struct *handle,
-                 const struct smb_filename *smb_fname)
+                const struct smb_filename *smb_fname)
 {
        struct smb_filename *smb_fname_onefs = NULL;
        int ret;
-       bool is_stream;
-       char *base = NULL;
-       char *stream = NULL;
        int dir_fd, saved_errno;
+       NTSTATUS status;
 
        /* Not a stream. */
        if (!is_ntfs_stream_smb_fname(smb_fname)) {
@@ -520,10 +518,6 @@ int onefs_vtimes_streams(vfs_handle_struct *handle,
 
        START_PROFILE(syscall_ntimes);
 
-       ret = onefs_is_stream(fname, &base, &stream, &is_stream);
-       if (ret)
-               return ret;
-
        if (!is_ntfs_stream_smb_fname(smb_fname)) {
                ret = vtimes(smb_fname->base_name, times, flags);
                return ret;
index 651e20a875d9b47d4cfd27d86592e7a8fc5d57f0..112ef3074911ffc3864d1fe5aadbfcb50547e3f3 100644 (file)
@@ -143,6 +143,9 @@ onefs_shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle,
        return ret;                                                   \
        } while (0)                                                   \
 
+/*
+ * XXX: Convert osc_canonicalize_path to use talloc instead of malloc.
+ */
 #define SHADOW_NEXT_SMB_FNAME(op, args, rtype) do {                  \
                char *smb_base_name_tmp = NULL;                       \
                char *cpath = NULL;                                   \
@@ -161,37 +164,6 @@ onefs_shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle,
                return ret;                                             \
        } while (0)                                                     \
 
-
-/*
- * XXX: Convert osc_canonicalize_path to use talloc instead of malloc.
- */
-#define SHADOW_NEXT_SMB_FNAME_CONST(op, args, rtype) do {            \
-               struct smb_filename *smb_fname_tmp  = NULL;           \
-               char *cpath = NULL;                                   \
-               char *snap_component = NULL;                          \
-               rtype ret;                                            \
-               if (shadow_copy_match_name(smb_fname->base_name,      \
-                       &snap_component)) {                             \
-                       cpath = osc_canonicalize_path(smb_fname->base_name, \
-                           snap_component);                            \
-                       smb_fname->base_name = cpath;                   \
-               }                                                       \
-               status = create_synthetic_smb_fname(talloc_tos(),       \
-                   cpath ?: smb_fname->base_name,                      \
-                   smb_fname->stream_name, &smb_fname->st,             \
-                   &smb_fname_tmp);                                    \
-               if (!NT_STATUS_IS_OK(status)) {                         \
-                       errno = map_errno_from_nt_status(status);       \
-                       return  ret;                                    \
-               }                                                       \
-               ret = SMB_VFS_NEXT_ ## op args;                         \
-               TALLOC_FREE(smb_fname_tmp)                              \
-               SAFE_FREE(cpath);                                       \
-               return ret;                                             \
-       } while (0)                                                     \
-
-
-
 static uint64_t
 onefs_shadow_copy_disk_free(vfs_handle_struct *handle, const char *path,
                            bool small_query, uint64_t *bsize, uint64_t *dfree,
@@ -351,11 +323,20 @@ onefs_shadow_copy_lstat(vfs_handle_struct *handle,
 
 static int
 onefs_shadow_copy_unlink(vfs_handle_struct *handle,
-                        const struct smb_filename *smb_fname)
+                        const struct smb_filename *smb_fname_in)
 {
-       SHADOW_NEXT_SMB_FNAME_CONST(UNLINK,
-                                   (handle, smb_fname_tmp),
-                                   int);
+       struct smb_filename *smb_fname = NULL;
+       NTSTATUS status;
+
+       status = copy_smb_filename(talloc_tos(), smb_fname_in, &smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               errno = map_errno_from_nt_status(status);
+               return -1;
+       }
+
+       SHADOW_NEXT_SMB_FNAME(UNLINK,
+                             (handle, smb_fname),
+                             int);
 }
 
 static int
@@ -395,12 +376,21 @@ onefs_shadow_copy_chdir(vfs_handle_struct *handle, const char *path)
 
 static int
 onefs_shadow_copy_ntimes(vfs_handle_struct *handle,
-                       const struct smb_filename *smb_fname,
+                       const struct smb_filename *smb_fname_in,
                        struct smb_file_time *ft)
 {
-       SHADOW_NEXT_SMB_FNAME_CONST(NTIMES,
-                                   (handle, smb_fname_tmp, ft),
-                                   int);
+       struct smb_filename *smb_fname = NULL;
+       NTSTATUS status;
+
+       status = copy_smb_filename(talloc_tos(), smb_fname_in, &smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               errno = map_errno_from_nt_status(status);
+               return -1;
+       }
+
+       SHADOW_NEXT_SMB_FNAME(NTIMES,
+                             (handle, smb_fname, ft),
+                             int);
 
 }