]> git.samba.org - samba.git/commitdiff
s3: VFS: Add SMB_VFS_READLINKAT().
authorJeremy Allison <jra@samba.org>
Thu, 22 Aug 2019 20:42:26 +0000 (13:42 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 23 Aug 2019 18:49:35 +0000 (18:49 +0000)
Currently identical to SMB_VFS_READLINK().

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

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 48d8e3df7f6562701c576ae41ff6af10e3cd25b8..603ddd46446f7f80094ba2ca8d5513548062a0ac 100644 (file)
@@ -473,6 +473,16 @@ static int skel_vfs_readlink(vfs_handle_struct *handle,
        return -1;
 }
 
+static int skel_vfs_readlinkat(vfs_handle_struct *handle,
+                       files_struct *dirfsp,
+                       const struct smb_filename *smb_fname,
+                       char *buf,
+                       size_t bufsiz)
+{
+       errno = ENOSYS;
+       return -1;
+}
+
 static int skel_linkat(vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *old_smb_fname,
@@ -1090,6 +1100,7 @@ static struct vfs_fn_pointers skel_opaque_fns = {
        .getlock_fn = skel_getlock,
        .symlink_fn = skel_symlink,
        .readlink_fn = skel_vfs_readlink,
+       .readlinkat_fn = skel_vfs_readlinkat,
        .linkat_fn = skel_linkat,
        .mknodat_fn = skel_mknodat,
        .realpath_fn = skel_realpath,
index ab43118ce37d43e4c96cda06a5c54b7576f17e7c..cb240791b663eca66b3a7a2124600bb60b063536 100644 (file)
@@ -571,6 +571,19 @@ static int skel_vfs_readlink(vfs_handle_struct *handle,
        return SMB_VFS_NEXT_READLINK(handle, smb_fname, buf, bufsiz);
 }
 
+static int skel_vfs_readlinkat(vfs_handle_struct *handle,
+                       files_struct *dirfsp,
+                       const struct smb_filename *smb_fname,
+                       char *buf,
+                       size_t bufsiz)
+{
+       return SMB_VFS_NEXT_READLINKAT(handle,
+                       dirfsp,
+                       smb_fname,
+                       buf,
+                       bufsiz);
+}
+
 static int skel_linkat(vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *old_smb_fname,
@@ -1365,6 +1378,7 @@ static struct vfs_fn_pointers skel_transparent_fns = {
        .getlock_fn = skel_getlock,
        .symlink_fn = skel_symlink,
        .readlink_fn = skel_vfs_readlink,
+       .readlinkat_fn = skel_vfs_readlinkat,
        .linkat_fn = skel_linkat,
        .mknodat_fn = skel_mknodat,
        .realpath_fn = skel_realpath,
index 048ce8504cd1ccdef183da87c4bf705365b3ccba..d4717f5286b06beaddd9025b8b6b134fb1952e47 100644 (file)
@@ -83,6 +83,7 @@ struct tevent_context;
        SMBPROFILE_STATS_BASIC(syscall_linux_setlease) \
        SMBPROFILE_STATS_BASIC(syscall_fcntl_getlock) \
        SMBPROFILE_STATS_BASIC(syscall_readlink) \
+       SMBPROFILE_STATS_BASIC(syscall_readlinkat) \
        SMBPROFILE_STATS_BASIC(syscall_symlink) \
        SMBPROFILE_STATS_BASIC(syscall_linkat) \
        SMBPROFILE_STATS_BASIC(syscall_mknodat) \
index 3463b574e5bac540fa8bc496e9f9e3dd45a23db4..70bf50a51192773dd070ac71fe811264d620306d 100644 (file)
 /* Version 42 - Move SMB_VFS_RENAME -> SMB_VFS_RENAMEAT */
 /* Version 42 - Move SMB_VFS_LINK -> SMB_VFS_LINKAT. */
 /* Version 42 - Move SMB_VFS_MKNOD -> SMB_VFS_MKDNODAT. */
+/* Version 42 - Add SMB_VFS_READLINKAT. */
 
 #define SMB_VFS_INTERFACE_VERSION 42
 
@@ -801,6 +802,11 @@ struct vfs_fn_pointers {
                                const struct smb_filename *smb_fname,
                                char *buf,
                                size_t bufsiz);
+       int (*readlinkat_fn)(struct vfs_handle_struct *handle,
+                               struct files_struct *dirfsp,
+                               const struct smb_filename *smb_fname,
+                               char *buf,
+                               size_t bufsiz);
        int (*linkat_fn)(struct vfs_handle_struct *handle,
                                struct files_struct *srcfsp,
                                const struct smb_filename *old_smb_fname,
@@ -1334,6 +1340,11 @@ int smb_vfs_call_readlink(struct vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname,
                        char *buf,
                        size_t bufsiz);
+int smb_vfs_call_readlinkat(struct vfs_handle_struct *handle,
+                       struct files_struct *dirfsp,
+                       const struct smb_filename *smb_fname,
+                       char *buf,
+                       size_t bufsiz);
 int smb_vfs_call_linkat(struct vfs_handle_struct *handle,
                        struct files_struct *srcfsp,
                        const struct smb_filename *old_smb_fname,
@@ -1764,6 +1775,11 @@ int vfs_not_implemented_vfs_readlink(vfs_handle_struct *handle,
                                     const struct smb_filename *smb_fname,
                                     char *buf,
                                     size_t bufsiz);
+int vfs_not_implemented_vfs_readlinkat(vfs_handle_struct *handle,
+                       struct files_struct *dirfsp,
+                       const struct smb_filename *smb_fname,
+                       char *buf,
+                       size_t bufsiz);
 int vfs_not_implemented_linkat(vfs_handle_struct *handle,
                        struct files_struct *srcfsp,
                        const struct smb_filename *old_smb_fname,
index 0f317ecbe311b33b555a0afb18feb696bcbd486a..61a45240c1e068421e7a9b61fe2e38ffdd2e0484 100644 (file)
 #define SMB_VFS_NEXT_READLINK(handle, smb_fname, buf, bufsiz) \
        smb_vfs_call_readlink((handle)->next, (smb_fname), (buf), (bufsiz))
 
+#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) \
+       smb_vfs_call_readlinkat((handle)->next, (dirfsp), (smb_fname), (buf), (bufsiz))
+
 #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) \
index 51928fd0b04a1f32233021ace2f902762bcb4223..70e7b31e5cbad6494a71c3067163e86e4aceac63 100644 (file)
@@ -2663,6 +2663,27 @@ static int vfswrap_readlink(vfs_handle_struct *handle,
        return result;
 }
 
+static int vfswrap_readlinkat(vfs_handle_struct *handle,
+                       files_struct *dirfsp,
+                       const struct smb_filename *smb_fname,
+                       char *buf,
+                       size_t bufsiz)
+{
+       int result;
+
+       START_PROFILE(syscall_readlinkat);
+
+       SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
+
+       result = readlinkat(dirfsp->fh->fd,
+                       smb_fname->base_name,
+                       buf,
+                       bufsiz);
+
+       END_PROFILE(syscall_readlinkat);
+       return result;
+}
+
 static int vfswrap_linkat(vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *old_smb_fname,
@@ -3487,6 +3508,7 @@ static struct vfs_fn_pointers vfs_default_fns = {
        .getlock_fn = vfswrap_getlock,
        .symlink_fn = vfswrap_symlink,
        .readlink_fn = vfswrap_readlink,
+       .readlinkat_fn = vfswrap_readlinkat,
        .linkat_fn = vfswrap_linkat,
        .mknodat_fn = vfswrap_mknodat,
        .realpath_fn = vfswrap_realpath,
index 02d36ecbaa480462c889266fcb2941284b7882de..d8e92849aa4b20b647b4ac6207e2577d2890e460 100644 (file)
@@ -471,6 +471,16 @@ int vfs_not_implemented_vfs_readlink(vfs_handle_struct *handle,
        return -1;
 }
 
+int vfs_not_implemented_vfs_readlinkat(vfs_handle_struct *handle,
+                       files_struct *dirfsp,
+                       const struct smb_filename *smb_fname,
+                       char *buf,
+                       size_t bufsiz)
+{
+       errno = ENOSYS;
+       return -1;
+}
+
 int vfs_not_implemented_linkat(vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *old_smb_fname,
@@ -1094,6 +1104,7 @@ static struct vfs_fn_pointers vfs_not_implemented_fns = {
        .getlock_fn = vfs_not_implemented_getlock,
        .symlink_fn = vfs_not_implemented_symlink,
        .readlink_fn = vfs_not_implemented_vfs_readlink,
+       .readlinkat_fn = vfs_not_implemented_vfs_readlinkat,
        .linkat_fn = vfs_not_implemented_linkat,
        .mknodat_fn = vfs_not_implemented_mknodat,
        .realpath_fn = vfs_not_implemented_realpath,
index 6f348da2fe81c4980b372017390b92fcfa051d62..27bb294be7ad9877967129557383dec77c7df1c6 100644 (file)
@@ -2210,6 +2210,20 @@ int smb_vfs_call_readlink(struct vfs_handle_struct *handle,
        return handle->fns->readlink_fn(handle, smb_fname, buf, bufsiz);
 }
 
+int smb_vfs_call_readlinkat(struct vfs_handle_struct *handle,
+                       struct files_struct *dirfsp,
+                       const struct smb_filename *smb_fname,
+                       char *buf,
+                       size_t bufsiz)
+{
+       VFS_FIND(readlinkat);
+       return handle->fns->readlinkat_fn(handle,
+                               dirfsp,
+                               smb_fname,
+                               buf,
+                               bufsiz);
+}
+
 int smb_vfs_call_linkat(struct vfs_handle_struct *handle,
                        struct files_struct *srcfsp,
                        const struct smb_filename *old_smb_fname,