]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: Add SMB_VFS_LINKAT().
authorJeremy Allison <jra@samba.org>
Mon, 12 Aug 2019 23:49:26 +0000 (16:49 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 20 Aug 2019 21:09:27 +0000 (21:09 +0000)
Currently identical to SMB_VFS_LINK().

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

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 40e16c342efa74ba3cc589250cc4160997cb27a4..351e0f690cb6738df3947bee9e6e7abacc3c84e5 100644 (file)
@@ -481,6 +481,17 @@ static int skel_link(vfs_handle_struct *handle,
        return -1;
 }
 
+static int skel_linkat(vfs_handle_struct *handle,
+                       files_struct *srcfsp,
+                       const struct smb_filename *old_smb_fname,
+                       files_struct *dstfsp,
+                       const struct smb_filename *new_smb_fname,
+                       int flags)
+{
+       errno = ENOSYS;
+       return -1;
+}
+
 static int skel_mknod(vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname,
                        mode_t mode,
@@ -1087,6 +1098,7 @@ static struct vfs_fn_pointers skel_opaque_fns = {
        .symlink_fn = skel_symlink,
        .readlink_fn = skel_vfs_readlink,
        .link_fn = skel_link,
+       .linkat_fn = skel_linkat,
        .mknod_fn = skel_mknod,
        .realpath_fn = skel_realpath,
        .chflags_fn = skel_chflags,
index b5d4437746383b0fcc89bf30668c812850309870..9b294ec6877a76e767ab4e9c711763a29cd86515 100644 (file)
@@ -578,6 +578,21 @@ static int skel_link(vfs_handle_struct *handle,
        return SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname);
 }
 
+static int skel_linkat(vfs_handle_struct *handle,
+                       files_struct *srcfsp,
+                       const struct smb_filename *old_smb_fname,
+                       files_struct *dstfsp,
+                       const struct smb_filename *new_smb_fname,
+                       int flags)
+{
+       return SMB_VFS_NEXT_LINKAT(handle,
+                       srcfsp,
+                       old_smb_fname,
+                       dstfsp,
+                       new_smb_fname,
+                       flags);
+}
+
 static int skel_mknod(vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname,
                        mode_t mode,
@@ -1353,6 +1368,7 @@ static struct vfs_fn_pointers skel_transparent_fns = {
        .symlink_fn = skel_symlink,
        .readlink_fn = skel_vfs_readlink,
        .link_fn = skel_link,
+       .linkat_fn = skel_linkat,
        .mknod_fn = skel_mknod,
        .realpath_fn = skel_realpath,
        .chflags_fn = skel_chflags,
index c479c76d508623c40757c02c19bd2a0c281b78a3..82021a22448f02d63ba623df642db46fee4e3097 100644 (file)
@@ -85,6 +85,7 @@ struct tevent_context;
        SMBPROFILE_STATS_BASIC(syscall_readlink) \
        SMBPROFILE_STATS_BASIC(syscall_symlink) \
        SMBPROFILE_STATS_BASIC(syscall_link) \
+       SMBPROFILE_STATS_BASIC(syscall_linkat) \
        SMBPROFILE_STATS_BASIC(syscall_mknod) \
        SMBPROFILE_STATS_BASIC(syscall_realpath) \
        SMBPROFILE_STATS_BASIC(syscall_get_quota) \
index dc407772079f437a69d88824bd045424902838b5..4b9c1ed949f97db823b0a11390de812e3b7a58c3 100644 (file)
 /* Version 42 - Remove share_access member from struct files_struct */
 /* Version 42 - Make "lease" a const* in create_file_fn */
 /* Version 42 - Move SMB_VFS_RENAME -> SMB_VFS_RENAMEAT */
+/* Version 42 - Add SMB_VFS_LINKAT. */
 
 #define SMB_VFS_INTERFACE_VERSION 42
 
@@ -802,6 +803,12 @@ struct vfs_fn_pointers {
        int (*link_fn)(struct vfs_handle_struct *handle,
                                const struct smb_filename *old_smb_fname,
                                const struct smb_filename *new_smb_fname);
+       int (*linkat_fn)(struct vfs_handle_struct *handle,
+                               struct files_struct *srcfsp,
+                               const struct smb_filename *old_smb_fname,
+                               struct files_struct *dstfsp,
+                               const struct smb_filename *new_smb_fname,
+                               int flags);
        int (*mknod_fn)(struct vfs_handle_struct *handle,
                                const struct smb_filename *smb_fname,
                                mode_t mode,
@@ -1331,6 +1338,12 @@ int smb_vfs_call_readlink(struct vfs_handle_struct *handle,
 int smb_vfs_call_link(struct vfs_handle_struct *handle,
                        const struct smb_filename *old_smb_fname,
                        const struct smb_filename *new_smb_fname);
+int smb_vfs_call_linkat(struct vfs_handle_struct *handle,
+                       struct files_struct *srcfsp,
+                       const struct smb_filename *old_smb_fname,
+                       struct files_struct *dstfsp,
+                       const struct smb_filename *new_smb_fname,
+                       int flags);
 int smb_vfs_call_mknod(struct vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname,
                        mode_t mode,
@@ -1757,6 +1770,12 @@ int vfs_not_implemented_vfs_readlink(vfs_handle_struct *handle,
 int vfs_not_implemented_link(vfs_handle_struct *handle,
                             const struct smb_filename *old_smb_fname,
                             const struct smb_filename *new_smb_fname);
+int vfs_not_implemented_linkat(vfs_handle_struct *handle,
+                       struct files_struct *srcfsp,
+                       const struct smb_filename *old_smb_fname,
+                       struct files_struct *dstfsp,
+                       const struct smb_filename *new_smb_fname,
+                       int flags);
 int vfs_not_implemented_mknod(vfs_handle_struct *handle,
                              const struct smb_filename *smb_fname,
                              mode_t mode,
index 7bbdc97a6c6af58159f3f92b29500d5d4b11e930..49edadb27867bbfe3d9105616d45dda25bb030ac 100644 (file)
 #define SMB_VFS_NEXT_LINK(handle, oldpath, newpath) \
        smb_vfs_call_link((handle)->next, (oldpath), (newpath))
 
+#define SMB_VFS_LINKAT(conn, srcfsp, oldpath, dstfsp, newpath, flags) \
+       smb_vfs_call_linkat((conn)->vfs_handles, (srcfsp), (oldpath), (dstfsp), (newpath), (flags))
+#define SMB_VFS_NEXT_LINKAT(handle, srcfsp, oldpath, dstfsp, newpath, flags) \
+       smb_vfs_call_linkat((handle)->next, (srcfsp), (oldpath), (dstfsp), (newpath), (flags))
+
 #define SMB_VFS_MKNOD(conn, smb_fname, mode, dev) \
        smb_vfs_call_mknod((conn)->vfs_handles, (smb_fname), (mode), (dev))
 #define SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev) \
index a2b6bf6e669b1c8a68ff7147f21e2e805332920d..997eb8871dc7b7e6acbed2903e2213fca2b452f4 100644 (file)
@@ -2675,6 +2675,30 @@ static int vfswrap_link(vfs_handle_struct *handle,
        return result;
 }
 
+static int vfswrap_linkat(vfs_handle_struct *handle,
+                       files_struct *srcfsp,
+                       const struct smb_filename *old_smb_fname,
+                       files_struct *dstfsp,
+                       const struct smb_filename *new_smb_fname,
+                       int flags)
+{
+       int result;
+
+       START_PROFILE(syscall_linkat);
+
+       SMB_ASSERT(srcfsp == srcfsp->conn->cwd_fsp);
+       SMB_ASSERT(dstfsp == dstfsp->conn->cwd_fsp);
+
+       result = linkat(srcfsp->fh->fd,
+                       old_smb_fname->base_name,
+                       dstfsp->fh->fd,
+                       new_smb_fname->base_name,
+                       flags);
+
+       END_PROFILE(syscall_linkat);
+       return result;
+}
+
 static int vfswrap_mknod(vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname,
                        mode_t mode,
@@ -3468,6 +3492,7 @@ static struct vfs_fn_pointers vfs_default_fns = {
        .symlink_fn = vfswrap_symlink,
        .readlink_fn = vfswrap_readlink,
        .link_fn = vfswrap_link,
+       .linkat_fn = vfswrap_linkat,
        .mknod_fn = vfswrap_mknod,
        .realpath_fn = vfswrap_realpath,
        .chflags_fn = vfswrap_chflags,
index 0a88f9e08cb03a2c18ad5762b5e9204b91e9f3c4..b5f56d7525fb908a45b44e4f668e7a1842183356 100644 (file)
@@ -479,6 +479,17 @@ int vfs_not_implemented_link(vfs_handle_struct *handle,
        return -1;
 }
 
+int vfs_not_implemented_linkat(vfs_handle_struct *handle,
+                       files_struct *srcfsp,
+                       const struct smb_filename *old_smb_fname,
+                       files_struct *dstfsp,
+                       const struct smb_filename *new_smb_fname,
+                       int flags)
+{
+       errno = ENOSYS;
+       return -1;
+}
+
 int vfs_not_implemented_mknod(vfs_handle_struct *handle,
                              const struct smb_filename *smb_fname,
                              mode_t mode,
@@ -1091,6 +1102,7 @@ static struct vfs_fn_pointers vfs_not_implemented_fns = {
        .symlink_fn = vfs_not_implemented_symlink,
        .readlink_fn = vfs_not_implemented_vfs_readlink,
        .link_fn = vfs_not_implemented_link,
+       .linkat_fn = vfs_not_implemented_linkat,
        .mknod_fn = vfs_not_implemented_mknod,
        .realpath_fn = vfs_not_implemented_realpath,
        .chflags_fn = vfs_not_implemented_chflags,
index ace5963359807b8460a83ae537a6519703cc244f..e0739ebe1075f116421cc0005756826071b4dec3 100644 (file)
@@ -2218,6 +2218,22 @@ int smb_vfs_call_link(struct vfs_handle_struct *handle,
        return handle->fns->link_fn(handle, old_smb_fname, new_smb_fname);
 }
 
+int smb_vfs_call_linkat(struct vfs_handle_struct *handle,
+                       struct files_struct *srcfsp,
+                       const struct smb_filename *old_smb_fname,
+                       struct files_struct *dstfsp,
+                       const struct smb_filename *new_smb_fname,
+                       int flags)
+{
+       VFS_FIND(linkat);
+       return handle->fns->linkat_fn(handle,
+                               srcfsp,
+                               old_smb_fname,
+                               dstfsp,
+                               new_smb_fname,
+                               flags);
+}
+
 int smb_vfs_call_mknod(struct vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname,
                        mode_t mode,