[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Mon Jul 1 23:22:02 UTC 2019


The branch, master has been updated
       via  6e65c283120 selftest: add a test that itime is not set when setting DOS attrs
       via  03690ec2180 vfs_fruit: change default for "fruit:zero_file_id" to false
       via  eb986786562 vfs_fruit: make "fruit:zero_file_id" a per share option
       via  076f26dd5c9 vfs_fruit: move zero file-id to vfs_fruit
       via  36d100e4b89 s3:smbd: set file_id in fetch_dos_mode_done()
       via  a3caf4140c0 s3:smbd: use stored file_id in SMB_VFS_FS_FILE_ID()
       via  df5752ec90d s3:vfs: move get_fs_file_id to vfs_default
       via  71996fef09f s3:vfs: add SMB_VFS_FS_FILE_ID()
       via  d2bac65e2ef s3:smbd: rename get_FileIndex() to get_fs_file_id()
       via  e6cdd4862f9 s3:smbd: return inode number, not FileIndex for UNIX query info level
       via  ebe7b8c58ca s3:smbd: use xattr_DosInfo4 in set_ea_dos_attribute()
       via  d54424a758b s3:smbd: parse xattr_DosInfo4 in parse_dos_attribute_blob()
       via  c03094cc1f9 s3:smbd: mark itime non-calculated if we created a file or dir
       via  a5a2ce953bb s3/lib: add make_file_index_from_itime()
       via  295d3501d71 s3/lib: add update_stat_ex_file_id()
       via  506ef2761c2 s3/lib: add update_stat_ex_itime()
       via  30b7f9ae2df s3: add st_ex_file_id to struct stat_ex
       via  df4a380d9f4 s3: add st_ex_itime to struct stat_ex
       via  d18bdc1c43b s3: convert struct stat_ex st_ex_calculated_birthtime bool to flags
       via  a5f4e33f87f s3: remove unused st_ex_mask from struct stat_ex
       via  3e005fb8f4f idl: add xattr_DosInfo4 to xattr_DosInfo in xattr.idl
       via  ae6dd4853e3 vfs_catia: pass stat info to synthetic_smb_fname()
      from  163c0cc84a1 s3:winbind: Add support for storing KRB5 credential in KCM

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


- Log -----------------------------------------------------------------
commit 6e65c283120e3e627f0d8570601263f904529996
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Jun 27 09:38:57 2019 +0200

    selftest: add a test that itime is not set when setting DOS attrs
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Mon Jul  1 23:21:07 UTC 2019 on sn-devel-184

commit 03690ec2180d10c6d0c01ed2d7392aa9f8d30c0b
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Jun 30 13:33:39 2019 +0200

    vfs_fruit: change default for "fruit:zero_file_id" to false
    
    Now that we have reliable File-IDs, change the default for the option
    "zero_file_id" to false.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit eb986786562d2551743e97f5cd59d59f574657ca
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Jun 30 14:24:59 2019 +0200

    vfs_fruit: make "fruit:zero_file_id" a per share option
    
    Now that File-ID calculation goes through the VFS, we can nicely make a
    per-share option out of it.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 076f26dd5c9d5b2c5836f2cb66c9b2d895076ab6
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Jun 29 14:35:49 2019 +0200

    vfs_fruit: move zero file-id to vfs_fruit
    
    Now that this stuff goes through the VFS, let's do it right. :)
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 36d100e4b8945edbccc94175c716197db9df12c9
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Jun 27 14:47:57 2019 +0200

    s3:smbd: set file_id in fetch_dos_mode_done()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a3caf4140c01136a412c129cae28b433e33ab014
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Jun 27 14:46:37 2019 +0200

    s3:smbd: use stored file_id in SMB_VFS_FS_FILE_ID()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit df5752ec90d2b648b221887840262acf8fe43ef6
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Jun 29 14:18:13 2019 +0200

    s3:vfs: move get_fs_file_id to vfs_default
    
    This makes get_fs_file_id() the default implementation of
    SMB_VFS_FS_FILE_ID(). No change in behaviour.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 71996fef09f28fba39637acb86a51b5e0c1da36b
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Jun 29 14:08:04 2019 +0200

    s3:vfs: add SMB_VFS_FS_FILE_ID()
    
    Not yet used, that comes next.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d2bac65e2ef76b7ceecd57e39072311008aea7f8
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Jun 28 10:12:44 2019 +0200

    s3:smbd: rename get_FileIndex() to get_fs_file_id()
    
    Also rename all variable used to store the result of the renamed
    get_fs_file_id() in the callers.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e6cdd4862f9c07101c8bab7c21b7c438164e13ec
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Jun 25 12:07:59 2019 +0200

    s3:smbd: return inode number, not FileIndex for UNIX query info level
    
    get_FileIndex() returns a stable and unique numerical identifier when "store dos
    attributes" is enabled. It is NOT the same as a file's inode number which used
    as the key for locking.tdb.
    
    For POSIX clients we should return the inode numbers in the POSIX query info
    level and the FileIndex in the corresponding SMB protocol fields (eg SMB2 QFID
    create context).
    
    This fix lets test "smbtorture_s3.plain.CLEANUP3" test work with get_FileIndex()
    returning something different then the file's inode number.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ebe7b8c58ca52005a68413e92d4148a17b1af671
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Jun 25 14:26:10 2019 +0200

    s3:smbd: use xattr_DosInfo4 in set_ea_dos_attribute()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d54424a758b4add7b1cf2bd40c7b6455fb779092
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Jun 25 14:25:21 2019 +0200

    s3:smbd: parse xattr_DosInfo4 in parse_dos_attribute_blob()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c03094cc1f975dbf6dd5bde9c5b246850b94ce16
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Jun 26 13:40:05 2019 +0200

    s3:smbd: mark itime non-calculated if we created a file or dir
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a5a2ce953bbfff72ab66f24604c347259321f266
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Jun 25 14:13:28 2019 +0200

    s3/lib: add make_file_index_from_itime()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 295d3501d719ffad1fd0349707ef10fd60f72b84
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Jun 25 14:24:17 2019 +0200

    s3/lib: add update_stat_ex_file_id()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 506ef2761c29f40720104ed4e3f9d9ba37a22f9d
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Jun 25 13:13:08 2019 +0200

    s3/lib: add update_stat_ex_itime()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 30b7f9ae2df26d2f0fc84b30e86fc4639da3972a
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Jun 27 18:17:20 2019 +0200

    s3: add st_ex_file_id to struct stat_ex
    
    st_ex_file_id is an immutable, never reused numeric identifier for objects in a
    filesystem.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit df4a380d9f459dcdd7e1edab8711b36af0cac09a
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Jun 27 18:14:43 2019 +0200

    s3: add st_ex_itime to struct stat_ex
    
    st_ex_itime is an immutable original birth time aka instantiation time. Set when
    a file is created, never changes thereafter. May not be set by the client.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d18bdc1c43b8573582bd77d153cd514f881a69b9
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Jun 27 17:06:46 2019 +0200

    s3: convert struct stat_ex st_ex_calculated_birthtime bool to flags
    
    Subsequent commits will add more flags, this paves the way.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a5f4e33f87fce8622b2b9d84968ed28d30f4e79a
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Jun 27 16:52:25 2019 +0200

    s3: remove unused st_ex_mask from struct stat_ex
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3e005fb8f4fa670384ad23c3218ed8d9bfad8880
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Jun 30 14:43:28 2019 +0200

    idl: add xattr_DosInfo4 to xattr_DosInfo in xattr.idl
    
    Adding itime, removing unused ea_size, size, alloc_size and change_time.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ae6dd4853e3e651f6e56ce735bcb0a2264857385
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Jun 27 12:50:37 2019 +0200

    vfs_catia: pass stat info to synthetic_smb_fname()
    
    This doesn't cause visible damage in vanilla Samba, but would affect downstream
    consumers that add additional fields to struct smb_filename.
    
    For the same reason there's no test.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14015
    RN: Ensure vfs_catia passes stat info to stacked VFS modules
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 WHATSNEW.txt                          |  1 +
 docs-xml/manpages/vfs_fruit.8.xml     | 33 ++++++++++----------
 examples/VFS/skel_opaque.c            |  8 +++++
 examples/VFS/skel_transparent.c       |  7 +++++
 librpc/idl/xattr.idl                  | 11 ++++++-
 selftest/target/Samba3.pm             |  7 +++++
 selftest/target/Samba4.pm             |  5 +++
 source3/include/includes.h            | 16 ++++++++--
 source3/include/proto.h               |  2 ++
 source3/include/vfs.h                 | 11 +++++++
 source3/include/vfs_macros.h          |  5 +++
 source3/lib/file_id.c                 | 34 ++++++++++++++++++++
 source3/lib/file_id.h                 |  5 +++
 source3/lib/system.c                  | 29 +++++++++++++++---
 source3/librpc/idl/open_files.idl     |  3 +-
 source3/modules/vfs_catia.c           | 42 ++++++++++++-------------
 source3/modules/vfs_ceph.c            |  5 ++-
 source3/modules/vfs_default.c         | 23 ++++++++++++++
 source3/modules/vfs_fruit.c           | 25 ++++++++++++---
 source3/modules/vfs_full_audit.c      | 17 ++++++++++
 source3/modules/vfs_gpfs.c            |  4 +--
 source3/modules/vfs_not_implemented.c |  8 +++++
 source3/modules/vfs_time_audit.c      | 20 ++++++++++++
 source3/script/tests/test_itime.sh    | 39 +++++++++++++++++++++++
 source3/selftest/tests.py             |  4 ++-
 source3/smbd/dosmode.c                | 58 ++++++++++++++++++++++++++++++++---
 source3/smbd/durable.c                | 26 +++-------------
 source3/smbd/globals.h                |  1 -
 source3/smbd/open.c                   |  6 ++++
 source3/smbd/proto.h                  |  2 --
 source3/smbd/smb2_create.c            |  7 +++--
 source3/smbd/smb2_query_directory.c   | 27 ++++++++++++++++
 source3/smbd/trans2.c                 | 50 ++++++------------------------
 source3/smbd/vfs.c                    |  7 +++++
 34 files changed, 419 insertions(+), 129 deletions(-)
 create mode 100755 source3/script/tests/test_itime.sh


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 3a5d978d6ee..7ba0dbeca13 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -110,6 +110,7 @@ smb.conf changes
   --------------                     -----------                -------
 
   web port                           Removed
+  fruit:zero_file_id                 Changed default            False
 
 
 KNOWN ISSUES
diff --git a/docs-xml/manpages/vfs_fruit.8.xml b/docs-xml/manpages/vfs_fruit.8.xml
index c5bd593a139..364b1536f66 100644
--- a/docs-xml/manpages/vfs_fruit.8.xml
+++ b/docs-xml/manpages/vfs_fruit.8.xml
@@ -143,23 +143,6 @@
 	    </listitem>
 	  </varlistentry>
 
-	  <varlistentry>
-	    <term>fruit:zero_file_id = yes | no</term>
-	    <listitem>
-	      <para>A <emphasis>global</emphasis> option whether to return
-	      zero to queries of on-disk file identifier, if the client
-	      has negotiated AAPL.</para>
-	      <para>Mac applications and / or the Mac SMB
-	      client code expect the on-disk file identifier to have the
-	      semantics of HFS+ Catalog Node Identifier (CNID). Samba
-	      doesn't provide those semantics, and that occasionally cause
-	      usability issues or even data loss. Returning a file identifier
-	      of zero causes the Mac client to stop using and trusting the
-	      file id returned from the server.</para>
-	      <para>The default is <emphasis>yes</emphasis>.</para>
-	    </listitem>
-	  </varlistentry>
-
 	  <varlistentry>
 	    <term>fruit:model = MacSamba</term>
 	    <listitem>
@@ -407,6 +390,22 @@
 	    </listitem>
 	  </varlistentry>
 
+	  <varlistentry>
+	    <term>fruit:zero_file_id = yes | no</term>
+	    <listitem>
+	      <para>Whether to return zero to queries of on-disk file
+	      identifier if the client has negotiated AAPL.</para>
+	      <para>Mac applications and / or the Mac SMB client code expect the
+	      on-disk file identifier to have the semantics of HFS+ Catalog Node
+	      Identifier (CNID). Samba provides File-IDs based on a file's
+	      initial creation date if the option <smbconfoption name="store dos
+	      attributes"/> is enabled.  Returning a file identifier of
+	      zero causes the Mac client to stop using and trusting the file id
+	      returned from the server.</para>
+	      <para>The default is <emphasis>yes</emphasis>.</para>
+	    </listitem>
+	  </varlistentry>
+
 	</variablelist>
 </refsect1>
 
diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index 6628bffe3eb..4e4475a11e8 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -513,6 +513,13 @@ static struct file_id skel_file_id_create(vfs_handle_struct *handle,
 	return id;
 }
 
+static uint64_t skel_fs_file_id(vfs_handle_struct *handle,
+				const SMB_STRUCT_STAT *sbuf)
+{
+	errno = ENOSYS;
+	return 0;
+}
+
 struct skel_offload_read_state {
 	bool dummy;
 };
@@ -1084,6 +1091,7 @@ static struct vfs_fn_pointers skel_opaque_fns = {
 	.realpath_fn = skel_realpath,
 	.chflags_fn = skel_chflags,
 	.file_id_create_fn = skel_file_id_create,
+	.fs_file_id_fn = skel_fs_file_id,
 	.offload_read_send_fn = skel_offload_read_send,
 	.offload_read_recv_fn = skel_offload_read_recv,
 	.offload_write_send_fn = skel_offload_write_send,
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index 9b5f336042e..ac2665ef07b 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -600,6 +600,12 @@ static struct file_id skel_file_id_create(vfs_handle_struct *handle,
 	return SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
 }
 
+static uint64_t skel_fs_file_id(vfs_handle_struct *handle,
+				const SMB_STRUCT_STAT *sbuf)
+{
+	return SMB_VFS_NEXT_FS_FILE_ID(handle, sbuf);
+}
+
 struct skel_offload_read_state {
 	struct vfs_handle_struct *handle;
 	DATA_BLOB token;
@@ -1348,6 +1354,7 @@ static struct vfs_fn_pointers skel_transparent_fns = {
 	.realpath_fn = skel_realpath,
 	.chflags_fn = skel_chflags,
 	.file_id_create_fn = skel_file_id_create,
+	.fs_file_id_fn = skel_fs_file_id,
 	.offload_read_send_fn = skel_offload_read_send,
 	.offload_read_recv_fn = skel_offload_read_recv,
 	.offload_write_send_fn = skel_offload_write_send,
diff --git a/librpc/idl/xattr.idl b/librpc/idl/xattr.idl
index 38d32fd85b1..a2c4f25d0fd 100644
--- a/librpc/idl/xattr.idl
+++ b/librpc/idl/xattr.idl
@@ -73,7 +73,8 @@ interface xattr
 		XATTR_DOSINFO_SIZE              = 0x00000004,
 		XATTR_DOSINFO_ALLOC_SIZE        = 0x00000008,
 		XATTR_DOSINFO_CREATE_TIME       = 0x00000010,
-		XATTR_DOSINFO_CHANGE_TIME       = 0x00000020
+		XATTR_DOSINFO_CHANGE_TIME       = 0x00000020,
+		XATTR_DOSINFO_ITIME             = 0x00000040
 	} xattr_DosInfoValidFlags;
 
 	typedef struct {
@@ -86,11 +87,19 @@ interface xattr
 		NTTIME change_time;
 	} xattr_DosInfo3;
 
+	typedef struct {
+		xattr_DosInfoValidFlags valid_flags;
+		uint32 attrib;
+		NTTIME itime;
+		NTTIME create_time;
+	} xattr_DosInfo4;
+
 	typedef [public,switch_type(uint16)] union {
 		[case(0xFFFF)] xattr_DosInfoFFFFCompat compatinfoFFFF;
                 [case(1)] xattr_DosInfo1 info1;
                 [case(2)] xattr_DosInfo2Old oldinfo2;
 		[case(3)] xattr_DosInfo3 info3;
+		[case(4)] xattr_DosInfo4 info4;
         } xattr_DosInfo;
 
 	typedef [public] struct {
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 34a9864cd48..6ce61a8b4ed 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -1995,6 +1995,13 @@ sub provision($$$$$$$$$)
 	fruit:delete_empty_adfiles = true
 	fruit:veto_appledouble = no
 
+[vfs_fruit_zero_fileid]
+	path = $shrdir
+	vfs objects = fruit streams_xattr acl_xattr xattr_tdb
+	fruit:resource = file
+	fruit:metadata = stream
+	fruit:zero_file_id=yes
+
 [badname-tmp]
 	path = $badnames_shrdir
 	guest ok = yes
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 59ea6f38e18..32de94cf21f 100755
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -1215,6 +1215,11 @@ sub provision($$$$$$$$$$)
 	fruit:locking = netatalk
 	fruit:encoding = native
 
+[xattr]
+	path = $ctx->{share}
+        # This can be used for testing real fs xattr stuff
+	vfs objects = streams_xattr acl_xattr
+
 $extra_smbconf_shares
 ";
 
diff --git a/source3/include/includes.h b/source3/include/includes.h
index c26b75f5791..abe12ac0930 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -190,6 +190,11 @@ typedef uint64_t br_off;
 #define SOFF_T_R(p, ofs, v) (SIVAL(p,(ofs)+4,(v)&0xFFFFFFFF), SIVAL(p,ofs,(v)>>32))
 #define IVAL_TO_SMB_OFF_T(buf,off) ((off_t)(( ((uint64_t)(IVAL((buf),(off)))) & ((uint64_t)0xFFFFFFFF) )))
 
+/* Is birthtime real, or was it calculated ? */
+#define ST_EX_IFLAG_CALCULATED_BTIME		(1 << 0)
+#define ST_EX_IFLAG_CALCULATED_ITIME		(1 << 1)
+#define ST_EX_IFLAG_CALCULATED_FILE_ID		(1 << 2)
+
 /*
  * Type for stat structure.
  */
@@ -197,6 +202,7 @@ typedef uint64_t br_off;
 struct stat_ex {
 	dev_t		st_ex_dev;
 	ino_t		st_ex_ino;
+	uint64_t	st_ex_file_id;
 	mode_t		st_ex_mode;
 	nlink_t		st_ex_nlink;
 	uid_t		st_ex_uid;
@@ -207,13 +213,17 @@ struct stat_ex {
 	struct timespec st_ex_mtime;
 	struct timespec st_ex_ctime;
 	struct timespec st_ex_btime; /* birthtime */
-	/* Is birthtime real, or was it calculated ? */
-	bool		st_ex_calculated_birthtime;
+	/*
+	 * Immutable original birth time aka instantiation time. Set when a file
+	 * is created, never changes thereafter. May not be set by the client.
+	 */
+	struct timespec st_ex_itime; /* instantiation time */
+
 	blksize_t	st_ex_blksize;
 	blkcnt_t	st_ex_blocks;
 
 	uint32_t	st_ex_flags;
-	uint32_t	st_ex_mask;
+	uint32_t	st_ex_iflags;
 };
 
 typedef struct stat_ex SMB_STRUCT_STAT;
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 484afc959b9..8b387f7c563 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -220,7 +220,9 @@ ssize_t sys_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *f
 int sys_fcntl_ptr(int fd, int cmd, void *arg);
 int sys_fcntl_long(int fd, int cmd, long arg);
 void update_stat_ex_mtime(struct stat_ex *dst, struct timespec write_ts);
+void update_stat_ex_itime(struct stat_ex *dst, struct timespec itime);
 void update_stat_ex_create_time(struct stat_ex *dst, struct timespec create_time);
+void update_stat_ex_file_id(struct stat_ex *dst, uint64_t file_id);
 int sys_stat(const char *fname, SMB_STRUCT_STAT *sbuf,
 	     bool fake_dir_create_times);
 int sys_fstat(int fd, SMB_STRUCT_STAT *sbuf,
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 67cbe758674..56f4b9dd1f8 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -261,6 +261,11 @@
 /* Version 40 - Add SMB_VFS_GET_DOS_ATTRIBUTES_SEND/RECV */
 /* Bump to version 41, Samba 4.11 will ship with that */
 /* Version 41 - Remove SMB_VFS_BRL_CANCEL_WINDOWS */
+/* Version 41 - Remove unused st_ex_mask from struct stat_ex */
+/* Version 41 - convert struct stat_ex.st_ex_calculated_birthtime to flags */
+/* Version 41 - add st_ex_itime to struct stat_ex */
+/* Version 41 - add st_ex_file_id to struct stat_ex */
+/* Version 41 - add SMB_VFS_FS_FILE_ID */
 
 #define SMB_VFS_INTERFACE_VERSION 41
 
@@ -796,6 +801,8 @@ struct vfs_fn_pointers {
 				unsigned int flags);
 	struct file_id (*file_id_create_fn)(struct vfs_handle_struct *handle,
 					    const SMB_STRUCT_STAT *sbuf);
+	uint64_t (*fs_file_id_fn)(struct vfs_handle_struct *handle,
+				  const SMB_STRUCT_STAT *sbuf);
 	struct tevent_req *(*offload_read_send_fn)(TALLOC_CTX *mem_ctx,
 						   struct tevent_context *ev,
 						   struct vfs_handle_struct *handle,
@@ -1323,6 +1330,8 @@ int smb_vfs_call_chflags(struct vfs_handle_struct *handle,
 			unsigned int flags);
 struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,
 					   const SMB_STRUCT_STAT *sbuf);
+uint64_t smb_vfs_call_fs_file_id(struct vfs_handle_struct *handle,
+				 const SMB_STRUCT_STAT *sbuf);
 NTSTATUS smb_vfs_call_streaminfo(struct vfs_handle_struct *handle,
 				 struct files_struct *fsp,
 				 const struct smb_filename *smb_fname,
@@ -1747,6 +1756,8 @@ int vfs_not_implemented_chflags(vfs_handle_struct *handle,
 				uint flags);
 struct file_id vfs_not_implemented_file_id_create(vfs_handle_struct *handle,
 						  const SMB_STRUCT_STAT *sbuf);
+uint64_t vfs_not_implemented_fs_file_id(vfs_handle_struct *handle,
+					const SMB_STRUCT_STAT *sbuf);
 struct tevent_req *vfs_not_implemented_offload_read_send(
 			TALLOC_CTX *mem_ctx,
 			struct tevent_context *ev,
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index e867810f30f..c4fa0fe022e 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -331,6 +331,11 @@
 #define SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf) \
 	smb_vfs_call_file_id_create((handle)->next, (sbuf))
 
+#define SMB_VFS_FS_FILE_ID(conn, sbuf) \
+	smb_vfs_call_fs_file_id((conn)->vfs_handles, (sbuf))
+#define SMB_VFS_NEXT_FS_FILE_ID(handle, sbuf) \
+	smb_vfs_call_fs_file_id((handle)->next, (sbuf))
+
 #define SMB_VFS_STREAMINFO(conn, fsp, smb_fname, mem_ctx, num_streams, streams) \
 	smb_vfs_call_streaminfo((conn)->vfs_handles, (fsp), (smb_fname), (mem_ctx), (num_streams), (streams))
 #define SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx, num_streams, streams) \
diff --git a/source3/lib/file_id.c b/source3/lib/file_id.c
index f8295ce738a..7d4fb006afe 100644
--- a/source3/lib/file_id.c
+++ b/source3/lib/file_id.c
@@ -90,3 +90,37 @@ void pull_file_id_24(const char *buf, struct file_id *id)
 	id->extid  = IVAL(buf,  16);
 	id->extid |= ((uint64_t)IVAL(buf,20))<<32;
 }
+
+uint64_t make_file_id_from_itime(SMB_STRUCT_STAT *st)
+{
+	struct timespec itime = st->st_ex_itime;
+	ino_t ino = st->st_ex_ino;
+	uint64_t file_id_low;
+	uint64_t file_id;
+
+	if (st->st_ex_iflags & ST_EX_IFLAG_CALCULATED_ITIME) {
+		return ino;
+	}
+
+	file_id_low = itime.tv_nsec;
+	if (file_id_low == 0) {
+		/*
+		 * This could be by coincidence, but more likely the filesystem
+		 * is only giving us seconds granularity. We need more fine
+		 * grained granularity for the File-ID, so combine with the
+		 * inode number.
+		 */
+		file_id_low = ino & ((1 << 30) - 1);
+	}
+
+	/*
+	 * Set the high bit so ideally File-IDs based on inode numbers and
+	 * File-IDs based on Birth Time use disjoint ranges, given inodes never
+	 * have the high bit set.
+	 */
+	file_id = ((uint64_t)1) << 63;
+	file_id |= (uint64_t)itime.tv_sec << 30;
+	file_id |= file_id_low;
+
+	return file_id;
+}
diff --git a/source3/lib/file_id.h b/source3/lib/file_id.h
index 6fa98400b85..509e924c1fe 100644
--- a/source3/lib/file_id.h
+++ b/source3/lib/file_id.h
@@ -35,3 +35,8 @@ const char *file_id_string(TALLOC_CTX *mem_ctx, const struct file_id *id);
 void push_file_id_16(char *buf, const struct file_id *id);
 void push_file_id_24(char *buf, const struct file_id *id);
 void pull_file_id_24(const char *buf, struct file_id *id);
+
+/*
+ * Make a SMB File-ID from itime
+ */
+uint64_t make_file_id_from_itime(SMB_STRUCT_STAT *st);
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 9dd04ca5e3d..a67388e436a 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -291,7 +291,7 @@ static void make_create_timespec(const struct stat *pst, struct stat_ex *dst,
 		dst->st_ex_btime.tv_nsec = 0;
 	}
 
-	dst->st_ex_calculated_birthtime = false;
+	dst->st_ex_iflags &= ~ST_EX_IFLAG_CALCULATED_BTIME;
 
 #if defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC)
 	dst->st_ex_btime = pst->st_birthtimespec;
@@ -303,7 +303,7 @@ static void make_create_timespec(const struct stat *pst, struct stat_ex *dst,
 	dst->st_ex_btime.tv_nsec = 0;
 #else
 	dst->st_ex_btime = calc_create_time_stat(pst);
-	dst->st_ex_calculated_birthtime = true;
+	dst->st_ex_iflags |= ST_EX_IFLAG_CALCULATED_BTIME;
 #endif
 
 	/* Deal with systems that don't initialize birthtime correctly.
@@ -311,8 +311,11 @@ static void make_create_timespec(const struct stat *pst, struct stat_ex *dst,
 	 */
 	if (null_timespec(dst->st_ex_btime)) {
 		dst->st_ex_btime = calc_create_time_stat(pst);
-		dst->st_ex_calculated_birthtime = true;
+		dst->st_ex_iflags |= ST_EX_IFLAG_CALCULATED_BTIME;
 	}
+
+	dst->st_ex_itime = dst->st_ex_btime;
+	dst->st_ex_iflags |= ST_EX_IFLAG_CALCULATED_ITIME;
 }
 
 /****************************************************************************
@@ -327,7 +330,7 @@ void update_stat_ex_mtime(struct stat_ex *dst,
 	dst->st_ex_mtime = write_ts;
 
 	/* We may have to recalculate btime. */
-	if (dst->st_ex_calculated_birthtime) {
+	if (dst->st_ex_iflags & ST_EX_IFLAG_CALCULATED_BTIME) {
 		dst->st_ex_btime = calc_create_time_stat_ex(dst);
 	}
 }
@@ -336,7 +339,20 @@ void update_stat_ex_create_time(struct stat_ex *dst,
                                 struct timespec create_time)
 {
 	dst->st_ex_btime = create_time;
-	dst->st_ex_calculated_birthtime = false;
+	dst->st_ex_iflags &= ~ST_EX_IFLAG_CALCULATED_BTIME;
+}
+
+void update_stat_ex_itime(struct stat_ex *dst,
+			  struct timespec itime)
+{
+	dst->st_ex_itime = itime;
+	dst->st_ex_iflags &= ~ST_EX_IFLAG_CALCULATED_ITIME;
+}
+
+void update_stat_ex_file_id(struct stat_ex *dst, uint64_t file_id)
+{
+	dst->st_ex_file_id = file_id;
+	dst->st_ex_iflags &= ~ST_EX_IFLAG_CALCULATED_FILE_ID;
 }
 
 void init_stat_ex_from_stat (struct stat_ex *dst,
@@ -354,6 +370,7 @@ void init_stat_ex_from_stat (struct stat_ex *dst,
 	dst->st_ex_atime = get_atimespec(src);
 	dst->st_ex_mtime = get_mtimespec(src);
 	dst->st_ex_ctime = get_ctimespec(src);
+	dst->st_ex_iflags = 0;
 	make_create_timespec(src, dst, fake_dir_create_times);
 #ifdef HAVE_STAT_ST_BLKSIZE
 	dst->st_ex_blksize = src->st_blksize;
@@ -372,6 +389,8 @@ void init_stat_ex_from_stat (struct stat_ex *dst,
 #else
 	dst->st_ex_flags = 0;
 #endif
+	dst->st_ex_file_id = dst->st_ex_ino;
+	dst->st_ex_iflags |= ST_EX_IFLAG_CALCULATED_FILE_ID;
 }
 
 /*******************************************************************
diff --git a/source3/librpc/idl/open_files.idl b/source3/librpc/idl/open_files.idl
index d724d738214..04305e24164 100644
--- a/source3/librpc/idl/open_files.idl
+++ b/source3/librpc/idl/open_files.idl
@@ -76,11 +76,10 @@ interface open_files
 		timespec	st_ex_mtime;
 		timespec	st_ex_ctime;
 		timespec	st_ex_btime;
-		boolean8	st_ex_calculated_birthtime;
 		hyper		st_ex_blksize;
 		hyper		st_ex_blocks;
 		uint32		st_ex_flags;
-		uint32		st_ex_mask;
+		uint32		st_ex_iflags;
 	} vfs_default_durable_stat;
 
 	typedef [public] struct {
diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index 5915e40ff28..762491ede31 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -193,7 +193,7 @@ static DIR *catia_opendir(vfs_handle_struct *handle,
 	mapped_smb_fname = synthetic_smb_fname(talloc_tos(),
 				name_mapped,
 				NULL,
-				NULL,
+				&smb_fname->st,
 				smb_fname->flags);
 	if (mapped_smb_fname == NULL) {
 		TALLOC_FREE(mapped_smb_fname);
@@ -722,7 +722,7 @@ static int catia_chown(vfs_handle_struct *handle,
 	catia_smb_fname = synthetic_smb_fname(talloc_tos(),
 					name,
 					NULL,
-					NULL,
+					&smb_fname->st,
 					smb_fname->flags);
 	if (catia_smb_fname == NULL) {
 		TALLOC_FREE(name);
@@ -760,7 +760,7 @@ static int catia_lchown(vfs_handle_struct *handle,
 	catia_smb_fname = synthetic_smb_fname(talloc_tos(),
 					name,
 					NULL,
-					NULL,
+					&smb_fname->st,
 					smb_fname->flags);
 	if (catia_smb_fname == NULL) {
 		TALLOC_FREE(name);
@@ -797,7 +797,7 @@ static int catia_chmod(vfs_handle_struct *handle,
 	catia_smb_fname = synthetic_smb_fname(talloc_tos(),
 					name,
 					NULL,
-					NULL,
+					&smb_fname->st,
 					smb_fname->flags);
 	if (catia_smb_fname == NULL) {
 		TALLOC_FREE(name);
@@ -832,7 +832,7 @@ static int catia_rmdir(vfs_handle_struct *handle,
 	catia_smb_fname = synthetic_smb_fname(talloc_tos(),
 					name,
 					NULL,
-					NULL,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list