[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu May 30 22:13:09 UTC 2019


The branch, master has been updated
       via  9a2c9834cb1 vfs_fruit: remove a now unnecessary include
       via  9fe84a6345b vfs_fruit: use VFS functions in ad_read_rsrc_adouble()
       via  70c4a8f0ac3 vfs_fruit: use fsp and remove syscalls from ad_convert_blank_rfork()
       via  3739ad90cf2 vfs_fruit: use VFS function in ad_convert_truncate()
       via  4e44b1da935 vfs_fruit: add VFS handle to ad_convert_truncate()
       via  4ff7ea0e031 vfs_fruit: use fsp and remove mmap in ad_convert_xattr()
       via  0041855af0b vfs_fruit: remove use of mmap() from ad_convert_move_reso()
       via  29418c726be vfs_fruit: convert ad_open_rsrc() to open a proper fsp with SMB_VFS_CREATE_FILE()
       via  f5f7d1e9bf7 vfs_fruit: only do cross protocol locking on non-internal opens
       via  97d485ff2cd vfs_fruit: remove a layer of indirection
       via  3919ea048fe vfs_fruit: pass VFS handle to ad_convert_move_reso()
       via  e3cb1cb24f2 vfs_fruit: remove xattr code from the AppleDouble subsystem
       via  cb9dffa1c66 vfs_fruit: remove now unused AppleDouble code for resource fork in xattr
       via  a23bcc1916a vfs_fruit: use stream code for resource fork size calculation in readdir_attr_rfork_size()
       via  83179a74119 vfs_fruit: use correct case FRUIT_RSRC_STREAM in readdir_attr_rfork_size()
       via  797dc649456 vfs_fruit: ignore AppleDouble files in fruit_unlink()
       via  44d8568001c vfs_fruit: add a missing else
       via  ad70c947c75 vfs_fruit: add and use is_adouble_file()
       via  e266daaed14 vfs_fruit: finally, remove ad_handle from struct adouble
       via  5f4d16b40e0 vfs_fruit: pass handle to ad_convert_delete_adfile()
       via  50874c1548d vfs_fruit: pass handle to ad_convert_finderinfo()
       via  adc7ac38b84 vfs_fruit: pass handle to ad_convert_blank_rfork()
       via  fd2f4cf828e vfs_fruit: pass handle to ad_convert_xattr()
       via  400b3c2f8c8 vfs_fruit: indentation fix
       via  661dfa4a196 vfs_fruit: pass handle to ad_read_rsrc() and all the way down
       via  30ca328c698 vfs_fruit: use proper VFS function in ad_read_meta()
       via  47721d8d359 vfs_fruit: indentation fix
       via  f8df09157f3 vfs_fruit: pass handle to ad_read_meta()
       via  d0abf945e68 vfs_fruit: pass handle to ad_read()
       via  c78ba30ac45 vfs_fruit: pass handle to ad_set()
       via  585d4d49770 vfs_fruit: pass handle to ad_fset()
      from  320a5c5425e samba-tool: add 'import samba.drs_utils' to fsmo.py

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9a2c9834cb1b77547b8b932c35870301afb9fc25
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 24 15:15:59 2019 +0200

    vfs_fruit: remove a now unnecessary include
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu May 30 22:12:50 UTC 2019 on sn-devel-184

commit 9fe84a6345bf5d9fdb1df87a853db3380e6fb0f7
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 24 14:51:17 2019 +0200

    vfs_fruit: use VFS functions in ad_read_rsrc_adouble()
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 70c4a8f0ac307009c26e857523192c95b42a92f5
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 24 12:51:15 2019 +0200

    vfs_fruit: use fsp and remove syscalls from ad_convert_blank_rfork()
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3739ad90cf2bbaa2094a34197c894363d2e24a5a
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 24 12:07:55 2019 +0200

    vfs_fruit: use VFS function in ad_convert_truncate()
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4e44b1da9357120f0ad74e24c650bc6386085c47
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 24 12:05:51 2019 +0200

    vfs_fruit: add VFS handle to ad_convert_truncate()
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4ff7ea0e0312c737aefd350f7b8fbed4c8602325
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 24 11:54:51 2019 +0200

    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 <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0041855af0b05d6c47558880d6eebd1970179272
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 23 22:44:21 2019 +0200

    vfs_fruit: remove use of mmap() from ad_convert_move_reso()
    
    We now have an fsp that we can use, so we can get rid of mmap() and
    sys_pread()/sys_pwrite().
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 29418c726be74feb1d8c3ac9f7b8c983901a2aab
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 23 16:42:52 2019 +0200

    vfs_fruit: convert ad_open_rsrc() to open a proper fsp with SMB_VFS_CREATE_FILE()
    
    A first step in converting all raw syscalls to use proper VFS functions. All
    existing users of the raw system filedescriptor continue to use the fd from
    fsp->fh for now.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f5f7d1e9bf7e39933ccf7c874e682f9df80a6fec
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 23 16:22:39 2019 +0200

    vfs_fruit: only do cross protocol locking on non-internal opens
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 97d485ff2cda85edeba163ea01b6abfa705db20f
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 23 08:27:37 2019 +0200

    vfs_fruit: remove a layer of indirection
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3919ea048fe3b763657e14cdfb5920184a900d27
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 23 08:14:18 2019 +0200

    vfs_fruit: pass VFS handle to ad_convert_move_reso()
    
    Not used for now, that comes next.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e3cb1cb24f2a31d7fd03f3bdf417f4704fb4ac7c
Author: Ralph Boehme <slow at samba.org>
Date:   Wed May 22 21:15:22 2019 +0200

    vfs_fruit: remove xattr code from the AppleDouble subsystem
    
    The subsystem consumers have been reworked in the previous commits, so this is
    not used anymore. ad_init() doesn't need a handle argument anymore due to this,
    remove it as well.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit cb9dffa1c66294b6eed85e7576aa99c642d0b541
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 17 14:31:15 2019 +0200

    vfs_fruit: remove now unused AppleDouble code for resource fork in xattr
    
    This was only needed to get the resourcefork size via the ad_* AppleDouble
    function. This is now done with a fstat on the low level xattr fd (remember,
    this is Solaris only code...), so we can remove the xattr special casing from
    the AppleDouble functions.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a23bcc1916a49bf3e0edece190e5434e39862d2c
Author: Ralph Boehme <slow at samba.org>
Date:   Wed May 22 18:08:14 2019 +0200

    vfs_fruit: use stream code for resource fork size calculation in readdir_attr_rfork_size()
    
    This works as well, using an fstat() on the filehandle to get the size. This is
    tested by the torture test "vfs.fruit.SMB2/CREATE context AAPL".
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 83179a74119de84d20f796c241aae6bccb83a68b
Author: Ralph Boehme <slow at samba.org>
Date:   Wed May 22 17:02:20 2019 +0200

    vfs_fruit: use correct case FRUIT_RSRC_STREAM in readdir_attr_rfork_size()
    
    This is a genuine bug, but luckily this would only impact configs which nobody
    uses:
    
      fruit:metadata = netatalk
      fruit:resource = stream
    
    With the above configuration the switch in readdir_attr_rfork_size() would hit
    the default case and so always report resource forks as 0 bytes in size.
    
    All deployment that I've seen that use fruit:resource=stream also use
    fruit:metadata=stream, so the switch takes FRUIT_META_STREAM case which runs the
    correct code readdir_attr_rfork_size_stream().
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 797dc649456f39add4af8b54b60db0268ad4e90e
Author: Ralph Boehme <slow at samba.org>
Date:   Tue May 21 11:42:47 2019 +0200

    vfs_fruit: ignore AppleDouble files in fruit_unlink()
    
    Otherwise, if SMB_VFS_UNLINK() is called for an AppleDouble path "._file", we
    try to delete "._._file" which doesn't make sense. AppleDouble files don't have
    AppleDouble themselves.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 44d8568001c87d28962dfc4e3fde6d0f7f409997
Author: Ralph Boehme <slow at samba.org>
Date:   Tue May 21 11:40:33 2019 +0200

    vfs_fruit: add a missing else
    
    Luckily the missing else has the same control flow due to the previous if and
    else blocks calling return.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ad70c947c759aa0965ee57f973fb8dc1909e0e39
Author: Ralph Boehme <slow at samba.org>
Date:   Tue May 21 11:39:18 2019 +0200

    vfs_fruit: add and use is_adouble_file()
    
    This adds a helper function that checks whether the last component of a path is
    an AppleDouble sidecar file with "._" name prefix.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e266daaed149561b746dbb8d5e9523862f0057b5
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 17 12:19:06 2019 +0200

    vfs_fruit: finally, remove ad_handle from struct adouble
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5f4d16b40e07acf8d27fee62f1a56de175663a1d
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 17 12:17:28 2019 +0200

    vfs_fruit: pass handle to ad_convert_delete_adfile()
    
    On the course of removing ad_handle from struct adouble, step 10.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 50874c1548d62ab0ddaaa6dd4124279ee5029fcf
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 17 12:05:07 2019 +0200

    vfs_fruit: pass handle to ad_convert_finderinfo()
    
    On the course of removing ad_handle from struct adouble, step 9.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit adc7ac38b849b4dce4a85fd6442c8d4b9da57686
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 17 12:02:46 2019 +0200

    vfs_fruit: pass handle to ad_convert_blank_rfork()
    
    On the course of removing ad_handle from struct adouble, step 8.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit fd2f4cf828ee4c31e3b5a27a79d3a0ee12a5877a
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 17 11:54:10 2019 +0200

    vfs_fruit: pass handle to ad_convert_xattr()
    
    On the course of removing ad_handle from struct adouble, step 7.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 400b3c2f8c82b1defe1e321e0cdae486b930344f
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 17 11:23:17 2019 +0200

    vfs_fruit: indentation fix
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 661dfa4a19673fdb30d5bf36279cdf867454b947
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 17 11:47:26 2019 +0200

    vfs_fruit: pass handle to ad_read_rsrc() and all the way down
    
    On the course of removing ad_handle from struct adouble, step 5.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 30ca328c698c2e035e240359bda7c9dcbeb646df
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 17 11:42:06 2019 +0200

    vfs_fruit: use proper VFS function in ad_read_meta()
    
    Continuing to ignore a possible error for now, this is in an error codepath
    anyway.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 47721d8d359ef78b8dd4f77f92c30c2caf2c4a80
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 17 11:23:17 2019 +0200

    vfs_fruit: indentation fix
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f8df09157f31b53dbe73eaf4349fc071bfcc1b90
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 17 11:22:24 2019 +0200

    vfs_fruit: pass handle to ad_read_meta()
    
    On the course of removing ad_handle from struct adouble, step 4.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d0abf945e683766029d28915541a4baf9f3879ab
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 17 11:19:53 2019 +0200

    vfs_fruit: pass handle to ad_read()
    
    On the course of removing ad_handle from struct adouble, step 3.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c78ba30ac4534b7037b979ac96b77b834b2eb2fe
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 17 10:43:55 2019 +0200

    vfs_fruit: pass handle to ad_set()
    
    On the course of removing ad_handle from struct adouble, step 2.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 585d4d49770b4ddc3f7d9dcbb3e322f072767781
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 17 10:41:29 2019 +0200

    vfs_fruit: pass handle to ad_fset()
    
    On the course of removing ad_handle from struct adouble, step 1.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/modules/vfs_fruit.c | 485 +++++++++++++++++++++-----------------------
 1 file changed, 231 insertions(+), 254 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 9e22a1338ae..f2964769a74 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -28,7 +28,6 @@
 #include "messages.h"
 #include "libcli/security/security.h"
 #include "../libcli/smb/smb2_create_ctx.h"
-#include "lib/util/sys_rw.h"
 #include "lib/util/tevent_ntstatus.h"
 #include "lib/util/tevent_unix.h"
 #include "offload_token.h"
@@ -413,8 +412,7 @@ struct ad_entry {
 };
 
 struct adouble {
-	vfs_handle_struct        *ad_handle;
-	int                       ad_fd;
+	files_struct             *ad_fsp;
 	bool                      ad_opened;
 	adouble_type_t            ad_type;
 	uint32_t                  ad_magic;
@@ -452,18 +450,6 @@ struct ad_entry_order entry_order_dot_und[ADEID_NUM_DOT_UND + 1] = {
 	{0, 0, 0}
 };
 
-/*
- * Fake AppleDouble entry oder for resource fork xattr.  The xattr
- * isn't an AppleDouble file, it simply contains the resource data,
- * but in order to be able to use some API calls like ad_getentryoff()
- * we build a fake/helper struct adouble with this entry order struct.
- */
-static const
-struct ad_entry_order entry_order_rsrc_xattr[ADEID_NUM_RSRC_XATTR + 1] = {
-	{ADEID_RFORK, 0, 0},
-	{0, 0, 0}
-};
-
 /* Conversion from enumerated id to on-disk AppleDouble id */
 #define AD_EID_DISK(a) (set_eid[a])
 static const uint32_t set_eid[] = {
@@ -535,14 +521,18 @@ struct fio {
 /*
  * Forward declarations
  */
-static struct adouble *ad_init(TALLOC_CTX *ctx, vfs_handle_struct *handle,
+static struct adouble *ad_init(TALLOC_CTX *ctx,
 			       adouble_type_t type);
 static struct adouble *ad_get(TALLOC_CTX *ctx,
 			      vfs_handle_struct *handle,
 			      const struct smb_filename *smb_fname,
 			      adouble_type_t type);
-static int ad_set(struct adouble *ad, const struct smb_filename *smb_fname);
-static int ad_fset(struct adouble *ad, files_struct *fsp);
+static int ad_set(vfs_handle_struct *handle,
+		  struct adouble *ad,
+		  const struct smb_filename *smb_fname);
+static int ad_fset(struct vfs_handle_struct *handle,
+		   struct adouble *ad,
+		   files_struct *fsp);
 static int adouble_path(TALLOC_CTX *ctx,
 			const struct smb_filename *smb_fname__in,
 			struct smb_filename **ppsmb_fname_out);
@@ -1003,67 +993,76 @@ static bool ad_unpack(struct adouble *ad, const size_t nentries,
 	return true;
 }
 
-static bool ad_convert_move_reso(struct adouble *ad,
+static bool ad_convert_move_reso(vfs_handle_struct *handle,
+				 struct adouble *ad,
 				 const struct smb_filename *smb_fname)
 {
-	char *map = MAP_FAILED;
-	size_t maplen;
-	ssize_t len;
-	int rc;
+	char *buf = NULL;
+	size_t rforklen;
+	size_t rforkoff;
+	ssize_t n;
+	int ret;
 	bool ok;
 
-	if (ad_getentrylen(ad, ADEID_RFORK) == 0) {
+	rforklen = ad_getentrylen(ad, ADEID_RFORK);
+	if (rforklen == 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));
+	buf = talloc_size(ad, rforklen);
+	if (buf == NULL) {
+		/*
+		 * This allocates a buffer for reading the resource fork data in
+		 * one big swoop. Resource forks won't be larger then, say, 64
+		 * MB, I swear, so just doing the allocation with the talloc
+		 * limit as safeguard seems safe.
+		 */
+		DBG_ERR("Failed to allocate %zu bytes for rfork\n",
+			rforklen);
 		return false;
 	}
 
+	rforkoff = ad_getentryoff(ad, ADEID_RFORK);
+
+	n = SMB_VFS_PREAD(ad->ad_fsp, buf, rforklen, rforkoff);
+	if (n != rforklen) {
+		DBG_ERR("Reading %zu bytes from rfork [%s] failed: %s\n",
+			rforklen, fsp_str_dbg(ad->ad_fsp), strerror(errno));
+		return false;
+	}
 
-	memmove(map + ADEDOFF_RFORK_DOT_UND,
-		map + ad_getentryoff(ad, ADEID_RFORK),
-		ad_getentrylen(ad, ADEID_RFORK));
+	rforkoff = ADEDOFF_RFORK_DOT_UND;
 
-	rc = munmap(map, maplen);
-	if (rc != 0) {
-		DBG_ERR("munmap failed: %s\n", strerror(errno));
+	n = SMB_VFS_PWRITE(ad->ad_fsp, buf, rforklen, rforkoff);
+	if (n != rforklen) {
+		DBG_ERR("Writing %zu bytes to rfork [%s] failed: %s\n",
+			rforklen, fsp_str_dbg(ad->ad_fsp), 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);
+	ret = ad_fset(handle, ad, ad->ad_fsp);
+	if (ret != 0) {
+		DBG_ERR("ad_fset on [%s] failed\n", fsp_str_dbg(ad->ad_fsp));
 		return false;
 	}
 
 	return true;
 }
 
-static bool ad_convert_xattr(struct adouble *ad,
+static bool ad_convert_xattr(vfs_handle_struct *handle,
+			     struct adouble *ad,
 			     const struct smb_filename *smb_fname,
 			     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;
@@ -1087,17 +1086,6 @@ static bool ad_convert_xattr(struct adouble *ad,
 		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_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;
@@ -1106,7 +1094,7 @@ static bool ad_convert_xattr(struct adouble *ad,
 		files_struct *fsp = NULL;
 		ssize_t nwritten;
 
-		status = string_replace_allocate(ad->ad_handle->conn,
+		status = string_replace_allocate(handle->conn,
 						 e->adx_name,
 						 string_replace_cmaps,
 						 talloc_tos(),
@@ -1143,7 +1131,7 @@ static bool ad_convert_xattr(struct adouble *ad,
 		DBG_DEBUG("stream_name: %s\n", smb_fname_str_dbg(stream_name));
 
 		status = SMB_VFS_CREATE_FILE(
-			ad->ad_handle->conn,		/* conn */
+			handle->conn,			/* conn */
 			NULL,				/* req */
 			0,				/* root_dir_fid */
 			stream_name,			/* fname */
@@ -1169,7 +1157,7 @@ static bool ad_convert_xattr(struct adouble *ad,
 		}
 
 		nwritten = SMB_VFS_PWRITE(fsp,
-					  map + e->adx_offset,
+					  ad->ad_data + e->adx_offset,
 					  e->adx_length,
 					  0);
 		if (nwritten == -1) {
@@ -1197,14 +1185,15 @@ static bool ad_convert_xattr(struct adouble *ad,
 		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);
+	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;
 	}
 
-	ok = ad_convert_move_reso(ad, smb_fname);
+	ok = ad_convert_move_reso(handle, ad, smb_fname);
 	if (!ok) {
 		goto fail;
 	}
@@ -1213,16 +1202,11 @@ static bool ad_convert_xattr(struct adouble *ad,
 	ok = true;
 
 fail:
-	rc = munmap(map, maplen);
-	if (rc != 0) {
-		DBG_ERR("munmap failed: %s\n", strerror(errno));
-		return false;
-	}
-
 	return ok;
 }
 
-static bool ad_convert_finderinfo(struct adouble *ad,
+static bool ad_convert_finderinfo(vfs_handle_struct *handle,
+				  struct adouble *ad,
 				  const struct smb_filename *smb_fname)
 {
 	char *p_ad = NULL;
@@ -1279,7 +1263,7 @@ static bool ad_convert_finderinfo(struct adouble *ad,
 	DBG_DEBUG("stream_name: %s\n", smb_fname_str_dbg(stream_name));
 
 	status = SMB_VFS_CREATE_FILE(
-		ad->ad_handle->conn,		/* conn */
+		handle->conn,			/* conn */
 		NULL,				/* req */
 		0,				/* root_dir_fid */
 		stream_name,			/* fname */
@@ -1324,17 +1308,16 @@ static bool ad_convert_finderinfo(struct adouble *ad,
 	return true;
 }
 
-static bool ad_convert_truncate(struct adouble *ad,
+static bool ad_convert_truncate(vfs_handle_struct *handle,
+				struct adouble *ad,
 				const struct smb_filename *smb_fname)
 {
 	int rc;
+	off_t newlen;
 
-	/*
-	 * FIXME: direct ftruncate(), but we don't have a fsp for the
-	 * VFS call
-	 */
-	rc = ftruncate(ad->ad_fd, ADEDOFF_RFORK_DOT_UND +
-		       ad_getentrylen(ad, ADEID_RFORK));
+	newlen = ADEDOFF_RFORK_DOT_UND + ad_getentrylen(ad, ADEID_RFORK);
+
+	rc = SMB_VFS_FTRUNCATE(ad->ad_fsp, newlen);
 	if (rc != 0) {
 		return false;
 	}
@@ -1342,63 +1325,52 @@ static bool ad_convert_truncate(struct adouble *ad,
 	return true;
 }
 
-static bool ad_convert_blank_rfork(struct adouble *ad,
+static bool ad_convert_blank_rfork(vfs_handle_struct *handle,
+				   struct adouble *ad,
 				   bool *blank)
 {
 	struct fruit_config_data *config = NULL;
-	uint8_t *map = MAP_FAILED;
-	size_t maplen;
+	size_t rforklen = sizeof(empty_resourcefork);
+	char buf[rforklen];
+	ssize_t nread;
 	int cmp;
-	ssize_t len;
 	int rc;
 	bool ok;
 
 	*blank = false;
 
-	SMB_VFS_HANDLE_GET_DATA(ad->ad_handle, config,
+	SMB_VFS_HANDLE_GET_DATA(handle, config,
 				struct fruit_config_data, return false);
 
 	if (!config->wipe_intentionally_left_blank_rfork) {
 		return true;
 	}
 
-	if (ad_getentrylen(ad, ADEID_RFORK) != sizeof(empty_resourcefork)) {
+	if (ad_getentrylen(ad, ADEID_RFORK) != rforklen) {
 		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;
-	}
-
-	cmp = memcmp(map + ADEDOFF_RFORK_DOT_UND,
-		     empty_resourcefork,
-		     sizeof(empty_resourcefork));
-	rc = munmap(map, maplen);
-	if (rc != 0) {
-		DBG_ERR("munmap failed: %s\n", strerror(errno));
+	nread = SMB_VFS_PREAD(ad->ad_fsp, buf, rforklen, ADEDOFF_RFORK_DOT_UND);
+	if (nread != rforklen) {
+		DBG_ERR("Reading %zu bytes from rfork [%s] failed: %s\n",
+			rforklen, fsp_str_dbg(ad->ad_fsp), strerror(errno));
 		return false;
 	}
 
+	cmp = memcmp(buf, empty_resourcefork, rforklen);
 	if (cmp != 0) {
 		return true;
 	}
 
 	ad_setentrylen(ad, ADEID_RFORK, 0);
-
 	ok = ad_pack(ad);
 	if (!ok) {
 		return false;
 	}
 
-	len = sys_pwrite(ad->ad_fd, ad->ad_data, AD_DATASZ_DOT_UND, 0);
-	if (len != AD_DATASZ_DOT_UND) {
+	rc = ad_fset(handle, ad, ad->ad_fsp);
+	if (rc != 0) {
+		DBG_ERR("ad_fset on [%s] failed\n", fsp_str_dbg(ad->ad_fsp));
 		return false;
 	}
 
@@ -1406,7 +1378,8 @@ static bool ad_convert_blank_rfork(struct adouble *ad,
 	return true;
 }
 
-static bool ad_convert_delete_adfile(struct adouble *ad,
+static bool ad_convert_delete_adfile(vfs_handle_struct *handle,
+				     struct adouble *ad,
 				     const struct smb_filename *smb_fname)
 {
 	struct fruit_config_data *config = NULL;
@@ -1417,7 +1390,7 @@ static bool ad_convert_delete_adfile(struct adouble *ad,
 		return true;
 	}
 
-	SMB_VFS_HANDLE_GET_DATA(ad->ad_handle, config,
+	SMB_VFS_HANDLE_GET_DATA(handle, config,
 				struct fruit_config_data, return false);
 
 	if (!config->delete_empty_adfiles) {
@@ -1429,7 +1402,7 @@ static bool ad_convert_delete_adfile(struct adouble *ad,
 		return false;
 	}
 
-	rc = SMB_VFS_NEXT_UNLINK(ad->ad_handle, ad_name);
+	rc = SMB_VFS_NEXT_UNLINK(handle, ad_name);
 	if (rc != 0) {
 		DBG_ERR("Unlinking [%s] failed: %s\n",
 			smb_fname_str_dbg(ad_name), strerror(errno));
@@ -1466,27 +1439,27 @@ static int ad_convert(struct vfs_handle_struct *handle,
 		return 0;
 	}
 
-	ok = ad_convert_xattr(ad, smb_fname, &converted_xattr);
+	ok = ad_convert_xattr(handle, ad, smb_fname, &converted_xattr);
 	if (!ok) {
 		ret = -1;
 		goto done;
 	}
 
-	ok = ad_convert_blank_rfork(ad, &blank);
+	ok = ad_convert_blank_rfork(handle, ad, &blank);
 	if (!ok) {
 		ret = -1;
 		goto done;
 	}
 
 	if (converted_xattr || blank) {
-		ok = ad_convert_truncate(ad, smb_fname);
+		ok = ad_convert_truncate(handle, ad, smb_fname);
 		if (!ok) {
 			ret = -1;
 			goto done;
 		}
 	}
 
-	ok = ad_convert_finderinfo(ad, smb_fname);
+	ok = ad_convert_finderinfo(handle, ad, smb_fname);
 	if (!ok) {
 		DBG_ERR("Failed to convert [%s]\n",
 			smb_fname_str_dbg(smb_fname));
@@ -1494,7 +1467,7 @@ static int ad_convert(struct vfs_handle_struct *handle,
 		goto done;
 	}
 
-	ok = ad_convert_delete_adfile(ad, smb_fname);
+	ok = ad_convert_delete_adfile(handle, ad, smb_fname);
 	if (!ok) {
 		ret = -1;
 		goto done;
@@ -1509,8 +1482,9 @@ done:
 /**
  * Read and parse Netatalk AppleDouble metadata xattr
  **/
-static ssize_t ad_read_meta(struct adouble *ad,
-				const struct smb_filename *smb_fname)
+static ssize_t ad_read_meta(vfs_handle_struct *handle,
+			    struct adouble *ad,
+			    const struct smb_filename *smb_fname)
 {
 	int      rc = 0;
 	ssize_t  ealen;
@@ -1518,7 +1492,7 @@ static ssize_t ad_read_meta(struct adouble *ad,
 
 	DEBUG(10, ("reading meta xattr for %s\n", smb_fname->base_name));
 
-	ealen = SMB_VFS_GETXATTR(ad->ad_handle->conn, smb_fname,
+	ealen = SMB_VFS_GETXATTR(handle->conn, smb_fname,
 				 AFPINFO_EA_NETATALK, ad->ad_data,
 				 AD_DATASZ_XATTR);
 	if (ealen == -1) {
@@ -1575,7 +1549,9 @@ exit:
 		ealen = -1;
 		if (errno == EINVAL) {
 			become_root();
-			removexattr(smb_fname->base_name, AFPINFO_EA_NETATALK);
+			(void)SMB_VFS_REMOVEXATTR(handle->conn,
+						  smb_fname,
+						  AFPINFO_EA_NETATALK);
 			unbecome_root();
 			errno = ENOENT;
 		}
@@ -1583,57 +1559,67 @@ exit:
 	return ealen;
 }
 
-static int ad_open_rsrc_xattr(const struct smb_filename *smb_fname,
-				int flags,
-				mode_t mode)
-{
-#ifdef HAVE_ATTROPEN
-	/* FIXME: direct Solaris xattr syscall */
-	return attropen(smb_fname->base_name,
-			AFPRESOURCE_EA_NETATALK, flags, mode);
-#else
-	errno = ENOSYS;
-	return -1;
-#endif
-}
-
-static int ad_open_rsrc_adouble(const struct smb_filename *smb_fname,
-				int flags,
-				mode_t mode)
+static int ad_open_rsrc(vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname,
+			int flags,
+			mode_t mode,
+			files_struct **_fsp)
 {
 	int ret;
-	int fd;
 	struct smb_filename *adp_smb_fname = NULL;
+	files_struct *fsp = NULL;
+	uint32_t access_mask;
+	uint32_t share_access;
+	uint32_t create_disposition;
+	NTSTATUS status;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list