From: Jeremy Allison Date: Tue, 20 Aug 2019 23:31:00 +0000 (-0700) Subject: s3: VFS: Add SMB_VFS_MKNODAT(). X-Git-Tag: tevent-0.10.1~214 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2246876d1ebdde2eaa2bd635e8907f1671b4159;p=thirdparty%2Fsamba.git s3: VFS: Add SMB_VFS_MKNODAT(). Currently identical to SMB_VFS_MKNOD(). Next, add to all VFS modules that implement mknod and eventually remove mknod. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Böhme --- diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index 8de97e85147..a47b98b9896 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -493,6 +493,16 @@ static int skel_mknod(vfs_handle_struct *handle, return -1; } +static int skel_mknodat(vfs_handle_struct *handle, + files_struct *dirfsp, + const struct smb_filename *smb_fname, + mode_t mode, + SMB_DEV_T dev) +{ + errno = ENOSYS; + return -1; +} + static struct smb_filename *skel_realpath(vfs_handle_struct *handle, TALLOC_CTX *ctx, const struct smb_filename *smb_fname) @@ -1091,6 +1101,7 @@ static struct vfs_fn_pointers skel_opaque_fns = { .readlink_fn = skel_vfs_readlink, .linkat_fn = skel_linkat, .mknod_fn = skel_mknod, + .mknodat_fn = skel_mknodat, .realpath_fn = skel_realpath, .chflags_fn = skel_chflags, .file_id_create_fn = skel_file_id_create, diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index 015f72c1549..e5f6305be4d 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -594,6 +594,19 @@ static int skel_mknod(vfs_handle_struct *handle, return SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev); } +static int skel_mknodat(vfs_handle_struct *handle, + files_struct *dirfsp, + const struct smb_filename *smb_fname, + mode_t mode, + SMB_DEV_T dev) +{ + return SMB_VFS_NEXT_MKNODAT(handle, + dirfsp, + smb_fname, + mode, + dev); +} + static struct smb_filename *skel_realpath(vfs_handle_struct *handle, TALLOC_CTX *ctx, const struct smb_filename *smb_fname) @@ -1362,6 +1375,7 @@ static struct vfs_fn_pointers skel_transparent_fns = { .readlink_fn = skel_vfs_readlink, .linkat_fn = skel_linkat, .mknod_fn = skel_mknod, + .mknodat_fn = skel_mknodat, .realpath_fn = skel_realpath, .chflags_fn = skel_chflags, .file_id_create_fn = skel_file_id_create, diff --git a/source3/include/smbprofile.h b/source3/include/smbprofile.h index 4568b19bfda..8344e8254e4 100644 --- a/source3/include/smbprofile.h +++ b/source3/include/smbprofile.h @@ -86,6 +86,7 @@ struct tevent_context; SMBPROFILE_STATS_BASIC(syscall_symlink) \ SMBPROFILE_STATS_BASIC(syscall_linkat) \ SMBPROFILE_STATS_BASIC(syscall_mknod) \ + SMBPROFILE_STATS_BASIC(syscall_mknodat) \ SMBPROFILE_STATS_BASIC(syscall_realpath) \ SMBPROFILE_STATS_BASIC(syscall_get_quota) \ SMBPROFILE_STATS_BASIC(syscall_set_quota) \ diff --git a/source3/include/vfs.h b/source3/include/vfs.h index c91b4a3789a..4f06d6e85dd 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -274,6 +274,7 @@ /* Version 42 - Make "lease" a const* in create_file_fn */ /* Version 42 - Move SMB_VFS_RENAME -> SMB_VFS_RENAMEAT */ /* Version 42 - Move SMB_VFS_LINK -> SMB_VFS_LINKAT. */ +/* Version 42 - Add SMB_VFS_MKDNODAT. */ #define SMB_VFS_INTERFACE_VERSION 42 @@ -810,6 +811,11 @@ struct vfs_fn_pointers { const struct smb_filename *smb_fname, mode_t mode, SMB_DEV_T dev); + int (*mknodat_fn)(struct vfs_handle_struct *handle, + struct files_struct *dirfsp, + const struct smb_filename *smb_fname, + mode_t mode, + SMB_DEV_T dev); struct smb_filename *(*realpath_fn)(struct vfs_handle_struct *handle, TALLOC_CTX *ctx, const struct smb_filename *smb_fname); @@ -1342,6 +1348,11 @@ int smb_vfs_call_mknod(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname, mode_t mode, SMB_DEV_T dev); +int smb_vfs_call_mknodat(struct vfs_handle_struct *handle, + struct files_struct *dirfsp, + const struct smb_filename *smb_fname, + mode_t mode, + SMB_DEV_T dev); struct smb_filename *smb_vfs_call_realpath(struct vfs_handle_struct *handle, TALLOC_CTX *ctx, const struct smb_filename *smb_fname); @@ -1771,6 +1782,11 @@ int vfs_not_implemented_mknod(vfs_handle_struct *handle, const struct smb_filename *smb_fname, mode_t mode, SMB_DEV_T dev); +int vfs_not_implemented_mknodat(vfs_handle_struct *handle, + struct files_struct *dirfsp, + const struct smb_filename *smb_fname, + mode_t mode, + SMB_DEV_T dev); struct smb_filename *vfs_not_implemented_realpath(vfs_handle_struct *handle, TALLOC_CTX *ctx, const struct smb_filename *smb_fname); diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index 1a90c74d775..26102896604 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -316,6 +316,11 @@ #define SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev) \ smb_vfs_call_mknod((handle)->next, (smb_fname), (mode), (dev)) +#define SMB_VFS_MKNODAT(conn, dirfsp, smb_fname, mode, dev) \ + smb_vfs_call_mknodat((conn)->vfs_handles, (dirfsp), (smb_fname), (mode), (dev)) +#define SMB_VFS_NEXT_MKNODAT(handle, dirfsp, smb_fname, mode, dev) \ + smb_vfs_call_mknodat((handle)->next, (dirfsp), (smb_fname), (mode), (dev)) + #define SMB_VFS_REALPATH(conn, ctx, smb_fname) \ smb_vfs_call_realpath((conn)->vfs_handles, (ctx), (smb_fname)) #define SMB_VFS_NEXT_REALPATH(handle, ctx, smb_fname) \ diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 6de217eca9c..6f2f4ef4535 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -2700,6 +2700,27 @@ static int vfswrap_mknod(vfs_handle_struct *handle, return result; } +static int vfswrap_mknodat(vfs_handle_struct *handle, + files_struct *dirfsp, + const struct smb_filename *smb_fname, + mode_t mode, + SMB_DEV_T dev) +{ + int result; + + START_PROFILE(syscall_mknodat); + + SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp); + + result = sys_mknodat(dirfsp->fh->fd, + smb_fname->base_name, + mode, + dev); + + END_PROFILE(syscall_mknodat); + return result; +} + static struct smb_filename *vfswrap_realpath(vfs_handle_struct *handle, TALLOC_CTX *ctx, const struct smb_filename *smb_fname) @@ -3481,6 +3502,7 @@ static struct vfs_fn_pointers vfs_default_fns = { .readlink_fn = vfswrap_readlink, .linkat_fn = vfswrap_linkat, .mknod_fn = vfswrap_mknod, + .mknodat_fn = vfswrap_mknodat, .realpath_fn = vfswrap_realpath, .chflags_fn = vfswrap_chflags, .file_id_create_fn = vfswrap_file_id_create, diff --git a/source3/modules/vfs_not_implemented.c b/source3/modules/vfs_not_implemented.c index 9a6847e83e0..7b604db0dd2 100644 --- a/source3/modules/vfs_not_implemented.c +++ b/source3/modules/vfs_not_implemented.c @@ -491,6 +491,16 @@ int vfs_not_implemented_mknod(vfs_handle_struct *handle, return -1; } +int vfs_not_implemented_mknodat(vfs_handle_struct *handle, + files_struct *dirfsp, + const struct smb_filename *smb_fname, + mode_t mode, + SMB_DEV_T dev) +{ + errno = ENOSYS; + return -1; +} + struct smb_filename *vfs_not_implemented_realpath(vfs_handle_struct *handle, TALLOC_CTX *ctx, const struct smb_filename *smb_fname) @@ -1095,6 +1105,7 @@ static struct vfs_fn_pointers vfs_not_implemented_fns = { .readlink_fn = vfs_not_implemented_vfs_readlink, .linkat_fn = vfs_not_implemented_linkat, .mknod_fn = vfs_not_implemented_mknod, + .mknodat_fn = vfs_not_implemented_mknodat, .realpath_fn = vfs_not_implemented_realpath, .chflags_fn = vfs_not_implemented_chflags, .file_id_create_fn = vfs_not_implemented_file_id_create, diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 845b2a2807c..900890ace00 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -2235,6 +2235,20 @@ int smb_vfs_call_mknod(struct vfs_handle_struct *handle, return handle->fns->mknod_fn(handle, smb_fname, mode, dev); } +int smb_vfs_call_mknodat(struct vfs_handle_struct *handle, + struct files_struct *dirfsp, + const struct smb_filename *smb_fname, + mode_t mode, + SMB_DEV_T dev) +{ + VFS_FIND(mknodat); + return handle->fns->mknodat_fn(handle, + dirfsp, + smb_fname, + mode, + dev); +} + struct smb_filename *smb_vfs_call_realpath(struct vfs_handle_struct *handle, TALLOC_CTX *ctx, const struct smb_filename *smb_fname)