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;
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-");
246 DEBUG(11, ("@GMT not found\n"));
249 if ((p > name) && (p[-1] != '/')) {
250 /* the GMT-token does not start a path-component */
251 DEBUG(10, ("not at start, p=%p, name=%p, p[-1]=%d\n",
252 p, name, (int)p[-1]));
255 q = strptime(p, GMT_FORMAT, &tm);
257 DEBUG(10, ("strptime failed\n"));
261 timestamp = timegm(&tm);
262 if (timestamp == (time_t)-1) {
263 DEBUG(10, ("timestamp==-1\n"));
268 * The name consists of only the GMT token or the GMT
269 * token is at the end of the path. XP seems to send
270 * @GMT- at the end under certain circumstances even
271 * with a path prefix.
273 if (pstripped != NULL) {
274 stripped = talloc_strndup(mem_ctx, name, p - name);
275 if (stripped == NULL) {
278 *pstripped = stripped;
280 *ptimestamp = timestamp;
285 * It is not a complete path component, i.e. the path
286 * component continues after the gmt-token.
288 DEBUG(10, ("q[0] = %d\n", (int)q[0]));
293 rest_len = strlen(q);
294 dst_len = (p-name) + rest_len;
296 if (config->snapdirseverywhere) {
299 insert = shadow_copy2_insert_string(talloc_tos(), handle,
301 if (insert == NULL) {
306 DEBUG(10, (__location__ ": snapdirseverywhere mode.\n"
308 "insert string '%s'\n", name, insert));
310 have_insert = (strstr(name, insert+1) != NULL);
311 DEBUG(10, ("have_insert=%d, name=%s, insert+1=%s\n",
312 (int)have_insert, name, insert+1));
314 DEBUG(10, (__location__ ": insert string '%s' found in "
315 "path '%s' found in snapdirseverywhere mode "
316 "==> already converted\n", insert, name));
325 snapshot_path = shadow_copy2_snapshot_path(talloc_tos(),
328 if (snapshot_path == NULL) {
333 DEBUG(10, (__location__ " path: '%s'.\n"
334 "snapshot path: '%s'\n", name, snapshot_path));
336 s = strstr(name, snapshot_path);
339 * this starts with "snapshot_basepath/GMT-Token"
340 * so it is already a converted absolute
341 * path. Don't process further.
343 DEBUG(10, (__location__ ": path '%s' starts with "
344 "snapshot path '%s' (not in "
345 "snapdirseverywhere mode) ==> "
346 "already converted\n", name, snapshot_path));
347 talloc_free(snapshot_path);
350 talloc_free(snapshot_path);
353 if (pstripped != NULL) {
354 stripped = talloc_array(mem_ctx, char, dst_len+1);
355 if (stripped == NULL) {
360 memcpy(stripped, name, p-name);
363 memcpy(stripped + (p-name), q, rest_len);
365 stripped[dst_len] = '\0';
366 *pstripped = stripped;
368 *ptimestamp = timestamp;
375 static char *shadow_copy2_find_mount_point(TALLOC_CTX *mem_ctx,
376 vfs_handle_struct *handle)
378 char *path = talloc_strdup(mem_ctx, handle->conn->connectpath);
383 if (stat(path, &st) != 0) {
390 while ((p = strrchr(path, '/')) && p > path) {
392 if (stat(path, &st) != 0) {
396 if (st.st_dev != dev) {
406 * Convert from a name as handed in via the SMB layer
407 * and a timestamp into the local path of the snapshot
408 * of the provided file at the provided time.
410 static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx,
411 struct vfs_handle_struct *handle,
412 const char *name, time_t timestamp)
414 struct smb_filename converted_fname;
416 size_t *slashes = NULL;
417 unsigned num_slashes;
421 char *converted = NULL;
425 struct shadow_copy2_config *config;
427 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
430 DEBUG(10, ("converting '%s'\n", name));
432 if (!config->snapdirseverywhere) {
436 snapshot_path = shadow_copy2_snapshot_path(talloc_tos(),
439 if (snapshot_path == NULL) {
443 if (config->rel_connectpath == NULL) {
444 converted = talloc_asprintf(mem_ctx, "%s/%s",
445 snapshot_path, name);
447 converted = talloc_asprintf(mem_ctx, "%s/%s/%s",
449 config->rel_connectpath,
452 if (converted == NULL) {
456 ZERO_STRUCT(converted_fname);
457 converted_fname.base_name = converted;
459 ret = SMB_VFS_NEXT_LSTAT(handle, &converted_fname);
460 DEBUG(10, ("Trying[not snapdirseverywhere] %s: %d (%s)\n",
462 ret, ret == 0 ? "ok" : strerror(errno)));
464 DEBUG(10, ("Found %s\n", converted));
472 /* never reached ... */
475 path = talloc_asprintf(mem_ctx, "%s/%s", handle->conn->connectpath,
481 pathlen = talloc_get_size(path)-1;
483 if (!shadow_copy2_find_slashes(talloc_tos(), path,
484 &slashes, &num_slashes)) {
488 insert = shadow_copy2_insert_string(talloc_tos(), handle, timestamp);
489 if (insert == NULL) {
492 insertlen = talloc_get_size(insert)-1;
495 * Note: We deliberatly don't expensively initialize the
496 * array with talloc_zero here: Putting zero into
497 * converted[pathlen+insertlen] below is sufficient, because
498 * in the following for loop, the insert string is inserted
499 * at various slash places. So the memory up to position
500 * pathlen+insertlen will always be initialized when the
501 * converted string is used.
503 converted = talloc_array(mem_ctx, char, pathlen + insertlen + 1);
504 if (converted == NULL) {
508 if (path[pathlen-1] != '/') {
510 * Append a fake slash to find the snapshot root
513 tmp = talloc_realloc(talloc_tos(), slashes,
514 size_t, num_slashes+1);
519 slashes[num_slashes] = pathlen;
525 if (!config->crossmountpoints) {
526 min_offset = strlen(config->mount_point);
529 memcpy(converted, path, pathlen+1);
530 converted[pathlen+insertlen] = '\0';
532 ZERO_STRUCT(converted_fname);
533 converted_fname.base_name = converted;
535 for (i = num_slashes-1; i>=0; i--) {
541 if (offset < min_offset) {
546 memcpy(converted+offset, insert, insertlen);
549 memcpy(converted+offset, path + slashes[i],
550 pathlen - slashes[i]);
552 ret = SMB_VFS_NEXT_LSTAT(handle, &converted_fname);
554 DEBUG(10, ("Trying[snapdirseverywhere] %s: %d (%s)\n",
556 ret, ret == 0 ? "ok" : strerror(errno)));
561 if (errno == ENOTDIR) {
563 * This is a valid condition: We appended the
564 * .snaphots/@GMT.. to a file name. Just try
565 * with the upper levels.
569 if (errno != ENOENT) {
570 /* Other problem than "not found" */
579 DEBUG(10, ("Found %s\n", converted));
587 TALLOC_FREE(converted);
589 TALLOC_FREE(slashes);
596 modify a sbuf return to ensure that inodes in the shadow directory
597 are different from those in the main directory
599 static void convert_sbuf(vfs_handle_struct *handle, const char *fname,
600 SMB_STRUCT_STAT *sbuf)
602 struct shadow_copy2_config *config;
604 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
607 if (config->fixinodes) {
608 /* some snapshot systems, like GPFS, return the name
609 device:inode for the snapshot files as the current
610 files. That breaks the 'restore' button in the shadow copy
611 GUI, as the client gets a sharing violation.
613 This is a crude way of allowing both files to be
614 open at once. It has a slight chance of inode
615 number collision, but I can't see a better approach
616 without significant VFS changes
620 shash = hash(fname, strlen(fname), 0) & 0xFF000000;
624 sbuf->st_ex_ino ^= shash;
628 static DIR *shadow_copy2_opendir(vfs_handle_struct *handle,
639 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
640 ×tamp, &stripped)) {
643 if (timestamp == 0) {
644 return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
646 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
647 TALLOC_FREE(stripped);
651 ret = SMB_VFS_NEXT_OPENDIR(handle, conv, mask, attr);
658 static int shadow_copy2_rename(vfs_handle_struct *handle,
659 const struct smb_filename *smb_fname_src,
660 const struct smb_filename *smb_fname_dst)
662 time_t timestamp_src, timestamp_dst;
664 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
665 smb_fname_src->base_name,
666 ×tamp_src, NULL)) {
669 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
670 smb_fname_dst->base_name,
671 ×tamp_dst, NULL)) {
674 if (timestamp_src != 0) {
678 if (timestamp_dst != 0) {
682 return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
685 static int shadow_copy2_symlink(vfs_handle_struct *handle,
686 const char *oldname, const char *newname)
688 time_t timestamp_old, timestamp_new;
690 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, oldname,
691 ×tamp_old, NULL)) {
694 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, newname,
695 ×tamp_new, NULL)) {
698 if ((timestamp_old != 0) || (timestamp_new != 0)) {
702 return SMB_VFS_NEXT_SYMLINK(handle, oldname, newname);
705 static int shadow_copy2_link(vfs_handle_struct *handle,
706 const char *oldname, const char *newname)
708 time_t timestamp_old, timestamp_new;
710 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, oldname,
711 ×tamp_old, NULL)) {
714 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, newname,
715 ×tamp_new, NULL)) {
718 if ((timestamp_old != 0) || (timestamp_new != 0)) {
722 return SMB_VFS_NEXT_LINK(handle, oldname, newname);
725 static int shadow_copy2_stat(vfs_handle_struct *handle,
726 struct smb_filename *smb_fname)
729 char *stripped, *tmp;
730 int ret, saved_errno;
732 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
733 smb_fname->base_name,
734 ×tamp, &stripped)) {
737 if (timestamp == 0) {
738 return SMB_VFS_NEXT_STAT(handle, smb_fname);
741 tmp = smb_fname->base_name;
742 smb_fname->base_name = shadow_copy2_convert(
743 talloc_tos(), handle, stripped, timestamp);
744 TALLOC_FREE(stripped);
746 if (smb_fname->base_name == NULL) {
747 smb_fname->base_name = tmp;
751 ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
754 TALLOC_FREE(smb_fname->base_name);
755 smb_fname->base_name = tmp;
758 convert_sbuf(handle, smb_fname->base_name, &smb_fname->st);
764 static int shadow_copy2_lstat(vfs_handle_struct *handle,
765 struct smb_filename *smb_fname)
768 char *stripped, *tmp;
769 int ret, saved_errno;
771 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
772 smb_fname->base_name,
773 ×tamp, &stripped)) {
776 if (timestamp == 0) {
777 return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
780 tmp = smb_fname->base_name;
781 smb_fname->base_name = shadow_copy2_convert(
782 talloc_tos(), handle, stripped, timestamp);
783 TALLOC_FREE(stripped);
785 if (smb_fname->base_name == NULL) {
786 smb_fname->base_name = tmp;
790 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
793 TALLOC_FREE(smb_fname->base_name);
794 smb_fname->base_name = tmp;
797 convert_sbuf(handle, smb_fname->base_name, &smb_fname->st);
803 static int shadow_copy2_fstat(vfs_handle_struct *handle, files_struct *fsp,
804 SMB_STRUCT_STAT *sbuf)
809 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
813 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
814 fsp->fsp_name->base_name,
818 if (timestamp != 0) {
819 convert_sbuf(handle, fsp->fsp_name->base_name, sbuf);
824 static int shadow_copy2_open(vfs_handle_struct *handle,
825 struct smb_filename *smb_fname, files_struct *fsp,
826 int flags, mode_t mode)
829 char *stripped, *tmp;
830 int ret, saved_errno;
832 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
833 smb_fname->base_name,
834 ×tamp, &stripped)) {
837 if (timestamp == 0) {
838 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
841 tmp = smb_fname->base_name;
842 smb_fname->base_name = shadow_copy2_convert(
843 talloc_tos(), handle, stripped, timestamp);
844 TALLOC_FREE(stripped);
846 if (smb_fname->base_name == NULL) {
847 smb_fname->base_name = tmp;
851 ret = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
854 TALLOC_FREE(smb_fname->base_name);
855 smb_fname->base_name = tmp;
861 static int shadow_copy2_unlink(vfs_handle_struct *handle,
862 const struct smb_filename *smb_fname)
866 int ret, saved_errno;
867 struct smb_filename *conv;
869 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
870 smb_fname->base_name,
871 ×tamp, &stripped)) {
874 if (timestamp == 0) {
875 return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
877 conv = cp_smb_filename(talloc_tos(), smb_fname);
882 conv->base_name = shadow_copy2_convert(
883 conv, handle, stripped, timestamp);
884 TALLOC_FREE(stripped);
885 if (conv->base_name == NULL) {
888 ret = SMB_VFS_NEXT_UNLINK(handle, conv);
895 static int shadow_copy2_chmod(vfs_handle_struct *handle, const char *fname,
900 int ret, saved_errno;
903 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
904 ×tamp, &stripped)) {
907 if (timestamp == 0) {
908 return SMB_VFS_NEXT_CHMOD(handle, fname, mode);
910 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
911 TALLOC_FREE(stripped);
915 ret = SMB_VFS_NEXT_CHMOD(handle, conv, mode);
922 static int shadow_copy2_chown(vfs_handle_struct *handle, const char *fname,
923 uid_t uid, gid_t gid)
927 int ret, saved_errno;
930 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
931 ×tamp, &stripped)) {
934 if (timestamp == 0) {
935 return SMB_VFS_NEXT_CHOWN(handle, fname, uid, gid);
937 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
938 TALLOC_FREE(stripped);
942 ret = SMB_VFS_NEXT_CHOWN(handle, conv, uid, gid);
949 static int shadow_copy2_chdir(vfs_handle_struct *handle,
954 int ret, saved_errno;
957 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
958 ×tamp, &stripped)) {
961 if (timestamp == 0) {
962 return SMB_VFS_NEXT_CHDIR(handle, fname);
964 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
965 TALLOC_FREE(stripped);
969 ret = SMB_VFS_NEXT_CHDIR(handle, conv);
976 static int shadow_copy2_ntimes(vfs_handle_struct *handle,
977 const struct smb_filename *smb_fname,
978 struct smb_file_time *ft)
982 int ret, saved_errno;
983 struct smb_filename *conv;
985 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
986 smb_fname->base_name,
987 ×tamp, &stripped)) {
990 if (timestamp == 0) {
991 return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
993 conv = cp_smb_filename(talloc_tos(), smb_fname);
998 conv->base_name = shadow_copy2_convert(
999 conv, handle, stripped, timestamp);
1000 TALLOC_FREE(stripped);
1001 if (conv->base_name == NULL) {
1004 ret = SMB_VFS_NEXT_NTIMES(handle, conv, ft);
1005 saved_errno = errno;
1007 errno = saved_errno;
1011 static int shadow_copy2_readlink(vfs_handle_struct *handle,
1012 const char *fname, char *buf, size_t bufsiz)
1016 int ret, saved_errno;
1019 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1020 ×tamp, &stripped)) {
1023 if (timestamp == 0) {
1024 return SMB_VFS_NEXT_READLINK(handle, fname, buf, bufsiz);
1026 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1027 TALLOC_FREE(stripped);
1031 ret = SMB_VFS_NEXT_READLINK(handle, conv, buf, bufsiz);
1032 saved_errno = errno;
1034 errno = saved_errno;
1038 static int shadow_copy2_mknod(vfs_handle_struct *handle,
1039 const char *fname, mode_t mode, SMB_DEV_T dev)
1043 int ret, saved_errno;
1046 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1047 ×tamp, &stripped)) {
1050 if (timestamp == 0) {
1051 return SMB_VFS_NEXT_MKNOD(handle, fname, mode, dev);
1053 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1054 TALLOC_FREE(stripped);
1058 ret = SMB_VFS_NEXT_MKNOD(handle, conv, mode, dev);
1059 saved_errno = errno;
1061 errno = saved_errno;
1065 static char *shadow_copy2_realpath(vfs_handle_struct *handle,
1069 char *stripped = NULL;
1071 char *result = NULL;
1072 char *inserted = NULL;
1073 char *inserted_to, *inserted_end;
1076 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1077 ×tamp, &stripped)) {
1080 if (timestamp == 0) {
1081 return SMB_VFS_NEXT_REALPATH(handle, fname);
1084 tmp = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1089 result = SMB_VFS_NEXT_REALPATH(handle, tmp);
1090 if (result == NULL) {
1095 * Take away what we've inserted. This removes the @GMT-thingy
1096 * completely, but will give a path under the share root.
1098 inserted = shadow_copy2_insert_string(talloc_tos(), handle, timestamp);
1099 if (inserted == NULL) {
1102 inserted_to = strstr_m(result, inserted);
1103 if (inserted_to == NULL) {
1104 DEBUG(2, ("SMB_VFS_NEXT_REALPATH removed %s\n", inserted));
1107 inserted_end = inserted_to + talloc_get_size(inserted) - 1;
1108 memmove(inserted_to, inserted_end, strlen(inserted_end)+1);
1111 saved_errno = errno;
1112 TALLOC_FREE(inserted);
1114 TALLOC_FREE(stripped);
1115 errno = saved_errno;
1120 * Check whether a given directory contains a
1121 * snapshot directory as direct subdirectory.
1122 * If yes, return the path of the snapshot-subdir,
1123 * otherwise return NULL.
1125 static char *have_snapdir(struct vfs_handle_struct *handle,
1128 struct smb_filename smb_fname;
1130 struct shadow_copy2_config *config;
1132 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
1135 ZERO_STRUCT(smb_fname);
1136 smb_fname.base_name = talloc_asprintf(talloc_tos(), "%s/%s",
1137 path, config->snapdir);
1138 if (smb_fname.base_name == NULL) {
1142 ret = SMB_VFS_NEXT_STAT(handle, &smb_fname);
1143 if ((ret == 0) && (S_ISDIR(smb_fname.st.st_ex_mode))) {
1144 return smb_fname.base_name;
1146 TALLOC_FREE(smb_fname.base_name);
1151 * Find the snapshot directory (if any) for the given
1152 * filename (which is relative to the share).
1154 static const char *shadow_copy2_find_snapdir(TALLOC_CTX *mem_ctx,
1155 struct vfs_handle_struct *handle,
1156 struct smb_filename *smb_fname)
1159 const char *snapdir;
1160 struct shadow_copy2_config *config;
1162 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
1166 * If the non-snapdisrseverywhere mode, we should not search!
1168 if (!config->snapdirseverywhere) {
1169 return config->snapshot_basepath;
1172 path = talloc_asprintf(mem_ctx, "%s/%s",
1173 handle->conn->connectpath,
1174 smb_fname->base_name);
1179 snapdir = have_snapdir(handle, path);
1180 if (snapdir != NULL) {
1185 while ((p = strrchr(path, '/')) && (p > path)) {
1189 snapdir = have_snapdir(handle, path);
1190 if (snapdir != NULL) {
1199 static bool shadow_copy2_snapshot_to_gmt(vfs_handle_struct *handle,
1201 char *gmt, size_t gmt_len)
1203 struct tm timestamp;
1205 unsigned long int timestamp_long;
1207 struct shadow_copy2_config *config;
1209 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
1212 fmt = config->gmt_format;
1214 ZERO_STRUCT(timestamp);
1215 if (config->use_sscanf) {
1216 if (sscanf(name, fmt, ×tamp_long) != 1) {
1217 DEBUG(10, ("shadow_copy2_snapshot_to_gmt: "
1218 "no sscanf match %s: %s\n",
1222 timestamp_t = timestamp_long;
1223 gmtime_r(×tamp_t, ×tamp);
1225 if (strptime(name, fmt, ×tamp) == NULL) {
1226 DEBUG(10, ("shadow_copy2_snapshot_to_gmt: "
1227 "no match %s: %s\n",
1231 DEBUG(10, ("shadow_copy2_snapshot_to_gmt: match %s: %s\n",
1234 if (config->use_localtime) {
1235 timestamp.tm_isdst = -1;
1236 timestamp_t = mktime(×tamp);
1237 gmtime_r(×tamp_t, ×tamp);
1241 strftime(gmt, gmt_len, GMT_FORMAT, ×tamp);
1245 static int shadow_copy2_label_cmp_asc(const void *x, const void *y)
1247 return strncmp((const char *)x, (const char *)y, sizeof(SHADOW_COPY_LABEL));
1250 static int shadow_copy2_label_cmp_desc(const void *x, const void *y)
1252 return -strncmp((const char *)x, (const char *)y, sizeof(SHADOW_COPY_LABEL));
1256 sort the shadow copy data in ascending or descending order
1258 static void shadow_copy2_sort_data(vfs_handle_struct *handle,
1259 struct shadow_copy_data *shadow_copy2_data)
1261 int (*cmpfunc)(const void *, const void *);
1263 struct shadow_copy2_config *config;
1265 SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
1268 sort = config->sort_order;
1273 if (strcmp(sort, "asc") == 0) {
1274 cmpfunc = shadow_copy2_label_cmp_asc;
1275 } else if (strcmp(sort, "desc") == 0) {
1276 cmpfunc = shadow_copy2_label_cmp_desc;
1281 if (shadow_copy2_data && shadow_copy2_data->num_volumes > 0 &&
1282 shadow_copy2_data->labels)
1284 TYPESAFE_QSORT(shadow_copy2_data->labels,
1285 shadow_copy2_data->num_volumes,
1290 static int shadow_copy2_get_shadow_copy_data(
1291 vfs_handle_struct *handle, files_struct *fsp,
1292 struct shadow_copy_data *shadow_copy2_data,
1296 const char *snapdir;
1298 TALLOC_CTX *tmp_ctx = talloc_stackframe();
1300 snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle, fsp->fsp_name);
1301 if (snapdir == NULL) {
1302 DEBUG(0,("shadow:snapdir not found for %s in get_shadow_copy_data\n",
1303 handle->conn->connectpath));
1305 talloc_free(tmp_ctx);
1309 p = SMB_VFS_NEXT_OPENDIR(handle, snapdir, NULL, 0);
1312 DEBUG(2,("shadow_copy2: SMB_VFS_NEXT_OPENDIR() failed for '%s'"
1313 " - %s\n", snapdir, strerror(errno)));
1314 talloc_free(tmp_ctx);
1319 shadow_copy2_data->num_volumes = 0;
1320 shadow_copy2_data->labels = NULL;
1322 while ((d = SMB_VFS_NEXT_READDIR(handle, p, NULL))) {
1323 char snapshot[GMT_NAME_LEN+1];
1324 SHADOW_COPY_LABEL *tlabels;
1327 * ignore names not of the right form in the snapshot
1330 if (!shadow_copy2_snapshot_to_gmt(
1332 snapshot, sizeof(snapshot))) {
1334 DEBUG(6, ("shadow_copy2_get_shadow_copy_data: "
1335 "ignoring %s\n", d->d_name));
1338 DEBUG(6,("shadow_copy2_get_shadow_copy_data: %s -> %s\n",
1339 d->d_name, snapshot));
1342 /* the caller doesn't want the labels */
1343 shadow_copy2_data->num_volumes++;
1347 tlabels = talloc_realloc(shadow_copy2_data,
1348 shadow_copy2_data->labels,
1350 shadow_copy2_data->num_volumes+1);
1351 if (tlabels == NULL) {
1352 DEBUG(0,("shadow_copy2: out of memory\n"));
1353 SMB_VFS_NEXT_CLOSEDIR(handle, p);
1354 talloc_free(tmp_ctx);
1358 strlcpy(tlabels[shadow_copy2_data->num_volumes], snapshot,
1361 shadow_copy2_data->num_volumes++;
1362 shadow_copy2_data->labels = tlabels;
1365 SMB_VFS_NEXT_CLOSEDIR(handle,p);
1367 shadow_copy2_sort_data(handle, shadow_copy2_data);
1369 talloc_free(tmp_ctx);
1373 static NTSTATUS shadow_copy2_fget_nt_acl(vfs_handle_struct *handle,
1374 struct files_struct *fsp,
1375 uint32 security_info,
1376 TALLOC_CTX *mem_ctx,
1377 struct security_descriptor **ppdesc)
1384 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
1385 fsp->fsp_name->base_name,
1386 ×tamp, &stripped)) {
1387 return map_nt_error_from_unix(errno);
1389 if (timestamp == 0) {
1390 return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
1394 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1395 TALLOC_FREE(stripped);
1397 return map_nt_error_from_unix(errno);
1399 status = SMB_VFS_NEXT_GET_NT_ACL(handle, conv, security_info,
1405 static NTSTATUS shadow_copy2_get_nt_acl(vfs_handle_struct *handle,
1407 uint32 security_info,
1408 TALLOC_CTX *mem_ctx,
1409 struct security_descriptor **ppdesc)
1416 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1417 ×tamp, &stripped)) {
1418 return map_nt_error_from_unix(errno);
1420 if (timestamp == 0) {
1421 return SMB_VFS_NEXT_GET_NT_ACL(handle, fname, security_info,
1424 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1425 TALLOC_FREE(stripped);
1427 return map_nt_error_from_unix(errno);
1429 status = SMB_VFS_NEXT_GET_NT_ACL(handle, conv, security_info,
1435 static int shadow_copy2_mkdir(vfs_handle_struct *handle,
1436 const char *fname, mode_t mode)
1440 int ret, saved_errno;
1443 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1444 ×tamp, &stripped)) {
1447 if (timestamp == 0) {
1448 return SMB_VFS_NEXT_MKDIR(handle, fname, mode);
1450 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1451 TALLOC_FREE(stripped);
1455 ret = SMB_VFS_NEXT_MKDIR(handle, conv, mode);
1456 saved_errno = errno;
1458 errno = saved_errno;
1462 static int shadow_copy2_rmdir(vfs_handle_struct *handle, const char *fname)
1466 int ret, saved_errno;
1469 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1470 ×tamp, &stripped)) {
1473 if (timestamp == 0) {
1474 return SMB_VFS_NEXT_RMDIR(handle, fname);
1476 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1477 TALLOC_FREE(stripped);
1481 ret = SMB_VFS_NEXT_RMDIR(handle, conv);
1482 saved_errno = errno;
1484 errno = saved_errno;
1488 static int shadow_copy2_chflags(vfs_handle_struct *handle, const char *fname,
1493 int ret, saved_errno;
1496 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1497 ×tamp, &stripped)) {
1500 if (timestamp == 0) {
1501 return SMB_VFS_NEXT_CHFLAGS(handle, fname, flags);
1503 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1504 TALLOC_FREE(stripped);
1508 ret = SMB_VFS_NEXT_CHFLAGS(handle, conv, flags);
1509 saved_errno = errno;
1511 errno = saved_errno;
1515 static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle,
1516 const char *fname, const char *aname,
1517 void *value, size_t size)
1525 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1526 ×tamp, &stripped)) {
1529 if (timestamp == 0) {
1530 return SMB_VFS_NEXT_GETXATTR(handle, fname, aname, value,
1533 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1534 TALLOC_FREE(stripped);
1538 ret = SMB_VFS_NEXT_GETXATTR(handle, conv, aname, value, size);
1539 saved_errno = errno;
1541 errno = saved_errno;
1545 static ssize_t shadow_copy2_listxattr(struct vfs_handle_struct *handle,
1547 char *list, size_t size)
1555 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1556 ×tamp, &stripped)) {
1559 if (timestamp == 0) {
1560 return SMB_VFS_NEXT_LISTXATTR(handle, fname, list, size);
1562 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1563 TALLOC_FREE(stripped);
1567 ret = SMB_VFS_NEXT_LISTXATTR(handle, conv, list, size);
1568 saved_errno = errno;
1570 errno = saved_errno;
1574 static int shadow_copy2_removexattr(vfs_handle_struct *handle,
1575 const char *fname, const char *aname)
1579 int ret, saved_errno;
1582 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1583 ×tamp, &stripped)) {
1586 if (timestamp == 0) {
1587 return SMB_VFS_NEXT_REMOVEXATTR(handle, fname, aname);
1589 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1590 TALLOC_FREE(stripped);
1594 ret = SMB_VFS_NEXT_REMOVEXATTR(handle, conv, aname);
1595 saved_errno = errno;
1597 errno = saved_errno;
1601 static int shadow_copy2_setxattr(struct vfs_handle_struct *handle,
1603 const char *aname, const void *value,
1604 size_t size, int flags)
1612 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1613 ×tamp, &stripped)) {
1616 if (timestamp == 0) {
1617 return SMB_VFS_NEXT_SETXATTR(handle, fname, aname, value, size,
1620 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1621 TALLOC_FREE(stripped);
1625 ret = SMB_VFS_NEXT_SETXATTR(handle, conv, aname, value, size, flags);
1626 saved_errno = errno;
1628 errno = saved_errno;
1632 static int shadow_copy2_chmod_acl(vfs_handle_struct *handle,
1633 const char *fname, mode_t mode)
1641 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
1642 ×tamp, &stripped)) {
1645 if (timestamp == 0) {
1646 return SMB_VFS_NEXT_CHMOD_ACL(handle, fname, mode);
1648 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1649 TALLOC_FREE(stripped);
1653 ret = SMB_VFS_NEXT_CHMOD_ACL(handle, conv, mode);
1654 saved_errno = errno;
1656 errno = saved_errno;
1660 static int shadow_copy2_get_real_filename(struct vfs_handle_struct *handle,
1663 TALLOC_CTX *mem_ctx,
1672 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, path,
1673 ×tamp, &stripped)) {
1676 if (timestamp == 0) {
1677 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
1678 mem_ctx, found_name);
1680 if (stripped[0] == '\0') {
1681 *found_name = talloc_strdup(mem_ctx, name);
1682 if (*found_name == NULL) {
1688 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1689 TALLOC_FREE(stripped);
1693 ret = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, conv, name,
1694 mem_ctx, found_name);
1695 saved_errno = errno;
1697 errno = saved_errno;
1701 static uint64_t shadow_copy2_disk_free(vfs_handle_struct *handle,
1702 const char *path, bool small_query,
1703 uint64_t *bsize, uint64_t *dfree,
1712 if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, path,
1713 ×tamp, &stripped)) {
1716 if (timestamp == 0) {
1717 return SMB_VFS_NEXT_DISK_FREE(handle, path, small_query,
1718 bsize, dfree, dsize);
1721 conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
1722 TALLOC_FREE(stripped);
1727 ret = SMB_VFS_NEXT_DISK_FREE(handle, conv, small_query, bsize, dfree,
1730 saved_errno = errno;
1732 errno = saved_errno;
1737 static int shadow_copy2_connect(struct vfs_handle_struct *handle,
1738 const char *service, const char *user)
1740 struct shadow_copy2_config *config;
1742 const char *snapdir;
1743 const char *gmt_format;
1744 const char *sort_order;
1745 const char *basedir;
1746 const char *mount_point;
1748 DEBUG(10, (__location__ ": cnum[%u], connectpath[%s]\n",
1749 (unsigned)handle->conn->cnum,
1750 handle->conn->connectpath));
1752 ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
1757 config = talloc_zero(handle->conn, struct shadow_copy2_config);
1758 if (config == NULL) {
1759 DEBUG(0, ("talloc_zero() failed\n"));
1764 gmt_format = lp_parm_const_string(SNUM(handle->conn),
1767 config->gmt_format = talloc_strdup(config, gmt_format);
1768 if (config->gmt_format == NULL) {
1769 DEBUG(0, ("talloc_strdup() failed\n"));
1774 config->use_sscanf = lp_parm_bool(SNUM(handle->conn),
1775 "shadow", "sscanf", false);
1777 config->use_localtime = lp_parm_bool(SNUM(handle->conn),
1778 "shadow", "localtime",
1781 snapdir = lp_parm_const_string(SNUM(handle->conn),
1782 "shadow", "snapdir",
1784 config->snapdir = talloc_strdup(config, snapdir);
1785 if (config->snapdir == NULL) {
1786 DEBUG(0, ("talloc_strdup() failed\n"));
1791 config->snapdirseverywhere = lp_parm_bool(SNUM(handle->conn),
1793 "snapdirseverywhere",
1796 config->crossmountpoints = lp_parm_bool(SNUM(handle->conn),
1797 "shadow", "crossmountpoints",
1800 config->fixinodes = lp_parm_bool(SNUM(handle->conn),
1801 "shadow", "fixinodes",
1804 sort_order = lp_parm_const_string(SNUM(handle->conn),
1805 "shadow", "sort", "desc");
1806 config->sort_order = talloc_strdup(config, sort_order);
1807 if (config->sort_order == NULL) {
1808 DEBUG(0, ("talloc_strdup() failed\n"));
1813 mount_point = lp_parm_const_string(SNUM(handle->conn),
1814 "shadow", "mountpoint", NULL);
1815 if (mount_point != NULL) {
1816 if (mount_point[0] != '/') {
1817 DEBUG(1, (__location__ " Warning: 'mountpoint' is "
1818 "relative ('%s'), but it has to be an "
1819 "absolute path. Ignoring provided value.\n",
1824 p = strstr(handle->conn->connectpath, mount_point);
1825 if (p != handle->conn->connectpath) {
1826 DEBUG(1, ("Warning: mount_point (%s) is not a "
1827 "subdirectory of the share root "
1828 "(%s). Ignoring provided value.\n",
1830 handle->conn->connectpath));
1836 if (mount_point != NULL) {
1837 config->mount_point = talloc_strdup(config, mount_point);
1838 if (config->mount_point == NULL) {
1839 DEBUG(0, (__location__ " talloc_strdup() failed\n"));
1843 config->mount_point = shadow_copy2_find_mount_point(config,
1845 if (config->mount_point == NULL) {
1846 DEBUG(0, (__location__ ": shadow_copy2_find_mount_point"
1847 " failed: %s\n", strerror(errno)));
1852 basedir = lp_parm_const_string(SNUM(handle->conn),
1853 "shadow", "basedir", NULL);
1855 if (basedir != NULL) {
1856 if (basedir[0] != '/') {
1857 DEBUG(1, (__location__ " Warning: 'basedir' is "
1858 "relative ('%s'), but it has to be an "
1859 "absolute path. Disabling basedir.\n",
1863 p = strstr(basedir, config->mount_point);
1865 DEBUG(1, ("Warning: basedir (%s) is not a "
1866 "subdirectory of the share root's "
1867 "mount point (%s). "
1868 "Disabling basedir\n",
1869 basedir, config->mount_point));
1871 config->basedir = talloc_strdup(config,
1873 if (config->basedir == NULL) {
1874 DEBUG(0, ("talloc_strdup() failed\n"));
1882 if (config->snapdirseverywhere && config->basedir != NULL) {
1883 DEBUG(1, (__location__ " Warning: 'basedir' is incompatible "
1884 "with 'snapdirseverywhere'. Disabling basedir.\n"));
1885 TALLOC_FREE(config->basedir);
1888 if (config->crossmountpoints && config->basedir != NULL) {
1889 DEBUG(1, (__location__ " Warning: 'basedir' is incompatible "
1890 "with 'crossmountpoints'. Disabling basedir.\n"));
1891 TALLOC_FREE(config->basedir);
1894 if (config->basedir == NULL) {
1895 config->basedir = config->mount_point;
1898 if (strlen(config->basedir) != strlen(handle->conn->connectpath)) {
1899 config->rel_connectpath = talloc_strdup(config,
1900 handle->conn->connectpath + strlen(config->basedir));
1901 if (config->rel_connectpath == NULL) {
1902 DEBUG(0, ("talloc_strdup() failed\n"));
1908 if (config->snapdir[0] == '/') {
1909 config->snapdir_absolute = true;
1911 if (config->snapdirseverywhere == true) {
1912 DEBUG(1, (__location__ " Warning: An absolute snapdir "
1913 "is incompatible with 'snapdirseverywhere', "
1914 "setting 'snapdirseverywhere' to false.\n"));
1915 config->snapdirseverywhere = false;
1918 if (config->crossmountpoints == true) {
1919 DEBUG(1, (__location__ " Warning: 'crossmountpoints' "
1920 "is not supported with an absolute snapdir. "
1921 "Disabling it.\n"));
1922 config->crossmountpoints = false;
1925 config->snapshot_basepath = config->snapdir;
1927 config->snapshot_basepath = talloc_asprintf(config, "%s/%s",
1928 config->mount_point, config->snapdir);
1929 if (config->snapshot_basepath == NULL) {
1930 DEBUG(0, ("talloc_asprintf() failed\n"));
1936 DEBUG(10, ("shadow_copy2_connect: configuration:\n"
1937 " share root: '%s'\n"
1939 " mountpoint: '%s'\n"
1940 " rel share root: '%s'\n"
1942 " snapshot base path: '%s'\n"
1945 " snapdirs everywhere: %s\n"
1946 " cross mountpoints: %s\n"
1950 handle->conn->connectpath,
1952 config->mount_point,
1953 config->rel_connectpath,
1955 config->snapshot_basepath,
1957 config->use_sscanf ? "yes" : "no",
1958 config->snapdirseverywhere ? "yes" : "no",
1959 config->crossmountpoints ? "yes" : "no",
1960 config->fixinodes ? "yes" : "no",
1965 SMB_VFS_HANDLE_SET_DATA(handle, config,
1966 NULL, struct shadow_copy2_config,
1972 static struct vfs_fn_pointers vfs_shadow_copy2_fns = {
1973 .connect_fn = shadow_copy2_connect,
1974 .opendir_fn = shadow_copy2_opendir,
1975 .disk_free_fn = shadow_copy2_disk_free,
1976 .rename_fn = shadow_copy2_rename,
1977 .link_fn = shadow_copy2_link,
1978 .symlink_fn = shadow_copy2_symlink,
1979 .stat_fn = shadow_copy2_stat,
1980 .lstat_fn = shadow_copy2_lstat,
1981 .fstat_fn = shadow_copy2_fstat,
1982 .open_fn = shadow_copy2_open,
1983 .unlink_fn = shadow_copy2_unlink,
1984 .chmod_fn = shadow_copy2_chmod,
1985 .chown_fn = shadow_copy2_chown,
1986 .chdir_fn = shadow_copy2_chdir,
1987 .ntimes_fn = shadow_copy2_ntimes,
1988 .readlink_fn = shadow_copy2_readlink,
1989 .mknod_fn = shadow_copy2_mknod,
1990 .realpath_fn = shadow_copy2_realpath,
1991 .get_nt_acl_fn = shadow_copy2_get_nt_acl,
1992 .fget_nt_acl_fn = shadow_copy2_fget_nt_acl,
1993 .get_shadow_copy_data_fn = shadow_copy2_get_shadow_copy_data,
1994 .mkdir_fn = shadow_copy2_mkdir,
1995 .rmdir_fn = shadow_copy2_rmdir,
1996 .getxattr_fn = shadow_copy2_getxattr,
1997 .listxattr_fn = shadow_copy2_listxattr,
1998 .removexattr_fn = shadow_copy2_removexattr,
1999 .setxattr_fn = shadow_copy2_setxattr,
2000 .chmod_acl_fn = shadow_copy2_chmod_acl,
2001 .chflags_fn = shadow_copy2_chflags,
2002 .get_real_filename_fn = shadow_copy2_get_real_filename,
2005 NTSTATUS vfs_shadow_copy2_init(void);
2006 NTSTATUS vfs_shadow_copy2_init(void)
2008 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2009 "shadow_copy2", &vfs_shadow_copy2_fns);