vfs: add SMB_VFS_OPENAT()
authorRalph Boehme <slow@samba.org>
Fri, 15 May 2020 14:29:44 +0000 (16:29 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 21 May 2020 20:38:31 +0000 (20:38 +0000)
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/smbprofile.h
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_not_implemented.c
source3/smbd/vfs.c

index 77bd471315e844192f0d557790571df2d0144276..4c42e3d96c25e85b9de87000974fb613853dc954 100644 (file)
@@ -198,6 +198,17 @@ static int skel_open(vfs_handle_struct *handle, struct smb_filename *smb_fname,
        return -1;
 }
 
+static int skel_openat(struct vfs_handle_struct *handle,
+                      const struct files_struct *dirfsp,
+                      const struct smb_filename *smb_fname,
+                      struct files_struct *fsp,
+                      int flags,
+                      mode_t mode)
+{
+       errno = ENOSYS;
+       return -1;
+}
+
 static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
                                 struct smb_request *req,
                                 struct files_struct **dirfsp,
@@ -1063,6 +1074,7 @@ static struct vfs_fn_pointers skel_opaque_fns = {
        /* File operations */
 
        .open_fn = skel_open,
+       .openat_fn = skel_openat,
        .create_file_fn = skel_create_file,
        .close_fn = skel_close_fn,
        .pread_fn = skel_pread,
index 5c758f2fc5fd9e55c06df44165fc31b810ebe553..a57102607e36ceedb5156373cd184c12e392186e 100644 (file)
@@ -206,6 +206,16 @@ static int skel_open(vfs_handle_struct *handle, struct smb_filename *smb_fname,
        return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
 }
 
+static int skel_openat(struct vfs_handle_struct *handle,
+                      const struct files_struct *dirfsp,
+                      const struct smb_filename *smb_fname,
+                      struct files_struct *fsp,
+                      int flags,
+                      mode_t mode)
+{
+       return SMB_VFS_NEXT_OPENAT(handle, dirfsp, smb_fname, fsp, flags, mode);
+}
+
 static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
                                 struct smb_request *req,
                                 struct files_struct **dirfsp,
@@ -1371,6 +1381,7 @@ static struct vfs_fn_pointers skel_transparent_fns = {
        /* File operations */
 
        .open_fn = skel_open,
+       .openat_fn = skel_openat,
        .create_file_fn = skel_create_file,
        .close_fn = skel_close_fn,
        .pread_fn = skel_pread,
index 91f3066124053d0c7f26e5834ea2f9997818a235..1dc3a088655543879903bd6561fc2a5bc6c61cc9 100644 (file)
@@ -51,6 +51,7 @@ struct tevent_context;
        SMBPROFILE_STATS_BASIC(syscall_mkdirat) \
        SMBPROFILE_STATS_BASIC(syscall_closedir) \
        SMBPROFILE_STATS_BASIC(syscall_open) \
+       SMBPROFILE_STATS_BASIC(syscall_openat) \
        SMBPROFILE_STATS_BASIC(syscall_createfile) \
        SMBPROFILE_STATS_BASIC(syscall_close) \
        SMBPROFILE_STATS_BYTES(syscall_pread) \
index 12d048f21380632faae9328f7928ffc5408b5ca2..17516c1b12e29a3ac52337e8e1a91ec36a6928f8 100644 (file)
  * Version 43 - Remove root_dir_fid from SMB_VFS_CREATE_FILE().
  * Version 43 - Add dirfsp to struct files_struct
  * Version 43 - Add dirfsp args to SMB_VFS_CREATE_FILE()
+ * Version 43 - Add SMB_VFS_OPENAT()
  */
 
 #define SMB_VFS_INTERFACE_VERSION 43
@@ -764,6 +765,12 @@ struct vfs_fn_pointers {
        int (*open_fn)(struct vfs_handle_struct *handle,
                       struct smb_filename *smb_fname, files_struct *fsp,
                       int flags, mode_t mode);
+       int (*openat_fn)(struct vfs_handle_struct *handle,
+                        const struct files_struct *dirfsp,
+                        const struct smb_filename *smb_fname,
+                        struct files_struct *fsp,
+                        int flags,
+                        mode_t mode);
        NTSTATUS (*create_file_fn)(struct vfs_handle_struct *handle,
                                   struct smb_request *req,
                                   struct files_struct **dirfsp,
@@ -1276,6 +1283,12 @@ int smb_vfs_call_closedir(struct vfs_handle_struct *handle,
 int smb_vfs_call_open(struct vfs_handle_struct *handle,
                      struct smb_filename *smb_fname, struct files_struct *fsp,
                      int flags, mode_t mode);
+int smb_vfs_call_openat(struct vfs_handle_struct *handle,
+                       const struct files_struct *dirfsp,
+                       const struct smb_filename *smb_fname,
+                       struct files_struct *fsp,
+                       int flags,
+                       mode_t mode);
 NTSTATUS smb_vfs_call_create_file(struct vfs_handle_struct *handle,
                                  struct smb_request *req,
                                  struct files_struct **dirfsp,
@@ -1731,6 +1744,12 @@ int vfs_not_implemented_closedir(vfs_handle_struct *handle, DIR *dir);
 int vfs_not_implemented_open(vfs_handle_struct *handle,
                             struct smb_filename *smb_fname,
                             files_struct *fsp, int flags, mode_t mode);
+int vfs_not_implemented_openat(vfs_handle_struct *handle,
+                              const struct files_struct *dirfsp,
+                              const struct smb_filename *smb_fname,
+                              struct files_struct *fsp,
+                              int flags,
+                              mode_t mode);
 NTSTATUS vfs_not_implemented_create_file(struct vfs_handle_struct *handle,
                                struct smb_request *req,
                                struct files_struct **dirfsp,
index 5ab825ec3124359002acd211a1902b723e28ff0d..6eaf47f76b228deb01a8d21b2e7c7e7f356ca0ec 100644 (file)
 #define SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode) \
        smb_vfs_call_open((handle)->next, (fname), (fsp), (flags), (mode))
 
+#define SMB_VFS_OPENAT(conn, dirfsp, smb_fname, fsp, flags, mode) \
+       smb_vfs_call_openat((conn)->vfs_handles, (dirfsp), (smb_fname), (fsp), (flags), (mode))
+#define SMB_VFS_NEXT_OPENAT(handle, dirfsp, smb_fname, fsp, flags, mode) \
+       smb_vfs_call_openat((handle)->next, (dirfsp), (smb_fname), (fsp), (flags), (mode))
+
 #define SMB_VFS_CREATE_FILE(conn, req, dirfsp, smb_fname, access_mask, share_access, create_disposition, \
         create_options, file_attributes, oplock_request, lease, allocation_size, private_flags, sd, ea_list, result, pinfo, in_context_blobs, out_context_blobs) \
         smb_vfs_call_create_file((conn)->vfs_handles, (req), (dirfsp), (smb_fname), (access_mask), (share_access), (create_disposition), \
index 1523ea565f699ef6d3e956f9a889ebd3d10b4a75..3521fb1248032ee4145f2ea75f01934a354795d7 100644 (file)
@@ -196,6 +196,17 @@ int vfs_not_implemented_open(vfs_handle_struct *handle,
        return -1;
 }
 
+int vfs_not_implemented_openat(vfs_handle_struct *handle,
+                              const struct files_struct *dirfsp,
+                              const struct smb_filename *smb_fname,
+                              struct files_struct *fsp,
+                              int flags,
+                              mode_t mode)
+{
+       errno = ENOSYS;
+       return -1;
+}
+
 NTSTATUS vfs_not_implemented_create_file(struct vfs_handle_struct *handle,
                                struct smb_request *req,
                                struct files_struct **dirsp,
@@ -1068,6 +1079,7 @@ static struct vfs_fn_pointers vfs_not_implemented_fns = {
        /* File operations */
 
        .open_fn = vfs_not_implemented_open,
+       .openat_fn = vfs_not_implemented_openat,
        .create_file_fn = vfs_not_implemented_create_file,
        .close_fn = vfs_not_implemented_close_fn,
        .pread_fn = vfs_not_implemented_pread,
index 454f88e5652eb02f989e70f4beea8d2585869488..ae82dd871c5458a7aa3c1e19beb7388f2a88f459 100644 (file)
@@ -1755,6 +1755,22 @@ int smb_vfs_call_open(struct vfs_handle_struct *handle,
        return handle->fns->open_fn(handle, smb_fname, fsp, flags, mode);
 }
 
+int smb_vfs_call_openat(struct vfs_handle_struct *handle,
+                       const struct files_struct *dirfsp,
+                       const struct smb_filename *smb_fname,
+                       struct files_struct *fsp,
+                       int flags,
+                       mode_t mode)
+{
+       VFS_FIND(openat);
+       return handle->fns->openat_fn(handle,
+                                     dirfsp,
+                                     smb_fname,
+                                     fsp,
+                                     flags,
+                                     mode);
+}
+
 NTSTATUS smb_vfs_call_create_file(struct vfs_handle_struct *handle,
                                  struct smb_request *req,
                                  struct files_struct **dirfsp,