flags);
}
-static int snapper_gmt_stat(vfs_handle_struct *handle,
- struct smb_filename *smb_fname)
+static int snapper_gmt_fstatat(struct vfs_handle_struct *handle,
+ const struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname,
+ SMB_STRUCT_STAT *sbuf,
+ int flags)
{
- time_t timestamp;
- char *stripped, *tmp;
- int ret, saved_errno;
+ struct smb_filename *tmp_fname = NULL;
+ int ret;
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle,
- smb_fname,
- ×tamp, &stripped)) {
- return -1;
- }
- if (timestamp == 0) {
- return SMB_VFS_NEXT_STAT(handle, smb_fname);
+ if (smb_fname->twrp == 0) {
+ return SMB_VFS_NEXT_FSTATAT(
+ handle, dirfsp, smb_fname, sbuf, flags);
}
- tmp = smb_fname->base_name;
- smb_fname->base_name = snapper_gmt_convert(talloc_tos(), handle,
- stripped, timestamp);
- TALLOC_FREE(stripped);
+ tmp_fname = cp_smb_filename(talloc_tos(), smb_fname);
+ if (tmp_fname == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
- if (smb_fname->base_name == NULL) {
- smb_fname->base_name = tmp;
+ tmp_fname->base_name = snapper_gmt_convert(tmp_fname,
+ handle,
+ smb_fname->base_name,
+ smb_fname->twrp);
+ if (tmp_fname->base_name == NULL) {
+ TALLOC_FREE(tmp_fname);
+ errno = ENOMEM;
return -1;
}
- ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
- saved_errno = errno;
+ ret = SMB_VFS_NEXT_FSTATAT(handle, dirfsp, tmp_fname, sbuf, flags);
- TALLOC_FREE(smb_fname->base_name);
- smb_fname->base_name = tmp;
+ {
+ int err = errno;
+ TALLOC_FREE(tmp_fname);
+ errno = err;
+ }
- errno = saved_errno;
return ret;
}
+static int snapper_gmt_stat(vfs_handle_struct *handle,
+ struct smb_filename *smb_fname)
+{
+ return snapper_gmt_fstatat(
+ handle, handle->conn->cwd_fsp, smb_fname, &smb_fname->st, 0);
+}
+
static int snapper_gmt_lstat(vfs_handle_struct *handle,
struct smb_filename *smb_fname)
{
- time_t timestamp;
- char *stripped, *tmp;
- int ret, saved_errno;
-
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle,
- smb_fname,
- ×tamp, &stripped)) {
- return -1;
- }
- if (timestamp == 0) {
- return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
- }
-
- tmp = smb_fname->base_name;
- smb_fname->base_name = snapper_gmt_convert(talloc_tos(), handle,
- stripped, timestamp);
- TALLOC_FREE(stripped);
-
- if (smb_fname->base_name == NULL) {
- smb_fname->base_name = tmp;
- return -1;
- }
-
- ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
- saved_errno = errno;
-
- TALLOC_FREE(smb_fname->base_name);
- smb_fname->base_name = tmp;
-
- errno = saved_errno;
- return ret;
+ return snapper_gmt_fstatat(handle,
+ handle->conn->cwd_fsp,
+ smb_fname,
+ &smb_fname->st,
+ AT_SYMLINK_NOFOLLOW);
}
static int snapper_gmt_openat(struct vfs_handle_struct *handle,
.symlinkat_fn = snapper_gmt_symlinkat,
.stat_fn = snapper_gmt_stat,
.lstat_fn = snapper_gmt_lstat,
+ .fstatat_fn = snapper_gmt_fstatat,
.openat_fn = snapper_gmt_openat,
.unlinkat_fn = snapper_gmt_unlinkat,
.fchmod_fn = snapper_gmt_fchmod,