1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-08 13:49:29 +03:00

vfs: add SMB_VFS_OPENAT()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme
2020-05-15 16:29:44 +02:00
committed by Jeremy Allison
parent d3c16d93d1
commit e4a38916e6
7 changed files with 76 additions and 0 deletions

View 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,

View 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,

View 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) \

View File

@ -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,

View File

@ -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), \

View 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,

View 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,