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 timstamp, build the posix level GTM-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 timstamp, 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 an 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;
239 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
242 DEBUG(10, (__location__ ": enter path '%s'\n", name));
244 p = strstr_m(name, "@GMT-");
248 if ((p > name) && (p[-1] != '/')) {
249 /* the GMT-token does not start a path-component */
252 q = strptime(p, GMT_FORMAT, &tm);
257 timestamp = timegm(&tm);
258 if (timestamp == (time_t)-1) {
261 if ((p == name) && (q[0] == '\0')) {
262 /* the name consists of only the GMT token */
263 if (pstripped != NULL) {
264 stripped = talloc_strdup(mem_ctx, "");
265 if (stripped == NULL) {
268 *pstripped = stripped;
270 *ptimestamp = timestamp;
275 * The GMT token is either at the end of the path
276 * or it is not a complete path component, i.e. the
277 * path component continues after the gmt-token.
279 * TODO: Is this correct? Or would the GMT tag as the
280 * last component be a valid input?
286 rest_len = strlen(q);
287 dst_len = (p-name) + rest_len;
289 if (config->snapdirseverywhere) {
292 insert = shadow_copy2_insert_string(talloc_tos(), handle,
294 if (insert == NULL) {
299 DEBUG(10, (__location__ ": snapdirseverywhere mode.\n"
301 "insert string '%s'\n", name, insert));
303 have_insert = (strstr(name, insert+1) != NULL);
305 DEBUG(10, (__location__ ": insert string '%s' found in "
306 "path '%s' found in snapdirseverywhere mode "
307 "==> already converted\n", insert, name));
316 snapshot_path = shadow_copy2_snapshot_path(talloc_tos(),
319 if (snapshot_path == NULL) {
324 DEBUG(10, (__location__ " path: '%s'.\n"
325 "snapshot path: '%s'\n", name, snapshot_path));
327 s = strstr(name, snapshot_path);
330 * this starts with "snapshot_basepath/GMT-Token"
331 * so it is already a converted absolute
332 * path. Don't process further.
334 DEBUG(10, (__location__ ": path '%s' starts with "
335 "snapshot path '%s' (not in "
336 "snapdirseverywhere mode) ==> "
337 "already converted\n", name, snapshot_path));
338 talloc_free(snapshot_path);
341 talloc_free(snapshot_path);
344 if (pstripped != NULL) {
345 stripped = talloc_array(mem_ctx, char, dst_len+1);
346 if (stripped == NULL) {
351 memcpy(stripped, name, p-name);
354 memcpy(stripped + (p-name), q, rest_len);
356 stripped[dst_len] = '\0';
357 *pstripped = stripped;
359 *ptimestamp = timestamp;
366 static char *shadow_copy2_find_mount_point(TALLOC_CTX *mem_ctx,
367 vfs_handle_struct *handle)
369 char *path = talloc_strdup(mem_ctx, handle->conn->connectpath);
374 if (stat(path, &st) != 0) {
381 while ((p = strrchr(path, '/')) && p > path) {
383 if (stat(path, &st) != 0) {
387 if (st.st_dev != dev) {
397 * Convert from a name as handed in via the SMB layer
398 * and a timestamp into the local path of the snapshot
399 * of the provided file at the provided time.
401 static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx,
402 struct vfs_handle_struct *handle,
403 const char *name, time_t timestamp)
405 struct smb_filename converted_fname;
407 size_t *slashes = NULL;
408 unsigned num_slashes;
412 char *converted = NULL;
416 struct shadow_copy2_config *config;
418 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
421 DEBUG(10, ("converting '%s'\n", name));
423 if (!config->snapdirseverywhere) {
427 snapshot_path = shadow_copy2_snapshot_path(talloc_tos(),
430 if (snapshot_path == NULL) {
434 if (config->rel_connectpath == NULL) {
435 converted = talloc_asprintf(mem_ctx, "%s/%s",
436 snapshot_path, name);
438 converted = talloc_asprintf(mem_ctx, "%s/%s/%s",
440 config->rel_connectpath,
443 if (converted == NULL) {
447 ZERO_STRUCT(converted_fname);
448 converted_fname.base_name = converted;
450 ret = SMB_VFS_NEXT_LSTAT(handle, &converted_fname);
451 DEBUG(10, ("Trying[not snapdirseverywhere] %s: %d (%s)\n",
453 ret, ret == 0 ? "ok" : strerror(errno)));
455 DEBUG(10, ("Found %s\n", converted));
463 /* never reached ... */
466 path = talloc_asprintf(mem_ctx, "%s/%s", handle->conn->connectpath,
472 pathlen = talloc_get_size(path)-1;
474 if (!shadow_copy2_find_slashes(talloc_tos(), path,
475 &slashes, &num_slashes)) {
479 insert = shadow_copy2_insert_string(talloc_tos(), handle, timestamp);
480 if (insert == NULL) {
483 insertlen = talloc_get_size(insert)-1;
485 converted = talloc_array(mem_ctx, char, pathlen + insertlen + 1);
486 if (converted == NULL) {
490 if (path[pathlen-1] != '/') {
492 * Append a fake slash to find the snapshot root
495 tmp = talloc_realloc(talloc_tos(), slashes,
496 size_t, num_slashes+1);
501 slashes[num_slashes] = pathlen;
507 if (!config->crossmountpoints) {
508 min_offset = strlen(config->mount_point);
511 memcpy(converted, path, pathlen+1);
512 converted[pathlen+insertlen] = '\0';
514 ZERO_STRUCT(converted_fname);
515 converted_fname.base_name = converted;
517 for (i = num_slashes-1; i>=0; i--) {
523 if (offset < min_offset) {
528 memcpy(converted+offset, insert, insertlen);
531 memcpy(converted+offset, path + slashes[i],
532 pathlen - slashes[i]);
534 ret = SMB_VFS_NEXT_LSTAT(handle, &converted_fname);
536 DEBUG(10, ("Trying[snapdirseverywhere] %s: %d (%s)\n",
538 ret, ret == 0 ? "ok" : strerror(errno)));
543 if (errno == ENOTDIR) {
545 * This is a valid condition: We appended the
546 * .snaphots/@GMT.. to a file name. Just try
547 * with the upper levels.
551 if (errno != ENOENT) {
552 /* Other problem than "not found" */
561 DEBUG(10, ("Found %s\n", converted));
569 TALLOC_FREE(converted);
571 TALLOC_FREE(slashes);
578 modify a sbuf return to ensure that inodes in the shadow directory
579 are different from those in the main directory
581 static void convert_sbuf(vfs_handle_struct *handle, const char *fname,
582 SMB_STRUCT_STAT *sbuf)
584 struct shadow_copy2_config *config;
586 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
589 if (config->fixinodes) {
590 /* some snapshot systems, like GPFS, return the name
591 device:inode for the snapshot files as the current
592 files. That breaks the 'restore' button in the shadow copy
593 GUI, as the client gets a sharing violation.
595 This is a crude way of allowing both files to be
596 open at once. It has a slight chance of inode
597 number collision, but I can't see a better approach
598 without significant VFS changes
602 shash = hash(fname, strlen(fname), 0) & 0xFF000000;
606 sbuf->st_ex_ino ^= shash;
610 static DIR *shadow_copy2_opendir(vfs_handle_struct *handle,
621 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
622 ×tamp, &stripped)) {
625 if (timestamp == 0) {
626 return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
628 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
629 TALLOC_FREE(stripped);
633 ret = SMB_VFS_NEXT_OPENDIR(handle, conv, mask, attr);
640 static int shadow_copy2_rename(vfs_handle_struct *handle,
641 const struct smb_filename *smb_fname_src,
642 const struct smb_filename *smb_fname_dst)
644 time_t timestamp_src, timestamp_dst;
646 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
647 smb_fname_src->base_name,
648 ×tamp_src, NULL)) {
651 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
652 smb_fname_dst->base_name,
653 ×tamp_dst, NULL)) {
656 if (timestamp_src != 0) {
660 if (timestamp_dst != 0) {
664 return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
667 static int shadow_copy2_symlink(vfs_handle_struct *handle,
668 const char *oldname, const char *newname)
670 time_t timestamp_old, timestamp_new;
672 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, oldname,
673 ×tamp_old, NULL)) {
676 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, newname,
677 ×tamp_new, NULL)) {
680 if ((timestamp_old != 0) || (timestamp_new != 0)) {
684 return SMB_VFS_NEXT_SYMLINK(handle, oldname, newname);
687 static int shadow_copy2_link(vfs_handle_struct *handle,
688 const char *oldname, const char *newname)
690 time_t timestamp_old, timestamp_new;
692 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, oldname,
693 ×tamp_old, NULL)) {
696 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, newname,
697 ×tamp_new, NULL)) {
700 if ((timestamp_old != 0) || (timestamp_new != 0)) {
704 return SMB_VFS_NEXT_LINK(handle, oldname, newname);
707 static int shadow_copy2_stat(vfs_handle_struct *handle,
708 struct smb_filename *smb_fname)
711 char *stripped, *tmp;
712 int ret, saved_errno;
714 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
715 smb_fname->base_name,
716 ×tamp, &stripped)) {
719 if (timestamp == 0) {
720 return SMB_VFS_NEXT_STAT(handle, smb_fname);
723 tmp = smb_fname->base_name;
724 smb_fname->base_name = shadow_copy2_convert(
725 talloc_tos(), handle, stripped, timestamp);
726 TALLOC_FREE(stripped);
728 if (smb_fname->base_name == NULL) {
729 smb_fname->base_name = tmp;
733 ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
736 TALLOC_FREE(smb_fname->base_name);
737 smb_fname->base_name = tmp;
740 convert_sbuf(handle, smb_fname->base_name, &smb_fname->st);
746 static int shadow_copy2_lstat(vfs_handle_struct *handle,
747 struct smb_filename *smb_fname)
750 char *stripped, *tmp;
751 int ret, saved_errno;
753 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
754 smb_fname->base_name,
755 ×tamp, &stripped)) {
758 if (timestamp == 0) {
759 return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
762 tmp = smb_fname->base_name;
763 smb_fname->base_name = shadow_copy2_convert(
764 talloc_tos(), handle, stripped, timestamp);
765 TALLOC_FREE(stripped);
767 if (smb_fname->base_name == NULL) {
768 smb_fname->base_name = tmp;
772 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
775 TALLOC_FREE(smb_fname->base_name);
776 smb_fname->base_name = tmp;
779 convert_sbuf(handle, smb_fname->base_name, &smb_fname->st);
785 static int shadow_copy2_fstat(vfs_handle_struct *handle, files_struct *fsp,
786 SMB_STRUCT_STAT *sbuf)
791 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
795 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
796 fsp->fsp_name->base_name,
800 if (timestamp != 0) {
801 convert_sbuf(handle, fsp->fsp_name->base_name, sbuf);
806 static int shadow_copy2_open(vfs_handle_struct *handle,
807 struct smb_filename *smb_fname, files_struct *fsp,
808 int flags, mode_t mode)
811 char *stripped, *tmp;
812 int ret, saved_errno;
814 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
815 smb_fname->base_name,
816 ×tamp, &stripped)) {
819 if (timestamp == 0) {
820 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
823 tmp = smb_fname->base_name;
824 smb_fname->base_name = shadow_copy2_convert(
825 talloc_tos(), handle, stripped, timestamp);
826 TALLOC_FREE(stripped);
828 if (smb_fname->base_name == NULL) {
829 smb_fname->base_name = tmp;
833 ret = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
836 TALLOC_FREE(smb_fname->base_name);
837 smb_fname->base_name = tmp;
843 static int shadow_copy2_unlink(vfs_handle_struct *handle,
844 const struct smb_filename *smb_fname)
848 int ret, saved_errno;
849 struct smb_filename *conv;
851 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
852 smb_fname->base_name,
853 ×tamp, &stripped)) {
856 if (timestamp == 0) {
857 return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
859 conv = cp_smb_filename(talloc_tos(), smb_fname);
864 conv->base_name = shadow_copy2_convert(
865 conv, handle, stripped, timestamp);
866 TALLOC_FREE(stripped);
867 if (conv->base_name == NULL) {
870 ret = SMB_VFS_NEXT_UNLINK(handle, conv);
877 static int shadow_copy2_chmod(vfs_handle_struct *handle, const char *fname,
882 int ret, saved_errno;
885 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
886 ×tamp, &stripped)) {
889 if (timestamp == 0) {
890 return SMB_VFS_NEXT_CHMOD(handle, fname, mode);
892 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
893 TALLOC_FREE(stripped);
897 ret = SMB_VFS_NEXT_CHMOD(handle, conv, mode);
904 static int shadow_copy2_chown(vfs_handle_struct *handle, const char *fname,
905 uid_t uid, gid_t gid)
909 int ret, saved_errno;
912 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
913 ×tamp, &stripped)) {
916 if (timestamp == 0) {
917 return SMB_VFS_NEXT_CHOWN(handle, fname, uid, gid);
919 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
920 TALLOC_FREE(stripped);
924 ret = SMB_VFS_NEXT_CHOWN(handle, conv, uid, gid);
931 static int shadow_copy2_chdir(vfs_handle_struct *handle,
936 int ret, saved_errno;
939 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
940 ×tamp, &stripped)) {
943 if (timestamp == 0) {
944 return SMB_VFS_NEXT_CHDIR(handle, fname);
946 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
947 TALLOC_FREE(stripped);
951 ret = SMB_VFS_NEXT_CHDIR(handle, conv);
958 static int shadow_copy2_ntimes(vfs_handle_struct *handle,
959 const struct smb_filename *smb_fname,
960 struct smb_file_time *ft)
964 int ret, saved_errno;
965 struct smb_filename *conv;
967 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
968 smb_fname->base_name,
969 ×tamp, &stripped)) {
972 if (timestamp == 0) {
973 return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
975 conv = cp_smb_filename(talloc_tos(), smb_fname);
980 conv->base_name = shadow_copy2_convert(
981 conv, handle, stripped, timestamp);
982 TALLOC_FREE(stripped);
983 if (conv->base_name == NULL) {
986 ret = SMB_VFS_NEXT_NTIMES(handle, conv, ft);
993 static int shadow_copy2_readlink(vfs_handle_struct *handle,
994 const char *fname, char *buf, size_t bufsiz)
998 int ret, saved_errno;
1001 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1002 ×tamp, &stripped)) {
1005 if (timestamp == 0) {
1006 return SMB_VFS_NEXT_READLINK(handle, fname, buf, bufsiz);
1008 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1009 TALLOC_FREE(stripped);
1013 ret = SMB_VFS_NEXT_READLINK(handle, conv, buf, bufsiz);
1014 saved_errno = errno;
1016 errno = saved_errno;
1020 static int shadow_copy2_mknod(vfs_handle_struct *handle,
1021 const char *fname, mode_t mode, SMB_DEV_T dev)
1025 int ret, saved_errno;
1028 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1029 ×tamp, &stripped)) {
1032 if (timestamp == 0) {
1033 return SMB_VFS_NEXT_MKNOD(handle, fname, mode, dev);
1035 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1036 TALLOC_FREE(stripped);
1040 ret = SMB_VFS_NEXT_MKNOD(handle, conv, mode, dev);
1041 saved_errno = errno;
1043 errno = saved_errno;
1047 static char *shadow_copy2_realpath(vfs_handle_struct *handle,
1051 char *stripped = NULL;
1053 char *result = NULL;
1054 char *inserted = NULL;
1055 char *inserted_to, *inserted_end;
1058 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1059 ×tamp, &stripped)) {
1062 if (timestamp == 0) {
1063 return SMB_VFS_NEXT_REALPATH(handle, fname);
1066 tmp = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1071 result = SMB_VFS_NEXT_REALPATH(handle, tmp);
1072 if (result == NULL) {
1077 * Take away what we've inserted. This removes the @GMT-thingy
1078 * completely, but will give a path under the share root.
1080 inserted = shadow_copy2_insert_string(talloc_tos(), handle, timestamp);
1081 if (inserted == NULL) {
1084 inserted_to = strstr_m(result, inserted);
1085 if (inserted_to == NULL) {
1086 DEBUG(2, ("SMB_VFS_NEXT_REALPATH removed %s\n", inserted));
1089 inserted_end = inserted_to + talloc_get_size(inserted) - 1;
1090 memmove(inserted_to, inserted_end, strlen(inserted_end)+1);
1093 saved_errno = errno;
1094 TALLOC_FREE(inserted);
1096 TALLOC_FREE(stripped);
1097 errno = saved_errno;
1102 * Check whether a given directory contains a
1103 * snapshot directory as direct subdirectory.
1104 * If yes, return the path of the snapshot-subdir,
1105 * otherwise return NULL.
1107 static char *have_snapdir(struct vfs_handle_struct *handle,
1110 struct smb_filename smb_fname;
1112 struct shadow_copy2_config *config;
1114 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
1117 ZERO_STRUCT(smb_fname);
1118 smb_fname.base_name = talloc_asprintf(talloc_tos(), "%s/%s",
1119 path, config->snapdir);
1120 if (smb_fname.base_name == NULL) {
1124 ret = SMB_VFS_NEXT_STAT(handle, &smb_fname);
1125 if ((ret == 0) && (S_ISDIR(smb_fname.st.st_ex_mode))) {
1126 return smb_fname.base_name;
1128 TALLOC_FREE(smb_fname.base_name);
1133 * Find the snapshot directory (if any) for the given
1134 * filename (which is relative to the share).
1136 static const char *shadow_copy2_find_snapdir(TALLOC_CTX *mem_ctx,
1137 struct vfs_handle_struct *handle,
1138 struct smb_filename *smb_fname)
1141 const char *snapdir;
1142 struct shadow_copy2_config *config;
1144 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
1148 * If the non-snapdisrseverywhere mode, we should not search!
1150 if (!config->snapdirseverywhere) {
1151 return config->snapshot_basepath;
1154 path = talloc_asprintf(mem_ctx, "%s/%s",
1155 handle->conn->connectpath,
1156 smb_fname->base_name);
1161 snapdir = have_snapdir(handle, path);
1162 if (snapdir != NULL) {
1167 while ((p = strrchr(path, '/')) && (p > path)) {
1171 snapdir = have_snapdir(handle, path);
1172 if (snapdir != NULL) {
1181 static bool shadow_copy2_snapshot_to_gmt(vfs_handle_struct *handle,
1183 char *gmt, size_t gmt_len)
1185 struct tm timestamp;
1187 unsigned long int timestamp_long;
1189 struct shadow_copy2_config *config;
1191 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
1194 fmt = config->gmt_format;
1196 ZERO_STRUCT(timestamp);
1197 if (config->use_sscanf) {
1198 if (sscanf(name, fmt, ×tamp_long) != 1) {
1199 DEBUG(10, ("shadow_copy2_snapshot_to_gmt: "
1200 "no sscanf match %s: %s\n",
1204 timestamp_t = timestamp_long;
1205 gmtime_r(×tamp_t, ×tamp);
1207 if (strptime(name, fmt, ×tamp) == NULL) {
1208 DEBUG(10, ("shadow_copy2_snapshot_to_gmt: "
1209 "no match %s: %s\n",
1213 DEBUG(10, ("shadow_copy2_snapshot_to_gmt: match %s: %s\n",
1216 if (config->use_localtime) {
1217 timestamp.tm_isdst = -1;
1218 timestamp_t = mktime(×tamp);
1219 gmtime_r(×tamp_t, ×tamp);
1223 strftime(gmt, gmt_len, GMT_FORMAT, ×tamp);
1227 static int shadow_copy2_label_cmp_asc(const void *x, const void *y)
1229 return strncmp((const char *)x, (const char *)y, sizeof(SHADOW_COPY_LABEL));
1232 static int shadow_copy2_label_cmp_desc(const void *x, const void *y)
1234 return -strncmp((const char *)x, (const char *)y, sizeof(SHADOW_COPY_LABEL));
1238 sort the shadow copy data in ascending or descending order
1240 static void shadow_copy2_sort_data(vfs_handle_struct *handle,
1241 struct shadow_copy_data *shadow_copy2_data)
1243 int (*cmpfunc)(const void *, const void *);
1245 struct shadow_copy2_config *config;
1247 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
1250 sort = config->sort_order;
1255 if (strcmp(sort, "asc") == 0) {
1256 cmpfunc = shadow_copy2_label_cmp_asc;
1257 } else if (strcmp(sort, "desc") == 0) {
1258 cmpfunc = shadow_copy2_label_cmp_desc;
1263 if (shadow_copy2_data && shadow_copy2_data->num_volumes > 0 &&
1264 shadow_copy2_data->labels)
1266 TYPESAFE_QSORT(shadow_copy2_data->labels,
1267 shadow_copy2_data->num_volumes,
1272 static int shadow_copy2_get_shadow_copy_data(
1273 vfs_handle_struct *handle, files_struct *fsp,
1274 struct shadow_copy_data *shadow_copy2_data,
1278 const char *snapdir;
1280 TALLOC_CTX *tmp_ctx = talloc_stackframe();
1282 snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle, fsp->fsp_name);
1283 if (snapdir == NULL) {
1284 DEBUG(0,("shadow:snapdir not found for %s in get_shadow_copy_data\n",
1285 handle->conn->connectpath));
1287 talloc_free(tmp_ctx);
1291 p = SMB_VFS_NEXT_OPENDIR(handle, snapdir, NULL, 0);
1294 DEBUG(2,("shadow_copy2: SMB_VFS_NEXT_OPENDIR() failed for '%s'"
1295 " - %s\n", snapdir, strerror(errno)));
1296 talloc_free(tmp_ctx);
1301 shadow_copy2_data->num_volumes = 0;
1302 shadow_copy2_data->labels = NULL;
1304 while ((d = SMB_VFS_NEXT_READDIR(handle, p, NULL))) {
1305 char snapshot[GMT_NAME_LEN+1];
1306 SHADOW_COPY_LABEL *tlabels;
1309 * ignore names not of the right form in the snapshot
1312 if (!shadow_copy2_snapshot_to_gmt(
1314 snapshot, sizeof(snapshot))) {
1316 DEBUG(6, ("shadow_copy2_get_shadow_copy_data: "
1317 "ignoring %s\n", d->d_name));
1320 DEBUG(6,("shadow_copy2_get_shadow_copy_data: %s -> %s\n",
1321 d->d_name, snapshot));
1324 /* the caller doesn't want the labels */
1325 shadow_copy2_data->num_volumes++;
1329 tlabels = talloc_realloc(shadow_copy2_data,
1330 shadow_copy2_data->labels,
1332 shadow_copy2_data->num_volumes+1);
1333 if (tlabels == NULL) {
1334 DEBUG(0,("shadow_copy2: out of memory\n"));
1335 SMB_VFS_NEXT_CLOSEDIR(handle, p);
1336 talloc_free(tmp_ctx);
1340 strlcpy(tlabels[shadow_copy2_data->num_volumes], snapshot,
1343 shadow_copy2_data->num_volumes++;
1344 shadow_copy2_data->labels = tlabels;
1347 SMB_VFS_NEXT_CLOSEDIR(handle,p);
1349 shadow_copy2_sort_data(handle, shadow_copy2_data);
1351 talloc_free(tmp_ctx);
1355 static NTSTATUS shadow_copy2_fget_nt_acl(vfs_handle_struct *handle,
1356 struct files_struct *fsp,
1357 uint32 security_info,
1358 TALLOC_CTX *mem_ctx,
1359 struct security_descriptor **ppdesc)
1366 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
1367 fsp->fsp_name->base_name,
1368 ×tamp, &stripped)) {
1369 return map_nt_error_from_unix(errno);
1371 if (timestamp == 0) {
1372 return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
1376 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1377 TALLOC_FREE(stripped);
1379 return map_nt_error_from_unix(errno);
1381 status = SMB_VFS_NEXT_GET_NT_ACL(handle, conv, security_info,
1387 static NTSTATUS shadow_copy2_get_nt_acl(vfs_handle_struct *handle,
1389 uint32 security_info,
1390 TALLOC_CTX *mem_ctx,
1391 struct security_descriptor **ppdesc)
1398 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1399 ×tamp, &stripped)) {
1400 return map_nt_error_from_unix(errno);
1402 if (timestamp == 0) {
1403 return SMB_VFS_NEXT_GET_NT_ACL(handle, fname, security_info,
1406 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1407 TALLOC_FREE(stripped);
1409 return map_nt_error_from_unix(errno);
1411 status = SMB_VFS_NEXT_GET_NT_ACL(handle, conv, security_info,
1417 static int shadow_copy2_mkdir(vfs_handle_struct *handle,
1418 const char *fname, mode_t mode)
1422 int ret, saved_errno;
1425 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1426 ×tamp, &stripped)) {
1429 if (timestamp == 0) {
1430 return SMB_VFS_NEXT_MKDIR(handle, fname, mode);
1432 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1433 TALLOC_FREE(stripped);
1437 ret = SMB_VFS_NEXT_MKDIR(handle, conv, mode);
1438 saved_errno = errno;
1440 errno = saved_errno;
1444 static int shadow_copy2_rmdir(vfs_handle_struct *handle, const char *fname)
1448 int ret, saved_errno;
1451 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1452 ×tamp, &stripped)) {
1455 if (timestamp == 0) {
1456 return SMB_VFS_NEXT_RMDIR(handle, fname);
1458 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1459 TALLOC_FREE(stripped);
1463 ret = SMB_VFS_NEXT_RMDIR(handle, conv);
1464 saved_errno = errno;
1466 errno = saved_errno;
1470 static int shadow_copy2_chflags(vfs_handle_struct *handle, const char *fname,
1475 int ret, saved_errno;
1478 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1479 ×tamp, &stripped)) {
1482 if (timestamp == 0) {
1483 return SMB_VFS_NEXT_CHFLAGS(handle, fname, flags);
1485 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1486 TALLOC_FREE(stripped);
1490 ret = SMB_VFS_NEXT_CHFLAGS(handle, conv, flags);
1491 saved_errno = errno;
1493 errno = saved_errno;
1497 static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle,
1498 const char *fname, const char *aname,
1499 void *value, size_t size)
1507 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1508 ×tamp, &stripped)) {
1511 if (timestamp == 0) {
1512 return SMB_VFS_NEXT_GETXATTR(handle, fname, aname, value,
1515 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1516 TALLOC_FREE(stripped);
1520 ret = SMB_VFS_NEXT_GETXATTR(handle, conv, aname, value, size);
1521 saved_errno = errno;
1523 errno = saved_errno;
1527 static ssize_t shadow_copy2_listxattr(struct vfs_handle_struct *handle,
1529 char *list, size_t size)
1537 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1538 ×tamp, &stripped)) {
1541 if (timestamp == 0) {
1542 return SMB_VFS_NEXT_LISTXATTR(handle, fname, list, size);
1544 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1545 TALLOC_FREE(stripped);
1549 ret = SMB_VFS_NEXT_LISTXATTR(handle, conv, list, size);
1550 saved_errno = errno;
1552 errno = saved_errno;
1556 static int shadow_copy2_removexattr(vfs_handle_struct *handle,
1557 const char *fname, const char *aname)
1561 int ret, saved_errno;
1564 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1565 ×tamp, &stripped)) {
1568 if (timestamp == 0) {
1569 return SMB_VFS_NEXT_REMOVEXATTR(handle, fname, aname);
1571 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1572 TALLOC_FREE(stripped);
1576 ret = SMB_VFS_NEXT_REMOVEXATTR(handle, conv, aname);
1577 saved_errno = errno;
1579 errno = saved_errno;
1583 static int shadow_copy2_setxattr(struct vfs_handle_struct *handle,
1585 const char *aname, const void *value,
1586 size_t size, int flags)
1594 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1595 ×tamp, &stripped)) {
1598 if (timestamp == 0) {
1599 return SMB_VFS_NEXT_SETXATTR(handle, fname, aname, value, size,
1602 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1603 TALLOC_FREE(stripped);
1607 ret = SMB_VFS_NEXT_SETXATTR(handle, conv, aname, value, size, flags);
1608 saved_errno = errno;
1610 errno = saved_errno;
1614 static int shadow_copy2_chmod_acl(vfs_handle_struct *handle,
1615 const char *fname, mode_t mode)
1623 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1624 ×tamp, &stripped)) {
1627 if (timestamp == 0) {
1628 return SMB_VFS_NEXT_CHMOD_ACL(handle, fname, mode);
1630 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1631 TALLOC_FREE(stripped);
1635 ret = SMB_VFS_NEXT_CHMOD_ACL(handle, conv, mode);
1636 saved_errno = errno;
1638 errno = saved_errno;
1642 static int shadow_copy2_get_real_filename(struct vfs_handle_struct *handle,
1645 TALLOC_CTX *mem_ctx,
1654 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, path,
1655 ×tamp, &stripped)) {
1658 if (timestamp == 0) {
1659 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
1660 mem_ctx, found_name);
1662 if (stripped[0] == '\0') {
1663 *found_name = talloc_strdup(mem_ctx, name);
1664 if (*found_name == NULL) {
1670 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1671 TALLOC_FREE(stripped);
1675 ret = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, conv, name,
1676 mem_ctx, found_name);
1677 saved_errno = errno;
1679 errno = saved_errno;
1683 static uint64_t shadow_copy2_disk_free(vfs_handle_struct *handle,
1684 const char *path, bool small_query,
1685 uint64_t *bsize, uint64_t *dfree,
1694 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, path,
1695 ×tamp, &stripped)) {
1698 if (timestamp == 0) {
1699 return SMB_VFS_NEXT_DISK_FREE(handle, path, small_query,
1700 bsize, dfree, dsize);
1703 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1704 TALLOC_FREE(stripped);
1709 ret = SMB_VFS_NEXT_DISK_FREE(handle, conv, small_query, bsize, dfree,
1712 saved_errno = errno;
1714 errno = saved_errno;
1719 static int shadow_copy2_connect(struct vfs_handle_struct *handle,
1720 const char *service, const char *user)
1722 struct shadow_copy2_config *config;
1724 const char *snapdir;
1725 const char *gmt_format;
1726 const char *sort_order;
1727 const char *basedir;
1728 const char *mount_point;
1730 DEBUG(10, (__location__ ": cnum[%u], connectpath[%s]\n",
1731 (unsigned)handle->conn->cnum,
1732 handle->conn->connectpath));
1734 ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
1739 config = talloc_zero(handle->conn, struct shadow_copy2_config);
1740 if (config == NULL) {
1741 DEBUG(0, ("talloc_zero() failed\n"));
1746 gmt_format = lp_parm_const_string(SNUM(handle->conn),
1749 config->gmt_format = talloc_strdup(config, gmt_format);
1750 if (config->gmt_format == NULL) {
1751 DEBUG(0, ("talloc_strdup() failed\n"));
1756 config->use_sscanf = lp_parm_bool(SNUM(handle->conn),
1757 "shadow", "sscanf", false);
1759 config->use_localtime = lp_parm_bool(SNUM(handle->conn),
1760 "shadow", "localtime",
1763 snapdir = lp_parm_const_string(SNUM(handle->conn),
1764 "shadow", "snapdir",
1766 config->snapdir = talloc_strdup(config, snapdir);
1767 if (config->snapdir == NULL) {
1768 DEBUG(0, ("talloc_strdup() failed\n"));
1773 config->snapdirseverywhere = lp_parm_bool(SNUM(handle->conn),
1775 "snapdirseverywhere",
1778 config->crossmountpoints = lp_parm_bool(SNUM(handle->conn),
1779 "shadow", "crossmountpoints",
1782 config->fixinodes = lp_parm_bool(SNUM(handle->conn),
1783 "shadow", "fixinodes",
1786 sort_order = lp_parm_const_string(SNUM(handle->conn),
1787 "shadow", "sort", "desc");
1788 config->sort_order = talloc_strdup(config, sort_order);
1789 if (config->sort_order == NULL) {
1790 DEBUG(0, ("talloc_strdup() failed\n"));
1795 mount_point = lp_parm_const_string(SNUM(handle->conn),
1796 "shadow", "mountpoint", NULL);
1797 if (mount_point != NULL) {
1798 if (mount_point[0] != '/') {
1799 DEBUG(1, (__location__ " Warning: 'mountpoint' is "
1800 "relative ('%s'), but it has to be an "
1801 "absolute path. Ignoring provided value.\n",
1806 p = strstr(handle->conn->connectpath, mount_point);
1807 if (p != handle->conn->connectpath) {
1808 DEBUG(1, ("Warning: mount_point (%s) is not a "
1809 "subdirectory of the share root "
1810 "(%s). Ignoring provided value.\n",
1812 handle->conn->connectpath));
1818 if (mount_point != NULL) {
1819 config->mount_point = talloc_strdup(config, mount_point);
1820 if (config->mount_point == NULL) {
1821 DEBUG(0, (__location__ " talloc_strdup() failed\n"));
1825 config->mount_point = shadow_copy2_find_mount_point(config,
1827 if (config->mount_point == NULL) {
1828 DEBUG(0, (__location__ ": shadow_copy2_find_mount_point"
1829 " failed: %s\n", strerror(errno)));
1834 basedir = lp_parm_const_string(SNUM(handle->conn),
1835 "shadow", "basedir", NULL);
1837 if (basedir != NULL) {
1838 if (basedir[0] != '/') {
1839 DEBUG(1, (__location__ " Warning: 'basedir' is "
1840 "relative ('%s'), but it has to be an "
1841 "absolute path. Disabling basedir.\n",
1845 p = strstr(basedir, config->mount_point);
1847 DEBUG(1, ("Warning: basedir (%s) is not a "
1848 "subdirectory of the share root's "
1849 "mount point (%s). "
1850 "Disabling basedir\n",
1851 basedir, config->mount_point));
1853 config->basedir = talloc_strdup(config,
1855 if (config->basedir == NULL) {
1856 DEBUG(0, ("talloc_strdup() failed\n"));
1864 if (config->snapdirseverywhere && config->basedir != NULL) {
1865 DEBUG(1, (__location__ " Warning: 'basedir' is incompatible "
1866 "with 'snapdirseverywhere'. Disabling basedir.\n"));
1867 TALLOC_FREE(config->basedir);
1870 if (config->crossmountpoints && config->basedir != NULL) {
1871 DEBUG(1, (__location__ " Warning: 'basedir' is incompatible "
1872 "with 'crossmountpoints'. Disabling basedir.\n"));
1873 TALLOC_FREE(config->basedir);
1876 if (config->basedir == NULL) {
1877 config->basedir = config->mount_point;
1880 if (strlen(config->basedir) != strlen(handle->conn->connectpath)) {
1881 config->rel_connectpath = talloc_strdup(config,
1882 handle->conn->connectpath + strlen(config->basedir));
1883 if (config->rel_connectpath == NULL) {
1884 DEBUG(0, ("talloc_strdup() failed\n"));
1890 if (config->snapdir[0] == '/') {
1891 config->snapdir_absolute = true;
1893 if (config->snapdirseverywhere == true) {
1894 DEBUG(1, (__location__ " Warning: An absolute snapdir "
1895 "is incompatible with 'snapdirseverywhere', "
1896 "setting 'snapdirseverywhere' to false.\n"));
1897 config->snapdirseverywhere = false;
1900 if (config->crossmountpoints == true) {
1901 DEBUG(1, (__location__ " Warning: 'crossmountpoints' "
1902 "is not supported with an absolute snapdir. "
1903 "Disabling it.\n"));
1904 config->crossmountpoints = false;
1907 config->snapshot_basepath = config->snapdir;
1909 config->snapshot_basepath = talloc_asprintf(config, "%s/%s",
1910 config->mount_point, config->snapdir);
1911 if (config->snapshot_basepath == NULL) {
1912 DEBUG(0, ("talloc_asprintf() failed\n"));
1918 DEBUG(10, ("shadow_copy2_connect: configuration:\n"
1919 " share root: '%s'\n"
1921 " mountpoint: '%s'\n"
1922 " rel share root: '%s'\n"
1924 " snapshot base path: '%s'\n"
1927 " snapdirs everywhere: %s\n"
1928 " cross mountpoints: %s\n"
1932 handle->conn->connectpath,
1934 config->mount_point,
1935 config->rel_connectpath,
1937 config->snapshot_basepath,
1939 config->use_sscanf ? "yes" : "no",
1940 config->snapdirseverywhere ? "yes" : "no",
1941 config->crossmountpoints ? "yes" : "no",
1942 config->fixinodes ? "yes" : "no",
1947 SMB_VFS_HANDLE_SET_DATA(handle, config,
1948 NULL, struct shadow_copy2_config,
1954 static struct vfs_fn_pointers vfs_shadow_copy2_fns = {
1955 .connect_fn = shadow_copy2_connect,
1956 .opendir_fn = shadow_copy2_opendir,
1957 .disk_free_fn = shadow_copy2_disk_free,
1958 .rename_fn = shadow_copy2_rename,
1959 .link_fn = shadow_copy2_link,
1960 .symlink_fn = shadow_copy2_symlink,
1961 .stat_fn = shadow_copy2_stat,
1962 .lstat_fn = shadow_copy2_lstat,
1963 .fstat_fn = shadow_copy2_fstat,
1964 .open_fn = shadow_copy2_open,
1965 .unlink_fn = shadow_copy2_unlink,
1966 .chmod_fn = shadow_copy2_chmod,
1967 .chown_fn = shadow_copy2_chown,
1968 .chdir_fn = shadow_copy2_chdir,
1969 .ntimes_fn = shadow_copy2_ntimes,
1970 .readlink_fn = shadow_copy2_readlink,
1971 .mknod_fn = shadow_copy2_mknod,
1972 .realpath_fn = shadow_copy2_realpath,
1973 .get_nt_acl_fn = shadow_copy2_get_nt_acl,
1974 .fget_nt_acl_fn = shadow_copy2_fget_nt_acl,
1975 .get_shadow_copy_data_fn = shadow_copy2_get_shadow_copy_data,
1976 .mkdir_fn = shadow_copy2_mkdir,
1977 .rmdir_fn = shadow_copy2_rmdir,
1978 .getxattr_fn = shadow_copy2_getxattr,
1979 .listxattr_fn = shadow_copy2_listxattr,
1980 .removexattr_fn = shadow_copy2_removexattr,
1981 .setxattr_fn = shadow_copy2_setxattr,
1982 .chmod_acl_fn = shadow_copy2_chmod_acl,
1983 .chflags_fn = shadow_copy2_chflags,
1984 .get_real_filename_fn = shadow_copy2_get_real_filename,
1987 NTSTATUS vfs_shadow_copy2_init(void);
1988 NTSTATUS vfs_shadow_copy2_init(void)
1990 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
1991 "shadow_copy2", &vfs_shadow_copy2_fns);