From: Ralph Boehme Date: Fri, 5 Oct 2018 20:05:43 +0000 (+0200) Subject: vfs_fruit: call ad_convert_move_reso() from ad_convert_xattr() X-Git-Tag: tdb-1.3.17~1346 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70d3ae5a89fc62db192c44b92a5b7fb67a93d88e;p=thirdparty%2Fsamba.git vfs_fruit: call ad_convert_move_reso() from ad_convert_xattr() ad_convert_xattr() is the place that triggers the need to move the resource fork, so it should also call ad_convert_move_reso(). Bug: https://bugzilla.samba.org/show_bug.cgi?id=13649 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index c76dcb38671..f7cba8a0728 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -942,6 +942,58 @@ static bool ad_unpack(struct adouble *ad, const size_t nentries, return true; } +static bool ad_convert_move_reso(struct adouble *ad, + const struct smb_filename *smb_fname) +{ + char *map = MAP_FAILED; + size_t maplen; + ssize_t len; + int rc; + bool ok; + + if (ad_getentrylen(ad, ADEID_RFORK) == 0) { + return true; + } + + maplen = ad_getentryoff(ad, ADEID_RFORK) + + ad_getentrylen(ad, ADEID_RFORK); + + /* FIXME: direct use of mmap(), vfs_aio_fork does it too */ + map = mmap(NULL, maplen, PROT_READ|PROT_WRITE, MAP_SHARED, + ad->ad_fd, 0); + if (map == MAP_FAILED) { + DBG_ERR("mmap AppleDouble: %s\n", strerror(errno)); + return false; + } + + + memmove(map + ADEDOFF_RFORK_DOT_UND, + map + ad_getentryoff(ad, ADEID_RFORK), + ad_getentrylen(ad, ADEID_RFORK)); + + rc = munmap(map, maplen); + if (rc != 0) { + DBG_ERR("munmap failed: %s\n", strerror(errno)); + return false; + } + + 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; +} + static bool ad_convert_xattr(struct adouble *ad, const struct smb_filename *smb_fname) { @@ -1088,6 +1140,11 @@ static bool ad_convert_xattr(struct adouble *ad, goto fail; } + ok = ad_convert_move_reso(ad, smb_fname); + if (!ok) { + goto fail; + } + ok = true; fail: @@ -1214,57 +1271,6 @@ static bool ad_convert_truncate(struct adouble *ad, return true; } -static bool ad_convert_move_reso(struct adouble *ad, - const struct smb_filename *smb_fname) -{ - char *map = MAP_FAILED; - size_t maplen; - ssize_t len; - int rc; - bool ok; - - if (ad_getentrylen(ad, ADEID_RFORK) == 0) { - return true; - } - - maplen = ad_getentryoff(ad, ADEID_RFORK) + - ad_getentrylen(ad, ADEID_RFORK); - - /* FIXME: direct use of mmap(), vfs_aio_fork does it too */ - map = mmap(NULL, maplen, PROT_READ|PROT_WRITE, MAP_SHARED, - ad->ad_fd, 0); - if (map == MAP_FAILED) { - DBG_ERR("mmap AppleDouble: %s\n", strerror(errno)); - return false; - } - - memmove(map + ADEDOFF_RFORK_DOT_UND, - map + ad_getentryoff(ad, ADEID_RFORK), - ad_getentrylen(ad, ADEID_RFORK)); - - rc = munmap(map, maplen); - if (rc != 0) { - DBG_ERR("munmap failed: %s\n", strerror(errno)); - return false; - } - - 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; -} - /** * Convert from Apple's ._ file to Netatalk * @@ -1288,11 +1294,6 @@ static int ad_convert(struct adouble *ad, return -1; } - ok = ad_convert_move_reso(ad, smb_fname); - if (!ok) { - return -1; - } - ok = ad_convert_truncate(ad, smb_fname); if (!ok) { return -1;