s3: VFS: Add SMB_VFS_SYMLINKAT().
authorJeremy Allison <jra@samba.org>
Fri, 30 Aug 2019 19:01:13 +0000 (12:01 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 3 Sep 2019 21:15:42 +0000 (21:15 +0000)
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>
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/smbprofile.h
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_default.c
source3/modules/vfs_not_implemented.c
source3/smbd/vfs.c

index ecc1c920c92bc051745dbd6d1a19f2e386147553..96661857b4caa04d43e84c61014b4e201de1ed0b 100644 (file)
@@ -464,6 +464,15 @@ static int skel_symlink(vfs_handle_struct *handle,
        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,
@@ -1090,6 +1099,7 @@ static struct vfs_fn_pointers skel_opaque_fns = {
        .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,
index 63cf4a4369a74d6c96dcaa6c270958138a4fe058..493c18a54173e7523f9eb6d781a699d2d3e46c33 100644 (file)
@@ -563,6 +563,17 @@ static int skel_symlink(vfs_handle_struct *handle,
        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,
@@ -1369,6 +1380,7 @@ static struct vfs_fn_pointers skel_transparent_fns = {
        .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,
index b6c9002973e423c2caea6473b05d1cfffb1ac0b0..51761e1104005f2b01b56f62ba4c9904b789aff5 100644 (file)
@@ -84,6 +84,7 @@ struct tevent_context;
        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) \
index 126ba32aa369aa93fb5fe2b0909267f67fa9648d..6970be1fb5e38047e65cdd4be1e1ba0be779bbe0 100644 (file)
 /* 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
 
@@ -798,6 +799,10 @@ struct vfs_fn_pointers {
        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,
@@ -1332,6 +1337,10 @@ bool smb_vfs_call_getlock(struct vfs_handle_struct *handle,
 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,
@@ -1763,6 +1772,10 @@ bool vfs_not_implemented_getlock(vfs_handle_struct *handle, files_struct *fsp,
 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,
index 247e9c286c7895f6b22f0dea61e09d54b68fbc83..f34becaadfa87b9086a55ae885b42285db18700f 100644 (file)
 #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) \
index 289ceab426638ccde755fdacf93a0d68d67181c9..4b4d7884694f99dacc6fe12b4b2ca6ddf7cb1a01 100644 (file)
@@ -2650,6 +2650,24 @@ static int vfswrap_symlink(vfs_handle_struct *handle,
        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,
@@ -3494,6 +3512,7 @@ static struct vfs_fn_pointers vfs_default_fns = {
        .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,
index 34b84287d07d3dcd9cd3f133d3d79873c15a850d..b8b5f77b36fae74375c451db94cf8d3680e20c78 100644 (file)
@@ -462,6 +462,15 @@ int vfs_not_implemented_symlink(vfs_handle_struct *handle,
        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,
@@ -1094,6 +1103,7 @@ static struct vfs_fn_pointers vfs_not_implemented_fns = {
        .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,
index 4366e2df0c4ff93eba7c7f9a02cb584babc3797b..e8fdb728ad5829ea21020c4644f5c6778dd23660 100644 (file)
@@ -2201,8 +2201,20 @@ int smb_vfs_call_symlink(struct vfs_handle_struct *handle,
        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)