vfs_fruit: add and use is_adouble_file()
authorRalph Boehme <slow@samba.org>
Tue, 21 May 2019 09:39:18 +0000 (11:39 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 30 May 2019 20:19:26 +0000 (20:19 +0000)
This adds a helper function that checks whether the last component of a path is
an AppleDouble sidecar file with "._" name prefix.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_fruit.c

index 00e371edcb77a16a538d45ceedf085908c30c2eb..2f970bb2e1167a240bb0e32b80f44c3d08dfcc4f 100644 (file)
@@ -2174,6 +2174,27 @@ static bool is_apple_stream(const struct smb_filename *smb_fname)
        return false;
 }
 
+static bool is_adouble_file(const char *path)
+{
+       const char *p = NULL;
+       int match;
+
+       p = strrchr(path, '/');
+       if (p == NULL) {
+               p = path;
+       } else {
+               p++;
+       }
+
+       match = strncmp(p,
+                       ADOUBLE_NAME_PREFIX,
+                       strlen(ADOUBLE_NAME_PREFIX));
+       if (match != 0) {
+               return false;
+       }
+       return true;
+}
+
 /**
  * Initialize config struct from our smb.conf config parameters
  **/
@@ -4227,16 +4248,12 @@ static int fruit_rmdir(struct vfs_handle_struct *handle,
        }
 
        while ((de = SMB_VFS_READDIR(handle->conn, dh, NULL)) != NULL) {
-               int match;
                struct adouble *ad = NULL;
                char *p = NULL;
                struct smb_filename *ad_smb_fname = NULL;
                int ret;
 
-               match = strncmp(de->d_name,
-                               ADOUBLE_NAME_PREFIX,
-                               strlen(ADOUBLE_NAME_PREFIX));
-               if (match != 0) {
+               if (!is_adouble_file(de->d_name)) {
                        continue;
                }