From: Ralph Boehme Date: Fri, 24 May 2019 09:54:51 +0000 (+0200) Subject: vfs_fruit: use fsp and remove mmap in ad_convert_xattr() X-Git-Tag: samba-4.9.10~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=015586a42274edc210d71fdc8d9158ecdd59d7b9;p=thirdparty%2Fsamba.git vfs_fruit: use fsp and remove mmap in ad_convert_xattr() No need to mmap() anyway, the xattr data is already available in ad->ad_data. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 4ff7ea0e0312c737aefd350f7b8fbed4c8602325) --- diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 08125169a71..e63ed959f35 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1061,10 +1061,7 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, bool *converted_xattr) { static struct char_mappings **string_replace_cmaps = NULL; - char *map = MAP_FAILED; - size_t maplen; uint16_t i; - ssize_t len; int saved_errno = 0; NTSTATUS status; int rc; @@ -1088,17 +1085,6 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, TALLOC_FREE(mappings); } - 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_fsp->fh->fd, 0); - if (map == MAP_FAILED) { - DBG_ERR("mmap AppleDouble: %s\n", strerror(errno)); - return false; - } - for (i = 0; i < ad->adx_header.adx_num_attrs; i++) { struct ad_xattr_entry *e = &ad->adx_entries[i]; char *mapped_name = NULL; @@ -1170,7 +1156,7 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, } nwritten = SMB_VFS_PWRITE(fsp, - map + e->adx_offset, + ad->ad_data + e->adx_offset, e->adx_length, 0); if (nwritten == -1) { @@ -1198,9 +1184,10 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, goto fail; } - len = sys_pwrite(ad->ad_fsp->fh->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); + rc = ad_fset(handle, ad, ad->ad_fsp); + if (rc != 0) { + DBG_ERR("ad_fset on [%s] failed: %s\n", + fsp_str_dbg(ad->ad_fsp), strerror(errno)); ok = false; goto fail; } @@ -1214,12 +1201,6 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, ok = true; fail: - rc = munmap(map, maplen); - if (rc != 0) { - DBG_ERR("munmap failed: %s\n", strerror(errno)); - return false; - } - return ok; }