diff options
author | Jeremy Allison <jra@samba.org> | 2019-08-22 14:28:26 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-08-23 18:49:36 +0000 |
commit | eef38b05092771f496f6614456a797848da474aa (patch) | |
tree | 7fd4ca0a54c1cad71199da2169a4c3d8181534c5 /source3/modules/vfs_snapper.c | |
parent | 06609f3ada9a4c8fe830e8b01d4ada2dcc640523 (diff) | |
download | samba-eef38b05092771f496f6614456a797848da474aa.tar.gz |
s3: VFS: vfs_snapper. Implement readlinkat().
Currently identical to readlink().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Diffstat (limited to 'source3/modules/vfs_snapper.c')
-rw-r--r-- | source3/modules/vfs_snapper.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c index cb451ebdcd2..ce0993806c7 100644 --- a/source3/modules/vfs_snapper.c +++ b/source3/modules/vfs_snapper.c @@ -2381,6 +2381,57 @@ static int snapper_gmt_readlink(vfs_handle_struct *handle, return ret; } +static int snapper_gmt_readlinkat(vfs_handle_struct *handle, + files_struct *dirfsp, + const struct smb_filename *smb_fname, + char *buf, + size_t bufsiz) +{ + time_t timestamp = 0; + char *stripped = NULL; + int ret; + int saved_errno = 0; + struct smb_filename *conv = NULL; + + if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, + smb_fname->base_name, + ×tamp, &stripped)) { + return -1; + } + if (timestamp == 0) { + return SMB_VFS_NEXT_READLINKAT(handle, + dirfsp, + smb_fname, + buf, + bufsiz); + } + conv = cp_smb_filename(talloc_tos(), smb_fname); + if (conv == NULL) { + TALLOC_FREE(stripped); + errno = ENOMEM; + return -1; + } + conv->base_name = snapper_gmt_convert(conv, handle, + stripped, timestamp); + TALLOC_FREE(stripped); + if (conv->base_name == NULL) { + return -1; + } + ret = SMB_VFS_NEXT_READLINKAT(handle, + dirfsp, + conv, + buf, + bufsiz); + if (ret == -1) { + saved_errno = errno; + } + TALLOC_FREE(conv); + if (saved_errno != 0) { + errno = saved_errno; + } + return ret; +} + static int snapper_gmt_mknodat(vfs_handle_struct *handle, files_struct *dirfsp, const struct smb_filename *smb_fname, @@ -2886,6 +2937,7 @@ static struct vfs_fn_pointers snapper_fns = { .chdir_fn = snapper_gmt_chdir, .ntimes_fn = snapper_gmt_ntimes, .readlink_fn = snapper_gmt_readlink, + .readlinkat_fn = snapper_gmt_readlinkat, .mknodat_fn = snapper_gmt_mknodat, .realpath_fn = snapper_gmt_realpath, .get_nt_acl_fn = snapper_gmt_get_nt_acl, |