Currently identical to SMB_VFS_UNLINK().
Next, add to all VFS modules that implement
unlink and eventually remove unlink.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
return -1;
}
+static int skel_unlinkat(vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ int flags)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
static int skel_chmod(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode)
.lstat_fn = skel_lstat,
.get_alloc_size_fn = skel_get_alloc_size,
.unlink_fn = skel_unlink,
+ .unlinkat_fn = skel_unlinkat,
.chmod_fn = skel_chmod,
.fchmod_fn = skel_fchmod,
.chown_fn = skel_chown,
return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
}
+static int skel_unlinkat(vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ int flags)
+{
+ return SMB_VFS_NEXT_UNLINKAT(handle,
+ dirfsp,
+ smb_fname,
+ flags);
+}
+
static int skel_chmod(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode)
.lstat_fn = skel_lstat,
.get_alloc_size_fn = skel_get_alloc_size,
.unlink_fn = skel_unlink,
+ .unlinkat_fn = skel_unlinkat,
.chmod_fn = skel_chmod,
.fchmod_fn = skel_fchmod,
.chown_fn = skel_chown,
SMBPROFILE_STATS_BASIC(syscall_lstat) \
SMBPROFILE_STATS_BASIC(syscall_get_alloc_size) \
SMBPROFILE_STATS_BASIC(syscall_unlink) \
+ SMBPROFILE_STATS_BASIC(syscall_unlinkat) \
SMBPROFILE_STATS_BASIC(syscall_chmod) \
SMBPROFILE_STATS_BASIC(syscall_fchmod) \
SMBPROFILE_STATS_BASIC(syscall_chown) \
/* Version 42 - Move change_to_user() -> change_to_user_and_service() */
/* Version 42 - Move change_to_user_by_fsp() -> change_to_user_and_service_by_fsp() */
/* Version 42 - Move [un]become_user*() -> [un]become_user_without_service*() */
+/* Version 42 - Add SMB_VFS_UNLINKAT. */
#define SMB_VFS_INTERFACE_VERSION 42
uint64_t (*get_alloc_size_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_STAT *sbuf);
int (*unlink_fn)(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname);
+ int (*unlinkat_fn)(struct vfs_handle_struct *handle,
+ struct files_struct *srcdir_fsp,
+ const struct smb_filename *smb_fname,
+ int flags);
int (*chmod_fn)(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode);
const SMB_STRUCT_STAT *sbuf);
int smb_vfs_call_unlink(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname);
+int smb_vfs_call_unlinkat(struct vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ int flags);
int smb_vfs_call_chmod(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode);
const SMB_STRUCT_STAT *sbuf);
int vfs_not_implemented_unlink(vfs_handle_struct *handle,
const struct smb_filename *smb_fname);
+int vfs_not_implemented_unlinkat(vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ int flags);
int vfs_not_implemented_chmod(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode);
#define SMB_VFS_NEXT_UNLINK(handle, path) \
smb_vfs_call_unlink((handle)->next, (path))
+#define SMB_VFS_UNLINKAT(conn, dirfsp, path, flags) \
+ smb_vfs_call_unlinkat((conn)->vfs_handles, (dirfsp), (path), (flags))
+#define SMB_VFS_NEXT_UNLINKAT(handle, dirfsp, path, flags) \
+ smb_vfs_call_unlinkat((handle)->next, (dirfsp), (path), (flags))
+
#define SMB_VFS_CHMOD(conn, smb_fname, mode) \
smb_vfs_call_chmod((conn)->vfs_handles, (smb_fname), (mode))
#define SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode) \
return result;
}
+static int vfswrap_unlinkat(vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ int flags)
+{
+ int result = -1;
+
+ START_PROFILE(syscall_unlinkat);
+
+ SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
+
+ if (smb_fname->stream_name) {
+ errno = ENOENT;
+ goto out;
+ }
+ result = unlinkat(dirfsp->fh->fd,
+ smb_fname->base_name,
+ flags);
+
+ out:
+ END_PROFILE(syscall_unlinkat);
+ return result;
+}
+
static int vfswrap_chmod(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode)
.lstat_fn = vfswrap_lstat,
.get_alloc_size_fn = vfswrap_get_alloc_size,
.unlink_fn = vfswrap_unlink,
+ .unlinkat_fn = vfswrap_unlinkat,
.chmod_fn = vfswrap_chmod,
.fchmod_fn = vfswrap_fchmod,
.chown_fn = vfswrap_chown,
return -1;
}
+int vfs_not_implemented_unlinkat(vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ int flags)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
int vfs_not_implemented_chmod(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode)
.lstat_fn = vfs_not_implemented_lstat,
.get_alloc_size_fn = vfs_not_implemented_get_alloc_size,
.unlink_fn = vfs_not_implemented_unlink,
+ .unlinkat_fn = vfs_not_implemented_unlinkat,
.chmod_fn = vfs_not_implemented_chmod,
.fchmod_fn = vfs_not_implemented_fchmod,
.chown_fn = vfs_not_implemented_chown,
return handle->fns->unlink_fn(handle, smb_fname);
}
+int smb_vfs_call_unlinkat(struct vfs_handle_struct *handle,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ int flags)
+{
+ VFS_FIND(unlinkat);
+ return handle->fns->unlinkat_fn(handle,
+ dirfsp,
+ smb_fname,
+ flags);
+}
+
int smb_vfs_call_chmod(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode)