s3:vfs: add SMB_VFS_FS_FILE_ID()
authorRalph Boehme <slow@samba.org>
Sat, 29 Jun 2019 12:08:04 +0000 (14:08 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 1 Jul 2019 21:43:24 +0000 (21:43 +0000)
Not yet used, that comes next.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_full_audit.c
source3/modules/vfs_not_implemented.c
source3/modules/vfs_time_audit.c
source3/smbd/vfs.c

index 6628bffe3eb4bc028ab6711e3ff1fbc51e0ed9d2..4e4475a11e887354194cc134bfe1097e22029ea1 100644 (file)
@@ -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,
index 9b5f336042e043c499bdeab2ca125ff3f16334df..ac2665ef07ba82733be82715f171e135c11eebdd 100644 (file)
@@ -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,
index 33c54c884cd1bffc6d3facdc870a46f91be15c1a..56f4b9dd1f85fc0a86221f3d05915f54b077fbfc 100644 (file)
 /* 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
 
@@ -800,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,
@@ -1327,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,
@@ -1751,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,
index e867810f30f58c122bd4d0bb394e8d0182dee1b7..c4fa0fe022e8bd1044411998d6622e4295a2e18c 100644 (file)
 #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) \
index 8c4dc44dc5d9b68974ef01cda0adf8bc65ab44c5..b20bca0a528b74a514693ebd628bf01b8e54f98a 100644 (file)
@@ -158,6 +158,7 @@ typedef enum _vfs_op_type {
        SMB_VFS_OP_REALPATH,
        SMB_VFS_OP_CHFLAGS,
        SMB_VFS_OP_FILE_ID_CREATE,
+       SMB_VFS_OP_FS_FILE_ID,
        SMB_VFS_OP_STREAMINFO,
        SMB_VFS_OP_GET_REAL_FILENAME,
        SMB_VFS_OP_CONNECTPATH,
@@ -300,6 +301,7 @@ static struct {
        { SMB_VFS_OP_REALPATH,  "realpath" },
        { SMB_VFS_OP_CHFLAGS,   "chflags" },
        { SMB_VFS_OP_FILE_ID_CREATE,    "file_id_create" },
+       { SMB_VFS_OP_FS_FILE_ID,        "fs_file_id" },
        { SMB_VFS_OP_STREAMINFO,        "streaminfo" },
        { SMB_VFS_OP_GET_REAL_FILENAME, "get_real_filename" },
        { SMB_VFS_OP_CONNECTPATH,       "connectpath" },
@@ -1820,6 +1822,20 @@ static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *ha
        return result;
 }
 
+static uint64_t smb_full_audit_fs_file_id(struct vfs_handle_struct *handle,
+                                         const SMB_STRUCT_STAT *sbuf)
+{
+       uint64_t result;
+
+       result = SMB_VFS_NEXT_FS_FILE_ID(handle, sbuf);
+
+       do_log(SMB_VFS_OP_FS_FILE_ID,
+              result != 0,
+              handle, "%" PRIu64, result);
+
+       return result;
+}
+
 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
                                          struct files_struct *fsp,
                                          const struct smb_filename *smb_fname,
@@ -2864,6 +2880,7 @@ static struct vfs_fn_pointers vfs_full_audit_fns = {
        .realpath_fn = smb_full_audit_realpath,
        .chflags_fn = smb_full_audit_chflags,
        .file_id_create_fn = smb_full_audit_file_id_create,
+       .fs_file_id_fn = smb_full_audit_fs_file_id,
        .offload_read_send_fn = smb_full_audit_offload_read_send,
        .offload_read_recv_fn = smb_full_audit_offload_read_recv,
        .offload_write_send_fn = smb_full_audit_offload_write_send,
index d3aca89906715ec8b1302eaa6619fe4a8f4dd215..aa7068ed0732f379460a1860448dc9143ec73257 100644 (file)
@@ -511,6 +511,13 @@ struct file_id vfs_not_implemented_file_id_create(vfs_handle_struct *handle,
        return id;
 }
 
+uint64_t vfs_not_implemented_fs_file_id(vfs_handle_struct *handle,
+                                       const SMB_STRUCT_STAT *sbuf)
+{
+       errno = ENOSYS;
+       return 0;
+}
+
 struct vfs_not_implemented_offload_read_state {
        bool dummy;
 };
@@ -1088,6 +1095,7 @@ static struct vfs_fn_pointers vfs_not_implemented_fns = {
        .realpath_fn = vfs_not_implemented_realpath,
        .chflags_fn = vfs_not_implemented_chflags,
        .file_id_create_fn = vfs_not_implemented_file_id_create,
+       .fs_file_id_fn = vfs_not_implemented_fs_file_id,
        .offload_read_send_fn = vfs_not_implemented_offload_read_send,
        .offload_read_recv_fn = vfs_not_implemented_offload_read_recv,
        .offload_write_send_fn = vfs_not_implemented_offload_write_send,
index 96847a4fde904ea54c35c9c1aa52b0c734a144c2..8e1c794c037b5d6a8de8681052afd629d8628892 100644 (file)
@@ -1520,6 +1520,25 @@ static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *ha
        return result;
 }
 
+static uint64_t smb_time_audit_fs_file_id(struct vfs_handle_struct *handle,
+                                         const SMB_STRUCT_STAT *sbuf)
+{
+       uint64_t result;
+       struct timespec ts1,ts2;
+       double timediff;
+
+       clock_gettime_mono(&ts1);
+       result = SMB_VFS_NEXT_FS_FILE_ID(handle, sbuf);
+       clock_gettime_mono(&ts2);
+       timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
+
+       if (timediff > audit_timeout) {
+               smb_time_audit_log("fs_file_id", timediff);
+       }
+
+       return result;
+}
+
 static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle,
                                          struct files_struct *fsp,
                                          const struct smb_filename *smb_fname,
@@ -2824,6 +2843,7 @@ static struct vfs_fn_pointers vfs_time_audit_fns = {
        .realpath_fn = smb_time_audit_realpath,
        .chflags_fn = smb_time_audit_chflags,
        .file_id_create_fn = smb_time_audit_file_id_create,
+       .fs_file_id_fn = smb_time_audit_fs_file_id,
        .offload_read_send_fn = smb_time_audit_offload_read_send,
        .offload_read_recv_fn = smb_time_audit_offload_read_recv,
        .offload_write_send_fn = smb_time_audit_offload_write_send,
index d3bb9c5d63fbb93e423012e3b530a60b072dd982..51a4aeb0f2253fbd76cb0950439f86f1f75ec691 100644 (file)
@@ -2237,6 +2237,13 @@ struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,
        return handle->fns->file_id_create_fn(handle, sbuf);
 }
 
+uint64_t smb_vfs_call_fs_file_id(struct vfs_handle_struct *handle,
+                                const SMB_STRUCT_STAT *sbuf)
+{
+       VFS_FIND(fs_file_id);
+       return handle->fns->fs_file_id_fn(handle, sbuf);
+}
+
 NTSTATUS smb_vfs_call_streaminfo(struct vfs_handle_struct *handle,
                                 struct files_struct *fsp,
                                 const struct smb_filename *smb_fname,