vfs_fruit: use fsp and remove mmap in ad_convert_xattr()
authorRalph Boehme <slow@samba.org>
Fri, 24 May 2019 09:54:51 +0000 (11:54 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 30 May 2019 20:19:27 +0000 (20:19 +0000)
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 <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_fruit.c

index b07a525e3c9b97040e0b98da1fdecfc44d9aef9a..f91adb936c3f7f43ccd1f10ba5f482d557a80bc1 100644 (file)
@@ -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;
 }