2 * implementation of an Shadow Copy module - version 2
4 * Copyright (C) Andrew Tridgell 2007
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 This is a 2nd implemetation of a shadow copy module for exposing
26 snapshots to windows clients as shadow copies. This version has the
29 1) you don't need to populate your shares with symlinks to the
30 snapshots. This can be very important when you have thousands of
31 shares, or use [homes]
33 2) the inode number of the files is altered so it is different
34 from the original. This allows the 'restore' button to work
35 without a sharing violation
39 shadow:snapdir = <directory where snapshots are kept>
41 This is the directory containing the @GMT-* snapshot directories. If it is an absolute
42 path it is used as-is. If it is a relative path, then it is taken relative to the mount
43 point of the filesystem that the root of this share is on
45 shadow:basedir = <base directory that snapshots are from>
47 This is an optional parameter that specifies the directory that
48 the snapshots are relative to. It defaults to the filesystem
51 shadow:fixinodes = yes/no
53 If you enable shadow:fixinodes then this module will modify the
54 apparent inode number of files in the snapshot directories using
55 a hash of the files path. This is needed for snapshot systems
56 where the snapshots have the same device:inode number as the
57 original files (such as happens with GPFS snapshots). If you
58 don't set this option then the 'restore' button in the shadow
59 copy UI will fail with a sharing violation.
61 Note that the directory names in the snapshot directory must take the form
62 @GMT-YYYY.MM.DD-HH.MM.SS
64 The following command would generate a correctly formatted directory name:
65 date -u +@GMT-%Y.%m.%d-%H.%M.%S
69 static int vfs_shadow_copy2_debug_level = DBGC_VFS;
72 #define DBGC_CLASS vfs_shadow_copy2_debug_level
74 #define GMT_NAME_LEN 24 /* length of a @GMT- name */
77 make very sure it is one of our special names
79 static inline bool shadow_copy2_match_name(const char *name, const char **gmt_start)
81 unsigned year, month, day, hr, min, sec;
86 p = strstr_m(name, "@GMT-");
87 if (p == NULL) return false;
88 if (p > name && p[-1] != '/') return False;
89 if (sscanf(p, "@GMT-%04u.%02u.%02u-%02u.%02u.%02u", &year, &month,
90 &day, &hr, &min, &sec) != 6) {
93 if (p[24] != 0 && p[24] != '/') {
103 shadow copy paths can also come into the server in this form:
105 /foo/bar/@GMT-XXXXX/some/file
107 This function normalises the filename to be of the form:
109 @GMT-XXXX/foo/bar/some/file
111 static const char *shadow_copy2_normalise_path(TALLOC_CTX *mem_ctx, const char *path, const char *gmt_start)
114 char buf[GMT_NAME_LEN];
117 if (path == gmt_start) {
121 prefix_len = gmt_start - path - 1;
123 DEBUG(10, ("path=%s, gmt_start=%s, prefix_len=%d\n", path, gmt_start,
127 * We've got a/b/c/@GMT-YYYY.MM.DD-HH.MM.SS/d/e. convert to
128 * @GMT-YYYY.MM.DD-HH.MM.SS/a/b/c/d/e before further
129 * processing. As many VFS calls provide a const char *,
130 * unfortunately we have to make a copy.
133 pcopy = talloc_strdup(talloc_tos(), path);
138 gmt_start = pcopy + prefix_len;
141 * Copy away "@GMT-YYYY.MM.DD-HH.MM.SS"
143 memcpy(buf, gmt_start+1, GMT_NAME_LEN);
146 * Make space for it including a trailing /
148 memmove(pcopy + GMT_NAME_LEN + 1, pcopy, prefix_len);
151 * Move in "@GMT-YYYY.MM.DD-HH.MM.SS/" at the beginning again
153 memcpy(pcopy, buf, GMT_NAME_LEN);
154 pcopy[GMT_NAME_LEN] = '/';
156 DEBUG(10, ("shadow_copy2_normalise_path: %s -> %s\n", path, pcopy));
162 convert a name to the shadow directory
165 #define _SHADOW2_NEXT(op, args, rtype, eret, extra) do { \
166 const char *name = fname; \
167 const char *gmt_start; \
168 if (shadow_copy2_match_name(fname, &gmt_start)) { \
171 name2 = convert_shadow2_name(handle, fname, gmt_start); \
172 if (name2 == NULL) { \
177 ret = SMB_VFS_NEXT_ ## op args; \
178 talloc_free(name2); \
179 if (ret != eret) extra; \
182 return SMB_VFS_NEXT_ ## op args; \
187 convert a name to the shadow directory: NTSTATUS-specific handling
190 #define _SHADOW2_NTSTATUS_NEXT(op, args, eret, extra) do { \
191 const char *name = fname; \
192 const char *gmt_start; \
193 if (shadow_copy2_match_name(fname, &gmt_start)) { \
196 name2 = convert_shadow2_name(handle, fname, gmt_start); \
197 if (name2 == NULL) { \
202 ret = SMB_VFS_NEXT_ ## op args; \
203 talloc_free(name2); \
204 if (!NT_STATUS_EQUAL(ret, eret)) extra; \
207 return SMB_VFS_NEXT_ ## op args; \
211 #define SHADOW2_NTSTATUS_NEXT(op, args, eret) _SHADOW2_NTSTATUS_NEXT(op, args, eret, )
213 #define SHADOW2_NEXT(op, args, rtype, eret) _SHADOW2_NEXT(op, args, rtype, eret, )
215 #define SHADOW2_NEXT2(op, args) do { \
216 const char *gmt_start1, *gmt_start2; \
217 if (shadow_copy2_match_name(oldname, &gmt_start1) || \
218 shadow_copy2_match_name(newname, &gmt_start2)) { \
222 return SMB_VFS_NEXT_ ## op args; \
227 find the mount point of a filesystem
229 static char *find_mount_point(TALLOC_CTX *mem_ctx, vfs_handle_struct *handle)
231 char *path = talloc_strdup(mem_ctx, handle->conn->connectpath);
236 if (stat(path, &st) != 0) {
243 while ((p = strrchr(path, '/')) && p > path) {
245 if (stat(path, &st) != 0) {
249 if (st.st_dev != dev) {
259 work out the location of the snapshot for this share
261 static const char *shadow_copy2_find_snapdir(TALLOC_CTX *mem_ctx, vfs_handle_struct *handle)
267 snapdir = lp_parm_const_string(SNUM(handle->conn), "shadow", "snapdir", NULL);
268 if (snapdir == NULL) {
271 /* if its an absolute path, we're done */
272 if (*snapdir == '/') {
276 /* other its relative to the filesystem mount point */
277 mount_point = find_mount_point(mem_ctx, handle);
278 if (mount_point == NULL) {
282 ret = talloc_asprintf(mem_ctx, "%s/%s", mount_point, snapdir);
283 talloc_free(mount_point);
288 work out the location of the base directory for snapshots of this share
290 static const char *shadow_copy2_find_basedir(TALLOC_CTX *mem_ctx, vfs_handle_struct *handle)
292 const char *basedir = lp_parm_const_string(SNUM(handle->conn), "shadow", "basedir", NULL);
294 /* other its the filesystem mount point */
295 if (basedir == NULL) {
296 basedir = find_mount_point(mem_ctx, handle);
303 convert a filename from a share relative path, to a path in the
306 static char *convert_shadow2_name(vfs_handle_struct *handle, const char *fname, const char *gmt_path)
308 TALLOC_CTX *tmp_ctx = talloc_new(handle->data);
309 const char *snapdir, *relpath, *baseoffset, *basedir;
313 snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle);
314 if (snapdir == NULL) {
315 DEBUG(2,("no snapdir found for share at %s\n", handle->conn->connectpath));
316 talloc_free(tmp_ctx);
320 basedir = shadow_copy2_find_basedir(tmp_ctx, handle);
321 if (basedir == NULL) {
322 DEBUG(2,("no basedir found for share at %s\n", handle->conn->connectpath));
323 talloc_free(tmp_ctx);
327 prefix = talloc_asprintf(tmp_ctx, "%s/@GMT-", snapdir);
328 if (strncmp(fname, prefix, strlen(prefix)) == 0) {
329 /* this looks like as we have already normalized it, leave it untouched*/
330 talloc_free(tmp_ctx);
331 return talloc_strdup(handle->data, fname);
334 if (strncmp(fname, "@GMT-", 5) != 0) {
335 fname = shadow_copy2_normalise_path(tmp_ctx, fname, gmt_path);
337 talloc_free(tmp_ctx);
342 relpath = fname + GMT_NAME_LEN;
343 baselen = strlen(basedir);
344 baseoffset = handle->conn->connectpath + baselen;
346 /* some sanity checks */
347 if (strncmp(basedir, handle->conn->connectpath, baselen) != 0 ||
348 (handle->conn->connectpath[baselen] != 0 && handle->conn->connectpath[baselen] != '/')) {
349 DEBUG(0,("convert_shadow2_name: basedir %s is not a parent of %s\n",
350 basedir, handle->conn->connectpath));
351 talloc_free(tmp_ctx);
355 if (*relpath == '/') relpath++;
356 if (*baseoffset == '/') baseoffset++;
358 ret = talloc_asprintf(handle->data, "%s/%.*s/%s/%s",
363 DEBUG(6,("convert_shadow2_name: '%s' -> '%s'\n", fname, ret));
364 talloc_free(tmp_ctx);
372 static uint32 string_hash(const char *s)
376 n = ((n << 5) + n) ^ (uint32)(*s++);
382 modify a sbuf return to ensure that inodes in the shadow directory
383 are different from those in the main directory
385 static void convert_sbuf(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf)
387 if (lp_parm_bool(SNUM(handle->conn), "shadow", "fixinodes", False)) {
388 /* some snapshot systems, like GPFS, return the name
389 device:inode for the snapshot files as the current
390 files. That breaks the 'restore' button in the shadow copy
391 GUI, as the client gets a sharing violation.
393 This is a crude way of allowing both files to be
394 open at once. It has a slight chance of inode
395 number collision, but I can't see a better approach
396 without significant VFS changes
398 uint32_t shash = string_hash(fname) & 0xFF000000;
402 sbuf->st_ex_ino ^= shash;
406 static int shadow_copy2_rename(vfs_handle_struct *handle,
407 const char *oldname, const char *newname)
409 if (shadow_copy2_match_name(oldname, NULL)) {
413 SHADOW2_NEXT2(RENAME, (handle, oldname, newname));
416 static int shadow_copy2_symlink(vfs_handle_struct *handle,
417 const char *oldname, const char *newname)
419 SHADOW2_NEXT2(SYMLINK, (handle, oldname, newname));
422 static int shadow_copy2_link(vfs_handle_struct *handle,
423 const char *oldname, const char *newname)
425 SHADOW2_NEXT2(LINK, (handle, oldname, newname));
428 static int shadow_copy2_open(vfs_handle_struct *handle,
429 const char *fname, files_struct *fsp, int flags, mode_t mode)
431 SHADOW2_NEXT(OPEN, (handle, name, fsp, flags, mode), int, -1);
434 static SMB_STRUCT_DIR *shadow_copy2_opendir(vfs_handle_struct *handle,
435 const char *fname, const char *mask, uint32 attr)
437 SHADOW2_NEXT(OPENDIR, (handle, name, mask, attr), SMB_STRUCT_DIR *, NULL);
440 static int shadow_copy2_stat(vfs_handle_struct *handle,
441 const char *fname, SMB_STRUCT_STAT *sbuf)
443 _SHADOW2_NEXT(STAT, (handle, name, sbuf), int, -1, convert_sbuf(handle, fname, sbuf));
446 static int shadow_copy2_lstat(vfs_handle_struct *handle,
447 const char *fname, SMB_STRUCT_STAT *sbuf)
449 _SHADOW2_NEXT(LSTAT, (handle, name, sbuf), int, -1, convert_sbuf(handle, fname, sbuf));
452 static int shadow_copy2_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf)
454 int ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
455 if (ret == 0 && shadow_copy2_match_name(fsp->fsp_name, NULL)) {
456 convert_sbuf(handle, fsp->fsp_name, sbuf);
461 static int shadow_copy2_unlink(vfs_handle_struct *handle, const char *fname)
463 SHADOW2_NEXT(UNLINK, (handle, name), int, -1);
466 static int shadow_copy2_chmod(vfs_handle_struct *handle,
467 const char *fname, mode_t mode)
469 SHADOW2_NEXT(CHMOD, (handle, name, mode), int, -1);
472 static int shadow_copy2_chown(vfs_handle_struct *handle,
473 const char *fname, uid_t uid, gid_t gid)
475 SHADOW2_NEXT(CHOWN, (handle, name, uid, gid), int, -1);
478 static int shadow_copy2_chdir(vfs_handle_struct *handle,
481 SHADOW2_NEXT(CHDIR, (handle, name), int, -1);
484 static int shadow_copy2_ntimes(vfs_handle_struct *handle,
485 const char *fname, struct smb_file_time *ft)
487 SHADOW2_NEXT(NTIMES, (handle, name, ft), int, -1);
490 static int shadow_copy2_readlink(vfs_handle_struct *handle,
491 const char *fname, char *buf, size_t bufsiz)
493 SHADOW2_NEXT(READLINK, (handle, name, buf, bufsiz), int, -1);
496 static int shadow_copy2_mknod(vfs_handle_struct *handle,
497 const char *fname, mode_t mode, SMB_DEV_T dev)
499 SHADOW2_NEXT(MKNOD, (handle, name, mode, dev), int, -1);
502 static char *shadow_copy2_realpath(vfs_handle_struct *handle,
503 const char *fname, char *resolved_path)
505 const char *gmt_start;
507 if (shadow_copy2_match_name(fname, &gmt_start)
508 && (gmt_start[GMT_NAME_LEN] == '\0')) {
511 copy = talloc_strdup(talloc_tos(), fname);
517 copy[gmt_start - fname] = '.';
518 copy[gmt_start - fname + 1] = '\0';
520 DEBUG(10, ("calling NEXT_REALPATH with %s\n", copy));
521 SHADOW2_NEXT(REALPATH, (handle, name, resolved_path), char *,
525 SHADOW2_NEXT(REALPATH, (handle, name, resolved_path), char *, NULL);
528 static const char *shadow_copy2_connectpath(struct vfs_handle_struct *handle,
531 TALLOC_CTX *tmp_ctx = talloc_stackframe();
532 const char *snapdir, *baseoffset, *basedir, *gmt_start;
536 DEBUG(10, ("shadow_copy2_connectpath called with %s\n", fname));
538 if (!shadow_copy2_match_name(fname, &gmt_start)) {
539 return handle->conn->connectpath;
542 fname = shadow_copy2_normalise_path(talloc_tos(), fname, gmt_start);
544 TALLOC_FREE(tmp_ctx);
548 snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle);
549 if (snapdir == NULL) {
550 DEBUG(2,("no snapdir found for share at %s\n",
551 handle->conn->connectpath));
552 TALLOC_FREE(tmp_ctx);
556 basedir = shadow_copy2_find_basedir(tmp_ctx, handle);
557 if (basedir == NULL) {
558 DEBUG(2,("no basedir found for share at %s\n",
559 handle->conn->connectpath));
560 TALLOC_FREE(tmp_ctx);
564 baselen = strlen(basedir);
565 baseoffset = handle->conn->connectpath + baselen;
567 /* some sanity checks */
568 if (strncmp(basedir, handle->conn->connectpath, baselen) != 0 ||
569 (handle->conn->connectpath[baselen] != 0
570 && handle->conn->connectpath[baselen] != '/')) {
571 DEBUG(0,("shadow_copy2_connectpath: basedir %s is not a "
572 "parent of %s\n", basedir,
573 handle->conn->connectpath));
574 TALLOC_FREE(tmp_ctx);
578 if (*baseoffset == '/') baseoffset++;
580 ret = talloc_asprintf(talloc_tos(), "%s/%.*s/%s",
584 DEBUG(6,("shadow_copy2_connectpath: '%s' -> '%s'\n", fname, ret));
585 TALLOC_FREE(tmp_ctx);
589 static NTSTATUS shadow_copy2_get_nt_acl(vfs_handle_struct *handle,
590 const char *fname, uint32 security_info,
591 struct security_descriptor **ppdesc)
593 SHADOW2_NTSTATUS_NEXT(GET_NT_ACL, (handle, name, security_info, ppdesc), NT_STATUS_ACCESS_DENIED);
596 static NTSTATUS shadow_copy2_fget_nt_acl(vfs_handle_struct *handle,
597 files_struct *fsp, uint32 security_info,
598 struct security_descriptor **ppdesc)
600 char* fname = fsp->fsp_name;
601 SHADOW2_NTSTATUS_NEXT(GET_NT_ACL, (handle, name, security_info, ppdesc), NT_STATUS_ACCESS_DENIED);
604 static int shadow_copy2_mkdir(vfs_handle_struct *handle, const char *fname, mode_t mode)
606 SHADOW2_NEXT(MKDIR, (handle, name, mode), int, -1);
609 static int shadow_copy2_rmdir(vfs_handle_struct *handle, const char *fname)
611 SHADOW2_NEXT(RMDIR, (handle, name), int, -1);
614 static int shadow_copy2_chflags(vfs_handle_struct *handle, const char *fname, int flags)
616 SHADOW2_NEXT(CHFLAGS, (handle, name, flags), int, -1);
619 static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle,
620 const char *fname, const char *aname, void *value, size_t size)
622 SHADOW2_NEXT(GETXATTR, (handle, name, aname, value, size), ssize_t, -1);
625 static ssize_t shadow_copy2_lgetxattr(vfs_handle_struct *handle,
626 const char *fname, const char *aname, void *value, size_t size)
628 SHADOW2_NEXT(LGETXATTR, (handle, name, aname, value, size), ssize_t, -1);
631 static ssize_t shadow_copy2_listxattr(struct vfs_handle_struct *handle, const char *fname,
632 char *list, size_t size)
634 SHADOW2_NEXT(LISTXATTR, (handle, name, list, size), ssize_t, -1);
637 static int shadow_copy2_removexattr(struct vfs_handle_struct *handle, const char *fname,
640 SHADOW2_NEXT(REMOVEXATTR, (handle, name, aname), int, -1);
643 static int shadow_copy2_lremovexattr(struct vfs_handle_struct *handle, const char *fname,
646 SHADOW2_NEXT(LREMOVEXATTR, (handle, name, aname), int, -1);
649 static int shadow_copy2_setxattr(struct vfs_handle_struct *handle, const char *fname,
650 const char *aname, const void *value, size_t size, int flags)
652 SHADOW2_NEXT(SETXATTR, (handle, name, aname, value, size, flags), int, -1);
655 static int shadow_copy2_lsetxattr(struct vfs_handle_struct *handle, const char *fname,
656 const char *aname, const void *value, size_t size, int flags)
658 SHADOW2_NEXT(LSETXATTR, (handle, name, aname, value, size, flags), int, -1);
661 static int shadow_copy2_chmod_acl(vfs_handle_struct *handle,
662 const char *fname, mode_t mode)
664 /* If the underlying VFS doesn't have ACL support... */
665 if (!handle->vfs_next.ops.chmod_acl) {
669 SHADOW2_NEXT(CHMOD_ACL, (handle, name, mode), int, -1);
672 static int shadow_copy2_get_shadow_copy2_data(vfs_handle_struct *handle,
674 SHADOW_COPY_DATA *shadow_copy2_data,
679 SMB_STRUCT_DIRENT *d;
680 TALLOC_CTX *tmp_ctx = talloc_new(handle->data);
682 snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle);
683 if (snapdir == NULL) {
684 DEBUG(0,("shadow:snapdir not found for %s in get_shadow_copy_data\n",
685 handle->conn->connectpath));
687 talloc_free(tmp_ctx);
691 p = SMB_VFS_NEXT_OPENDIR(handle, snapdir, NULL, 0);
694 DEBUG(2,("shadow_copy2: SMB_VFS_NEXT_OPENDIR() failed for '%s'"
695 " - %s\n", snapdir, strerror(errno)));
696 talloc_free(tmp_ctx);
701 talloc_free(tmp_ctx);
703 shadow_copy2_data->num_volumes = 0;
704 shadow_copy2_data->labels = NULL;
706 while ((d = SMB_VFS_NEXT_READDIR(handle, p, NULL))) {
707 SHADOW_COPY_LABEL *tlabels;
709 /* ignore names not of the right form in the snapshot directory */
710 if (!shadow_copy2_match_name(d->d_name, NULL)) {
715 /* the caller doesn't want the labels */
716 shadow_copy2_data->num_volumes++;
720 tlabels = talloc_realloc(shadow_copy2_data->mem_ctx,
721 shadow_copy2_data->labels,
722 SHADOW_COPY_LABEL, shadow_copy2_data->num_volumes+1);
723 if (tlabels == NULL) {
724 DEBUG(0,("shadow_copy2: out of memory\n"));
725 SMB_VFS_NEXT_CLOSEDIR(handle, p);
729 strlcpy(tlabels[shadow_copy2_data->num_volumes], d->d_name, sizeof(*tlabels));
730 shadow_copy2_data->num_volumes++;
731 shadow_copy2_data->labels = tlabels;
734 SMB_VFS_NEXT_CLOSEDIR(handle,p);
738 /* VFS operations structure */
740 static vfs_op_tuple shadow_copy2_ops[] = {
741 {SMB_VFS_OP(shadow_copy2_opendir), SMB_VFS_OP_OPENDIR, SMB_VFS_LAYER_TRANSPARENT},
743 /* directory operations */
744 {SMB_VFS_OP(shadow_copy2_mkdir), SMB_VFS_OP_MKDIR, SMB_VFS_LAYER_TRANSPARENT},
745 {SMB_VFS_OP(shadow_copy2_rmdir), SMB_VFS_OP_RMDIR, SMB_VFS_LAYER_TRANSPARENT},
747 /* xattr and flags operations */
748 {SMB_VFS_OP(shadow_copy2_chflags), SMB_VFS_OP_CHFLAGS, SMB_VFS_LAYER_TRANSPARENT},
749 {SMB_VFS_OP(shadow_copy2_getxattr), SMB_VFS_OP_GETXATTR, SMB_VFS_LAYER_TRANSPARENT},
750 {SMB_VFS_OP(shadow_copy2_lgetxattr), SMB_VFS_OP_LGETXATTR, SMB_VFS_LAYER_TRANSPARENT},
751 {SMB_VFS_OP(shadow_copy2_listxattr), SMB_VFS_OP_LISTXATTR, SMB_VFS_LAYER_TRANSPARENT},
752 {SMB_VFS_OP(shadow_copy2_removexattr), SMB_VFS_OP_REMOVEXATTR, SMB_VFS_LAYER_TRANSPARENT},
753 {SMB_VFS_OP(shadow_copy2_lremovexattr),SMB_VFS_OP_LREMOVEXATTR,SMB_VFS_LAYER_TRANSPARENT},
754 {SMB_VFS_OP(shadow_copy2_setxattr), SMB_VFS_OP_SETXATTR, SMB_VFS_LAYER_TRANSPARENT},
755 {SMB_VFS_OP(shadow_copy2_lsetxattr), SMB_VFS_OP_LSETXATTR, SMB_VFS_LAYER_TRANSPARENT},
757 /* File operations */
758 {SMB_VFS_OP(shadow_copy2_open), SMB_VFS_OP_OPEN, SMB_VFS_LAYER_TRANSPARENT},
759 {SMB_VFS_OP(shadow_copy2_rename), SMB_VFS_OP_RENAME, SMB_VFS_LAYER_TRANSPARENT},
760 {SMB_VFS_OP(shadow_copy2_stat), SMB_VFS_OP_STAT, SMB_VFS_LAYER_TRANSPARENT},
761 {SMB_VFS_OP(shadow_copy2_lstat), SMB_VFS_OP_LSTAT, SMB_VFS_LAYER_TRANSPARENT},
762 {SMB_VFS_OP(shadow_copy2_fstat), SMB_VFS_OP_FSTAT, SMB_VFS_LAYER_TRANSPARENT},
763 {SMB_VFS_OP(shadow_copy2_unlink), SMB_VFS_OP_UNLINK, SMB_VFS_LAYER_TRANSPARENT},
764 {SMB_VFS_OP(shadow_copy2_chmod), SMB_VFS_OP_CHMOD, SMB_VFS_LAYER_TRANSPARENT},
765 {SMB_VFS_OP(shadow_copy2_chown), SMB_VFS_OP_CHOWN, SMB_VFS_LAYER_TRANSPARENT},
766 {SMB_VFS_OP(shadow_copy2_chdir), SMB_VFS_OP_CHDIR, SMB_VFS_LAYER_TRANSPARENT},
767 {SMB_VFS_OP(shadow_copy2_ntimes), SMB_VFS_OP_NTIMES, SMB_VFS_LAYER_TRANSPARENT},
768 {SMB_VFS_OP(shadow_copy2_symlink), SMB_VFS_OP_SYMLINK, SMB_VFS_LAYER_TRANSPARENT},
769 {SMB_VFS_OP(shadow_copy2_readlink), SMB_VFS_OP_READLINK, SMB_VFS_LAYER_TRANSPARENT},
770 {SMB_VFS_OP(shadow_copy2_link), SMB_VFS_OP_LINK, SMB_VFS_LAYER_TRANSPARENT},
771 {SMB_VFS_OP(shadow_copy2_mknod), SMB_VFS_OP_MKNOD, SMB_VFS_LAYER_TRANSPARENT},
772 {SMB_VFS_OP(shadow_copy2_realpath), SMB_VFS_OP_REALPATH, SMB_VFS_LAYER_TRANSPARENT},
773 {SMB_VFS_OP(shadow_copy2_connectpath), SMB_VFS_OP_CONNECTPATH, SMB_VFS_LAYER_OPAQUE},
775 /* NT File ACL operations */
776 {SMB_VFS_OP(shadow_copy2_get_nt_acl), SMB_VFS_OP_GET_NT_ACL, SMB_VFS_LAYER_TRANSPARENT},
777 {SMB_VFS_OP(shadow_copy2_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL, SMB_VFS_LAYER_TRANSPARENT},
779 /* POSIX ACL operations */
780 {SMB_VFS_OP(shadow_copy2_chmod_acl), SMB_VFS_OP_CHMOD_ACL, SMB_VFS_LAYER_TRANSPARENT},
782 /* special shadown copy op */
783 {SMB_VFS_OP(shadow_copy2_get_shadow_copy2_data),
784 SMB_VFS_OP_GET_SHADOW_COPY_DATA,SMB_VFS_LAYER_OPAQUE},
786 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
789 NTSTATUS vfs_shadow_copy2_init(void);
790 NTSTATUS vfs_shadow_copy2_init(void)
794 ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "shadow_copy2", shadow_copy2_ops);
796 if (!NT_STATUS_IS_OK(ret))
799 vfs_shadow_copy2_debug_level = debug_add_class("shadow_copy2");
800 if (vfs_shadow_copy2_debug_level == -1) {
801 vfs_shadow_copy2_debug_level = DBGC_VFS;
802 DEBUG(0, ("%s: Couldn't register custom debugging class!\n",
803 "vfs_shadow_copy2_init"));
805 DEBUG(10, ("%s: Debug class number of '%s': %d\n",
806 "vfs_shadow_copy2_init","shadow_copy2",vfs_shadow_copy2_debug_level));