]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_fruit: split out truncating from ad_convert()
authorRalph Boehme <slow@samba.org>
Fri, 5 Oct 2018 17:13:16 +0000 (19:13 +0200)
committerKarolin Seeger <kseeger@samba.org>
Thu, 18 Oct 2018 11:00:10 +0000 (13:00 +0200)
This may look a little ill-advised as this increases line count, but
the goal here is modularizing ad_convert() itself and making it as slick
as possible helps achieving that goal.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 98bd7c0a46f72b097011a5c59e899ac4862ff651)

source3/modules/vfs_fruit.c

index aa49422ee67ef4ae8de6b35493d990f961a496c3..a77f365f5ae45fff115e18ccd4df44732b260b6e 100644 (file)
@@ -1152,6 +1152,24 @@ static bool ad_convert_finderinfo(struct adouble *ad,
        return true;
 }
 
+static bool ad_convert_truncate(struct adouble *ad,
+                               const struct smb_filename *smb_fname)
+{
+       int rc;
+
+       /*
+        * FIXME: direct ftruncate(), but we don't have a fsp for the
+        * VFS call
+        */
+       rc = ftruncate(ad->ad_fd, ad_getentryoff(ad, ADEID_RFORK)
+                      + ad_getentrylen(ad, ADEID_RFORK));
+       if (rc != 0) {
+               return false;
+       }
+
+       return true;
+}
+
 /**
  * Convert from Apple's ._ file to Netatalk
  *
@@ -1200,13 +1218,8 @@ static int ad_convert(struct adouble *ad,
        ad_setentryoff(ad, ADEID_RFORK,
                       ad_getentryoff(ad, ADEID_FINDERI) + ADEDLEN_FINDERI);
 
-       /*
-        * FIXME: direct ftruncate(), but we don't have a fsp for the
-        * VFS call
-        */
-       rc = ftruncate(ad->ad_fd, ad_getentryoff(ad, ADEID_RFORK)
-                      + ad_getentrylen(ad, ADEID_RFORK));
-       if (rc != 0) {
+       ok = ad_convert_truncate(ad, smb_fname);
+       if (!ok) {
                munmap(map, origlen);
                return -1;
        }