NTSTATUS status;
char *conf_name;
char *base_path;
- char *snap_path;
+ char *snap_path = NULL;
TALLOC_CTX *tmp_ctx;
tmp_ctx = talloc_new(mem_ctx);
uint32_t snap_id)
{
NTSTATUS status;
- DBusMessage *req_msg;
+ DBusMessage *req_msg = NULL;
DBusMessage *rsp_msg;
status = snapper_del_snap_pack(mem_ctx, conf_name, snap_id, &req_msg);
NTSTATUS status;
char *conf_name;
char *base_path;
- DBusMessage *req_msg;
+ DBusMessage *req_msg = NULL;
DBusMessage *rsp_msg;
uint32_t num_snaps;
struct snapper_snap *snaps;
char *q;
char *stripped;
size_t rest_len, dst_len;
+ ptrdiff_t len_before_gmt;
p = strstr_m(name, "@GMT-");
if (p == NULL) {
if ((p > name) && (p[-1] != '/')) {
goto no_snapshot;
}
+ len_before_gmt = p - name;
q = strptime(p, GMT_FORMAT, &tm);
if (q == NULL) {
goto no_snapshot;
if (timestamp == (time_t)-1) {
goto no_snapshot;
}
- if ((p == name) && (q[0] == '\0')) {
+ if (q[0] == '\0') {
+ /*
+ * The name consists of only the GMT token or the GMT
+ * token is at the end of the path. XP seems to send
+ * @GMT- at the end under certain circumstances even
+ * with a path prefix.
+ */
if (pstripped != NULL) {
- stripped = talloc_strdup(mem_ctx, "");
+ if (len_before_gmt > 0) {
+ /*
+ * There is a slash before
+ * the @GMT-. Remove it.
+ */
+ len_before_gmt -= 1;
+ }
+ stripped = talloc_strndup(mem_ctx, name,
+ len_before_gmt);
if (stripped == NULL) {
return false;
}
return true;
}
if (q[0] != '/') {
+ /*
+ * It is not a complete path component, i.e. the path
+ * component continues after the gmt-token.
+ */
goto no_snapshot;
}
q += 1;
rest_len = strlen(q);
- dst_len = (p-name) + rest_len;
+ dst_len = len_before_gmt + rest_len;
if (pstripped != NULL) {
stripped = talloc_array(mem_ctx, char, dst_len+1);
return false;
}
if (p > name) {
- memcpy(stripped, name, p-name);
+ memcpy(stripped, name, len_before_gmt);
}
if (rest_len > 0) {
- memcpy(stripped + (p-name), q, rest_len);
+ memcpy(stripped + len_before_gmt, q, rest_len);
}
stripped[dst_len] = '\0';
*pstripped = stripped;
char **snap_path_out)
{
NTSTATUS status;
- DBusMessage *req_msg;
+ DBusMessage *req_msg = NULL;
DBusMessage *rsp_msg;
uint32_t num_snaps;
struct snapper_snap *snaps;
}
if (num_snaps == 0) {
- DEBUG(4, ("no snapshots found with time: %lu\n", snaptime));
+ DEBUG(4, ("no snapshots found with time: %lu\n",
+ (unsigned long)snaptime));
status = NT_STATUS_INVALID_PARAMETER;
goto err_snap_array_free;
} else if (num_snaps > 0) {
DEBUG(4, ("got %u snapshots for single time %lu, using top\n",
- num_snaps, snaptime));
+ num_snaps, (unsigned long)snaptime));
}
status = snapper_snap_id_to_path(mem_ctx, base_path, snaps[0].id,
NTSTATUS status;
char *conf_name;
char *base_path;
- char *snap_path;
+ char *snap_path = NULL;
dconn = snapper_dbus_conn_create();
if (dconn == NULL) {
}
static DIR *snapper_gmt_opendir(vfs_handle_struct *handle,
- const char *fname,
+ const struct smb_filename *smb_fname,
const char *mask,
uint32_t attr)
{
DIR *ret;
int saved_errno;
char *conv;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
+ if (!snapper_gmt_strip_snapshot(talloc_tos(),
+ handle,
+ smb_fname->base_name,
+ ×tamp,
+ &stripped)) {
return NULL;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
+ return SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
}
conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return NULL;
}
- ret = SMB_VFS_NEXT_OPENDIR(handle, conv, mask, attr);
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
+ if (conv_smb_fname == NULL) {
+ TALLOC_FREE(conv);
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ ret = SMB_VFS_NEXT_OPENDIR(handle, conv_smb_fname, mask, attr);
saved_errno = errno;
TALLOC_FREE(conv);
+ TALLOC_FREE(conv_smb_fname);
errno = saved_errno;
return ret;
}
}
static int snapper_gmt_link(vfs_handle_struct *handle,
- const char *oldname, const char *newname)
+ const struct smb_filename *old_smb_fname,
+ const struct smb_filename *new_smb_fname)
{
- time_t timestamp_old, timestamp_new;
+ time_t timestamp_old = 0;
+ time_t timestamp_new = 0;
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, oldname,
- ×tamp_old, NULL)) {
+ if (!snapper_gmt_strip_snapshot(talloc_tos(),
+ handle,
+ old_smb_fname->base_name,
+ ×tamp_old,
+ NULL)) {
return -1;
}
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, newname,
- ×tamp_new, NULL)) {
+ if (!snapper_gmt_strip_snapshot(talloc_tos(),
+ handle,
+ new_smb_fname->base_name,
+ ×tamp_new,
+ NULL)) {
return -1;
}
if ((timestamp_old != 0) || (timestamp_new != 0)) {
errno = EROFS;
return -1;
}
- return SMB_VFS_NEXT_LINK(handle, oldname, newname);
+ return SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname);
}
static int snapper_gmt_stat(vfs_handle_struct *handle,
return ret;
}
-static int snapper_gmt_chmod(vfs_handle_struct *handle, const char *fname,
- mode_t mode)
+static int snapper_gmt_chmod(vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ mode_t mode)
{
time_t timestamp;
- char *stripped;
+ char *stripped = NULL;
int ret, saved_errno;
- char *conv;
-
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
+ char *conv = NULL;
+ struct smb_filename *conv_smb_fname = NULL;
+
+ if (!snapper_gmt_strip_snapshot(talloc_tos(),
+ handle,
+ smb_fname->base_name,
+ ×tamp,
+ &stripped)) {
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_CHMOD(handle, fname, mode);
+ TALLOC_FREE(stripped);
+ return SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode);
}
conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_CHMOD(handle, conv, mode);
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
+ if (conv_smb_fname == NULL) {
+ TALLOC_FREE(conv);
+ errno = ENOMEM;
+ return -1;
+ }
+
+ ret = SMB_VFS_NEXT_CHMOD(handle, conv_smb_fname, mode);
saved_errno = errno;
TALLOC_FREE(conv);
+ TALLOC_FREE(conv_smb_fname);
errno = saved_errno;
return ret;
}
-static int snapper_gmt_chown(vfs_handle_struct *handle, const char *fname,
- uid_t uid, gid_t gid)
+static int snapper_gmt_chown(vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ uid_t uid,
+ gid_t gid)
{
time_t timestamp;
- char *stripped;
+ char *stripped = NULL;
int ret, saved_errno;
- char *conv;
-
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
+ char *conv = NULL;
+ struct smb_filename *conv_smb_fname = NULL;
+
+ if (!snapper_gmt_strip_snapshot(talloc_tos(),
+ handle,
+ smb_fname->base_name,
+ ×tamp,
+ &stripped)) {
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_CHOWN(handle, fname, uid, gid);
+ TALLOC_FREE(stripped);
+ return SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
}
conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_CHOWN(handle, conv, uid, gid);
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
+ if (conv_smb_fname == NULL) {
+ TALLOC_FREE(conv);
+ errno = ENOMEM;
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_CHOWN(handle, conv_smb_fname, uid, gid);
saved_errno = errno;
TALLOC_FREE(conv);
+ TALLOC_FREE(conv_smb_fname);
errno = saved_errno;
return ret;
}
}
static int snapper_gmt_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;
- char *stripped;
- int ret, saved_errno;
- char *conv;
+ time_t timestamp = (time_t)0;
+ char *stripped = NULL;
+ int ret, saved_errno = 0;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
+ if (!snapper_gmt_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 = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
+ conv_smb_fname = cp_smb_filename(talloc_tos(), smb_fname);
+ if (conv_smb_fname == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+ conv_smb_fname->base_name = snapper_gmt_convert(conv_smb_fname, handle,
+ stripped, timestamp);
TALLOC_FREE(stripped);
- if (conv == NULL) {
+ if (conv_smb_fname->base_name == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_MKNOD(handle, conv, mode, dev);
- saved_errno = errno;
- TALLOC_FREE(conv);
- errno = saved_errno;
+ ret = SMB_VFS_NEXT_MKNOD(handle, conv_smb_fname, mode, dev);
+ if (ret == -1) {
+ saved_errno = errno;
+ }
+ TALLOC_FREE(conv_smb_fname);
+ if (saved_errno != 0) {
+ errno = saved_errno;
+ }
return ret;
}
smb_fname = synthetic_smb_fname(talloc_tos(),
conv,
NULL,
- NULL);
+ NULL,
+ fsp->fsp_name->flags);
TALLOC_FREE(conv);
if (smb_fname == NULL) {
return NT_STATUS_NO_MEMORY;
smb_fname = synthetic_smb_fname(talloc_tos(),
conv,
NULL,
- NULL);
+ NULL,
+ fname->flags);
TALLOC_FREE(conv);
if (smb_fname == NULL) {
return NT_STATUS_NO_MEMORY;
smb_fname = synthetic_smb_fname(talloc_tos(),
conv,
NULL,
- NULL);
+ NULL,
+ fname->flags);
TALLOC_FREE(conv);
if (smb_fname == NULL) {
errno = ENOMEM;
return ret;
}
-static int snapper_gmt_rmdir(vfs_handle_struct *handle, const char *fname)
+static int snapper_gmt_rmdir(vfs_handle_struct *handle,
+ const struct smb_filename *fname)
{
time_t timestamp;
char *stripped;
int ret, saved_errno;
char *conv;
+ struct smb_filename *smb_fname = NULL;
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
+ if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname->base_name,
×tamp, &stripped)) {
return -1;
}
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_RMDIR(handle, conv);
- saved_errno = errno;
+ smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ fname->flags);
TALLOC_FREE(conv);
+ if (smb_fname == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
+ saved_errno = errno;
+ TALLOC_FREE(smb_fname);
errno = saved_errno;
return ret;
}
-static int snapper_gmt_chflags(vfs_handle_struct *handle, const char *fname,
- unsigned int flags)
+static int snapper_gmt_chflags(vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ unsigned int flags)
{
- time_t timestamp;
- char *stripped;
- int ret, saved_errno;
- char *conv;
+ time_t timestamp = 0;
+ char *stripped = NULL;
+ int ret = -1;
+ int saved_errno = 0;
+ char *conv = NULL;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
+ if (!snapper_gmt_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 = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_CHFLAGS(handle, conv, flags);
- saved_errno = errno;
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
TALLOC_FREE(conv);
- errno = saved_errno;
+ if (conv_smb_fname == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_CHFLAGS(handle, conv_smb_fname, flags);
+ if (ret == -1) {
+ saved_errno = errno;
+ }
+ TALLOC_FREE(conv_smb_fname);
+ if (saved_errno != 0) {
+ errno = saved_errno;
+ }
return ret;
}
static ssize_t snapper_gmt_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;
- char *stripped;
+ time_t timestamp = 0;
+ char *stripped = NULL;
ssize_t ret;
- int saved_errno;
- char *conv;
+ int saved_errno = 0;
+ char *conv = NULL;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
+ if (!snapper_gmt_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 = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_GETXATTR(handle, conv, aname, value, size);
- saved_errno = errno;
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
TALLOC_FREE(conv);
- errno = saved_errno;
+ if (conv_smb_fname == NULL) {
+ errno = ENOMEM;
+ 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;
+ }
return ret;
}
static ssize_t snapper_gmt_listxattr(struct vfs_handle_struct *handle,
- const char *fname,
+ const struct smb_filename *smb_fname,
char *list, size_t size)
{
- time_t timestamp;
- char *stripped;
+ time_t timestamp = 0;
+ char *stripped = NULL;
ssize_t ret;
- int saved_errno;
- char *conv;
+ int saved_errno = 0;
+ char *conv = NULL;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
+ if (!snapper_gmt_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 = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_LISTXATTR(handle, conv, list, size);
- saved_errno = errno;
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
TALLOC_FREE(conv);
- errno = saved_errno;
+ if (conv_smb_fname == NULL) {
+ errno = ENOMEM;
+ 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;
+ }
return ret;
}
static int snapper_gmt_removexattr(vfs_handle_struct *handle,
- const char *fname, const char *aname)
+ const struct smb_filename *smb_fname,
+ const char *aname)
{
- time_t timestamp;
- char *stripped;
- int ret, saved_errno;
- char *conv;
+ time_t timestamp = 0;
+ char *stripped = NULL;
+ ssize_t ret;
+ int saved_errno = 0;
+ char *conv = NULL;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
+ if (!snapper_gmt_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 = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_REMOVEXATTR(handle, conv, aname);
- saved_errno = errno;
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
TALLOC_FREE(conv);
- errno = saved_errno;
+ if (conv_smb_fname == NULL) {
+ errno = ENOMEM;
+ 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;
+ }
return ret;
}
static int snapper_gmt_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)
{
- time_t timestamp;
- char *stripped;
+ time_t timestamp = 0;
+ char *stripped = NULL;
ssize_t ret;
- int saved_errno;
- char *conv;
+ int saved_errno = 0;
+ char *conv = NULL;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
+ if (!snapper_gmt_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 = snapper_gmt_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);
- saved_errno = errno;
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
TALLOC_FREE(conv);
- errno = saved_errno;
+ if (conv_smb_fname == NULL) {
+ errno = ENOMEM;
+ 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;
+ }
return ret;
}
static int snapper_gmt_chmod_acl(vfs_handle_struct *handle,
- const char *fname, mode_t mode)
+ const struct smb_filename *smb_fname,
+ mode_t mode)
{
time_t timestamp;
char *stripped;
ssize_t ret;
int saved_errno;
char *conv;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
+ if (!snapper_gmt_strip_snapshot(talloc_tos(),
+ handle,
+ smb_fname->base_name,
+ ×tamp,
+ &stripped)) {
return -1;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_CHMOD_ACL(handle, fname, mode);
+ return SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode);
}
conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_CHMOD_ACL(handle, conv, mode);
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
+ if (conv_smb_fname == NULL) {
+ TALLOC_FREE(conv);
+ errno = ENOMEM;
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_CHMOD_ACL(handle, conv_smb_fname, mode);
saved_errno = errno;
TALLOC_FREE(conv);
+ TALLOC_FREE(conv_smb_fname);
errno = saved_errno;
return ret;
}
}
static uint64_t snapper_gmt_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;
- char *stripped;
- ssize_t ret;
- int saved_errno;
- char *conv;
+ time_t timestamp = 0;
+ char *stripped = NULL;
+ uint64_t ret;
+ int saved_errno = 0;
+ char *conv = NULL;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, path,
- ×tamp, &stripped)) {
- return -1;
+ if (!snapper_gmt_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 = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
- return -1;
+ return (uint64_t)-1;
+ }
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
+ if (conv_smb_fname == NULL) {
+ TALLOC_FREE(conv);
+ errno = ENOMEM;
+ return (uint64_t)-1;
}
- ret = SMB_VFS_NEXT_DISK_FREE(handle, conv, bsize, dfree, dsize);
-
- saved_errno = errno;
- TALLOC_FREE(conv);
- errno = saved_errno;
+ ret = SMB_VFS_NEXT_DISK_FREE(handle, conv_smb_fname,
+ bsize, dfree, dsize);
+ if (ret == (uint64_t)-1) {
+ saved_errno = errno;
+ }
+ TALLOC_FREE(conv_smb_fname);
+ if (saved_errno != 0) {
+ errno = saved_errno;
+ }
return ret;
}
-static int snapper_gmt_get_quota(vfs_handle_struct *handle, const char *path,
- enum SMB_QUOTA_TYPE qtype, unid_t id,
- SMB_DISK_QUOTA *dq)
+static int snapper_gmt_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;
- char *stripped;
+ time_t timestamp = 0;
+ char *stripped = NULL;
int ret;
- int saved_errno;
- char *conv;
+ int saved_errno = 0;
+ char *conv = NULL;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, path, ×tamp,
- &stripped)) {
+ if (!snapper_gmt_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 = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
if (conv == NULL) {
return -1;
}
-
- ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv, qtype, id, dq);
-
- saved_errno = errno;
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL,
+ smb_fname->flags);
TALLOC_FREE(conv);
- errno = saved_errno;
+ if (conv_smb_fname == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv_smb_fname, qtype, id, dq);
+ if (ret == -1) {
+ saved_errno = errno;
+ }
+ TALLOC_FREE(conv_smb_fname);
+ if (saved_errno != 0) {
+ errno = saved_errno;
+ }
return ret;
}
.get_real_filename_fn = snapper_gmt_get_real_filename,
};
-NTSTATUS vfs_snapper_init(void);
-NTSTATUS vfs_snapper_init(void)
+NTSTATUS vfs_snapper_init(TALLOC_CTX *);
+NTSTATUS vfs_snapper_init(TALLOC_CTX *ctx)
{
return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
"snapper", &snapper_fns);