Currently identical to SMB_VFS_SYMLINK().
Next, add to all VFS modules that implement
symlink and eventually remove symlink.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
return -1;
}
+static int skel_symlinkat(vfs_handle_struct *handle,
+ const char *link_contents,
+ struct files_struct *dirfsp,
+ const struct smb_filename *new_smb_fname)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
static int skel_vfs_readlinkat(vfs_handle_struct *handle,
files_struct *dirfsp,
const struct smb_filename *smb_fname,
.linux_setlease_fn = skel_linux_setlease,
.getlock_fn = skel_getlock,
.symlink_fn = skel_symlink,
+ .symlinkat_fn = skel_symlinkat,
.readlinkat_fn = skel_vfs_readlinkat,
.linkat_fn = skel_linkat,
.mknodat_fn = skel_mknodat,
return SMB_VFS_NEXT_SYMLINK(handle, link_contents, new_smb_fname);
}
+static int skel_symlinkat(vfs_handle_struct *handle,
+ const char *link_contents,
+ struct files_struct *dirfsp,
+ const struct smb_filename *new_smb_fname)
+{
+ return SMB_VFS_NEXT_SYMLINKAT(handle,
+ link_contents,
+ dirfsp,
+ new_smb_fname);
+}
+
static int skel_vfs_readlinkat(vfs_handle_struct *handle,
files_struct *dirfsp,
const struct smb_filename *smb_fname,
.linux_setlease_fn = skel_linux_setlease,
.getlock_fn = skel_getlock,
.symlink_fn = skel_symlink,
+ .symlinkat_fn = skel_symlinkat,
.readlinkat_fn = skel_vfs_readlinkat,
.linkat_fn = skel_linkat,
.mknodat_fn = skel_mknodat,
SMBPROFILE_STATS_BASIC(syscall_fcntl_getlock) \
SMBPROFILE_STATS_BASIC(syscall_readlinkat) \
SMBPROFILE_STATS_BASIC(syscall_symlink) \
+ SMBPROFILE_STATS_BASIC(syscall_symlinkat) \
SMBPROFILE_STATS_BASIC(syscall_linkat) \
SMBPROFILE_STATS_BASIC(syscall_mknodat) \
SMBPROFILE_STATS_BASIC(syscall_realpath) \
/* Version 42 - Move SMB_VFS_LINK -> SMB_VFS_LINKAT. */
/* Version 42 - Move SMB_VFS_MKNOD -> SMB_VFS_MKDNODAT. */
/* Version 42 - Move SMB_VFS_READLINK -> SMB_VFS_READLINKAT. */
+/* Version 42 - Add SMB_VFS_SYMLINKAT. */
#define SMB_VFS_INTERFACE_VERSION 42
int (*symlink_fn)(struct vfs_handle_struct *handle,
const char *link_contents,
const struct smb_filename *new_smb_fname);
+ int (*symlinkat_fn)(struct vfs_handle_struct *handle,
+ const char *link_contents,
+ struct files_struct *dirfsp,
+ const struct smb_filename *new_smb_fname);
int (*readlinkat_fn)(struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
const struct smb_filename *smb_fname,
int smb_vfs_call_symlink(struct vfs_handle_struct *handle,
const char *link_contents,
const struct smb_filename *new_smb_fname);
+int smb_vfs_call_symlinkat(struct vfs_handle_struct *handle,
+ const char *link_contents,
+ struct files_struct *dirfsp,
+ const struct smb_filename *new_smb_fname);
int smb_vfs_call_readlinkat(struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
const struct smb_filename *smb_fname,
int vfs_not_implemented_symlink(vfs_handle_struct *handle,
const char *link_contents,
const struct smb_filename *new_smb_fname);
+int vfs_not_implemented_symlinkat(vfs_handle_struct *handle,
+ const char *link_contents,
+ struct files_struct *dirfsp,
+ const struct smb_filename *new_smb_fname);
int vfs_not_implemented_vfs_readlinkat(vfs_handle_struct *handle,
struct files_struct *dirfsp,
const struct smb_filename *smb_fname,
#define SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath) \
smb_vfs_call_symlink((handle)->next, (oldpath), (newpath))
+#define SMB_VFS_SYMLINKAT(conn, oldpath, dirfsp, newpath) \
+ smb_vfs_call_symlinkat((conn)->vfs_handles, (oldpath), (dirfsp), (newpath))
+#define SMB_VFS_NEXT_SYMLINKAT(handle, oldpath, dirfsp, newpath) \
+ smb_vfs_call_symlinkat((handle)->next, (oldpath), (dirfsp), (newpath))
+
#define SMB_VFS_READLINKAT(conn, dirfsp, smb_fname, buf, bufsiz) \
smb_vfs_call_readlinkat((conn)->vfs_handles, (dirfsp), (smb_fname), (buf), (bufsiz))
#define SMB_VFS_NEXT_READLINKAT(handle, dirfsp, smb_fname, buf, bufsiz) \
return result;
}
+static int vfswrap_symlinkat(vfs_handle_struct *handle,
+ const char *link_target,
+ struct files_struct *dirfsp,
+ const struct smb_filename *new_smb_fname)
+{
+ int result;
+
+ START_PROFILE(syscall_symlinkat);
+
+ SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
+
+ result = symlinkat(link_target,
+ dirfsp->fh->fd,
+ new_smb_fname->base_name);
+ END_PROFILE(syscall_symlinkat);
+ return result;
+}
+
static int vfswrap_readlinkat(vfs_handle_struct *handle,
files_struct *dirfsp,
const struct smb_filename *smb_fname,
.linux_setlease_fn = vfswrap_linux_setlease,
.getlock_fn = vfswrap_getlock,
.symlink_fn = vfswrap_symlink,
+ .symlinkat_fn = vfswrap_symlinkat,
.readlinkat_fn = vfswrap_readlinkat,
.linkat_fn = vfswrap_linkat,
.mknodat_fn = vfswrap_mknodat,
return -1;
}
+int vfs_not_implemented_symlinkat(vfs_handle_struct *handle,
+ const char *link_contents,
+ struct files_struct *dirfsp,
+ const struct smb_filename *new_smb_fname)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
int vfs_not_implemented_vfs_readlinkat(vfs_handle_struct *handle,
files_struct *dirfsp,
const struct smb_filename *smb_fname,
.linux_setlease_fn = vfs_not_implemented_linux_setlease,
.getlock_fn = vfs_not_implemented_getlock,
.symlink_fn = vfs_not_implemented_symlink,
+ .symlinkat_fn = vfs_not_implemented_symlinkat,
.readlinkat_fn = vfs_not_implemented_vfs_readlinkat,
.linkat_fn = vfs_not_implemented_linkat,
.mknodat_fn = vfs_not_implemented_mknodat,
return handle->fns->symlink_fn(handle, link_target, new_smb_fname);
}
-int smb_vfs_call_readlinkat(struct vfs_handle_struct *handle,
+int smb_vfs_call_symlinkat(struct vfs_handle_struct *handle,
+ const char *link_target,
struct files_struct *dirfsp,
+ const struct smb_filename *new_smb_fname)
+{
+ VFS_FIND(symlinkat);
+ return handle->fns->symlinkat_fn(handle,
+ link_target,
+ dirfsp,
+ new_smb_fname);
+}
+
+int smb_vfs_call_readlinkat(struct vfs_handle_struct *handle,
+ files_struct *dirfsp,
const struct smb_filename *smb_fname,
char *buf,
size_t bufsiz)