From: Ralph Boehme Date: Fri, 15 May 2020 14:29:44 +0000 (+0200) Subject: vfs: add SMB_VFS_OPENAT() X-Git-Tag: ldb-2.2.0~406 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4a38916e60dd092901cd5c431980b012978e2ee;p=thirdparty%2Fsamba.git vfs: add SMB_VFS_OPENAT() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index 77bd471315e..4c42e3d96c2 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -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, diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index 5c758f2fc5f..a57102607e3 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -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, diff --git a/source3/include/smbprofile.h b/source3/include/smbprofile.h index 91f30661240..1dc3a088655 100644 --- a/source3/include/smbprofile.h +++ b/source3/include/smbprofile.h @@ -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) \ diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 12d048f2138..17516c1b12e 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -322,6 +322,7 @@ * 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, diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index 5ab825ec312..6eaf47f76b2 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -147,6 +147,11 @@ #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), \ diff --git a/source3/modules/vfs_not_implemented.c b/source3/modules/vfs_not_implemented.c index 1523ea565f6..3521fb12480 100644 --- a/source3/modules/vfs_not_implemented.c +++ b/source3/modules/vfs_not_implemented.c @@ -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, diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 454f88e5652..ae82dd871c5 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -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,