2 * shadow_copy2: a shadow copy module (second implementation)
4 * Copyright (C) Andrew Tridgell 2007 (portions taken from shadow_copy2)
5 * Copyright (C) Ed Plese 2009
6 * Copyright (C) Volker Lendecke 2011
7 * Copyright (C) Christian Ambach 2011
8 * Copyright (C) Michael Adam 2013
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * This is a second implemetation of a shadow copy module for exposing
27 * file system snapshots to windows clients as shadow copies.
29 * See the manual page for documentation.
33 #include "system/filesys.h"
34 #include "include/ntioctl.h"
35 #include <ccan/hash/hash.h>
38 struct shadow_copy2_config {
43 bool snapdirseverywhere;
44 bool crossmountpoints;
47 bool snapdir_absolute;
50 char *rel_connectpath; /* share root, relative to the basedir */
51 char *snapshot_basepath; /* the absolute version of snapdir */
54 static bool shadow_copy2_find_slashes(TALLOC_CTX *mem_ctx, const char *str,
56 unsigned *pnum_offsets)
65 while ((p = strchr(p, '/')) != NULL) {
70 offsets = talloc_array(mem_ctx, size_t, num_offsets);
71 if (offsets == NULL) {
77 while ((p = strchr(p, '/')) != NULL) {
78 offsets[num_offsets] = p-str;
84 *pnum_offsets = num_offsets;
89 * Given a timestamp, build the posix level GMT-tag string
90 * based on the configurable format.
92 static size_t shadow_copy2_posix_gmt_string(struct vfs_handle_struct *handle,
94 char *snaptime_string,
99 struct shadow_copy2_config *config;
101 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
104 if (config->use_sscanf) {
105 snaptime_len = snprintf(snaptime_string,
108 (unsigned long)snapshot);
109 if (snaptime_len <= 0) {
110 DEBUG(10, ("snprintf failed\n"));
114 if (config->use_localtime) {
115 if (localtime_r(&snapshot, &snap_tm) == 0) {
116 DEBUG(10, ("gmtime_r failed\n"));
120 if (gmtime_r(&snapshot, &snap_tm) == 0) {
121 DEBUG(10, ("gmtime_r failed\n"));
125 snaptime_len = strftime(snaptime_string,
129 if (snaptime_len == 0) {
130 DEBUG(10, ("strftime failed\n"));
139 * Given a timestamp, build the string to insert into a path
140 * as a path component for creating the local path to the
141 * snapshot at the given timestamp of the input path.
143 * In the case of a parallel snapdir (specified with an
144 * absolute path), this is the inital portion of the
145 * local path of any snapshot file. The complete path is
146 * obtained by appending the portion of the file's path
147 * below the share root's mountpoint.
149 static char *shadow_copy2_insert_string(TALLOC_CTX *mem_ctx,
150 struct vfs_handle_struct *handle,
153 fstring snaptime_string;
154 size_t snaptime_len = 0;
156 struct shadow_copy2_config *config;
158 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
161 snaptime_len = shadow_copy2_posix_gmt_string(handle,
164 sizeof(snaptime_string));
165 if (snaptime_len <= 0) {
169 if (config->snapdir_absolute) {
170 result = talloc_asprintf(mem_ctx, "%s/%s",
171 config->snapdir, snaptime_string);
173 result = talloc_asprintf(mem_ctx, "/%s/%s",
174 config->snapdir, snaptime_string);
176 if (result == NULL) {
177 DEBUG(1, (__location__ " talloc_asprintf failed\n"));
184 * Build the posix snapshot path for the connection
185 * at the given timestamp, i.e. the absolute posix path
186 * that contains the snapshot for this file system.
188 * This only applies to classical case, i.e. not
189 * to the "snapdirseverywhere" mode.
191 static char *shadow_copy2_snapshot_path(TALLOC_CTX *mem_ctx,
192 struct vfs_handle_struct *handle,
195 fstring snaptime_string;
196 size_t snaptime_len = 0;
198 struct shadow_copy2_config *config;
200 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
203 snaptime_len = shadow_copy2_posix_gmt_string(handle,
206 sizeof(snaptime_string));
207 if (snaptime_len <= 0) {
211 result = talloc_asprintf(mem_ctx, "%s/%s",
212 config->snapshot_basepath, snaptime_string);
213 if (result == NULL) {
214 DEBUG(1, (__location__ " talloc_asprintf failed\n"));
221 * Strip a snapshot component from a filename as
222 * handed in via the smb layer.
223 * Returns the parsed timestamp and the stripped filename.
225 static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx,
226 struct vfs_handle_struct *handle,
236 size_t rest_len, dst_len;
237 struct shadow_copy2_config *config;
240 ptrdiff_t len_before_gmt;
242 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
245 DEBUG(10, (__location__ ": enter path '%s'\n", name));
247 p = strstr_m(name, "@GMT-");
249 DEBUG(11, ("@GMT not found\n"));
252 if ((p > name) && (p[-1] != '/')) {
253 /* the GMT-token does not start a path-component */
254 DEBUG(10, ("not at start, p=%p, name=%p, p[-1]=%d\n",
255 p, name, (int)p[-1]));
260 * Figure out whether we got an already converted string. One
261 * case where this happens is in a smb2 create call with the
262 * mxac create blob set. We do the get_acl call on
263 * fsp->fsp_name, which is already converted. We are converted
264 * if we got a file name of the form ".snapshots/@GMT-",
265 * i.e. ".snapshots/" precedes "p".
268 snapdir = lp_parm_const_string(SNUM(handle->conn), "shadow", "snapdir",
270 snapdirlen = strlen(snapdir);
271 len_before_gmt = p - name;
273 if ((len_before_gmt >= (snapdirlen + 1)) && (p[-1] == '/')) {
274 const char *parent_snapdir = p - (snapdirlen+1);
276 DEBUG(10, ("parent_snapdir = %s\n", parent_snapdir));
278 if (strncmp(parent_snapdir, snapdir, snapdirlen) == 0) {
279 DEBUG(10, ("name=%s is already converted\n", name));
283 q = strptime(p, GMT_FORMAT, &tm);
285 DEBUG(10, ("strptime failed\n"));
289 timestamp = timegm(&tm);
290 if (timestamp == (time_t)-1) {
291 DEBUG(10, ("timestamp==-1\n"));
296 * The name consists of only the GMT token or the GMT
297 * token is at the end of the path. XP seems to send
298 * @GMT- at the end under certain circumstances even
299 * with a path prefix.
301 if (pstripped != NULL) {
302 stripped = talloc_strndup(mem_ctx, name, p - name);
303 if (stripped == NULL) {
306 *pstripped = stripped;
308 *ptimestamp = timestamp;
313 * It is not a complete path component, i.e. the path
314 * component continues after the gmt-token.
316 DEBUG(10, ("q[0] = %d\n", (int)q[0]));
321 rest_len = strlen(q);
322 dst_len = (p-name) + rest_len;
324 if (config->snapdirseverywhere) {
327 insert = shadow_copy2_insert_string(talloc_tos(), handle,
329 if (insert == NULL) {
334 DEBUG(10, (__location__ ": snapdirseverywhere mode.\n"
336 "insert string '%s'\n", name, insert));
338 have_insert = (strstr(name, insert+1) != NULL);
339 DEBUG(10, ("have_insert=%d, name=%s, insert+1=%s\n",
340 (int)have_insert, name, insert+1));
342 DEBUG(10, (__location__ ": insert string '%s' found in "
343 "path '%s' found in snapdirseverywhere mode "
344 "==> already converted\n", insert, name));
353 snapshot_path = shadow_copy2_snapshot_path(talloc_tos(),
356 if (snapshot_path == NULL) {
361 DEBUG(10, (__location__ " path: '%s'.\n"
362 "snapshot path: '%s'\n", name, snapshot_path));
364 s = strstr(name, snapshot_path);
367 * this starts with "snapshot_basepath/GMT-Token"
368 * so it is already a converted absolute
369 * path. Don't process further.
371 DEBUG(10, (__location__ ": path '%s' starts with "
372 "snapshot path '%s' (not in "
373 "snapdirseverywhere mode) ==> "
374 "already converted\n", name, snapshot_path));
375 talloc_free(snapshot_path);
378 talloc_free(snapshot_path);
381 if (pstripped != NULL) {
382 stripped = talloc_array(mem_ctx, char, dst_len+1);
383 if (stripped == NULL) {
388 memcpy(stripped, name, p-name);
391 memcpy(stripped + (p-name), q, rest_len);
393 stripped[dst_len] = '\0';
394 *pstripped = stripped;
396 *ptimestamp = timestamp;
403 static char *shadow_copy2_find_mount_point(TALLOC_CTX *mem_ctx,
404 vfs_handle_struct *handle)
406 char *path = talloc_strdup(mem_ctx, handle->conn->connectpath);
411 if (stat(path, &st) != 0) {
418 while ((p = strrchr(path, '/')) && p > path) {
420 if (stat(path, &st) != 0) {
424 if (st.st_dev != dev) {
434 * Convert from a name as handed in via the SMB layer
435 * and a timestamp into the local path of the snapshot
436 * of the provided file at the provided time.
438 static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx,
439 struct vfs_handle_struct *handle,
440 const char *name, time_t timestamp)
442 struct smb_filename converted_fname;
444 size_t *slashes = NULL;
445 unsigned num_slashes;
449 char *converted = NULL;
453 struct shadow_copy2_config *config;
455 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
458 DEBUG(10, ("converting '%s'\n", name));
460 if (!config->snapdirseverywhere) {
464 snapshot_path = shadow_copy2_snapshot_path(talloc_tos(),
467 if (snapshot_path == NULL) {
471 if (config->rel_connectpath == NULL) {
472 converted = talloc_asprintf(mem_ctx, "%s/%s",
473 snapshot_path, name);
475 converted = talloc_asprintf(mem_ctx, "%s/%s/%s",
477 config->rel_connectpath,
480 if (converted == NULL) {
484 ZERO_STRUCT(converted_fname);
485 converted_fname.base_name = converted;
487 ret = SMB_VFS_NEXT_LSTAT(handle, &converted_fname);
488 DEBUG(10, ("Trying[not snapdirseverywhere] %s: %d (%s)\n",
490 ret, ret == 0 ? "ok" : strerror(errno)));
492 DEBUG(10, ("Found %s\n", converted));
500 /* never reached ... */
504 path = talloc_strdup(mem_ctx, handle->conn->connectpath);
506 path = talloc_asprintf(
507 mem_ctx, "%s/%s", handle->conn->connectpath, name);
513 pathlen = talloc_get_size(path)-1;
515 if (!shadow_copy2_find_slashes(talloc_tos(), path,
516 &slashes, &num_slashes)) {
520 insert = shadow_copy2_insert_string(talloc_tos(), handle, timestamp);
521 if (insert == NULL) {
524 insertlen = talloc_get_size(insert)-1;
527 * Note: We deliberatly don't expensively initialize the
528 * array with talloc_zero here: Putting zero into
529 * converted[pathlen+insertlen] below is sufficient, because
530 * in the following for loop, the insert string is inserted
531 * at various slash places. So the memory up to position
532 * pathlen+insertlen will always be initialized when the
533 * converted string is used.
535 converted = talloc_array(mem_ctx, char, pathlen + insertlen + 1);
536 if (converted == NULL) {
540 if (path[pathlen-1] != '/') {
542 * Append a fake slash to find the snapshot root
545 tmp = talloc_realloc(talloc_tos(), slashes,
546 size_t, num_slashes+1);
551 slashes[num_slashes] = pathlen;
557 if (!config->crossmountpoints) {
558 min_offset = strlen(config->mount_point);
561 memcpy(converted, path, pathlen+1);
562 converted[pathlen+insertlen] = '\0';
564 ZERO_STRUCT(converted_fname);
565 converted_fname.base_name = converted;
567 for (i = num_slashes-1; i>=0; i--) {
573 if (offset < min_offset) {
578 memcpy(converted+offset, insert, insertlen);
581 memcpy(converted+offset, path + slashes[i],
582 pathlen - slashes[i]);
584 ret = SMB_VFS_NEXT_LSTAT(handle, &converted_fname);
586 DEBUG(10, ("Trying[snapdirseverywhere] %s: %d (%s)\n",
588 ret, ret == 0 ? "ok" : strerror(errno)));
593 if (errno == ENOTDIR) {
595 * This is a valid condition: We appended the
596 * .snaphots/@GMT.. to a file name. Just try
597 * with the upper levels.
601 if (errno != ENOENT) {
602 /* Other problem than "not found" */
611 DEBUG(10, ("Found %s\n", converted));
619 TALLOC_FREE(converted);
621 TALLOC_FREE(slashes);
628 modify a sbuf return to ensure that inodes in the shadow directory
629 are different from those in the main directory
631 static void convert_sbuf(vfs_handle_struct *handle, const char *fname,
632 SMB_STRUCT_STAT *sbuf)
634 struct shadow_copy2_config *config;
636 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
639 if (config->fixinodes) {
640 /* some snapshot systems, like GPFS, return the name
641 device:inode for the snapshot files as the current
642 files. That breaks the 'restore' button in the shadow copy
643 GUI, as the client gets a sharing violation.
645 This is a crude way of allowing both files to be
646 open at once. It has a slight chance of inode
647 number collision, but I can't see a better approach
648 without significant VFS changes
652 shash = hash(fname, strlen(fname), 0) & 0xFF000000;
656 sbuf->st_ex_ino ^= shash;
660 static DIR *shadow_copy2_opendir(vfs_handle_struct *handle,
671 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
672 ×tamp, &stripped)) {
675 if (timestamp == 0) {
676 return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
678 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
679 TALLOC_FREE(stripped);
683 ret = SMB_VFS_NEXT_OPENDIR(handle, conv, mask, attr);
690 static int shadow_copy2_rename(vfs_handle_struct *handle,
691 const struct smb_filename *smb_fname_src,
692 const struct smb_filename *smb_fname_dst)
694 time_t timestamp_src, timestamp_dst;
696 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
697 smb_fname_src->base_name,
698 ×tamp_src, NULL)) {
701 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
702 smb_fname_dst->base_name,
703 ×tamp_dst, NULL)) {
706 if (timestamp_src != 0) {
710 if (timestamp_dst != 0) {
714 return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
717 static int shadow_copy2_symlink(vfs_handle_struct *handle,
718 const char *oldname, const char *newname)
720 time_t timestamp_old, timestamp_new;
722 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, oldname,
723 ×tamp_old, NULL)) {
726 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, newname,
727 ×tamp_new, NULL)) {
730 if ((timestamp_old != 0) || (timestamp_new != 0)) {
734 return SMB_VFS_NEXT_SYMLINK(handle, oldname, newname);
737 static int shadow_copy2_link(vfs_handle_struct *handle,
738 const char *oldname, const char *newname)
740 time_t timestamp_old, timestamp_new;
742 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, oldname,
743 ×tamp_old, NULL)) {
746 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, newname,
747 ×tamp_new, NULL)) {
750 if ((timestamp_old != 0) || (timestamp_new != 0)) {
754 return SMB_VFS_NEXT_LINK(handle, oldname, newname);
757 static int shadow_copy2_stat(vfs_handle_struct *handle,
758 struct smb_filename *smb_fname)
761 char *stripped, *tmp;
762 int ret, saved_errno;
764 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
765 smb_fname->base_name,
766 ×tamp, &stripped)) {
769 if (timestamp == 0) {
770 return SMB_VFS_NEXT_STAT(handle, smb_fname);
773 tmp = smb_fname->base_name;
774 smb_fname->base_name = shadow_copy2_convert(
775 talloc_tos(), handle, stripped, timestamp);
776 TALLOC_FREE(stripped);
778 if (smb_fname->base_name == NULL) {
779 smb_fname->base_name = tmp;
783 ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
786 TALLOC_FREE(smb_fname->base_name);
787 smb_fname->base_name = tmp;
790 convert_sbuf(handle, smb_fname->base_name, &smb_fname->st);
796 static int shadow_copy2_lstat(vfs_handle_struct *handle,
797 struct smb_filename *smb_fname)
800 char *stripped, *tmp;
801 int ret, saved_errno;
803 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
804 smb_fname->base_name,
805 ×tamp, &stripped)) {
808 if (timestamp == 0) {
809 return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
812 tmp = smb_fname->base_name;
813 smb_fname->base_name = shadow_copy2_convert(
814 talloc_tos(), handle, stripped, timestamp);
815 TALLOC_FREE(stripped);
817 if (smb_fname->base_name == NULL) {
818 smb_fname->base_name = tmp;
822 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
825 TALLOC_FREE(smb_fname->base_name);
826 smb_fname->base_name = tmp;
829 convert_sbuf(handle, smb_fname->base_name, &smb_fname->st);
835 static int shadow_copy2_fstat(vfs_handle_struct *handle, files_struct *fsp,
836 SMB_STRUCT_STAT *sbuf)
841 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
845 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
846 fsp->fsp_name->base_name,
850 if (timestamp != 0) {
851 convert_sbuf(handle, fsp->fsp_name->base_name, sbuf);
856 static int shadow_copy2_open(vfs_handle_struct *handle,
857 struct smb_filename *smb_fname, files_struct *fsp,
858 int flags, mode_t mode)
861 char *stripped, *tmp;
862 int ret, saved_errno;
864 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
865 smb_fname->base_name,
866 ×tamp, &stripped)) {
869 if (timestamp == 0) {
870 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
873 tmp = smb_fname->base_name;
874 smb_fname->base_name = shadow_copy2_convert(
875 talloc_tos(), handle, stripped, timestamp);
876 TALLOC_FREE(stripped);
878 if (smb_fname->base_name == NULL) {
879 smb_fname->base_name = tmp;
883 ret = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
886 TALLOC_FREE(smb_fname->base_name);
887 smb_fname->base_name = tmp;
893 static int shadow_copy2_unlink(vfs_handle_struct *handle,
894 const struct smb_filename *smb_fname)
898 int ret, saved_errno;
899 struct smb_filename *conv;
901 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
902 smb_fname->base_name,
903 ×tamp, &stripped)) {
906 if (timestamp == 0) {
907 return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
909 conv = cp_smb_filename(talloc_tos(), smb_fname);
914 conv->base_name = shadow_copy2_convert(
915 conv, handle, stripped, timestamp);
916 TALLOC_FREE(stripped);
917 if (conv->base_name == NULL) {
920 ret = SMB_VFS_NEXT_UNLINK(handle, conv);
927 static int shadow_copy2_chmod(vfs_handle_struct *handle, const char *fname,
932 int ret, saved_errno;
935 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
936 ×tamp, &stripped)) {
939 if (timestamp == 0) {
940 return SMB_VFS_NEXT_CHMOD(handle, fname, mode);
942 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
943 TALLOC_FREE(stripped);
947 ret = SMB_VFS_NEXT_CHMOD(handle, conv, mode);
954 static int shadow_copy2_chown(vfs_handle_struct *handle, const char *fname,
955 uid_t uid, gid_t gid)
959 int ret, saved_errno;
962 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
963 ×tamp, &stripped)) {
966 if (timestamp == 0) {
967 return SMB_VFS_NEXT_CHOWN(handle, fname, uid, gid);
969 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
970 TALLOC_FREE(stripped);
974 ret = SMB_VFS_NEXT_CHOWN(handle, conv, uid, gid);
981 static int shadow_copy2_chdir(vfs_handle_struct *handle,
986 int ret, saved_errno;
989 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
990 ×tamp, &stripped)) {
993 if (timestamp == 0) {
994 return SMB_VFS_NEXT_CHDIR(handle, fname);
996 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
997 TALLOC_FREE(stripped);
1001 ret = SMB_VFS_NEXT_CHDIR(handle, conv);
1002 saved_errno = errno;
1004 errno = saved_errno;
1008 static int shadow_copy2_ntimes(vfs_handle_struct *handle,
1009 const struct smb_filename *smb_fname,
1010 struct smb_file_time *ft)
1014 int ret, saved_errno;
1015 struct smb_filename *conv;
1017 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
1018 smb_fname->base_name,
1019 ×tamp, &stripped)) {
1022 if (timestamp == 0) {
1023 return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
1025 conv = cp_smb_filename(talloc_tos(), smb_fname);
1030 conv->base_name = shadow_copy2_convert(
1031 conv, handle, stripped, timestamp);
1032 TALLOC_FREE(stripped);
1033 if (conv->base_name == NULL) {
1036 ret = SMB_VFS_NEXT_NTIMES(handle, conv, ft);
1037 saved_errno = errno;
1039 errno = saved_errno;
1043 static int shadow_copy2_readlink(vfs_handle_struct *handle,
1044 const char *fname, char *buf, size_t bufsiz)
1048 int ret, saved_errno;
1051 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1052 ×tamp, &stripped)) {
1055 if (timestamp == 0) {
1056 return SMB_VFS_NEXT_READLINK(handle, fname, buf, bufsiz);
1058 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1059 TALLOC_FREE(stripped);
1063 ret = SMB_VFS_NEXT_READLINK(handle, conv, buf, bufsiz);
1064 saved_errno = errno;
1066 errno = saved_errno;
1070 static int shadow_copy2_mknod(vfs_handle_struct *handle,
1071 const char *fname, mode_t mode, SMB_DEV_T dev)
1075 int ret, saved_errno;
1078 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1079 ×tamp, &stripped)) {
1082 if (timestamp == 0) {
1083 return SMB_VFS_NEXT_MKNOD(handle, fname, mode, dev);
1085 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1086 TALLOC_FREE(stripped);
1090 ret = SMB_VFS_NEXT_MKNOD(handle, conv, mode, dev);
1091 saved_errno = errno;
1093 errno = saved_errno;
1097 static char *shadow_copy2_realpath(vfs_handle_struct *handle,
1101 char *stripped = NULL;
1103 char *result = NULL;
1104 char *inserted = NULL;
1105 char *inserted_to, *inserted_end;
1108 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1109 ×tamp, &stripped)) {
1112 if (timestamp == 0) {
1113 return SMB_VFS_NEXT_REALPATH(handle, fname);
1116 tmp = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1121 result = SMB_VFS_NEXT_REALPATH(handle, tmp);
1122 if (result == NULL) {
1127 * Take away what we've inserted. This removes the @GMT-thingy
1128 * completely, but will give a path under the share root.
1130 inserted = shadow_copy2_insert_string(talloc_tos(), handle, timestamp);
1131 if (inserted == NULL) {
1134 inserted_to = strstr_m(result, inserted);
1135 if (inserted_to == NULL) {
1136 DEBUG(2, ("SMB_VFS_NEXT_REALPATH removed %s\n", inserted));
1139 inserted_end = inserted_to + talloc_get_size(inserted) - 1;
1140 memmove(inserted_to, inserted_end, strlen(inserted_end)+1);
1143 saved_errno = errno;
1144 TALLOC_FREE(inserted);
1146 TALLOC_FREE(stripped);
1147 errno = saved_errno;
1152 * Check whether a given directory contains a
1153 * snapshot directory as direct subdirectory.
1154 * If yes, return the path of the snapshot-subdir,
1155 * otherwise return NULL.
1157 static char *have_snapdir(struct vfs_handle_struct *handle,
1160 struct smb_filename smb_fname;
1162 struct shadow_copy2_config *config;
1164 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
1167 ZERO_STRUCT(smb_fname);
1168 smb_fname.base_name = talloc_asprintf(talloc_tos(), "%s/%s",
1169 path, config->snapdir);
1170 if (smb_fname.base_name == NULL) {
1174 ret = SMB_VFS_NEXT_STAT(handle, &smb_fname);
1175 if ((ret == 0) && (S_ISDIR(smb_fname.st.st_ex_mode))) {
1176 return smb_fname.base_name;
1178 TALLOC_FREE(smb_fname.base_name);
1183 * Find the snapshot directory (if any) for the given
1184 * filename (which is relative to the share).
1186 static const char *shadow_copy2_find_snapdir(TALLOC_CTX *mem_ctx,
1187 struct vfs_handle_struct *handle,
1188 struct smb_filename *smb_fname)
1191 const char *snapdir;
1192 struct shadow_copy2_config *config;
1194 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
1198 * If the non-snapdisrseverywhere mode, we should not search!
1200 if (!config->snapdirseverywhere) {
1201 return config->snapshot_basepath;
1204 path = talloc_asprintf(mem_ctx, "%s/%s",
1205 handle->conn->connectpath,
1206 smb_fname->base_name);
1211 snapdir = have_snapdir(handle, path);
1212 if (snapdir != NULL) {
1217 while ((p = strrchr(path, '/')) && (p > path)) {
1221 snapdir = have_snapdir(handle, path);
1222 if (snapdir != NULL) {
1231 static bool shadow_copy2_snapshot_to_gmt(vfs_handle_struct *handle,
1233 char *gmt, size_t gmt_len)
1235 struct tm timestamp;
1237 unsigned long int timestamp_long;
1239 struct shadow_copy2_config *config;
1241 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
1244 fmt = config->gmt_format;
1246 ZERO_STRUCT(timestamp);
1247 if (config->use_sscanf) {
1248 if (sscanf(name, fmt, ×tamp_long) != 1) {
1249 DEBUG(10, ("shadow_copy2_snapshot_to_gmt: "
1250 "no sscanf match %s: %s\n",
1254 timestamp_t = timestamp_long;
1255 gmtime_r(×tamp_t, ×tamp);
1257 if (strptime(name, fmt, ×tamp) == NULL) {
1258 DEBUG(10, ("shadow_copy2_snapshot_to_gmt: "
1259 "no match %s: %s\n",
1263 DEBUG(10, ("shadow_copy2_snapshot_to_gmt: match %s: %s\n",
1266 if (config->use_localtime) {
1267 timestamp.tm_isdst = -1;
1268 timestamp_t = mktime(×tamp);
1269 gmtime_r(×tamp_t, ×tamp);
1273 strftime(gmt, gmt_len, GMT_FORMAT, ×tamp);
1277 static int shadow_copy2_label_cmp_asc(const void *x, const void *y)
1279 return strncmp((const char *)x, (const char *)y, sizeof(SHADOW_COPY_LABEL));
1282 static int shadow_copy2_label_cmp_desc(const void *x, const void *y)
1284 return -strncmp((const char *)x, (const char *)y, sizeof(SHADOW_COPY_LABEL));
1288 sort the shadow copy data in ascending or descending order
1290 static void shadow_copy2_sort_data(vfs_handle_struct *handle,
1291 struct shadow_copy_data *shadow_copy2_data)
1293 int (*cmpfunc)(const void *, const void *);
1295 struct shadow_copy2_config *config;
1297 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
1300 sort = config->sort_order;
1305 if (strcmp(sort, "asc") == 0) {
1306 cmpfunc = shadow_copy2_label_cmp_asc;
1307 } else if (strcmp(sort, "desc") == 0) {
1308 cmpfunc = shadow_copy2_label_cmp_desc;
1313 if (shadow_copy2_data && shadow_copy2_data->num_volumes > 0 &&
1314 shadow_copy2_data->labels)
1316 TYPESAFE_QSORT(shadow_copy2_data->labels,
1317 shadow_copy2_data->num_volumes,
1322 static int shadow_copy2_get_shadow_copy_data(
1323 vfs_handle_struct *handle, files_struct *fsp,
1324 struct shadow_copy_data *shadow_copy2_data,
1328 const char *snapdir;
1330 TALLOC_CTX *tmp_ctx = talloc_stackframe();
1332 snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle, fsp->fsp_name);
1333 if (snapdir == NULL) {
1334 DEBUG(0,("shadow:snapdir not found for %s in get_shadow_copy_data\n",
1335 handle->conn->connectpath));
1337 talloc_free(tmp_ctx);
1341 p = SMB_VFS_NEXT_OPENDIR(handle, snapdir, NULL, 0);
1344 DEBUG(2,("shadow_copy2: SMB_VFS_NEXT_OPENDIR() failed for '%s'"
1345 " - %s\n", snapdir, strerror(errno)));
1346 talloc_free(tmp_ctx);
1351 shadow_copy2_data->num_volumes = 0;
1352 shadow_copy2_data->labels = NULL;
1354 while ((d = SMB_VFS_NEXT_READDIR(handle, p, NULL))) {
1355 char snapshot[GMT_NAME_LEN+1];
1356 SHADOW_COPY_LABEL *tlabels;
1359 * ignore names not of the right form in the snapshot
1362 if (!shadow_copy2_snapshot_to_gmt(
1364 snapshot, sizeof(snapshot))) {
1366 DEBUG(6, ("shadow_copy2_get_shadow_copy_data: "
1367 "ignoring %s\n", d->d_name));
1370 DEBUG(6,("shadow_copy2_get_shadow_copy_data: %s -> %s\n",
1371 d->d_name, snapshot));
1374 /* the caller doesn't want the labels */
1375 shadow_copy2_data->num_volumes++;
1379 tlabels = talloc_realloc(shadow_copy2_data,
1380 shadow_copy2_data->labels,
1382 shadow_copy2_data->num_volumes+1);
1383 if (tlabels == NULL) {
1384 DEBUG(0,("shadow_copy2: out of memory\n"));
1385 SMB_VFS_NEXT_CLOSEDIR(handle, p);
1386 talloc_free(tmp_ctx);
1390 strlcpy(tlabels[shadow_copy2_data->num_volumes], snapshot,
1393 shadow_copy2_data->num_volumes++;
1394 shadow_copy2_data->labels = tlabels;
1397 SMB_VFS_NEXT_CLOSEDIR(handle,p);
1399 shadow_copy2_sort_data(handle, shadow_copy2_data);
1401 talloc_free(tmp_ctx);
1405 static NTSTATUS shadow_copy2_fget_nt_acl(vfs_handle_struct *handle,
1406 struct files_struct *fsp,
1407 uint32 security_info,
1408 TALLOC_CTX *mem_ctx,
1409 struct security_descriptor **ppdesc)
1416 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
1417 fsp->fsp_name->base_name,
1418 ×tamp, &stripped)) {
1419 return map_nt_error_from_unix(errno);
1421 if (timestamp == 0) {
1422 return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
1426 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1427 TALLOC_FREE(stripped);
1429 return map_nt_error_from_unix(errno);
1431 status = SMB_VFS_NEXT_GET_NT_ACL(handle, conv, security_info,
1437 static NTSTATUS shadow_copy2_get_nt_acl(vfs_handle_struct *handle,
1439 uint32 security_info,
1440 TALLOC_CTX *mem_ctx,
1441 struct security_descriptor **ppdesc)
1448 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1449 ×tamp, &stripped)) {
1450 return map_nt_error_from_unix(errno);
1452 if (timestamp == 0) {
1453 return SMB_VFS_NEXT_GET_NT_ACL(handle, fname, security_info,
1456 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1457 TALLOC_FREE(stripped);
1459 return map_nt_error_from_unix(errno);
1461 status = SMB_VFS_NEXT_GET_NT_ACL(handle, conv, security_info,
1467 static int shadow_copy2_mkdir(vfs_handle_struct *handle,
1468 const char *fname, mode_t mode)
1472 int ret, saved_errno;
1475 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1476 ×tamp, &stripped)) {
1479 if (timestamp == 0) {
1480 return SMB_VFS_NEXT_MKDIR(handle, fname, mode);
1482 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1483 TALLOC_FREE(stripped);
1487 ret = SMB_VFS_NEXT_MKDIR(handle, conv, mode);
1488 saved_errno = errno;
1490 errno = saved_errno;
1494 static int shadow_copy2_rmdir(vfs_handle_struct *handle, const char *fname)
1498 int ret, saved_errno;
1501 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1502 ×tamp, &stripped)) {
1505 if (timestamp == 0) {
1506 return SMB_VFS_NEXT_RMDIR(handle, fname);
1508 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1509 TALLOC_FREE(stripped);
1513 ret = SMB_VFS_NEXT_RMDIR(handle, conv);
1514 saved_errno = errno;
1516 errno = saved_errno;
1520 static int shadow_copy2_chflags(vfs_handle_struct *handle, const char *fname,
1525 int ret, saved_errno;
1528 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1529 ×tamp, &stripped)) {
1532 if (timestamp == 0) {
1533 return SMB_VFS_NEXT_CHFLAGS(handle, fname, flags);
1535 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1536 TALLOC_FREE(stripped);
1540 ret = SMB_VFS_NEXT_CHFLAGS(handle, conv, flags);
1541 saved_errno = errno;
1543 errno = saved_errno;
1547 static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle,
1548 const char *fname, const char *aname,
1549 void *value, size_t size)
1557 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1558 ×tamp, &stripped)) {
1561 if (timestamp == 0) {
1562 return SMB_VFS_NEXT_GETXATTR(handle, fname, aname, value,
1565 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1566 TALLOC_FREE(stripped);
1570 ret = SMB_VFS_NEXT_GETXATTR(handle, conv, aname, value, size);
1571 saved_errno = errno;
1573 errno = saved_errno;
1577 static ssize_t shadow_copy2_listxattr(struct vfs_handle_struct *handle,
1579 char *list, size_t size)
1587 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1588 ×tamp, &stripped)) {
1591 if (timestamp == 0) {
1592 return SMB_VFS_NEXT_LISTXATTR(handle, fname, list, size);
1594 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1595 TALLOC_FREE(stripped);
1599 ret = SMB_VFS_NEXT_LISTXATTR(handle, conv, list, size);
1600 saved_errno = errno;
1602 errno = saved_errno;
1606 static int shadow_copy2_removexattr(vfs_handle_struct *handle,
1607 const char *fname, const char *aname)
1611 int ret, saved_errno;
1614 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1615 ×tamp, &stripped)) {
1618 if (timestamp == 0) {
1619 return SMB_VFS_NEXT_REMOVEXATTR(handle, fname, aname);
1621 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1622 TALLOC_FREE(stripped);
1626 ret = SMB_VFS_NEXT_REMOVEXATTR(handle, conv, aname);
1627 saved_errno = errno;
1629 errno = saved_errno;
1633 static int shadow_copy2_setxattr(struct vfs_handle_struct *handle,
1635 const char *aname, const void *value,
1636 size_t size, int flags)
1644 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1645 ×tamp, &stripped)) {
1648 if (timestamp == 0) {
1649 return SMB_VFS_NEXT_SETXATTR(handle, fname, aname, value, size,
1652 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1653 TALLOC_FREE(stripped);
1657 ret = SMB_VFS_NEXT_SETXATTR(handle, conv, aname, value, size, flags);
1658 saved_errno = errno;
1660 errno = saved_errno;
1664 static int shadow_copy2_chmod_acl(vfs_handle_struct *handle,
1665 const char *fname, mode_t mode)
1673 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1674 ×tamp, &stripped)) {
1677 if (timestamp == 0) {
1678 return SMB_VFS_NEXT_CHMOD_ACL(handle, fname, mode);
1680 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1681 TALLOC_FREE(stripped);
1685 ret = SMB_VFS_NEXT_CHMOD_ACL(handle, conv, mode);
1686 saved_errno = errno;
1688 errno = saved_errno;
1692 static int shadow_copy2_get_real_filename(struct vfs_handle_struct *handle,
1695 TALLOC_CTX *mem_ctx,
1704 DEBUG(10, ("shadow_copy2_get_real_filename called for path=[%s], "
1705 "name=[%s]\n", path, name));
1707 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, path,
1708 ×tamp, &stripped)) {
1709 DEBUG(10, ("shadow_copy2_strip_snapshot failed\n"));
1712 if (timestamp == 0) {
1713 DEBUG(10, ("timestamp == 0\n"));
1714 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
1715 mem_ctx, found_name);
1717 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1718 TALLOC_FREE(stripped);
1720 DEBUG(10, ("shadow_copy2_convert failed\n"));
1723 DEBUG(10, ("Calling NEXT_GET_REAL_FILE_NAME for conv=[%s], "
1724 "name=[%s]\n", conv, name));
1725 ret = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, conv, name,
1726 mem_ctx, found_name);
1727 DEBUG(10, ("NEXT_REAL_FILE_NAME returned %d\n", (int)ret));
1728 saved_errno = errno;
1730 errno = saved_errno;
1734 static uint64_t shadow_copy2_disk_free(vfs_handle_struct *handle,
1735 const char *path, bool small_query,
1736 uint64_t *bsize, uint64_t *dfree,
1745 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, path,
1746 ×tamp, &stripped)) {
1749 if (timestamp == 0) {
1750 return SMB_VFS_NEXT_DISK_FREE(handle, path, small_query,
1751 bsize, dfree, dsize);
1754 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1755 TALLOC_FREE(stripped);
1760 ret = SMB_VFS_NEXT_DISK_FREE(handle, conv, small_query, bsize, dfree,
1763 saved_errno = errno;
1765 errno = saved_errno;
1770 static int shadow_copy2_connect(struct vfs_handle_struct *handle,
1771 const char *service, const char *user)
1773 struct shadow_copy2_config *config;
1775 const char *snapdir;
1776 const char *gmt_format;
1777 const char *sort_order;
1778 const char *basedir;
1779 const char *mount_point;
1781 DEBUG(10, (__location__ ": cnum[%u], connectpath[%s]\n",
1782 (unsigned)handle->conn->cnum,
1783 handle->conn->connectpath));
1785 ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
1790 config = talloc_zero(handle->conn, struct shadow_copy2_config);
1791 if (config == NULL) {
1792 DEBUG(0, ("talloc_zero() failed\n"));
1797 gmt_format = lp_parm_const_string(SNUM(handle->conn),
1800 config->gmt_format = talloc_strdup(config, gmt_format);
1801 if (config->gmt_format == NULL) {
1802 DEBUG(0, ("talloc_strdup() failed\n"));
1807 config->use_sscanf = lp_parm_bool(SNUM(handle->conn),
1808 "shadow", "sscanf", false);
1810 config->use_localtime = lp_parm_bool(SNUM(handle->conn),
1811 "shadow", "localtime",
1814 snapdir = lp_parm_const_string(SNUM(handle->conn),
1815 "shadow", "snapdir",
1817 config->snapdir = talloc_strdup(config, snapdir);
1818 if (config->snapdir == NULL) {
1819 DEBUG(0, ("talloc_strdup() failed\n"));
1824 config->snapdirseverywhere = lp_parm_bool(SNUM(handle->conn),
1826 "snapdirseverywhere",
1829 config->crossmountpoints = lp_parm_bool(SNUM(handle->conn),
1830 "shadow", "crossmountpoints",
1833 config->fixinodes = lp_parm_bool(SNUM(handle->conn),
1834 "shadow", "fixinodes",
1837 sort_order = lp_parm_const_string(SNUM(handle->conn),
1838 "shadow", "sort", "desc");
1839 config->sort_order = talloc_strdup(config, sort_order);
1840 if (config->sort_order == NULL) {
1841 DEBUG(0, ("talloc_strdup() failed\n"));
1846 mount_point = lp_parm_const_string(SNUM(handle->conn),
1847 "shadow", "mountpoint", NULL);
1848 if (mount_point != NULL) {
1849 if (mount_point[0] != '/') {
1850 DEBUG(1, (__location__ " Warning: 'mountpoint' is "
1851 "relative ('%s'), but it has to be an "
1852 "absolute path. Ignoring provided value.\n",
1857 p = strstr(handle->conn->connectpath, mount_point);
1858 if (p != handle->conn->connectpath) {
1859 DEBUG(1, ("Warning: mount_point (%s) is not a "
1860 "subdirectory of the share root "
1861 "(%s). Ignoring provided value.\n",
1863 handle->conn->connectpath));
1869 if (mount_point != NULL) {
1870 config->mount_point = talloc_strdup(config, mount_point);
1871 if (config->mount_point == NULL) {
1872 DEBUG(0, (__location__ " talloc_strdup() failed\n"));
1876 config->mount_point = shadow_copy2_find_mount_point(config,
1878 if (config->mount_point == NULL) {
1879 DEBUG(0, (__location__ ": shadow_copy2_find_mount_point"
1880 " failed: %s\n", strerror(errno)));
1885 basedir = lp_parm_const_string(SNUM(handle->conn),
1886 "shadow", "basedir", NULL);
1888 if (basedir != NULL) {
1889 if (basedir[0] != '/') {
1890 DEBUG(1, (__location__ " Warning: 'basedir' is "
1891 "relative ('%s'), but it has to be an "
1892 "absolute path. Disabling basedir.\n",
1896 p = strstr(basedir, config->mount_point);
1898 DEBUG(1, ("Warning: basedir (%s) is not a "
1899 "subdirectory of the share root's "
1900 "mount point (%s). "
1901 "Disabling basedir\n",
1902 basedir, config->mount_point));
1904 config->basedir = talloc_strdup(config,
1906 if (config->basedir == NULL) {
1907 DEBUG(0, ("talloc_strdup() failed\n"));
1915 if (config->snapdirseverywhere && config->basedir != NULL) {
1916 DEBUG(1, (__location__ " Warning: 'basedir' is incompatible "
1917 "with 'snapdirseverywhere'. Disabling basedir.\n"));
1918 TALLOC_FREE(config->basedir);
1921 if (config->crossmountpoints && config->basedir != NULL) {
1922 DEBUG(1, (__location__ " Warning: 'basedir' is incompatible "
1923 "with 'crossmountpoints'. Disabling basedir.\n"));
1924 TALLOC_FREE(config->basedir);
1927 if (config->basedir == NULL) {
1928 config->basedir = config->mount_point;
1931 if (strlen(config->basedir) != strlen(handle->conn->connectpath)) {
1932 config->rel_connectpath = talloc_strdup(config,
1933 handle->conn->connectpath + strlen(config->basedir));
1934 if (config->rel_connectpath == NULL) {
1935 DEBUG(0, ("talloc_strdup() failed\n"));
1941 if (config->snapdir[0] == '/') {
1942 config->snapdir_absolute = true;
1944 if (config->snapdirseverywhere == true) {
1945 DEBUG(1, (__location__ " Warning: An absolute snapdir "
1946 "is incompatible with 'snapdirseverywhere', "
1947 "setting 'snapdirseverywhere' to false.\n"));
1948 config->snapdirseverywhere = false;
1951 if (config->crossmountpoints == true) {
1952 DEBUG(1, (__location__ " Warning: 'crossmountpoints' "
1953 "is not supported with an absolute snapdir. "
1954 "Disabling it.\n"));
1955 config->crossmountpoints = false;
1958 config->snapshot_basepath = config->snapdir;
1960 config->snapshot_basepath = talloc_asprintf(config, "%s/%s",
1961 config->mount_point, config->snapdir);
1962 if (config->snapshot_basepath == NULL) {
1963 DEBUG(0, ("talloc_asprintf() failed\n"));
1969 DEBUG(10, ("shadow_copy2_connect: configuration:\n"
1970 " share root: '%s'\n"
1972 " mountpoint: '%s'\n"
1973 " rel share root: '%s'\n"
1975 " snapshot base path: '%s'\n"
1978 " snapdirs everywhere: %s\n"
1979 " cross mountpoints: %s\n"
1983 handle->conn->connectpath,
1985 config->mount_point,
1986 config->rel_connectpath,
1988 config->snapshot_basepath,
1990 config->use_sscanf ? "yes" : "no",
1991 config->snapdirseverywhere ? "yes" : "no",
1992 config->crossmountpoints ? "yes" : "no",
1993 config->fixinodes ? "yes" : "no",
1998 SMB_VFS_HANDLE_SET_DATA(handle, config,
1999 NULL, struct shadow_copy2_config,
2005 static struct vfs_fn_pointers vfs_shadow_copy2_fns = {
2006 .connect_fn = shadow_copy2_connect,
2007 .opendir_fn = shadow_copy2_opendir,
2008 .disk_free_fn = shadow_copy2_disk_free,
2009 .rename_fn = shadow_copy2_rename,
2010 .link_fn = shadow_copy2_link,
2011 .symlink_fn = shadow_copy2_symlink,
2012 .stat_fn = shadow_copy2_stat,
2013 .lstat_fn = shadow_copy2_lstat,
2014 .fstat_fn = shadow_copy2_fstat,
2015 .open_fn = shadow_copy2_open,
2016 .unlink_fn = shadow_copy2_unlink,
2017 .chmod_fn = shadow_copy2_chmod,
2018 .chown_fn = shadow_copy2_chown,
2019 .chdir_fn = shadow_copy2_chdir,
2020 .ntimes_fn = shadow_copy2_ntimes,
2021 .readlink_fn = shadow_copy2_readlink,
2022 .mknod_fn = shadow_copy2_mknod,
2023 .realpath_fn = shadow_copy2_realpath,
2024 .get_nt_acl_fn = shadow_copy2_get_nt_acl,
2025 .fget_nt_acl_fn = shadow_copy2_fget_nt_acl,
2026 .get_shadow_copy_data_fn = shadow_copy2_get_shadow_copy_data,
2027 .mkdir_fn = shadow_copy2_mkdir,
2028 .rmdir_fn = shadow_copy2_rmdir,
2029 .getxattr_fn = shadow_copy2_getxattr,
2030 .listxattr_fn = shadow_copy2_listxattr,
2031 .removexattr_fn = shadow_copy2_removexattr,
2032 .setxattr_fn = shadow_copy2_setxattr,
2033 .chmod_acl_fn = shadow_copy2_chmod_acl,
2034 .chflags_fn = shadow_copy2_chflags,
2035 .get_real_filename_fn = shadow_copy2_get_real_filename,
2038 NTSTATUS vfs_shadow_copy2_init(void);
2039 NTSTATUS vfs_shadow_copy2_init(void)
2041 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2042 "shadow_copy2", &vfs_shadow_copy2_fns);