Currently identical to SMB_VFS_MKDIR().
Next, add to all VFS modules that implement
mkdir and eventually remove mkdir.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
return -1;
}
+static int skel_mkdirat(vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ mode_t mode)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
static int skel_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
.telldir_fn = skel_telldir,
.rewind_dir_fn = skel_rewind_dir,
.mkdir_fn = skel_mkdir,
+ .mkdirat_fn = skel_mkdirat,
.rmdir_fn = skel_rmdir,
.closedir_fn = skel_closedir,
return SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode);
}
+static int skel_mkdirat(vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ mode_t mode)
+{
+ return SMB_VFS_NEXT_MKDIRAT(handle,
+ dirfsp,
+ smb_fname,
+ mode);
+}
+
static int skel_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
.telldir_fn = skel_telldir,
.rewind_dir_fn = skel_rewind_dir,
.mkdir_fn = skel_mkdir,
+ .mkdirat_fn = skel_mkdirat,
.rmdir_fn = skel_rmdir,
.closedir_fn = skel_closedir,
SMBPROFILE_STATS_BASIC(syscall_telldir) \
SMBPROFILE_STATS_BASIC(syscall_rewinddir) \
SMBPROFILE_STATS_BASIC(syscall_mkdir) \
+ SMBPROFILE_STATS_BASIC(syscall_mkdirat) \
SMBPROFILE_STATS_BASIC(syscall_rmdir) \
SMBPROFILE_STATS_BASIC(syscall_closedir) \
SMBPROFILE_STATS_BASIC(syscall_open) \
/* Version 42 - Move SMB_VFS_MKNOD -> SMB_VFS_MKDNODAT. */
/* Version 42 - Move SMB_VFS_READLINK -> SMB_VFS_READLINKAT. */
/* Version 42 - Move SMB_VFS_SYMLINK -> SMB_VFS_SYMLINKAT. */
+/* Version 42 - Add SMB_VFS_MKDIRAT. */
#define SMB_VFS_INTERFACE_VERSION 42
int (*mkdir_fn)(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode);
+ int (*mkdirat_fn)(struct vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ mode_t mode);
int (*rmdir_fn)(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname);
int (*closedir_fn)(struct vfs_handle_struct *handle, DIR *dir);
int smb_vfs_call_mkdir(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode);
+int smb_vfs_call_mkdirat(struct vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ mode_t mode);
int smb_vfs_call_rmdir(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname);
int smb_vfs_call_closedir(struct vfs_handle_struct *handle,
int vfs_not_implemented_mkdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode);
+int vfs_not_implemented_mkdirat(vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ mode_t mode);
int vfs_not_implemented_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname);
int vfs_not_implemented_closedir(vfs_handle_struct *handle, DIR *dir);
#define SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode) \
smb_vfs_call_mkdir((handle)->next,(smb_fname), (mode))
+#define SMB_VFS_MKDIRAT(conn, dirfsp, smb_fname, mode) \
+ smb_vfs_call_mkdirat((conn)->vfs_handles,(dirfsp), (smb_fname), (mode))
+#define SMB_VFS_NEXT_MKDIRAT(handle, dirfsp, smb_fname, mode) \
+ smb_vfs_call_mkdirat((handle)->next,(dirfsp), (smb_fname), (mode))
+
#define SMB_VFS_RMDIR(conn, smb_fname) \
smb_vfs_call_rmdir((conn)->vfs_handles, (smb_fname))
#define SMB_VFS_NEXT_RMDIR(handle, smb_fname) \
return result;
}
+static int vfswrap_mkdirat(vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ mode_t mode)
+{
+ int result;
+ const char *path = smb_fname->base_name;
+ char *parent = NULL;
+
+ START_PROFILE(syscall_mkdirat);
+
+ SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
+
+ if (lp_inherit_acls(SNUM(handle->conn))
+ && parent_dirname(talloc_tos(), path, &parent, NULL)
+ && directory_has_default_acl(handle->conn, parent)) {
+ mode = (0777 & lp_directory_mask(SNUM(handle->conn)));
+ }
+
+ TALLOC_FREE(parent);
+
+ result = mkdirat(dirfsp->fh->fd, path, mode);
+
+ END_PROFILE(syscall_mkdirat);
+ return result;
+}
+
static int vfswrap_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
.telldir_fn = vfswrap_telldir,
.rewind_dir_fn = vfswrap_rewinddir,
.mkdir_fn = vfswrap_mkdir,
+ .mkdirat_fn = vfswrap_mkdirat,
.rmdir_fn = vfswrap_rmdir,
.closedir_fn = vfswrap_closedir,
return -1;
}
+int vfs_not_implemented_mkdirat(vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ mode_t mode)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
int vfs_not_implemented_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
.telldir_fn = vfs_not_implemented_telldir,
.rewind_dir_fn = vfs_not_implemented_rewind_dir,
.mkdir_fn = vfs_not_implemented_mkdir,
+ .mkdirat_fn = vfs_not_implemented_mkdirat,
.rmdir_fn = vfs_not_implemented_rmdir,
.closedir_fn = vfs_not_implemented_closedir,
return handle->fns->mkdir_fn(handle, smb_fname, mode);
}
+int smb_vfs_call_mkdirat(struct vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ mode_t mode)
+{
+ VFS_FIND(mkdirat);
+ return handle->fns->mkdirat_fn(handle,
+ dirfsp,
+ smb_fname,
+ mode);
+}
+
int smb_vfs_call_rmdir(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{