From d82d470263da87a476c6673900ab6aba4f043d66 Mon Sep 17 00:00:00 2001 From: Aaron Laffin Date: Mon, 5 Dec 2016 17:05:46 -0600 Subject: [PATCH] Fixes to fruit:resource=stream and fruit:metadata=stream functionality. Goal is to allow the resource fork or FinderInfo streams to pass through for management by streams_xattr. fruit_rename() - After SMB_VFS_NEXT_RENAME(), skip rename of AppleDouble file maintained by fruit:resource=file mode. Return if not in fruit:resource=file mode (config->rsrc != FRUIT_RSRC_ADFILE). fruit_rmdir() - Skip fruit:resource=file code that attempts an opendir/readdir/closedir cycle to remove orphan AppleDouble files. Such cleanup is unnecessary in the stream or xattr case. Call the goto exit_rmdir, deferring to SMB_VFS_NEXT_RMDIR(). fruit_stat() - fruit_lstat() - Add extra checks for the fruit:metadata or fruit:resource settings to avoid entry to fruit_stat_meta() or fruit_stat_rsrc() for the metadata or resource fork streams, respectively. In the stream case, want to call SMB_VFS_NEXT_STAT()/SMB_VFS_NEXT_LSTAT(). fruit_ntimes() - Add a check for the fruit:metadata to skip calls to ad_*() when in stream mode. Defer fully to SMB_VFS_NEXT_NTIMES(). --- source3/modules/vfs_fruit.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 605b3e0..34a62ef 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -2421,7 +2421,7 @@ static int fruit_rename(struct vfs_handle_struct *handle, SMB_VFS_HANDLE_GET_DATA(handle, config, struct fruit_config_data, return -1); - if (config->rsrc == FRUIT_RSRC_XATTR) { + if (config->rsrc != FRUIT_RSRC_ADFILE) { return rc; } @@ -2643,7 +2643,7 @@ static int fruit_rmdir(struct vfs_handle_struct *handle, SMB_VFS_HANDLE_GET_DATA(handle, config, struct fruit_config_data, return -1); - if (!handle->conn->cwd || !path || (config->rsrc == FRUIT_RSRC_XATTR)) { + if (!handle->conn->cwd || !path || (config->rsrc != FRUIT_RSRC_ADFILE)) { goto exit_rmdir; } @@ -2997,6 +2997,10 @@ static int fruit_stat(vfs_handle_struct *handle, struct smb_filename *smb_fname) { int rc = -1; + struct fruit_config_data *config = NULL; + + SMB_VFS_HANDLE_GET_DATA(handle, config, + struct fruit_config_data, return -1); DEBUG(10, ("fruit_stat called for %s\n", smb_fname_str_dbg(smb_fname))); @@ -3017,9 +3021,9 @@ static int fruit_stat(vfs_handle_struct *handle, * not following links here. */ - if (is_afpinfo_stream(smb_fname)) { + if (is_afpinfo_stream(smb_fname) && config->meta != FRUIT_META_STREAM) { rc = fruit_stat_meta(handle, smb_fname, true); - } else if (is_afpresource_stream(smb_fname)) { + } else if (is_afpresource_stream(smb_fname) && config->rsrc != FRUIT_RSRC_STREAM) { rc = fruit_stat_rsrc(handle, smb_fname, true); } else { return SMB_VFS_NEXT_STAT(handle, smb_fname); @@ -3039,6 +3043,10 @@ static int fruit_lstat(vfs_handle_struct *handle, struct smb_filename *smb_fname) { int rc = -1; + struct fruit_config_data *config = NULL; + + SMB_VFS_HANDLE_GET_DATA(handle, config, + struct fruit_config_data, return -1); DEBUG(10, ("fruit_lstat called for %s\n", smb_fname_str_dbg(smb_fname))); @@ -3052,9 +3060,9 @@ static int fruit_lstat(vfs_handle_struct *handle, return rc; } - if (is_afpinfo_stream(smb_fname)) { + if (is_afpinfo_stream(smb_fname) && config->meta != FRUIT_META_STREAM) { rc = fruit_stat_meta(handle, smb_fname, false); - } else if (is_afpresource_stream(smb_fname)) { + } else if (is_afpresource_stream(smb_fname) && config->rsrc != FRUIT_RSRC_STREAM) { rc = fruit_stat_rsrc(handle, smb_fname, false); } else { return SMB_VFS_NEXT_LSTAT(handle, smb_fname); @@ -3270,8 +3278,13 @@ static int fruit_ntimes(vfs_handle_struct *handle, { int rc = 0; struct adouble *ad = NULL; + struct fruit_config_data *config = NULL; + + SMB_VFS_HANDLE_GET_DATA(handle, config, + struct fruit_config_data, return -1); - if (null_timespec(ft->create_time)) { + if (null_timespec(ft->create_time) || + config->meta == FRUIT_META_STREAM) { goto exit; } -- 1.8.3.1