From 4e3656b8d1d0bf8c0c4ade01332e7384ea890810 Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Tue, 16 Jun 2009 12:01:13 -0700 Subject: s3: Change SMB_VFS_OPEN to take an smb_filename struct This was a little messy because of all of the vfs modules I had to touch. Most of them were pretty straight forward, but the streams modules required a little attention to handle smb_filename. Since the use of smb_filename enables the vfs modules to access the raw, over-the-wire stream, a little bit of the handling that was being done by split_ntfs_stream_name has now been shifted into the individual stream modules. It may be a little more code, but overall it gives more flexibility to the streams modules, while also allowing correct stream handling. --- source3/modules/vfs_shadow_copy2.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'source3/modules/vfs_shadow_copy2.c') diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 030d3e2b01..7b5b85d4be 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -115,6 +115,28 @@ static inline bool shadow_copy2_match_name(const char *name) } \ } while (0) +#define _SHADOW2_NEXT_SMB_FNAME(op, args, rtype, eret, extra) do { \ + if (shadow_copy2_match_name(smb_fname->base_name)) { \ + char *name2; \ + char *smb_base_name_tmp = NULL; \ + rtype ret; \ + name2 = convert_shadow2_name(handle, smb_fname->base_name); \ + if (name2 == NULL) { \ + errno = EINVAL; \ + return eret; \ + } \ + smb_base_name_tmp = smb_fname->base_name; \ + smb_fname->base_name = name2; \ + ret = SMB_VFS_NEXT_ ## op args; \ + smb_fname->base_name = smb_base_name_tmp; \ + talloc_free(name2); \ + if (ret != eret) extra; \ + return ret; \ + } else { \ + return SMB_VFS_NEXT_ ## op args; \ + } \ +} while (0) + /* convert a name to the shadow directory: NTSTATUS-specific handling */ @@ -143,6 +165,8 @@ static inline bool shadow_copy2_match_name(const char *name) #define SHADOW2_NEXT(op, args, rtype, eret) _SHADOW2_NEXT(op, args, rtype, eret, ) +#define SHADOW2_NEXT_SMB_FNAME(op, args, rtype, eret) _SHADOW2_NEXT_SMB_FNAME(op, args, rtype, eret, ) + #define SHADOW2_NEXT2(op, args) do { \ if (shadow_copy2_match_name(oldname) || shadow_copy2_match_name(newname)) { \ errno = EROFS; \ @@ -337,9 +361,12 @@ static int shadow_copy2_link(vfs_handle_struct *handle, } static int shadow_copy2_open(vfs_handle_struct *handle, - const char *fname, files_struct *fsp, int flags, mode_t mode) + struct smb_filename *smb_fname, files_struct *fsp, + int flags, mode_t mode) { - SHADOW2_NEXT(OPEN, (handle, name, fsp, flags, mode), int, -1); + SHADOW2_NEXT_SMB_FNAME(OPEN, + (handle, smb_fname, fsp, flags, mode), + int, -1); } static SMB_STRUCT_DIR *shadow_copy2_opendir(vfs_handle_struct *handle, -- cgit