Skip to content

Commit

Permalink
s3: VFS: Add SMB_VFS_MKNODAT().
Browse files Browse the repository at this point in the history
Currently identical to SMB_VFS_MKNOD().

Next, add to all VFS modules that implement
mknod and eventually remove mknod.

Signed-off-by: Jeremy Allison <[email protected]>
Reviewed-by: Ralph Böhme <[email protected]>
  • Loading branch information
jrasamba committed Aug 22, 2019
1 parent e4c4af6 commit e224687
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/VFS/skel_opaque.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions examples/VFS/skel_transparent.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions source3/include/smbprofile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
16 changes: 16 additions & 0 deletions source3/include/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions source3/include/vfs_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
22 changes: 22 additions & 0 deletions source3/modules/vfs_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions source3/modules/vfs_not_implemented.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions source3/smbd/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e224687

Please sign in to comment.