samba/samba-4.10.6-vfs_fruit.patch

3176 lines
111 KiB
Diff

From 919036329cf0005ac0d97a6f3eacac24617bbf26 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Tue, 21 May 2019 18:39:52 +0200
Subject: [PATCH 1/5] s4:torture/vfs/fruit: ensure test_adouble_conversion()
uses a non-emtpy resourcefork
This ensures the resource fork is not deleted as part of the AppleDouble file
conversion for the option fruit:wipe_intentionally_left_blank_rfork=yes.
This is currently not a problem in selftest, as we don't enable the option, but
a subsequent commit will run all vfs.fruit tests against a share with this
option enabled.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13958
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit c3d28d49be3c7536d1ccfe8d00553ce72843f369)
---
source4/torture/vfs/fruit.c | 671 +++++++++++++++++++++++++++++++++++-
1 file changed, 668 insertions(+), 3 deletions(-)
diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c
index e0ba935ff99..1c0754af456 100644
--- a/source4/torture/vfs/fruit.c
+++ b/source4/torture/vfs/fruit.c
@@ -1027,6 +1027,666 @@ static char osx_adouble_without_xattr[] = {
0x00, 0x00, 0x00, 0x1c, 0x00, 0x1e, 0xff, 0xff
};
+/*
+The buf below contains the following AppleDouble encoded data:
+
+-------------------------------------------------------------------------------
+MagicNumber: 00051607 : AppleDouble
+Version : 00020000 : Version 2
+Filler : 4D 61 63 20 4F 53 20 58 20 20 20 20 20 20 20 20 : Mac OS X
+Num. of ent: 0002 : 2
+
+-------------------------------------------------------------------------------
+Entry ID : 00000009 : Finder Info
+Offset : 00000032 : 50
+Length : 00000EB0 : 3760
+
+-FInfo-----:
+Type : 54455354 : TEST
+Creator : 534C4F57 : SLOW
+isAlias : 0
+Invisible : 0
+hasBundle : 0
+nameLocked : 0
+Stationery : 0
+CustomIcon : 0
+Reserved : 0
+Inited : 0
+NoINITS : 0
+Shared : 0
+SwitchLaunc: 0
+Hidden Ext : 0
+color : 100 : blue
+isOnDesk : 0
+Location v : 0000 : 0
+Location h : 0000 : 0
+Fldr : 0000 : ..
+
+-FXInfo----:
+Rsvd|IconID: 0000 : 0
+Rsvd : 0000 : ..
+Rsvd : 0000 : ..
+Rsvd : 0000 : ..
+AreInvalid : 0
+unknown bit: 0
+unknown bit: 0
+unknown bit: 0
+unknown bit: 0
+unknown bit: 0
+unknown bit: 0
+CustomBadge: 0
+ObjctIsBusy: 0
+unknown bit: 0
+unknown bit: 0
+unknown bit: 0
+unknown bit: 0
+RoutingInfo: 0
+unknown bit: 0
+unknown bit: 0
+Rsvd|commnt: 0000 : 0
+PutAway : 00000000 : 0
+
+-EA--------:
+pad : 0000 : ..
+magic : 41545452 : ATTR
+debug_tag : 53D4580C : 1406425100
+total_size : 00000EE2 : 3810
+data_start : 000000BC : 188
+data_length: 0000005E : 94
+reserved[0]: 00000000 : ....
+reserved[1]: 00000000 : ....
+reserved[2]: 00000000 : ....
+flags : 0000 : ..
+num_attrs : 0002 : 2
+-EA ENTRY--:
+offset : 000000BC : 188
+length : 0000005B : 91
+flags : 0000 : ..
+namelen : 24 : 36
+-EA NAME---: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
+00000000 : 63 6F 6D 2E 61 70 70 6C 65 2E 6D 65 74 61 64 61 : com.apple.metada
+00000010 : 74 61 3A 5F 6B 4D 44 49 74 65 6D 55 73 65 72 54 : ta:_kMDItemUserT
+00000020 : 61 67 73 00 : ags.
+-EA VALUE--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
+00000000 : 62 70 6C 69 73 74 30 30 A5 01 02 03 04 05 54 74 : bplist00......Tt
+00000010 : 65 73 74 66 00 47 00 72 00 FC 00 6E 00 0A 00 32 : estf.G.r...n...2
+00000020 : 56 4C 69 6C 61 0A 33 56 47 65 6C 62 0A 35 56 42 : VLila.3VGelb.5VB
+00000030 : 6C 61 75 0A 34 08 0E 13 20 27 2E 00 00 00 00 00 : lau.4... '......
+00000040 : 00 01 01 00 00 00 00 00 00 00 06 00 00 00 00 00 : ................
+00000050 : 00 00 00 00 00 00 00 00 00 00 35 : ..........5
+-EA ENTRY--:
+offset : 00000117 : 279
+length : 00000003 : 3
+flags : 0000 : ..
+namelen : 08 : 8
+-EA NAME---: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
+00000000 : 66 6F 6F 3A 62 61 72 00 : foo:bar.
+-EA VALUE--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
+00000000 : 62 61 7A : baz
+
+-RAW DUMP--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
+00000000 : 54 45 53 54 53 4C 4F 57 00 08 00 00 00 00 00 00 : TESTSLOW........
+00000010 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+00000020 : 00 00 41 54 54 52 53 D4 58 0C 00 00 0E E2 00 00 : ..ATTRS.X.......
+00000030 : 00 BC 00 00 00 5E 00 00 00 00 00 00 00 00 00 00 : .....^..........
+00000040 : 00 00 00 00 00 02 00 00 00 BC 00 00 00 5B 00 00 : .............[..
+00000050 : 24 63 6F 6D 2E 61 70 70 6C 65 2E 6D 65 74 61 64 : $com.apple.metad
+00000060 : 61 74 61 3A 5F 6B 4D 44 49 74 65 6D 55 73 65 72 : ata:_kMDItemUser
+00000070 : 54 61 67 73 00 00 00 00 01 17 00 00 00 03 00 00 : Tags............
+00000080 : 08 66 6F 6F 3A 62 61 72 00 66 62 70 6C 69 73 74 : .foo:bar.fbplist
+00000090 : 30 30 A5 01 02 03 04 05 54 74 65 73 74 66 00 47 : 00......Ttestf.G
+000000A0 : 00 72 00 FC 00 6E 00 0A 00 32 56 4C 69 6C 61 0A : .r...n...2VLila.
+000000B0 : 33 56 47 65 6C 62 0A 35 56 42 6C 61 75 0A 34 08 : 3VGelb.5VBlau.4.
+000000C0 : 0E 13 20 27 2E 00 00 00 00 00 00 01 01 00 00 00 : .. '............
+000000D0 : 00 00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 : ................
+000000E0 : 00 00 00 00 35 62 61 7A 00 00 00 00 00 00 00 00 : ....5baz........
+000000F0 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+... all zeroes ...
+00000EA0 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+
+-------------------------------------------------------------------------------
+Entry ID : 00000002 : Resource Fork
+Offset : 00000EE2 : 3810
+Length : 0000011E : 286
+
+-RAW DUMP--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
+00000000 : 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 1E : ................
+00000010 : F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF : This resource fo
+00000020 : 72 6B 20 69 6E 74 65 6E 74 69 6F 6E 61 6C 6C 79 : rk intentionally
+00000030 : 20 6C 65 66 74 20 62 6C 61 6E 6B 20 20 20 00 00 : left blank ..
+00000040 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+00000050 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+00000060 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+00000070 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+00000080 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+00000090 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+000000A0 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+000000B0 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+000000C0 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+000000D0 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+000000E0 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+000000F0 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
+00000100 : 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 1E : ................
+00000110 : 00 00 00 00 00 00 00 00 00 1C 00 1E FF FF : ..............
+
+It was created with:
+$ hexdump -ve '"\t" 7/1 "0x%02x, " 1/1 " 0x%02x," "\n"'
+*/
+static char osx_adouble_non_empty_rfork_w_xattr[] = {
+ 0x00, 0x05, 0x16, 0x07, 0x00, 0x02, 0x00, 0x00,
+ 0x4d, 0x61, 0x63, 0x20, 0x4f, 0x53, 0x20, 0x58,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
+ 0x00, 0x32, 0x00, 0x00, 0x0e, 0xb0, 0x00, 0x00,
+ 0x00, 0x02, 0x00, 0x00, 0x0e, 0xe2, 0x00, 0x00,
+ 0x01, 0x1e, 0x54, 0x45, 0x53, 0x54, 0x53, 0x4c,
+ 0x4f, 0x57, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x41, 0x54, 0x54, 0x52,
+ 0x53, 0xd4, 0x58, 0x0c, 0x00, 0x00, 0x0e, 0xe2,
+ 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x5e,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x5b,
+ 0x00, 0x00, 0x24, 0x63, 0x6f, 0x6d, 0x2e, 0x61,
+ 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x6d, 0x65, 0x74,
+ 0x61, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x5f, 0x6b,
+ 0x4d, 0x44, 0x49, 0x74, 0x65, 0x6d, 0x55, 0x73,
+ 0x65, 0x72, 0x54, 0x61, 0x67, 0x73, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x17, 0x00, 0x00, 0x00, 0x03,
+ 0x00, 0x00, 0x08, 0x66, 0x6f, 0x6f, 0x3a, 0x62,
+ 0x61, 0x72, 0x00, 0x66, 0x62, 0x70, 0x6c, 0x69,
+ 0x73, 0x74, 0x30, 0x30, 0xa5, 0x01, 0x02, 0x03,
+ 0x04, 0x05, 0x54, 0x74, 0x65, 0x73, 0x74, 0x66,
+ 0x00, 0x47, 0x00, 0x72, 0x00, 0xfc, 0x00, 0x6e,
+ 0x00, 0x0a, 0x00, 0x32, 0x56, 0x4c, 0x69, 0x6c,
+ 0x61, 0x0a, 0x33, 0x56, 0x47, 0x65, 0x6c, 0x62,
+ 0x0a, 0x35, 0x56, 0x42, 0x6c, 0x61, 0x75, 0x0a,
+ 0x34, 0x08, 0x0e, 0x13, 0x20, 0x27, 0x2e, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, 0x62,
+ 0x61, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x1e, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5,
+ 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd,
+ 0xfe, 0xff, 0x72, 0x6b, 0x20, 0x69, 0x6e, 0x74,
+ 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c,
+ 0x6c, 0x79, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x20,
+ 0x62, 0x6c, 0x61, 0x6e, 0x6b, 0x20, 0x20, 0x20,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x1c, 0x00, 0x1e, 0xff, 0xff
+};
+
/**
* talloc and intialize an AfpInfo
**/
@@ -2082,8 +2742,11 @@ static bool test_adouble_conversion(struct torture_context *tctx,
NTSTATUS status;
struct smb2_handle testdirh;
bool ret = true;
- const char *data = "This resource fork intentionally left blank";
- size_t datalen = strlen(data);
+ const char data[] = {
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
+ };
+ size_t datalen = sizeof(data);
const char *streams[] = {
"::$DATA",
AFPINFO_STREAM,
@@ -2113,7 +2776,9 @@ static bool test_adouble_conversion(struct torture_context *tctx,
ret = write_stream(tree, __location__, tctx, mem_ctx,
adname, NULL,
- 0, sizeof(osx_adouble_w_xattr), osx_adouble_w_xattr);
+ 0,
+ sizeof(osx_adouble_non_empty_rfork_w_xattr),
+ osx_adouble_non_empty_rfork_w_xattr);
torture_assert_goto(tctx, ret == true, ret, done,
"write_stream failed\n");
--
2.21.0
From 824a6bd86625611d79cec7c7aa7951c1537a843e Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Tue, 21 May 2019 18:39:52 +0200
Subject: [PATCH 2/5] s4:torture/vfs/fruit: ensure
test_adouble_conversion_wo_xattr() uses a non-emtpy resourcefork
This ensures the resource fork is not deleted as part of the AppleDouble file
conversion for the option fruit:wipe_intentionally_left_blank_rfork=yes.
This is currently not a problem in selftest, as we don't enable the option, but
a subsequent commit will run all vfs.fruit tests against a share with this
option enabled.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13958
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit bb5a457f2872a383b58d62981dade322fca9b283)
---
source4/torture/vfs/fruit.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c
index 1c0754af456..8e8731662fb 100644
--- a/source4/torture/vfs/fruit.c
+++ b/source4/torture/vfs/fruit.c
@@ -902,7 +902,7 @@ static char osx_adouble_w_xattr[] = {
*
* -RAW DUMP--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
* 00000000 : 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 1E : ................
- * 00000010 : 54 68 69 73 20 72 65 73 6F 75 72 63 65 20 66 6F : This resource fo
+ * 00000010 : F0 F1 F2 F3 F5 F5 F6 F7 F8 F9 FA FB FC FD FE FF : ................
* 00000020 : 72 6B 20 69 6E 74 65 6E 74 69 6F 6E 61 6C 6C 79 : rk intentionally
* 00000030 : 20 6C 65 66 74 20 62 6C 61 6E 6B 20 20 20 00 00 : left blank ..
* 00000040 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
@@ -991,9 +991,9 @@ static char osx_adouble_without_xattr[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x1e, 0x54, 0x68, 0x69, 0x73, 0x20, 0x72,
- 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20,
- 0x66, 0x6f, 0x72, 0x6b, 0x20, 0x69, 0x6e, 0x74,
+ 0x00, 0x1e, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5,
+ 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd,
+ 0xfe, 0xff, 0x72, 0x6b, 0x20, 0x69, 0x6e, 0x74,
0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c,
0x6c, 0x79, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x20,
0x62, 0x6c, 0x61, 0x6e, 0x6b, 0x20, 0x20, 0x20,
@@ -2833,8 +2833,11 @@ static bool test_adouble_conversion_wo_xattr(struct torture_context *tctx,
struct smb2_find find;
unsigned int count;
union smb_search_data *d;
- const char *data = "This resource fork intentionally left blank";
- size_t datalen = strlen(data);
+ const char data[] = {
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
+ };
+ size_t datalen = sizeof(data);
bool is_osx = torture_setting_bool(tctx, "osx", false);
if (is_osx) {
--
2.21.0
From a648e79902108152f15998a0a5a236cecec80ad0 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Tue, 21 May 2019 14:05:04 +0200
Subject: [PATCH 3/5] selftest: run vfs.fruit test against a share that deletes
empty resource forks
This reveals a bug in the AppleDouble conversion code: the conversion code that
unlinks an empty resource fork AppleDouble sidecar file ("._file") gets
triggered as part of open_file_ntcreate(..., "file:AFP_AfpResource", ...):
after SMB_VFS_OPEN() has been called with O_CREAT, what created the file, we
call SMB_VFS_FSTAT() on the just created filehandle. This ends up in
ad_convert(), finds the resource fork empty and thus deletes the file.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13958
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 8ed9b6b457923d2353d1d18838f4a278db48c6b9)
---
selftest/knownfail.d/samba3.vfs.fruit | 13 +++++++++++++
source3/selftest/tests.py | 1 +
2 files changed, 14 insertions(+)
diff --git a/selftest/knownfail.d/samba3.vfs.fruit b/selftest/knownfail.d/samba3.vfs.fruit
index 6307e2b3404..b1a28bedff6 100644
--- a/selftest/knownfail.d/samba3.vfs.fruit
+++ b/selftest/knownfail.d/samba3.vfs.fruit
@@ -1,2 +1,15 @@
^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion\(nt4_dc\)
^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion without embedded xattr\(nt4_dc\)
+^samba3.vfs.fruit fruit_delete_empty_adfiles.copyfile\(nt4_dc\)
+^samba3.vfs.fruit fruit_delete_empty_adfiles.resource fork IO\(nt4_dc\)
+^samba3.vfs.fruit fruit_delete_empty_adfiles.SMB2/CREATE context AAPL\(nt4_dc\)
+^samba3.vfs.fruit fruit_delete_empty_adfiles.truncate resource fork to 0 bytes\(nt4_dc\)
+^samba3.vfs.fruit fruit_delete_empty_adfiles.opening and creating resource fork\(nt4_dc\)
+^samba3.vfs.fruit fruit_delete_empty_adfiles.create delete-on-close AFP_AfpResource\(nt4_dc\)
+^samba3.vfs.fruit fruit_delete_empty_adfiles.setinfo delete-on-close AFP_AfpResource\(nt4_dc\)
+^samba3.vfs.fruit fruit_delete_empty_adfiles.delete\(nt4_dc\)
+^samba3.vfs.fruit fruit_delete_empty_adfiles.read open rsrc after rename\(nt4_dc\)
+^samba3.vfs.fruit fruit_delete_empty_adfiles.readdir_attr with names with illegal ntfs characters\(nt4_dc\)
+^samba3.vfs.fruit fruit_delete_empty_adfiles.copy-chunk streams\(nt4_dc\)
+^samba3.vfs.fruit fruit_delete_empty_adfiles.empty_stream\(nt4_dc\)
+^samba3.vfs.fruit fruit_delete_empty_adfiles.setinfo eof AFP_AfpResource\(nt4_dc\)
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 7067abc5fb4..1db806ef887 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -595,6 +595,7 @@ tests = base + raw + smb2 + rpc + unix + local + rap + nbt + libsmbclient + idma
plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/vfs_fruit -U$USERNAME%$PASSWORD --option=torture:localdir=$SELFTEST_PREFIX/nt4_dc/share --option=torture:share2=vfs_wo_fruit', 'metadata_netatalk')
plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/vfs_fruit_metadata_stream -U$USERNAME%$PASSWORD --option=torture:localdir=$SELFTEST_PREFIX/nt4_dc/share --option=torture:share2=vfs_wo_fruit', 'metadata_stream')
plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/vfs_fruit_stream_depot -U$USERNAME%$PASSWORD --option=torture:localdir=$SELFTEST_PREFIX/nt4_dc/share --option=torture:share2=vfs_wo_fruit_stream_depot', 'streams_depot')
+ plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/vfs_fruit_delete_empty_adfiles -U$USERNAME%$PASSWORD --option=torture:localdir=$SELFTEST_PREFIX/nt4_dc/share --option=torture:share2=vfs_wo_fruit', 'fruit_delete_empty_adfiles')
elif t == "vfs.fruit_netatalk":
plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/vfs_fruit_xattr -U$USERNAME%$PASSWORD --option=torture:localdir=$SELFTEST_PREFIX/nt4_dc/share')
elif t == "vfs.fruit_timemachine":
--
2.21.0
From e5185fa8b4ae25a60557a014d3c30ee4bd6bbaff Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Tue, 21 May 2019 16:00:00 +0200
Subject: [PATCH 4/5] vfs_fruit: add a forward declaration for ad_get()
Will be needed in the next commit.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13958
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 4777d1163a7c18c89ce9be955903427a18134415)
---
source3/modules/vfs_fruit.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index f54038f53d4..b74d26ca711 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -535,6 +535,10 @@ struct fio {
*/
static struct adouble *ad_init(TALLOC_CTX *ctx, vfs_handle_struct *handle,
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 adouble_path(TALLOC_CTX *ctx,
--
2.21.0
From d95745e8603906d105ec6cd12bc91a62d62fef6c Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Tue, 21 May 2019 16:00:53 +0200
Subject: [PATCH 5/5] vfs_fruit: change trigger points of AppleDouble
conversion
This moves the trigger points where AppleDouble file conversion is run by
ad_convert() from deep down the callchain in ad_read_rsrc_adouble() to high
level VFS entry points.
Currently ad_convert() will be triggered as part of open_file_ntcreate(...,
"file:AFP_AfpResource", ...): after SMB_VFS_OPEN() has been called with O_CREAT,
what created the file, we call SMB_VFS_FSTAT() on the just created
filehandle. This ends up in ad_convert(), finds the resource fork empty and thus
deletes the file.
This commit moves calling of the conversion funtion to the high level VFS entry
points where the converted metadata is needed:
o for directory enumerations SMB_VFS_READDIR_ATTR() is called to fill in the
repurposed fields in the directory entry metadata
o obviously for SMB_VFS_CREATE_FILE() on an macOS stream
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13958
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 78a4639b2d06cc69788861618d2e91945e142d2b)
---
selftest/knownfail.d/samba3.vfs.fruit | 13 ------
source3/modules/vfs_fruit.c | 61 ++++++++++++++++++---------
2 files changed, 40 insertions(+), 34 deletions(-)
diff --git a/selftest/knownfail.d/samba3.vfs.fruit b/selftest/knownfail.d/samba3.vfs.fruit
index b1a28bedff6..6307e2b3404 100644
--- a/selftest/knownfail.d/samba3.vfs.fruit
+++ b/selftest/knownfail.d/samba3.vfs.fruit
@@ -1,15 +1,2 @@
^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion\(nt4_dc\)
^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion without embedded xattr\(nt4_dc\)
-^samba3.vfs.fruit fruit_delete_empty_adfiles.copyfile\(nt4_dc\)
-^samba3.vfs.fruit fruit_delete_empty_adfiles.resource fork IO\(nt4_dc\)
-^samba3.vfs.fruit fruit_delete_empty_adfiles.SMB2/CREATE context AAPL\(nt4_dc\)
-^samba3.vfs.fruit fruit_delete_empty_adfiles.truncate resource fork to 0 bytes\(nt4_dc\)
-^samba3.vfs.fruit fruit_delete_empty_adfiles.opening and creating resource fork\(nt4_dc\)
-^samba3.vfs.fruit fruit_delete_empty_adfiles.create delete-on-close AFP_AfpResource\(nt4_dc\)
-^samba3.vfs.fruit fruit_delete_empty_adfiles.setinfo delete-on-close AFP_AfpResource\(nt4_dc\)
-^samba3.vfs.fruit fruit_delete_empty_adfiles.delete\(nt4_dc\)
-^samba3.vfs.fruit fruit_delete_empty_adfiles.read open rsrc after rename\(nt4_dc\)
-^samba3.vfs.fruit fruit_delete_empty_adfiles.readdir_attr with names with illegal ntfs characters\(nt4_dc\)
-^samba3.vfs.fruit fruit_delete_empty_adfiles.copy-chunk streams\(nt4_dc\)
-^samba3.vfs.fruit fruit_delete_empty_adfiles.empty_stream\(nt4_dc\)
-^samba3.vfs.fruit fruit_delete_empty_adfiles.setinfo eof AFP_AfpResource\(nt4_dc\)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index b74d26ca711..be85c9f5412 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1450,27 +1450,37 @@ static bool ad_convert_delete_adfile(struct adouble *ad,
* @return -1 in case an error occurred, 0 if no conversion was done, 1
* otherwise
**/
-static int ad_convert(struct adouble *ad,
+static int ad_convert(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
+ struct adouble *ad = NULL;
bool ok;
bool converted_xattr = false;
bool blank;
+ int ret;
+
+ ad = ad_get(talloc_tos(), handle, smb_fname, ADOUBLE_RSRC);
+ if (ad == NULL) {
+ return 0;
+ }
ok = ad_convert_xattr(ad, smb_fname, &converted_xattr);
if (!ok) {
- return -1;
+ ret = -1;
+ goto done;
}
ok = ad_convert_blank_rfork(ad, &blank);
if (!ok) {
- return -1;
+ ret = -1;
+ goto done;
}
if (converted_xattr || blank) {
ok = ad_convert_truncate(ad, smb_fname);
if (!ok) {
- return -1;
+ ret = -1;
+ goto done;
}
}
@@ -1478,15 +1488,20 @@ static int ad_convert(struct adouble *ad,
if (!ok) {
DBG_ERR("Failed to convert [%s]\n",
smb_fname_str_dbg(smb_fname));
- return -1;
+ ret = -1;
+ goto done;
}
ok = ad_convert_delete_adfile(ad, smb_fname);
if (!ok) {
- return -1;
+ ret = -1;
+ goto done;
}
- return 0;
+ ret = 0;
+done:
+ TALLOC_FREE(ad);
+ return ret;
}
/**
@@ -1739,17 +1754,6 @@ static ssize_t ad_read_rsrc_adouble(struct adouble *ad,
return -1;
}
- /*
- * Try to fixup AppleDouble files created by OS X with xattrs
- * appended to the ADEID_FINDERI entry.
- */
-
- ret = ad_convert(ad, smb_fname);
- if (ret != 0) {
- DBG_WARNING("Failed to convert [%s]\n", smb_fname->base_name);
- return len;
- }
-
return len;
}
@@ -2137,9 +2141,8 @@ static bool is_afpresource_stream(const struct smb_filename *smb_fname)
}
/**
- * Test whether stream is an Apple stream, not used atm
+ * Test whether stream is an Apple stream.
**/
-#if 0
static bool is_apple_stream(const struct smb_filename *smb_fname)
{
if (is_afpinfo_stream(smb_fname)) {
@@ -2150,7 +2153,6 @@ static bool is_apple_stream(const struct smb_filename *smb_fname)
}
return false;
}
-#endif
/**
* Initialize config struct from our smb.conf config parameters
@@ -6051,6 +6053,8 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
struct fruit_config_data *config = NULL;
files_struct *fsp = NULL;
struct fio *fio = NULL;
+ bool internal_open = (oplock_request & INTERNAL_OPEN_ONLY);
+ int ret;
status = check_aapl(handle, req, in_context_blobs, out_context_blobs);
if (!NT_STATUS_IS_OK(status)) {
@@ -6060,6 +6064,14 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
SMB_VFS_HANDLE_GET_DATA(handle, config, struct fruit_config_data,
return NT_STATUS_UNSUCCESSFUL);
+ if (is_apple_stream(smb_fname) && !internal_open) {
+ ret = ad_convert(handle, smb_fname);
+ if (ret != 0) {
+ DBG_ERR("ad_convert() failed\n");
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ }
+
status = SMB_VFS_NEXT_CREATE_FILE(
handle, req, root_dir_fid, smb_fname,
access_mask, share_access,
@@ -6142,6 +6154,7 @@ static NTSTATUS fruit_readdir_attr(struct vfs_handle_struct *handle,
struct fruit_config_data *config = NULL;
struct readdir_attr_data *attr_data;
NTSTATUS status;
+ int ret;
SMB_VFS_HANDLE_GET_DATA(handle, config,
struct fruit_config_data,
@@ -6153,6 +6166,12 @@ static NTSTATUS fruit_readdir_attr(struct vfs_handle_struct *handle,
DEBUG(10, ("fruit_readdir_attr %s\n", fname->base_name));
+ ret = ad_convert(handle, fname);
+ if (ret != 0) {
+ DBG_ERR("ad_convert() failed\n");
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
*pattr_data = talloc_zero(mem_ctx, struct readdir_attr_data);
if (*pattr_data == NULL) {
return NT_STATUS_UNSUCCESSFUL;
--
2.21.0
From 99b63b4e720122ef9cbb8155c8cc73a1f2613650 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 17 May 2019 10:41:29 +0200
Subject: [PATCH 01/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 585d4d49770b4ddc3f7d9dcbb3e322f072767781)
---
source3/modules/vfs_fruit.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index be85c9f5412..bef9bac2036 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -540,7 +540,9 @@ static struct adouble *ad_get(TALLOC_CTX *ctx,
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_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);
@@ -2065,7 +2067,9 @@ static int ad_set(struct adouble *ad, const struct smb_filename *smb_fname)
*
* @return status code, 0 means success
**/
-static int ad_fset(struct adouble *ad, files_struct *fsp)
+static int ad_fset(struct vfs_handle_struct *handle,
+ struct adouble *ad,
+ files_struct *fsp)
{
int rc = -1;
ssize_t len;
@@ -2087,7 +2091,7 @@ static int ad_fset(struct adouble *ad, files_struct *fsp)
switch (ad->ad_type) {
case ADOUBLE_META:
- rc = SMB_VFS_NEXT_SETXATTR(ad->ad_handle,
+ rc = SMB_VFS_NEXT_SETXATTR(handle,
fsp->fsp_name,
AFPINFO_EA_NETATALK,
ad->ad_data,
@@ -2095,7 +2099,7 @@ static int ad_fset(struct adouble *ad, files_struct *fsp)
break;
case ADOUBLE_RSRC:
- len = SMB_VFS_NEXT_PWRITE(ad->ad_handle,
+ len = SMB_VFS_NEXT_PWRITE(handle,
fsp,
ad->ad_data,
AD_DATASZ_DOT_UND,
@@ -3588,7 +3592,7 @@ static int fruit_open_rsrc_adouble(vfs_handle_struct *handle,
fsp->fh->fd = hostfd;
- rc = ad_fset(ad, fsp);
+ rc = ad_fset(handle, ad, fsp);
fsp->fh->fd = -1;
if (rc != 0) {
rc = -1;
@@ -4676,7 +4680,7 @@ static ssize_t fruit_pwrite_meta_netatalk(vfs_handle_struct *handle,
memcpy(p, &ai->afpi_FinderInfo[0], ADEDLEN_FINDERI);
- ret = ad_fset(ad, fsp);
+ ret = ad_fset(handle, ad, fsp);
if (ret != 0) {
DBG_ERR("ad_pwrite [%s] failed\n", fsp_str_dbg(fsp));
TALLOC_FREE(ad);
@@ -4832,7 +4836,7 @@ static ssize_t fruit_pwrite_rsrc_adouble(vfs_handle_struct *handle,
if ((n + offset) > ad_getentrylen(ad, ADEID_RFORK)) {
ad_setentrylen(ad, ADEID_RFORK, n + offset);
- ret = ad_fset(ad, fsp);
+ ret = ad_fset(handle, ad, fsp);
if (ret != 0) {
DBG_ERR("ad_pwrite [%s] failed\n", fsp_str_dbg(fsp));
TALLOC_FREE(ad);
@@ -5934,7 +5938,7 @@ static int fruit_ftruncate_rsrc_adouble(struct vfs_handle_struct *handle,
ad_setentrylen(ad, ADEID_RFORK, offset);
- rc = ad_fset(ad, fsp);
+ rc = ad_fset(handle, ad, fsp);
if (rc != 0) {
DBG_ERR("ad_fset [%s] failed [%s]\n",
fsp_str_dbg(fsp), strerror(errno));
--
2.21.0
From aa457fc63f493208ef85d833e5764f84578f5858 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 17 May 2019 10:43:55 +0200
Subject: [PATCH 02/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit c78ba30ac4534b7037b979ac96b77b834b2eb2fe)
---
source3/modules/vfs_fruit.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index bef9bac2036..cb87396b9b2 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -539,7 +539,9 @@ 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_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);
@@ -2030,7 +2032,9 @@ static struct adouble *ad_fget(TALLOC_CTX *ctx, vfs_handle_struct *handle,
*
* @return status code, 0 means success
**/
-static int ad_set(struct adouble *ad, const struct smb_filename *smb_fname)
+static int ad_set(vfs_handle_struct *handle,
+ struct adouble *ad,
+ const struct smb_filename *smb_fname)
{
bool ok;
int ret;
@@ -2048,7 +2052,7 @@ static int ad_set(struct adouble *ad, const struct smb_filename *smb_fname)
return -1;
}
- ret = SMB_VFS_SETXATTR(ad->ad_handle->conn,
+ ret = SMB_VFS_SETXATTR(handle->conn,
smb_fname,
AFPINFO_EA_NETATALK,
ad->ad_data,
@@ -5874,7 +5878,7 @@ static int fruit_ntimes(vfs_handle_struct *handle,
ad_setdate(ad, AD_DATE_CREATE | AD_DATE_UNIX,
convert_time_t_to_uint32_t(ft->create_time.tv_sec));
- rc = ad_set(ad, smb_fname);
+ rc = ad_set(handle, ad, smb_fname);
exit:
--
2.21.0
From c045cf398f4b59112539000fe629d89ff7d3bbc3 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 17 May 2019 11:19:53 +0200
Subject: [PATCH 03/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit d0abf945e683766029d28915541a4baf9f3879ab)
---
source3/modules/vfs_fruit.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index cb87396b9b2..7e1d27476aa 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1785,7 +1785,9 @@ static ssize_t ad_read_rsrc(struct adouble *ad,
/**
* Read and unpack an AppleDouble metadata xattr or resource
**/
-static ssize_t ad_read(struct adouble *ad, const struct smb_filename *smb_fname)
+static ssize_t ad_read(vfs_handle_struct *handle,
+ struct adouble *ad,
+ const struct smb_filename *smb_fname)
{
switch (ad->ad_type) {
case ADOUBLE_META:
@@ -1970,7 +1972,7 @@ static struct adouble *ad_get_internal(TALLOC_CTX *ctx,
}
- len = ad_read(ad, smb_fname);
+ len = ad_read(handle, ad, smb_fname);
if (len == -1) {
DEBUG(10, ("error reading AppleDouble for %s\n",
smb_fname->base_name));
--
2.21.0
From ac757c82574c0434e2a0afc94a30571437dd4ee2 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 17 May 2019 11:22:24 +0200
Subject: [PATCH 04/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit f8df09157f31b53dbe73eaf4349fc071bfcc1b90)
---
source3/modules/vfs_fruit.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 7e1d27476aa..fab361164ac 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1511,7 +1511,8 @@ static int ad_convert(struct vfs_handle_struct *handle,
/**
* Read and parse Netatalk AppleDouble metadata xattr
**/
-static ssize_t ad_read_meta(struct adouble *ad,
+static ssize_t ad_read_meta(vfs_handle_struct *handle,
+ struct adouble *ad,
const struct smb_filename *smb_fname)
{
int rc = 0;
@@ -1520,7 +1521,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) {
@@ -1791,7 +1792,7 @@ static ssize_t ad_read(vfs_handle_struct *handle,
{
switch (ad->ad_type) {
case ADOUBLE_META:
- return ad_read_meta(ad, smb_fname);
+ return ad_read_meta(handle, ad, smb_fname);
case ADOUBLE_RSRC:
return ad_read_rsrc(ad, smb_fname);
default:
--
2.21.0
From b802829d7648fce8e6641633f02f62e494d67eb9 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 17 May 2019 11:23:17 +0200
Subject: [PATCH 05/31] vfs_fruit: indentation fix
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>
(cherry picked from commit 47721d8d359ef78b8dd4f77f92c30c2caf2c4a80)
---
source3/modules/vfs_fruit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index fab361164ac..1e9ab4f615f 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1513,7 +1513,7 @@ static int ad_convert(struct vfs_handle_struct *handle,
**/
static ssize_t ad_read_meta(vfs_handle_struct *handle,
struct adouble *ad,
- const struct smb_filename *smb_fname)
+ const struct smb_filename *smb_fname)
{
int rc = 0;
ssize_t ealen;
--
2.21.0
From 297ee52a9c6e1b5808d68cacd0b3c972bf7b7313 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 17 May 2019 11:42:06 +0200
Subject: [PATCH 06/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 30ca328c698c2e035e240359bda7c9dcbeb646df)
---
source3/modules/vfs_fruit.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 1e9ab4f615f..046fa2da2e2 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1578,7 +1578,9 @@ static ssize_t ad_read_meta(vfs_handle_struct *handle,
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;
}
--
2.21.0
From d515ff9c7cc6f5b8a6863362d78af5911afec985 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 17 May 2019 11:47:26 +0200
Subject: [PATCH 07/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 661dfa4a19673fdb30d5bf36279cdf867454b947)
---
source3/modules/vfs_fruit.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 046fa2da2e2..0bcf67c5834 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1682,7 +1682,8 @@ static int ad_open(vfs_handle_struct *handle,
return 0;
}
-static ssize_t ad_read_rsrc_xattr(struct adouble *ad)
+static ssize_t ad_read_rsrc_xattr(vfs_handle_struct *handle,
+ struct adouble *ad)
{
int ret;
SMB_STRUCT_STAT st;
@@ -1690,7 +1691,7 @@ static ssize_t ad_read_rsrc_xattr(struct adouble *ad)
/* FIXME: direct sys_fstat(), don't have an fsp */
ret = sys_fstat(ad->ad_fd, &st,
lp_fake_directory_create_times(
- SNUM(ad->ad_handle->conn)));
+ SNUM(handle->conn)));
if (ret != 0) {
return -1;
}
@@ -1699,7 +1700,8 @@ static ssize_t ad_read_rsrc_xattr(struct adouble *ad)
return st.st_ex_size;
}
-static ssize_t ad_read_rsrc_adouble(struct adouble *ad,
+static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle,
+ struct adouble *ad,
const struct smb_filename *smb_fname)
{
SMB_STRUCT_STAT sbuf;
@@ -1710,7 +1712,7 @@ static ssize_t ad_read_rsrc_adouble(struct adouble *ad,
bool ok;
ret = sys_fstat(ad->ad_fd, &sbuf, lp_fake_directory_create_times(
- SNUM(ad->ad_handle->conn)));
+ SNUM(handle->conn)));
if (ret != 0) {
return -1;
}
@@ -1767,19 +1769,20 @@ static ssize_t ad_read_rsrc_adouble(struct adouble *ad,
/**
* Read and parse resource fork, either ._ AppleDouble file or xattr
**/
-static ssize_t ad_read_rsrc(struct adouble *ad,
+static ssize_t ad_read_rsrc(vfs_handle_struct *handle,
+ struct adouble *ad,
const struct smb_filename *smb_fname)
{
struct fruit_config_data *config = NULL;
ssize_t len;
- SMB_VFS_HANDLE_GET_DATA(ad->ad_handle, config,
+ SMB_VFS_HANDLE_GET_DATA(handle, config,
struct fruit_config_data, return -1);
if (config->rsrc == FRUIT_RSRC_XATTR) {
- len = ad_read_rsrc_xattr(ad);
+ len = ad_read_rsrc_xattr(handle, ad);
} else {
- len = ad_read_rsrc_adouble(ad, smb_fname);
+ len = ad_read_rsrc_adouble(handle, ad, smb_fname);
}
return len;
@@ -1796,7 +1799,7 @@ static ssize_t ad_read(vfs_handle_struct *handle,
case ADOUBLE_META:
return ad_read_meta(handle, ad, smb_fname);
case ADOUBLE_RSRC:
- return ad_read_rsrc(ad, smb_fname);
+ return ad_read_rsrc(handle, ad, smb_fname);
default:
return -1;
}
--
2.21.0
From cda7ebf61991a8640b696916d0769f965af325b5 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 17 May 2019 11:23:17 +0200
Subject: [PATCH 08/31] vfs_fruit: indentation fix
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>
(cherry picked from commit 400b3c2f8c82b1defe1e321e0cdae486b930344f)
---
source3/modules/vfs_fruit.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 0bcf67c5834..c649710d754 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1702,7 +1702,7 @@ static ssize_t ad_read_rsrc_xattr(vfs_handle_struct *handle,
static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle,
struct adouble *ad,
- const struct smb_filename *smb_fname)
+ const struct smb_filename *smb_fname)
{
SMB_STRUCT_STAT sbuf;
char *p_ad = NULL;
@@ -1771,7 +1771,7 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle,
**/
static ssize_t ad_read_rsrc(vfs_handle_struct *handle,
struct adouble *ad,
- const struct smb_filename *smb_fname)
+ const struct smb_filename *smb_fname)
{
struct fruit_config_data *config = NULL;
ssize_t len;
--
2.21.0
From 796677632779f18cecb51209a4892de0ac6db84b Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 17 May 2019 11:54:10 +0200
Subject: [PATCH 09/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit fd2f4cf828ee4c31e3b5a27a79d3a0ee12a5877a)
---
source3/modules/vfs_fruit.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index c649710d754..0b58cf1a1e5 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1057,7 +1057,8 @@ static bool ad_convert_move_reso(struct adouble *ad,
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)
{
@@ -1108,7 +1109,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(),
@@ -1145,7 +1146,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 */
@@ -1468,7 +1469,7 @@ 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;
--
2.21.0
From ebae25734342988d6fcbe0489b4264455c27c97b Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 17 May 2019 12:02:46 +0200
Subject: [PATCH 10/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit adc7ac38b849b4dce4a85fd6442c8d4b9da57686)
---
source3/modules/vfs_fruit.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 0b58cf1a1e5..80a647dc847 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1345,7 +1345,8 @@ 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;
@@ -1358,7 +1359,7 @@ static bool ad_convert_blank_rfork(struct adouble *ad,
*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) {
@@ -1475,7 +1476,7 @@ static int ad_convert(struct vfs_handle_struct *handle,
goto done;
}
- ok = ad_convert_blank_rfork(ad, &blank);
+ ok = ad_convert_blank_rfork(handle, ad, &blank);
if (!ok) {
ret = -1;
goto done;
--
2.21.0
From 203ef7c510f358c76aa7e582b6b7c519b4154e06 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 17 May 2019 12:05:07 +0200
Subject: [PATCH 11/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 50874c1548d62ab0ddaaa6dd4124279ee5029fcf)
---
source3/modules/vfs_fruit.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 80a647dc847..eb6137202a7 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1225,7 +1225,8 @@ static bool ad_convert_xattr(vfs_handle_struct *handle,
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;
@@ -1282,7 +1283,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 */
@@ -1490,7 +1491,7 @@ static int ad_convert(struct vfs_handle_struct *handle,
}
}
- 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));
--
2.21.0
From 6701abc1b2c68df2e134e5e7257c386fd35ea9fe Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 17 May 2019 12:17:28 +0200
Subject: [PATCH 12/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 5f4d16b40e07acf8d27fee62f1a56de175663a1d)
---
source3/modules/vfs_fruit.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index eb6137202a7..38bfa5e2b6b 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1411,7 +1411,8 @@ static bool ad_convert_blank_rfork(vfs_handle_struct *handle,
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;
@@ -1422,7 +1423,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) {
@@ -1434,7 +1435,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));
@@ -1499,7 +1500,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;
--
2.21.0
From 6f953506ef2704ffc3c99cc492dfeb739128e5a8 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 17 May 2019 12:19:06 +0200
Subject: [PATCH 13/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit e266daaed149561b746dbb8d5e9523862f0057b5)
---
source3/modules/vfs_fruit.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 38bfa5e2b6b..e79b548a511 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -411,7 +411,6 @@ struct ad_entry {
};
struct adouble {
- vfs_handle_struct *ad_handle;
int ad_fd;
bool ad_opened;
adouble_type_t ad_type;
@@ -1868,7 +1867,6 @@ static struct adouble *ad_alloc(TALLOC_CTX *ctx, vfs_handle_struct *handle,
}
}
- ad->ad_handle = handle;
ad->ad_type = type;
ad->ad_magic = AD_MAGIC;
ad->ad_version = AD_VERSION;
--
2.21.0
From 42f996a6983d0a2895bf49778446e6238b5bac10 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Tue, 21 May 2019 11:39:18 +0200
Subject: [PATCH 14/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit ad70c947c759aa0965ee57f973fb8dc1909e0e39)
---
source3/modules/vfs_fruit.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index e79b548a511..0dd24293c9b 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -2172,6 +2172,27 @@ static bool is_apple_stream(const struct smb_filename *smb_fname)
return false;
}
+static bool is_adouble_file(const char *path)
+{
+ const char *p = NULL;
+ int match;
+
+ p = strrchr(path, '/');
+ if (p == NULL) {
+ p = path;
+ } else {
+ p++;
+ }
+
+ match = strncmp(p,
+ ADOUBLE_NAME_PREFIX,
+ strlen(ADOUBLE_NAME_PREFIX));
+ if (match != 0) {
+ return false;
+ }
+ return true;
+}
+
/**
* Initialize config struct from our smb.conf config parameters
**/
@@ -4204,16 +4225,12 @@ static int fruit_rmdir(struct vfs_handle_struct *handle,
}
while ((de = SMB_VFS_READDIR(handle->conn, dh, NULL)) != NULL) {
- int match;
struct adouble *ad = NULL;
char *p = NULL;
struct smb_filename *ad_smb_fname = NULL;
int ret;
- match = strncmp(de->d_name,
- ADOUBLE_NAME_PREFIX,
- strlen(ADOUBLE_NAME_PREFIX));
- if (match != 0) {
+ if (!is_adouble_file(de->d_name)) {
continue;
}
--
2.21.0
From 12c65cc8aa37440c7e549da876564ff5cd47220b Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Tue, 21 May 2019 11:40:33 +0200
Subject: [PATCH 15/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 44d8568001c87d28962dfc4e3fde6d0f7f409997)
---
source3/modules/vfs_fruit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 0dd24293c9b..c7cb4cdba7d 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -4079,7 +4079,7 @@ static int fruit_unlink(vfs_handle_struct *handle,
return fruit_unlink_meta(handle, smb_fname);
} else if (is_afpresource_stream(smb_fname)) {
return fruit_unlink_rsrc(handle, smb_fname, false);
- } if (is_ntfs_stream_smb_fname(smb_fname)) {
+ } else if (is_ntfs_stream_smb_fname(smb_fname)) {
return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
}
--
2.21.0
From 359fae9e2e0ef599d6778c65fcb3355d0bf5a8a0 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Tue, 21 May 2019 11:42:47 +0200
Subject: [PATCH 16/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 797dc649456f39add4af8b54b60db0268ad4e90e)
---
source3/modules/vfs_fruit.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index c7cb4cdba7d..e7e14673e10 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -4081,6 +4081,8 @@ static int fruit_unlink(vfs_handle_struct *handle,
return fruit_unlink_rsrc(handle, smb_fname, false);
} else if (is_ntfs_stream_smb_fname(smb_fname)) {
return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+ } else if (is_adouble_file(smb_fname->base_name)) {
+ return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
}
/*
--
2.21.0
From 39bccb6c88eb19b6abcf3d49f72ae73bec1d6af6 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Wed, 22 May 2019 17:02:20 +0200
Subject: [PATCH 17/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 83179a74119de84d20f796c241aae6bccb83a68b)
---
source3/modules/vfs_fruit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index e7e14673e10..96a026acbf8 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -3223,7 +3223,7 @@ static uint64_t readdir_attr_rfork_size(struct vfs_handle_struct *handle,
smb_fname);
break;
- case FRUIT_META_STREAM:
+ case FRUIT_RSRC_STREAM:
rfork_size = readdir_attr_rfork_size_stream(handle,
smb_fname);
break;
--
2.21.0
From 4f611e9da46c49a5be3a0b7c491b23c9c5084526 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Wed, 22 May 2019 18:08:14 +0200
Subject: [PATCH 18/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit a23bcc1916a49bf3e0edece190e5434e39862d2c)
---
source3/modules/vfs_fruit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 96a026acbf8..82c20dbea13 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -3218,11 +3218,11 @@ static uint64_t readdir_attr_rfork_size(struct vfs_handle_struct *handle,
switch (config->rsrc) {
case FRUIT_RSRC_ADFILE:
- case FRUIT_RSRC_XATTR:
rfork_size = readdir_attr_rfork_size_adouble(handle,
smb_fname);
break;
+ case FRUIT_RSRC_XATTR:
case FRUIT_RSRC_STREAM:
rfork_size = readdir_attr_rfork_size_stream(handle,
smb_fname);
--
2.21.0
From 7e2a1d4771b73f2956005f70b588a6c37cc953a8 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 17 May 2019 14:31:15 +0200
Subject: [PATCH 19/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit cb9dffa1c66294b6eed85e7576aa99c642d0b541)
---
source3/modules/vfs_fruit.c | 70 ++-----------------------------------
1 file changed, 3 insertions(+), 67 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 82c20dbea13..74b10a32449 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1591,20 +1591,6 @@ static ssize_t ad_read_meta(vfs_handle_struct *handle,
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)
@@ -1629,19 +1615,7 @@ static int ad_open_rsrc(vfs_handle_struct *handle,
int flags,
mode_t mode)
{
- struct fruit_config_data *config = NULL;
- int fd;
-
- SMB_VFS_HANDLE_GET_DATA(handle, config,
- struct fruit_config_data, return -1);
-
- if (config->rsrc == FRUIT_RSRC_XATTR) {
- fd = ad_open_rsrc_xattr(smb_fname, flags, mode);
- } else {
- fd = ad_open_rsrc_adouble(smb_fname, flags, mode);
- }
-
- return fd;
+ return ad_open_rsrc_adouble(smb_fname, flags, mode);
}
/*
@@ -1685,24 +1659,6 @@ static int ad_open(vfs_handle_struct *handle,
return 0;
}
-static ssize_t ad_read_rsrc_xattr(vfs_handle_struct *handle,
- struct adouble *ad)
-{
- int ret;
- SMB_STRUCT_STAT st;
-
- /* FIXME: direct sys_fstat(), don't have an fsp */
- ret = sys_fstat(ad->ad_fd, &st,
- lp_fake_directory_create_times(
- SNUM(handle->conn)));
- if (ret != 0) {
- return -1;
- }
-
- ad_setentrylen(ad, ADEID_RFORK, st.st_ex_size);
- return st.st_ex_size;
-}
-
static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle,
struct adouble *ad,
const struct smb_filename *smb_fname)
@@ -1776,19 +1732,7 @@ static ssize_t ad_read_rsrc(vfs_handle_struct *handle,
struct adouble *ad,
const struct smb_filename *smb_fname)
{
- struct fruit_config_data *config = NULL;
- ssize_t len;
-
- SMB_VFS_HANDLE_GET_DATA(handle, config,
- struct fruit_config_data, return -1);
-
- if (config->rsrc == FRUIT_RSRC_XATTR) {
- len = ad_read_rsrc_xattr(handle, ad);
- } else {
- len = ad_read_rsrc_adouble(handle, ad, smb_fname);
- }
-
- return len;
+ return ad_read_rsrc_adouble(handle, ad, smb_fname);
}
/**
@@ -1896,22 +1840,14 @@ static struct adouble *ad_init(TALLOC_CTX *ctx, vfs_handle_struct *handle,
int rc = 0;
const struct ad_entry_order *eid;
struct adouble *ad = NULL;
- struct fruit_config_data *config;
time_t t = time(NULL);
- SMB_VFS_HANDLE_GET_DATA(handle, config,
- struct fruit_config_data, return NULL);
-
switch (type) {
case ADOUBLE_META:
eid = entry_order_meta_xattr;
break;
case ADOUBLE_RSRC:
- if (config->rsrc == FRUIT_RSRC_ADFILE) {
- eid = entry_order_dot_und;
- } else {
- eid = entry_order_rsrc_xattr;
- }
+ eid = entry_order_dot_und;
break;
default:
return NULL;
--
2.21.0
From eb48ba0846b109a44b704241a6a57df3c9ad3216 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Wed, 22 May 2019 21:15:22 +0200
Subject: [PATCH 20/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit e3cb1cb24f2a31d7fd03f3bdf417f4704fb4ac7c)
---
source3/modules/vfs_fruit.c | 35 ++++++++---------------------------
1 file changed, 8 insertions(+), 27 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 74b10a32449..1e560bf07b5 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -449,18 +449,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[] = {
@@ -532,7 +520,7 @@ 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,
@@ -1773,25 +1761,19 @@ static int adouble_destructor(struct adouble *ad)
*
* @return adouble handle
**/
-static struct adouble *ad_alloc(TALLOC_CTX *ctx, vfs_handle_struct *handle,
+static struct adouble *ad_alloc(TALLOC_CTX *ctx,
adouble_type_t type)
{
int rc = 0;
size_t adsize = 0;
struct adouble *ad;
- struct fruit_config_data *config;
-
- SMB_VFS_HANDLE_GET_DATA(handle, config,
- struct fruit_config_data, return NULL);
switch (type) {
case ADOUBLE_META:
adsize = AD_DATASZ_XATTR;
break;
case ADOUBLE_RSRC:
- if (config->rsrc == FRUIT_RSRC_ADFILE) {
- adsize = AD_DATASZ_DOT_UND;
- }
+ adsize = AD_DATASZ_DOT_UND;
break;
default:
return NULL;
@@ -1829,12 +1811,11 @@ static struct adouble *ad_alloc(TALLOC_CTX *ctx, vfs_handle_struct *handle,
* Allocate and initialize a new struct adouble
*
* @param[in] ctx talloc context
- * @param[in] handle vfs handle
* @param[in] type type of AppleDouble, ADOUBLE_META or ADOUBLE_RSRC
*
* @return adouble handle, initialized
**/
-static struct adouble *ad_init(TALLOC_CTX *ctx, vfs_handle_struct *handle,
+static struct adouble *ad_init(TALLOC_CTX *ctx,
adouble_type_t type)
{
int rc = 0;
@@ -1853,7 +1834,7 @@ static struct adouble *ad_init(TALLOC_CTX *ctx, vfs_handle_struct *handle,
return NULL;
}
- ad = ad_alloc(ctx, handle, type);
+ ad = ad_alloc(ctx, type);
if (ad == NULL) {
return NULL;
}
@@ -1895,7 +1876,7 @@ static struct adouble *ad_get_internal(TALLOC_CTX *ctx,
type == ADOUBLE_META ? "meta" : "rsrc",
smb_fname->base_name));
- ad = ad_alloc(ctx, handle, type);
+ ad = ad_alloc(ctx, type);
if (ad == NULL) {
rc = -1;
goto exit;
@@ -3555,7 +3536,7 @@ static int fruit_open_rsrc_adouble(vfs_handle_struct *handle,
}
if (flags & (O_CREAT | O_TRUNC)) {
- ad = ad_init(fsp, handle, ADOUBLE_RSRC);
+ ad = ad_init(fsp, ADOUBLE_RSRC);
if (ad == NULL) {
rc = -1;
goto exit;
@@ -4635,7 +4616,7 @@ static ssize_t fruit_pwrite_meta_netatalk(vfs_handle_struct *handle,
ad = ad_fget(talloc_tos(), handle, fsp, ADOUBLE_META);
if (ad == NULL) {
- ad = ad_init(talloc_tos(), handle, ADOUBLE_META);
+ ad = ad_init(talloc_tos(), ADOUBLE_META);
if (ad == NULL) {
return -1;
}
--
2.21.0
From 8598f79e210655549996a52bfc15888906208c4f Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Thu, 23 May 2019 08:14:18 +0200
Subject: [PATCH 21/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 3919ea048fe3b763657e14cdfb5920184a900d27)
---
source3/modules/vfs_fruit.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 1e560bf07b5..01f6fa821c0 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -992,7 +992,8 @@ 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;
@@ -1194,7 +1195,7 @@ static bool ad_convert_xattr(vfs_handle_struct *handle,
goto fail;
}
- ok = ad_convert_move_reso(ad, smb_fname);
+ ok = ad_convert_move_reso(handle, ad, smb_fname);
if (!ok) {
goto fail;
}
--
2.21.0
From 3c32a8da96b8d3233c47593be4b5de6de44d08f8 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Thu, 23 May 2019 08:27:37 +0200
Subject: [PATCH 22/31] vfs_fruit: remove a layer of indirection
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>
(cherry picked from commit 97d485ff2cda85edeba163ea01b6abfa705db20f)
---
source3/modules/vfs_fruit.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 01f6fa821c0..b927660db9c 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1580,9 +1580,10 @@ static ssize_t ad_read_meta(vfs_handle_struct *handle,
return ealen;
}
-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)
{
int ret;
int fd;
@@ -1599,14 +1600,6 @@ static int ad_open_rsrc_adouble(const struct smb_filename *smb_fname,
return fd;
}
-static int ad_open_rsrc(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- int flags,
- mode_t mode)
-{
- return ad_open_rsrc_adouble(smb_fname, flags, mode);
-}
-
/*
* Here's the deal: for ADOUBLE_META we can do without an fd as we can issue
* path based xattr calls. For ADOUBLE_RSRC however we need a full-fledged fd
--
2.21.0
From 79fc20532535da8ceaa5d0348da46a422f4e9369 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Thu, 23 May 2019 16:22:39 +0200
Subject: [PATCH 23/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit f5f7d1e9bf7e39933ccf7c874e682f9df80a6fec)
---
source3/modules/vfs_fruit.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index b927660db9c..fc9e0c90606 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -6071,7 +6071,9 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
return status;
}
- if (config->locking == FRUIT_LOCKING_NETATALK) {
+ if ((config->locking == FRUIT_LOCKING_NETATALK) &&
+ (fsp->op != NULL))
+ {
status = fruit_check_access(
handle, *result,
access_mask,
--
2.21.0
From f381b0af9e9d3ca53ba742444cf4e58bb6cd8172 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Thu, 23 May 2019 16:42:52 +0200
Subject: [PATCH 24/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 29418c726be74feb1d8c3ac9f7b8c983901a2aab)
---
source3/modules/vfs_fruit.c | 103 +++++++++++++++++++++++++++---------
1 file changed, 77 insertions(+), 26 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index fc9e0c90606..d6d9fce7956 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -411,7 +411,7 @@ struct ad_entry {
};
struct adouble {
- int ad_fd;
+ files_struct *ad_fsp;
bool ad_opened;
adouble_type_t ad_type;
uint32_t ad_magic;
@@ -1011,7 +1011,7 @@ static bool ad_convert_move_reso(vfs_handle_struct *handle,
/* 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);
+ ad->ad_fsp->fh->fd, 0);
if (map == MAP_FAILED) {
DBG_ERR("mmap AppleDouble: %s\n", strerror(errno));
return false;
@@ -1036,7 +1036,7 @@ static bool ad_convert_move_reso(vfs_handle_struct *handle,
return false;
}
- len = sys_pwrite(ad->ad_fd, ad->ad_data, AD_DATASZ_DOT_UND, 0);
+ 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);
return false;
@@ -1083,7 +1083,7 @@ static bool ad_convert_xattr(vfs_handle_struct *handle,
/* 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);
+ ad->ad_fsp->fh->fd, 0);
if (map == MAP_FAILED) {
DBG_ERR("mmap AppleDouble: %s\n", strerror(errno));
return false;
@@ -1188,7 +1188,7 @@ static bool ad_convert_xattr(vfs_handle_struct *handle,
goto fail;
}
- len = sys_pwrite(ad->ad_fd, ad->ad_data, AD_DATASZ_DOT_UND, 0);
+ 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);
ok = false;
@@ -1325,7 +1325,7 @@ static bool ad_convert_truncate(struct adouble *ad,
* FIXME: direct ftruncate(), but we don't have a fsp for the
* VFS call
*/
- rc = ftruncate(ad->ad_fd, ADEDOFF_RFORK_DOT_UND +
+ rc = ftruncate(ad->ad_fsp->fh->fd, ADEDOFF_RFORK_DOT_UND +
ad_getentrylen(ad, ADEID_RFORK));
if (rc != 0) {
return false;
@@ -1364,7 +1364,7 @@ static bool ad_convert_blank_rfork(vfs_handle_struct *handle,
/* 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);
+ ad->ad_fsp->fh->fd, 0);
if (map == MAP_FAILED) {
DBG_ERR("mmap AppleDouble: %s\n", strerror(errno));
return false;
@@ -1390,7 +1390,7 @@ static bool ad_convert_blank_rfork(vfs_handle_struct *handle,
return false;
}
- len = sys_pwrite(ad->ad_fd, ad->ad_data, AD_DATASZ_DOT_UND, 0);
+ len = sys_pwrite(ad->ad_fsp->fh->fd, ad->ad_data, AD_DATASZ_DOT_UND, 0);
if (len != AD_DATASZ_DOT_UND) {
return false;
}
@@ -1583,21 +1583,64 @@ static ssize_t ad_read_meta(vfs_handle_struct *handle,
static int ad_open_rsrc(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
int flags,
- mode_t mode)
+ 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;
ret = adouble_path(talloc_tos(), smb_fname, &adp_smb_fname);
if (ret != 0) {
return -1;
}
- fd = open(adp_smb_fname->base_name, flags, mode);
+ ret = SMB_VFS_STAT(handle->conn, adp_smb_fname);
+ if (ret != 0) {
+ TALLOC_FREE(adp_smb_fname);
+ return -1;
+ }
+
+ access_mask = FILE_GENERIC_READ;
+ share_access = FILE_SHARE_READ | FILE_SHARE_WRITE;
+ create_disposition = FILE_OPEN;
+
+ if (flags & O_RDWR) {
+ access_mask |= FILE_GENERIC_WRITE;
+ share_access &= ~FILE_SHARE_WRITE;
+ }
+
+ status = SMB_VFS_CREATE_FILE(
+ handle->conn, /* conn */
+ NULL, /* req */
+ 0, /* root_dir_fid */
+ adp_smb_fname,
+ access_mask,
+ share_access,
+ create_disposition,
+ 0, /* create_options */
+ 0, /* file_attributes */
+ INTERNAL_OPEN_ONLY, /* oplock_request */
+ NULL, /* lease */
+ 0, /* allocation_size */
+ 0, /* private_flags */
+ NULL, /* sd */
+ NULL, /* ea_list */
+ &fsp,
+ NULL, /* psbuf */
+ NULL, NULL); /* create context */
TALLOC_FREE(adp_smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_ERR("SMB_VFS_CREATE_FILE failed\n");
+ return -1;
+ }
- return fd;
+ *_fsp = fsp;
+ return 0;
}
/*
@@ -1612,7 +1655,7 @@ static int ad_open(vfs_handle_struct *handle,
int flags,
mode_t mode)
{
- int fd;
+ int ret;
DBG_DEBUG("Path [%s] type [%s]\n", smb_fname->base_name,
ad->ad_type == ADOUBLE_META ? "meta" : "rsrc");
@@ -1621,22 +1664,21 @@ static int ad_open(vfs_handle_struct *handle,
return 0;
}
- if ((fsp != NULL) && (fsp->fh != NULL) && (fsp->fh->fd != -1)) {
- ad->ad_fd = fsp->fh->fd;
+ if (fsp != NULL) {
+ ad->ad_fsp = fsp;
ad->ad_opened = false;
return 0;
}
- fd = ad_open_rsrc(handle, smb_fname, flags, mode);
- if (fd == -1) {
+ ret = ad_open_rsrc(handle, smb_fname, flags, mode, &ad->ad_fsp);
+ if (ret != 0) {
return -1;
}
ad->ad_opened = true;
- ad->ad_fd = fd;
- DBG_DEBUG("Path [%s] type [%s] fd [%d]\n",
+ DBG_DEBUG("Path [%s] type [%s]\n",
smb_fname->base_name,
- ad->ad_type == ADOUBLE_META ? "meta" : "rsrc", fd);
+ ad->ad_type == ADOUBLE_META ? "meta" : "rsrc");
return 0;
}
@@ -1652,7 +1694,7 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle,
int ret;
bool ok;
- ret = sys_fstat(ad->ad_fd, &sbuf, lp_fake_directory_create_times(
+ ret = sys_fstat(ad->ad_fsp->fh->fd, &sbuf, lp_fake_directory_create_times(
SNUM(handle->conn)));
if (ret != 0) {
return -1;
@@ -1678,7 +1720,7 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle,
ad->ad_data = p_ad;
}
- len = sys_pread(ad->ad_fd, ad->ad_data,
+ len = sys_pread(ad->ad_fsp->fh->fd, ad->ad_data,
talloc_array_length(ad->ad_data), 0);
if (len != talloc_array_length(ad->ad_data)) {
DBG_NOTICE("%s %s: bad size: %zd\n",
@@ -1736,10 +1778,20 @@ static ssize_t ad_read(vfs_handle_struct *handle,
static int adouble_destructor(struct adouble *ad)
{
- if ((ad->ad_fd != -1) && ad->ad_opened) {
- close(ad->ad_fd);
- ad->ad_fd = -1;
+ NTSTATUS status;
+
+ if (!ad->ad_opened) {
+ return 0;
}
+
+ SMB_ASSERT(ad->ad_fsp != NULL);
+
+ status = close_file(NULL, ad->ad_fsp, NORMAL_CLOSE);
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_ERR("Closing [%s] failed: %s\n",
+ fsp_str_dbg(ad->ad_fsp), nt_errstr(status));
+ }
+
return 0;
}
@@ -1790,7 +1842,6 @@ static struct adouble *ad_alloc(TALLOC_CTX *ctx,
ad->ad_type = type;
ad->ad_magic = AD_MAGIC;
ad->ad_version = AD_VERSION;
- ad->ad_fd = -1;
talloc_set_destructor(ad, adouble_destructor);
--
2.21.0
From 6a1beb430229e4d2dbace960b6a0a6a82af30f54 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Thu, 23 May 2019 22:44:21 +0200
Subject: [PATCH 25/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 0041855af0b05d6c47558880d6eebd1970179272)
---
source3/modules/vfs_fruit.c | 56 ++++++++++++++++++++++---------------
1 file changed, 33 insertions(+), 23 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index d6d9fce7956..426da55816b 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -996,49 +996,59 @@ 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_fsp->fh->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);
- memmove(map + ADEDOFF_RFORK_DOT_UND,
- map + ad_getentryoff(ad, ADEID_RFORK),
- ad_getentrylen(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;
+ }
- rc = munmap(map, maplen);
- if (rc != 0) {
- DBG_ERR("munmap failed: %s\n", strerror(errno));
+ rforkoff = ADEDOFF_RFORK_DOT_UND;
+
+ 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_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);
+ 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;
}
--
2.21.0
From 2a680e4998febc492d33c275268d0a1b06d40386 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 24 May 2019 11:54:51 +0200
Subject: [PATCH 26/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 4ff7ea0e0312c737aefd350f7b8fbed4c8602325)
---
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 426da55816b..630d53afbe7 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;
}
--
2.21.0
From 945f0734c2f37c6327361dc638133f57e81910e5 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 24 May 2019 12:05:51 +0200
Subject: [PATCH 27/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 4e44b1da9357120f0ad74e24c650bc6386085c47)
---
source3/modules/vfs_fruit.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 630d53afbe7..46355d2146e 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1307,7 +1307,8 @@ static bool ad_convert_finderinfo(vfs_handle_struct *handle,
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;
@@ -1464,7 +1465,7 @@ static int ad_convert(struct vfs_handle_struct *handle,
}
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;
--
2.21.0
From 1fca33d6436923925ceae855388f81bdd6ba9a53 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 24 May 2019 12:07:55 +0200
Subject: [PATCH 28/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 3739ad90cf2bbaa2094a34197c894363d2e24a5a)
---
source3/modules/vfs_fruit.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 46355d2146e..a11f390326d 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1312,13 +1312,11 @@ static bool ad_convert_truncate(vfs_handle_struct *handle,
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_fsp->fh->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;
}
--
2.21.0
From 7dd37035e053775d7b392ebaaf0130f9af7acc3a Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 24 May 2019 12:51:15 +0200
Subject: [PATCH 29/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 70c4a8f0ac307009c26e857523192c95b42a92f5)
---
source3/modules/vfs_fruit.c | 36 ++++++++++++------------------------
1 file changed, 12 insertions(+), 24 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index a11f390326d..2d34b70090e 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1329,10 +1329,10 @@ static bool ad_convert_blank_rfork(vfs_handle_struct *handle,
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;
@@ -1345,43 +1345,31 @@ static bool ad_convert_blank_rfork(vfs_handle_struct *handle,
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_fsp->fh->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_fsp->fh->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;
}
--
2.21.0
From 602ba28322bd343a47c811f2d9e441a7886a2664 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 24 May 2019 14:51:17 +0200
Subject: [PATCH 30/31] 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@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 9fe84a6345bf5d9fdb1df87a853db3380e6fb0f7)
---
source3/modules/vfs_fruit.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 2d34b70090e..38c201b38e0 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1665,16 +1665,16 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle,
struct adouble *ad,
const struct smb_filename *smb_fname)
{
- SMB_STRUCT_STAT sbuf;
char *p_ad = NULL;
size_t size;
ssize_t len;
int ret;
bool ok;
- ret = sys_fstat(ad->ad_fsp->fh->fd, &sbuf, lp_fake_directory_create_times(
- SNUM(handle->conn)));
+ ret = SMB_VFS_NEXT_FSTAT(handle, ad->ad_fsp, &ad->ad_fsp->fsp_name->st);
if (ret != 0) {
+ DBG_ERR("fstat [%s] failed: %s\n",
+ fsp_str_dbg(ad->ad_fsp), strerror(errno));
return -1;
}
@@ -1686,7 +1686,7 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle,
*
* Read as much as we can up to AD_XATTR_MAX_HDR_SIZE.
*/
- size = sbuf.st_ex_size;
+ size = ad->ad_fsp->fsp_name->st.st_ex_size;
if (size > talloc_array_length(ad->ad_data)) {
if (size > AD_XATTR_MAX_HDR_SIZE) {
size = AD_XATTR_MAX_HDR_SIZE;
@@ -1698,8 +1698,7 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle,
ad->ad_data = p_ad;
}
- len = sys_pread(ad->ad_fsp->fh->fd, ad->ad_data,
- talloc_array_length(ad->ad_data), 0);
+ len = SMB_VFS_NEXT_PREAD(handle, ad->ad_fsp, ad->ad_data, talloc_array_length(ad->ad_data), 0);
if (len != talloc_array_length(ad->ad_data)) {
DBG_NOTICE("%s %s: bad size: %zd\n",
smb_fname->base_name, strerror(errno), len);
@@ -1707,7 +1706,7 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle,
}
/* Now parse entries */
- ok = ad_unpack(ad, ADEID_NUM_DOT_UND, sbuf.st_ex_size);
+ ok = ad_unpack(ad, ADEID_NUM_DOT_UND, size);
if (!ok) {
DBG_ERR("invalid AppleDouble resource %s\n",
smb_fname->base_name);
--
2.21.0
From 3f5303416f9189c5e81444e65aac98f2444183b1 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Fri, 24 May 2019 15:15:59 +0200
Subject: [PATCH 31/31] vfs_fruit: remove a now unnecessary include
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>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu May 30 22:12:50 UTC 2019 on sn-devel-184
(cherry picked from commit 9a2c9834cb1b77547b8b932c35870301afb9fc25)
---
source3/modules/vfs_fruit.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 38c201b38e0..20121818129 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -29,7 +29,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"
--
2.21.0