From: Ralph Boehme Date: Fri, 5 Oct 2018 15:07:45 +0000 (+0200) Subject: vfs_fruit: let the ad_convert_*() subfunction update the on-disk AppleDoube header... X-Git-Tag: samba-4.8.8~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1c29dbf87f3edaa6c71f198131e683f4db0fd07;p=thirdparty%2Fsamba.git vfs_fruit: let the ad_convert_*() subfunction update the on-disk AppleDoube header as needed Another step in simplifying ad_convert() itself. It means that we may write to disk twice, but is only ever done once per AppleDouble file. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13649 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 1692ca5fd8ae2560dae6828f3c5c05a65c530726) --- diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 28f24316502..a519effb72a 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -949,6 +949,7 @@ static bool ad_convert_xattr(struct adouble *ad, char *map = MAP_FAILED; size_t maplen; uint16_t i; + ssize_t len; int saved_errno = 0; NTSTATUS status; int rc; @@ -1073,6 +1074,20 @@ static bool ad_convert_xattr(struct adouble *ad, } ad_setentrylen(ad, ADEID_FINDERI, ADEDLEN_FINDERI); + + ok = ad_pack(ad); + if (!ok) { + DBG_WARNING("ad_pack [%s] failed\n", smb_fname->base_name); + goto fail; + } + + len = sys_pwrite(ad->ad_fd, ad->ad_data, AD_DATASZ_DOT_UND, 0); + if (len != AD_DATASZ_DOT_UND) { + DBG_ERR("%s: bad size: %zd\n", smb_fname->base_name, len); + ok = false; + goto fail; + } + ok = true; fail: @@ -1204,7 +1219,9 @@ static bool ad_convert_move_reso(struct adouble *ad, { char *map = MAP_FAILED; size_t maplen; + ssize_t len; int rc; + bool ok; if (ad_getentrylen(ad, ADEID_RFORK) == 0) { return true; @@ -1233,6 +1250,18 @@ static bool ad_convert_move_reso(struct adouble *ad, ad_setentryoff(ad, ADEID_RFORK, ADEDOFF_RFORK_DOT_UND); + ok = ad_pack(ad); + if (!ok) { + DBG_WARNING("ad_pack [%s] failed\n", smb_fname->base_name); + return false; + } + + len = sys_pwrite(ad->ad_fd, ad->ad_data, AD_DATASZ_DOT_UND, 0); + if (len != AD_DATASZ_DOT_UND) { + DBG_ERR("%s: bad size: %zd\n", smb_fname->base_name, len); + return false; + } + return true; } @@ -1248,7 +1277,6 @@ static bool ad_convert_move_reso(struct adouble *ad, static int ad_convert(struct adouble *ad, const struct smb_filename *smb_fname) { - ssize_t len; bool ok; if (ad_getentrylen(ad, ADEID_FINDERI) == ADEDLEN_FINDERI) { @@ -1270,18 +1298,6 @@ static int ad_convert(struct adouble *ad, return -1; } - ok = ad_pack(ad); - if (!ok) { - DBG_WARNING("ad_pack [%s] failed\n", smb_fname->base_name); - return -1; - } - - len = sys_pwrite(ad->ad_fd, ad->ad_data, AD_DATASZ_DOT_UND, 0); - if (len != AD_DATASZ_DOT_UND) { - DBG_ERR("%s: bad size: %zd\n", smb_fname->base_name, len); - return -1; - } - ok = ad_convert_finderinfo(ad, smb_fname); if (!ok) { DBG_ERR("Failed to convert [%s]\n",