vfs_fruit: refactor fruit_stat_rsrc()
authorRalph Boehme <slow@samba.org>
Fri, 2 Dec 2016 10:26:22 +0000 (11:26 +0100)
committerUri Simchoni <uri@samba.org>
Wed, 1 Mar 2017 23:32:21 +0000 (00:32 +0100)
Use helper functions for the fruit:resource cases. No change in
behaveour.

The next patch will add the proper helper functions for
fruit:resource=xattr and fruit:resource=stream.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
source3/modules/vfs_fruit.c

index eb20baaa14c8c061db5a17db4b3b7751f0593b09..07221d37f2575ae5d205dd798fc57872d8679105 100644 (file)
@@ -3592,15 +3592,12 @@ static int fruit_stat_meta(vfs_handle_struct *handle,
        return ret;
 }
 
-static int fruit_stat_rsrc(vfs_handle_struct *handle,
-                          struct smb_filename *smb_fname,
-                          bool follow_links)
-
+static int fruit_stat_rsrc_netatalk(vfs_handle_struct *handle,
+                                   struct smb_filename *smb_fname,
+                                   bool follow_links)
 {
        struct adouble *ad = NULL;
-
-       DEBUG(10, ("fruit_stat_rsrc called for %s\n",
-                  smb_fname_str_dbg(smb_fname)));
+       int ret;
 
        ad = ad_get(talloc_tos(), handle, smb_fname->base_name, ADOUBLE_RSRC);
        if (ad == NULL) {
@@ -3609,7 +3606,8 @@ static int fruit_stat_rsrc(vfs_handle_struct *handle,
        }
 
        /* Populate the stat struct with info from the base file. */
-       if (fruit_stat_base(handle, smb_fname, follow_links) == -1) {
+       ret = fruit_stat_base(handle, smb_fname, follow_links);
+       if (ret != 0) {
                TALLOC_FREE(ad);
                return -1;
        }
@@ -3621,6 +3619,33 @@ static int fruit_stat_rsrc(vfs_handle_struct *handle,
        return 0;
 }
 
+static int fruit_stat_rsrc(vfs_handle_struct *handle,
+                          struct smb_filename *smb_fname,
+                          bool follow_links)
+{
+       struct fruit_config_data *config = NULL;
+       int ret;
+
+       DBG_DEBUG("Path [%s]\n", smb_fname_str_dbg(smb_fname));
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct fruit_config_data, return -1);
+
+       switch (config->rsrc) {
+       case FRUIT_RSRC_STREAM:
+       case FRUIT_RSRC_XATTR:
+       case FRUIT_RSRC_ADFILE:
+               ret = fruit_stat_rsrc_netatalk(handle, smb_fname, follow_links);
+               break;
+
+       default:
+               DBG_ERR("Unexpected rsrc config [%d]\n", config->rsrc);
+               return -1;
+       }
+
+       return ret;
+}
+
 static int fruit_stat(vfs_handle_struct *handle,
                      struct smb_filename *smb_fname)
 {