vfs_fruit: optionally delete AppleDouble files without Resourcefork data
authorRalph Boehme <slow@samba.org>
Tue, 9 Oct 2018 12:54:31 +0000 (14:54 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 31 Oct 2018 20:27:18 +0000 (21:27 +0100)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/samba3.vfs.fruit
source3/modules/vfs_fruit.c

index 8b9aed48b63e691f3b70dfe8cfb897fc19c5992b..6307e2b34043b5f960a67ad7861eeb004b5bed3e 100644 (file)
@@ -1,3 +1,2 @@
 ^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion\(nt4_dc\)
 ^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion without embedded xattr\(nt4_dc\)
-^samba3.vfs.fruit_conversion delete_empty_adfiles.convert_xattr_and_empty_rfork_then_delete\(nt4_dc\)
index 5c872854ed7214e8f787dd074754eab8b3f44234..6dd0b13bfcc9c054cc5c885e0333d201d95d8592 100644 (file)
@@ -1386,6 +1386,43 @@ static bool ad_convert_blank_rfork(struct adouble *ad,
        return true;
 }
 
+static bool ad_convert_delete_adfile(struct adouble *ad,
+                                    const struct smb_filename *smb_fname)
+{
+       struct fruit_config_data *config = NULL;
+       struct smb_filename *ad_name = NULL;
+       int rc;
+
+       if (ad_getentrylen(ad, ADEID_RFORK) > 0) {
+               return true;
+       }
+
+       SMB_VFS_HANDLE_GET_DATA(ad->ad_handle, config,
+                               struct fruit_config_data, return false);
+
+       if (!config->delete_empty_adfiles) {
+               return true;
+       }
+
+       rc = adouble_path(talloc_tos(), smb_fname, &ad_name);
+       if (rc != 0) {
+               return false;
+       }
+
+       rc = SMB_VFS_NEXT_UNLINK(ad->ad_handle, ad_name);
+       if (rc != 0) {
+               DBG_ERR("Unlinking [%s] failed: %s\n",
+                       smb_fname_str_dbg(ad_name), strerror(errno));
+               TALLOC_FREE(ad_name);
+               return false;
+       }
+
+       DBG_WARNING("Unlinked [%s] after conversion\n", smb_fname_str_dbg(ad_name));
+       TALLOC_FREE(ad_name);
+
+       return true;
+}
+
 /**
  * Convert from Apple's ._ file to Netatalk
  *
@@ -1426,6 +1463,11 @@ static int ad_convert(struct adouble *ad,
                return -1;
        }
 
+       ok = ad_convert_delete_adfile(ad, smb_fname);
+       if (!ok) {
+               return -1;
+       }
+
        return 0;
 }