}
static int shadow_copy2_mknod(vfs_handle_struct *handle,
- const char *fname, mode_t mode, SMB_DEV_T dev)
+ const struct smb_filename *smb_fname,
+ mode_t mode,
+ SMB_DEV_T dev)
{
time_t timestamp = 0;
char *stripped = NULL;
int saved_errno = 0;
int ret;
- char *conv;
+ struct smb_filename *conv = NULL;
- if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
+ smb_fname->base_name,
×tamp, &stripped)) {
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_MKNOD(handle, fname, mode, dev);
+ return SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev);
}
- conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
- TALLOC_FREE(stripped);
+ conv = cp_smb_filename(talloc_tos(), smb_fname);
if (conv == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+ conv->base_name = shadow_copy2_convert(
+ conv, handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv->base_name == NULL) {
return -1;
}
ret = SMB_VFS_NEXT_MKNOD(handle, conv, mode, dev);
return ret;
}
-static int shadow_copy2_chflags(vfs_handle_struct *handle, const char *fname,
+static int shadow_copy2_chflags(vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
unsigned int flags)
{
time_t timestamp = 0;
int saved_errno = 0;
int ret;
char *conv;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
+ if (!shadow_copy2_strip_snapshot(talloc_tos(),
+ handle,
+ smb_fname->base_name,
+ ×tamp,
+ &stripped)) {
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_CHFLAGS(handle, fname, flags);
+ return SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
}
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_CHFLAGS(handle, conv, flags);
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
+ if (conv_smb_fname == NULL) {
+ TALLOC_FREE(conv);
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
if (ret == -1) {
saved_errno = errno;
}
+ TALLOC_FREE(conv_smb_fname);
TALLOC_FREE(conv);
if (saved_errno != 0) {
errno = saved_errno;
}
static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle,
- const char *fname, const char *aname,
- void *value, size_t size)
+ const struct smb_filename *smb_fname,
+ const char *aname,
+ void *value,
+ size_t size)
{
time_t timestamp = 0;
char *stripped = NULL;
ssize_t ret;
int saved_errno = 0;
char *conv;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
+ if (!shadow_copy2_strip_snapshot(talloc_tos(),
+ handle,
+ smb_fname->base_name,
+ ×tamp,
+ &stripped)) {
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_GETXATTR(handle, fname, aname, value,
+ return SMB_VFS_NEXT_GETXATTR(handle, smb_fname, aname, value,
size);
}
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_GETXATTR(handle, conv, aname, value, size);
+
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
+ if (conv_smb_fname == NULL) {
+ TALLOC_FREE(conv);
+ return -1;
+ }
+
+ ret = SMB_VFS_NEXT_GETXATTR(handle, conv_smb_fname, aname, value, size);
if (ret == -1) {
saved_errno = errno;
}
+ TALLOC_FREE(conv_smb_fname);
TALLOC_FREE(conv);
if (saved_errno != 0) {
errno = saved_errno;
}
static ssize_t shadow_copy2_listxattr(struct vfs_handle_struct *handle,
- const char *fname,
+ const struct smb_filename *smb_fname,
char *list, size_t size)
{
time_t timestamp = 0;
ssize_t ret;
int saved_errno = 0;
char *conv;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
+ if (!shadow_copy2_strip_snapshot(talloc_tos(),
+ handle,
+ smb_fname->base_name,
+ ×tamp,
+ &stripped)) {
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_LISTXATTR(handle, fname, list, size);
+ return SMB_VFS_NEXT_LISTXATTR(handle, smb_fname, list, size);
}
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_LISTXATTR(handle, conv, list, size);
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
+ if (conv_smb_fname == NULL) {
+ TALLOC_FREE(conv);
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_LISTXATTR(handle, conv_smb_fname, list, size);
if (ret == -1) {
saved_errno = errno;
}
+ TALLOC_FREE(conv_smb_fname);
TALLOC_FREE(conv);
if (saved_errno != 0) {
errno = saved_errno;
}
static int shadow_copy2_removexattr(vfs_handle_struct *handle,
- const char *fname, const char *aname)
+ const struct smb_filename *smb_fname,
+ const char *aname)
{
time_t timestamp = 0;
char *stripped = NULL;
int saved_errno = 0;
int ret;
char *conv;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
+ if (!shadow_copy2_strip_snapshot(talloc_tos(),
+ handle,
+ smb_fname->base_name,
+ ×tamp,
+ &stripped)) {
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_REMOVEXATTR(handle, fname, aname);
+ return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, aname);
}
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_REMOVEXATTR(handle, conv, aname);
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
+ if (conv_smb_fname == NULL) {
+ TALLOC_FREE(conv);
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_REMOVEXATTR(handle, conv_smb_fname, aname);
if (ret == -1) {
saved_errno = errno;
}
+ TALLOC_FREE(conv_smb_fname);
TALLOC_FREE(conv);
if (saved_errno != 0) {
errno = saved_errno;
}
static int shadow_copy2_setxattr(struct vfs_handle_struct *handle,
- const char *fname,
+ const struct smb_filename *smb_fname,
const char *aname, const void *value,
size_t size, int flags)
{
ssize_t ret;
int saved_errno = 0;
char *conv;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
+ if (!shadow_copy2_strip_snapshot(talloc_tos(),
+ handle,
+ smb_fname->base_name,
+ ×tamp,
+ &stripped)) {
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_SETXATTR(handle, fname, aname, value, size,
- flags);
+ return SMB_VFS_NEXT_SETXATTR(handle, smb_fname,
+ aname, value, size, flags);
}
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_SETXATTR(handle, conv, aname, value, size, flags);
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
+ if (conv_smb_fname == NULL) {
+ TALLOC_FREE(conv);
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_SETXATTR(handle, conv_smb_fname,
+ aname, value, size, flags);
if (ret == -1) {
saved_errno = errno;
}
+ TALLOC_FREE(conv_smb_fname);
TALLOC_FREE(conv);
if (saved_errno != 0) {
errno = saved_errno;
}
static uint64_t shadow_copy2_disk_free(vfs_handle_struct *handle,
- const char *path, uint64_t *bsize,
- uint64_t *dfree, uint64_t *dsize)
+ const struct smb_filename *smb_fname,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
time_t timestamp = 0;
char *stripped = NULL;
- ssize_t ret;
int saved_errno = 0;
- char *conv;
+ char *conv = NULL;
+ struct smb_filename *conv_smb_fname = NULL;
+ uint64_t ret = (uint64_t)-1;
- if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, path,
- ×tamp, &stripped)) {
- return -1;
+ if (!shadow_copy2_strip_snapshot(talloc_tos(),
+ handle,
+ smb_fname->base_name,
+ ×tamp,
+ &stripped)) {
+ return (uint64_t)-1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_DISK_FREE(handle, path,
+ return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname,
bsize, dfree, dsize);
}
-
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
- return -1;
+ return (uint64_t)-1;
}
-
- ret = SMB_VFS_NEXT_DISK_FREE(handle, conv, bsize, dfree, dsize);
-
- if (ret == -1) {
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
+ if (conv_smb_fname == NULL) {
+ TALLOC_FREE(conv);
+ return (uint64_t)-1;
+ }
+ ret = SMB_VFS_NEXT_DISK_FREE(handle, conv_smb_fname,
+ bsize, dfree, dsize);
+ if (ret == (uint64_t)-1) {
saved_errno = errno;
}
TALLOC_FREE(conv);
+ TALLOC_FREE(conv_smb_fname);
if (saved_errno != 0) {
errno = saved_errno;
}
-
return ret;
}
-static int shadow_copy2_get_quota(vfs_handle_struct *handle, const char *path,
- enum SMB_QUOTA_TYPE qtype, unid_t id,
- SMB_DISK_QUOTA *dq)
+static int shadow_copy2_get_quota(vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *dq)
{
time_t timestamp = 0;
char *stripped = NULL;
int ret;
int saved_errno = 0;
char *conv;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, path, ×tamp,
- &stripped)) {
+ if (!shadow_copy2_strip_snapshot(talloc_tos(),
+ handle,
+ smb_fname->base_name,
+ ×tamp,
+ &stripped)) {
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq);
+ return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq);
}
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
if (conv == NULL) {
return -1;
}
-
- ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv, qtype, id, dq);
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
+ if (conv_smb_fname == NULL) {
+ TALLOC_FREE(conv);
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv_smb_fname, qtype, id, dq);
if (ret == -1) {
saved_errno = errno;
}
TALLOC_FREE(conv);
+ TALLOC_FREE(conv_smb_fname);
if (saved_errno != 0) {
errno = saved_errno;
}
.connectpath_fn = shadow_copy2_connectpath,
};
-NTSTATUS vfs_shadow_copy2_init(void);
-NTSTATUS vfs_shadow_copy2_init(void)
+NTSTATUS vfs_shadow_copy2_init(TALLOC_CTX *);
+NTSTATUS vfs_shadow_copy2_init(TALLOC_CTX *ctx)
{
return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
"shadow_copy2", &vfs_shadow_copy2_fns);