From 4ff7ea0e0312c737aefd350f7b8fbed4c8602325 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 24 May 2019 11:54:51 +0200 Subject: [PATCH] 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 --- source3/modules/vfs_fruit.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index b07a525e3c9..f91adb936c3 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1063,10 +1063,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; @@ -1090,17 +1087,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; @@ -1172,7 +1158,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) { @@ -1200,9 +1186,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; } @@ -1216,12 +1203,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; } -- 2.47.3