s3: Plumb smb_filename through SMB_VFS_UNLINK
[samba.git] / source3 / modules / vfs_onefs_shadow_copy.c
1 /*
2  * OneFS shadow copy implementation that utilizes the file system's native
3  * snapshot support. This is based on the original shadow copy module from
4  * 2004.
5  *
6  * Copyright (C) Stefan Metzmacher      2003-2004
7  * Copyright (C) Tim Prouty             2009
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24 #include "includes.h"
25 #include "onefs_shadow_copy.h"
26
27 static int vfs_onefs_shadow_copy_debug_level = DBGC_VFS;
28
29 #undef DBGC_CLASS
30 #define DBGC_CLASS vfs_onefs_shadow_copy_debug_level
31
32 #define SHADOW_COPY_PREFIX "@GMT-"
33 #define SHADOW_COPY_SAMPLE "@GMT-2004.02.18-15.44.00"
34
35 bool
36 shadow_copy_match_name(const char *name, char **snap_component)
37 {
38         uint32  i = 0;
39         char delim[] = SHADOW_COPY_PREFIX;
40         char* start;
41
42         start = strstr( name, delim );
43
44         /*
45          * The name could have SHADOW_COPY_PREFIX in it so we need to keep
46          * trying until we get something that is the full length of the
47          * SHADOW_COPY_SAMPLE.
48          */
49         while (start != NULL) {
50
51                 DEBUG(10,("Processing %s\n", name));
52
53                 /* size / correctness check */
54                 *snap_component = start;
55                 for ( i = sizeof(SHADOW_COPY_PREFIX);
56                       i < sizeof(SHADOW_COPY_SAMPLE); i++) {
57                         if (start[i] == '/') {
58                                 if (i == sizeof(SHADOW_COPY_SAMPLE) - 1)
59                                         return true;
60                                 else
61                                         break;
62                         } else if (start[i] == '\0')
63                                 return (i == sizeof(SHADOW_COPY_SAMPLE) - 1);
64                 }
65
66                 start = strstr( start, delim );
67         }
68
69         return false;
70 }
71
72 static int
73 onefs_shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle,
74                                        files_struct *fsp,
75                                        SHADOW_COPY_DATA *shadow_copy_data,
76                                        bool labels)
77 {
78         void *p = osc_version_opendir();
79         char *snap_component = NULL;
80         shadow_copy_data->num_volumes = 0;
81         shadow_copy_data->labels = NULL;
82
83         if (!p) {
84                 DEBUG(0, ("shadow_copy_get_shadow_copy_data: osc_opendir() "
85                           "failed for [%s]\n",fsp->conn->connectpath));
86                 return -1;
87         }
88
89         while (true) {
90                 SHADOW_COPY_LABEL *tlabels;
91                 char *d;
92
93                 d = osc_version_readdir(p);
94                 if (d == NULL)
95                         break;
96
97                 if (!shadow_copy_match_name(d, &snap_component)) {
98                         DEBUG(10,("shadow_copy_get_shadow_copy_data: ignore "
99                                   "[%s]\n",d));
100                         continue;
101                 }
102
103                 DEBUG(7,("shadow_copy_get_shadow_copy_data: not ignore "
104                          "[%s]\n",d));
105
106                 if (!labels) {
107                         shadow_copy_data->num_volumes++;
108                         continue;
109                 }
110
111                 tlabels = (SHADOW_COPY_LABEL *)TALLOC_REALLOC(
112                         shadow_copy_data->mem_ctx,
113                         shadow_copy_data->labels,
114                         (shadow_copy_data->num_volumes+1) *
115                         sizeof(SHADOW_COPY_LABEL));
116
117                 if (tlabels == NULL) {
118                         DEBUG(0,("shadow_copy_get_shadow_copy_data: Out of "
119                                  "memory\n"));
120                         osc_version_closedir(p);
121                         return -1;
122                 }
123
124                 snprintf(tlabels[shadow_copy_data->num_volumes++],
125                          sizeof(*tlabels), "%s",d);
126
127                 shadow_copy_data->labels = tlabels;
128         }
129
130         osc_version_closedir(p);
131
132         return 0;
133 }
134
135 #define SHADOW_NEXT(op, args, rtype) do {                             \
136         char *cpath = NULL;                                           \
137         char *snap_component = NULL;                                  \
138         rtype ret;                                                    \
139         if (shadow_copy_match_name(path, &snap_component))            \
140                 cpath = osc_canonicalize_path(path, snap_component); \
141         ret = SMB_VFS_NEXT_ ## op args;                               \
142         SAFE_FREE(cpath);                                             \
143         return ret;                                                   \
144         } while (0)                                                   \
145
146 #define SHADOW_NEXT_SMB_FNAME(op, args, rtype) do {                   \
147                 char *smb_base_name_tmp = NULL;                       \
148                 char *cpath = NULL;                                   \
149                 char *snap_component = NULL;                          \
150                 rtype ret;                                            \
151                 smb_base_name_tmp = smb_fname->base_name;             \
152                 if (shadow_copy_match_name(smb_fname->base_name,      \
153                         &snap_component)) {                             \
154                         cpath = osc_canonicalize_path(smb_fname->base_name, \
155                             snap_component);                            \
156                         smb_fname->base_name = cpath;                   \
157                 }                                                       \
158                 ret = SMB_VFS_NEXT_ ## op args;                         \
159                 smb_fname->base_name = smb_base_name_tmp;               \
160                 SAFE_FREE(cpath);                                       \
161                 return ret;                                             \
162         } while (0)                                                     \
163
164
165 /*
166  * XXX: Convert osc_canonicalize_path to use talloc instead of malloc.
167  */
168 #define SHADOW_NEXT_SMB_FNAME_CONST(op, args, rtype) do {             \
169                 struct smb_filename *smb_fname_tmp  = NULL;           \
170                 char *cpath = NULL;                                   \
171                 char *snap_component = NULL;                          \
172                 rtype ret;                                            \
173                 if (shadow_copy_match_name(smb_fname->base_name,      \
174                         &snap_component)) {                             \
175                         cpath = osc_canonicalize_path(smb_fname->base_name, \
176                             snap_component);                            \
177                         smb_fname->base_name = cpath;                   \
178                 }                                                       \
179                 status = create_synthetic_smb_fname(talloc_tos(),       \
180                     cpath ?: smb_fname->base_name,                      \
181                     smb_fname->stream_name, &smb_fname->st,             \
182                     &smb_fname_tmp);                                    \
183                 if (!NT_STATUS_IS_OK(status)) {                         \
184                         errno = map_errno_from_nt_status(status);       \
185                         return  ret;                                    \
186                 }                                                       \
187                 ret = SMB_VFS_NEXT_ ## op args;                         \
188                 TALLOC_FREE(smb_fname_tmp)                              \
189                 SAFE_FREE(cpath);                                       \
190                 return ret;                                             \
191         } while (0)                                                     \
192
193
194
195 static uint64_t
196 onefs_shadow_copy_disk_free(vfs_handle_struct *handle, const char *path,
197                             bool small_query, uint64_t *bsize, uint64_t *dfree,
198                             uint64_t *dsize)
199 {
200
201         SHADOW_NEXT(DISK_FREE,
202                     (handle, cpath ?: path, small_query, bsize, dfree, dsize),
203                     uint64_t);
204
205 }
206
207 static int
208 onefs_shadow_copy_statvfs(struct vfs_handle_struct *handle, const char *path,
209                           struct vfs_statvfs_struct *statbuf)
210 {
211         SHADOW_NEXT(STATVFS,
212                     (handle, cpath ?: path, statbuf),
213                     int);
214 }
215
216 static SMB_STRUCT_DIR *
217 onefs_shadow_copy_opendir(vfs_handle_struct *handle, const char *path,
218                           const char *mask, uint32_t attr)
219 {
220         SHADOW_NEXT(OPENDIR,
221                     (handle, cpath ?: path, mask, attr),
222                     SMB_STRUCT_DIR *);
223 }
224
225 static int
226 onefs_shadow_copy_mkdir(vfs_handle_struct *handle, const char *path,
227                         mode_t mode)
228 {
229         SHADOW_NEXT(MKDIR,
230                     (handle, cpath ?: path, mode),
231                     int);
232 }
233
234 static int
235 onefs_shadow_copy_rmdir(vfs_handle_struct *handle, const char *path)
236 {
237         SHADOW_NEXT(RMDIR,
238                     (handle, cpath ?: path),
239                     int);
240 }
241
242 static int
243 onefs_shadow_copy_open(vfs_handle_struct *handle,
244                        struct smb_filename *smb_fname, files_struct *fsp,
245                        int flags, mode_t mode)
246 {
247         SHADOW_NEXT_SMB_FNAME(OPEN,
248                               (handle, smb_fname, fsp, flags, mode),
249                               int);
250 }
251
252 static NTSTATUS
253 onefs_shadow_copy_create_file(vfs_handle_struct *handle,
254                               struct smb_request *req,
255                               uint16_t root_dir_fid,
256                               struct smb_filename *smb_fname,
257                               uint32_t access_mask,
258                               uint32_t share_access,
259                               uint32_t create_disposition,
260                               uint32_t create_options,
261                               uint32_t file_attributes,
262                               uint32_t oplock_request,
263                               uint64_t allocation_size,
264                               struct security_descriptor *sd,
265                               struct ea_list *ea_list,
266                               files_struct **result,
267                               int *pinfo)
268 {
269         SHADOW_NEXT_SMB_FNAME(CREATE_FILE,
270                               (handle, req, root_dir_fid, smb_fname,
271                                   access_mask, share_access,
272                                   create_disposition, create_options,
273                                   file_attributes, oplock_request,
274                                   allocation_size, sd, ea_list, result, pinfo),
275                               NTSTATUS);
276 }
277
278 /**
279  * XXX: macro-ize
280  */
281 static int
282 onefs_shadow_copy_rename(vfs_handle_struct *handle,
283                          const struct smb_filename *smb_fname_src,
284                          const struct smb_filename *smb_fname_dst)
285 {
286         char *old_cpath = NULL;
287         char *old_snap_component = NULL;
288         char *new_cpath = NULL;
289         char *new_snap_component = NULL;
290         struct smb_filename *smb_fname_src_tmp = NULL;
291         struct smb_filename *smb_fname_dst_tmp = NULL;
292         NTSTATUS status;
293         int ret = -1;
294
295         status = copy_smb_filename(talloc_tos(), smb_fname_src,
296                                    &smb_fname_src_tmp);
297         if (!NT_STATUS_IS_OK(status)) {
298                 errno = map_errno_from_nt_status(status);
299                 goto out;
300         }
301         status = copy_smb_filename(talloc_tos(), smb_fname_dst,
302                                    &smb_fname_dst_tmp);
303         if (!NT_STATUS_IS_OK(status)) {
304                 errno = map_errno_from_nt_status(status);
305                 goto out;
306         }
307
308         if (shadow_copy_match_name(smb_fname_src_tmp->base_name,
309                                    &old_snap_component)) {
310                 old_cpath = osc_canonicalize_path(smb_fname_src_tmp->base_name,
311                                           old_snap_component);
312                 smb_fname_src_tmp->base_name = old_cpath;
313         }
314
315         if (shadow_copy_match_name(smb_fname_dst_tmp->base_name,
316                                    &new_snap_component)) {
317                 new_cpath = osc_canonicalize_path(smb_fname_dst_tmp->base_name,
318                                           new_snap_component);
319                 smb_fname_dst_tmp->base_name = new_cpath;
320         }
321
322         ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src_tmp,
323                                   smb_fname_dst_tmp);
324
325  out:
326         SAFE_FREE(old_cpath);
327         SAFE_FREE(new_cpath);
328         TALLOC_FREE(smb_fname_src_tmp);
329         TALLOC_FREE(smb_fname_dst_tmp);
330
331         return ret;
332 }
333
334 static int
335 onefs_shadow_copy_stat(vfs_handle_struct *handle,
336                        struct smb_filename *smb_fname)
337 {
338         SHADOW_NEXT_SMB_FNAME(STAT,
339                               (handle, smb_fname),
340                               int);
341 }
342
343 static int
344 onefs_shadow_copy_lstat(vfs_handle_struct *handle,
345                         struct smb_filename *smb_fname)
346 {
347         SHADOW_NEXT_SMB_FNAME(LSTAT,
348                               (handle, smb_fname),
349                               int);
350 }
351
352 static int
353 onefs_shadow_copy_unlink(vfs_handle_struct *handle,
354                          const struct smb_filename *smb_fname)
355 {
356         SHADOW_NEXT_SMB_FNAME_CONST(UNLINK,
357                                     (handle, smb_fname_tmp),
358                                     int);
359 }
360
361 static int
362 onefs_shadow_copy_chmod(vfs_handle_struct *handle, const char *path,
363                         mode_t mode)
364 {
365         SHADOW_NEXT(CHMOD,
366                     (handle, cpath ?: path, mode),
367                     int);
368 }
369
370 static int
371 onefs_shadow_copy_chown(vfs_handle_struct *handle, const char *path,
372                         uid_t uid, gid_t gid)
373 {
374         SHADOW_NEXT(CHOWN,
375                     (handle, cpath ?: path, uid, gid),
376                     int);
377 }
378
379 static int
380 onefs_shadow_copy_lchown(vfs_handle_struct *handle, const char *path,
381                          uid_t uid, gid_t gid)
382 {
383         SHADOW_NEXT(LCHOWN,
384                     (handle, cpath ?: path, uid, gid),
385                     int);
386 }
387
388 static int
389 onefs_shadow_copy_chdir(vfs_handle_struct *handle, const char *path)
390 {
391         SHADOW_NEXT(CHDIR,
392                     (handle, cpath ?: path),
393                     int);
394 }
395
396 static int
397 onefs_shadow_copy_ntimes(vfs_handle_struct *handle, const char *path,
398                         struct smb_file_time *ft)
399 {
400         SHADOW_NEXT(NTIMES,
401                     (handle, cpath ?: path, ft),
402                     int);
403
404 }
405
406 /**
407  * XXX: macro-ize
408  */
409 static bool
410 onefs_shadow_copy_symlink(vfs_handle_struct *handle,
411     const char *oldpath, const char *newpath)
412 {
413         char *old_cpath = NULL;
414         char *old_snap_component = NULL;
415         char *new_cpath = NULL;
416         char *new_snap_component = NULL;
417         bool ret;
418
419         if (shadow_copy_match_name(oldpath, &old_snap_component))
420                 old_cpath = osc_canonicalize_path(oldpath, old_snap_component);
421
422         if (shadow_copy_match_name(newpath, &new_snap_component))
423                 new_cpath = osc_canonicalize_path(newpath, new_snap_component);
424
425         ret = SMB_VFS_NEXT_SYMLINK(handle, old_cpath ?: oldpath,
426             new_cpath ?: newpath);
427
428         SAFE_FREE(old_cpath);
429         SAFE_FREE(new_cpath);
430
431         return ret;
432 }
433
434 static int
435 onefs_shadow_copy_readlink(vfs_handle_struct *handle, const char *path,
436                            char *buf, size_t bufsiz)
437 {
438         SHADOW_NEXT(READLINK,
439                     (handle, cpath ?: path, buf, bufsiz),
440                     int);
441 }
442
443 /**
444  * XXX: macro-ize
445  */
446 static int
447 onefs_shadow_copy_link(vfs_handle_struct *handle, const char *oldpath,
448                        const char *newpath)
449 {
450         char *old_cpath = NULL;
451         char *old_snap_component = NULL;
452         char *new_cpath = NULL;
453         char *new_snap_component = NULL;
454         int ret;
455
456         if (shadow_copy_match_name(oldpath, &old_snap_component))
457                 old_cpath = osc_canonicalize_path(oldpath, old_snap_component);
458
459         if (shadow_copy_match_name(newpath, &new_snap_component))
460                 new_cpath = osc_canonicalize_path(newpath, new_snap_component);
461
462         ret = SMB_VFS_NEXT_LINK(handle, old_cpath ?: oldpath,
463             new_cpath ?: newpath);
464
465         SAFE_FREE(old_cpath);
466         SAFE_FREE(new_cpath);
467
468         return ret;
469 }
470
471 static int
472 onefs_shadow_copy_mknod(vfs_handle_struct *handle, const char *path,
473                         mode_t mode, SMB_DEV_T dev)
474 {
475         SHADOW_NEXT(MKNOD,
476                     (handle, cpath ?: path, mode, dev),
477                     int);
478 }
479
480 static char *
481 onefs_shadow_copy_realpath(vfs_handle_struct *handle, const char *path,
482                            char *resolved_path)
483 {
484         SHADOW_NEXT(REALPATH,
485                     (handle, cpath ?: path, resolved_path),
486                     char *);
487 }
488
489 static int onefs_shadow_copy_chflags(struct vfs_handle_struct *handle,
490                                      const char *path, unsigned int flags)
491 {
492         SHADOW_NEXT(CHFLAGS,
493                     (handle, cpath ?: path, flags),
494                     int);
495 }
496
497 static NTSTATUS
498 onefs_shadow_copy_streaminfo(struct vfs_handle_struct *handle,
499                              struct files_struct *fsp,
500                              const char *path,
501                              TALLOC_CTX *mem_ctx,
502                              unsigned int *num_streams,
503                              struct stream_struct **streams)
504 {
505         SHADOW_NEXT(STREAMINFO,
506                     (handle, fsp, cpath ?: path, mem_ctx, num_streams,
507                         streams),
508                     NTSTATUS);
509 }
510
511 static int
512 onefs_shadow_copy_get_real_filename(struct vfs_handle_struct *handle,
513                                     const char *full_path,
514                                     const char *path,
515                                     TALLOC_CTX *mem_ctx,
516                                     char **found_name)
517 {
518         SHADOW_NEXT(GET_REAL_FILENAME,
519                     (handle, full_path, cpath ?: path, mem_ctx, found_name),
520                     int);
521 }
522
523 static NTSTATUS
524 onefs_shadow_copy_get_nt_acl(struct vfs_handle_struct *handle,
525                             const char *path, uint32 security_info,
526                             struct security_descriptor **ppdesc)
527 {
528         SHADOW_NEXT(GET_NT_ACL,
529                     (handle, cpath ?: path, security_info, ppdesc),
530                     NTSTATUS);
531 }
532
533 static int
534 onefs_shadow_copy_chmod_acl(vfs_handle_struct *handle, const char *path,
535                             mode_t mode)
536 {
537         SHADOW_NEXT(CHMOD_ACL,
538                     (handle, cpath ?: path, mode),
539                     int);
540 }
541
542 static SMB_ACL_T
543 onefs_shadow_copy_sys_acl_get_file(vfs_handle_struct *handle,
544                                    const char *path, SMB_ACL_TYPE_T type)
545 {
546         SHADOW_NEXT(SYS_ACL_GET_FILE,
547                     (handle, cpath ?: path, type),
548                     SMB_ACL_T);
549 }
550
551 static int
552 onefs_shadow_copy_sys_acl_set_file(vfs_handle_struct *handle, const char *path,
553                                    SMB_ACL_TYPE_T type, SMB_ACL_T theacl)
554 {
555         SHADOW_NEXT(SYS_ACL_SET_FILE,
556                     (handle, cpath ?: path, type, theacl),
557                     int);
558 }
559
560 static int
561 onefs_shadow_copy_sys_acl_delete_def_file(vfs_handle_struct *handle,
562                                           const char *path)
563 {
564         SHADOW_NEXT(SYS_ACL_DELETE_DEF_FILE,
565                     (handle, cpath ?: path),
566                     int);
567 }
568
569 static ssize_t
570 onefs_shadow_copy_getxattr(vfs_handle_struct *handle, const char *path,
571                            const char *name, void *value, size_t size)
572 {
573         SHADOW_NEXT(GETXATTR,
574                     (handle, cpath ?: path, name, value, size),
575                     ssize_t);
576 }
577
578 static ssize_t
579 onefs_shadow_copy_lgetxattr(vfs_handle_struct *handle, const char *path,
580                             const char *name, void *value, size_t size)
581 {
582         SHADOW_NEXT(LGETXATTR,
583                     (handle, cpath ?: path, name, value, size),
584                     ssize_t);
585 }
586
587 static ssize_t
588 onefs_shadow_copy_listxattr(vfs_handle_struct *handle, const char *path,
589                             char *list, size_t size)
590 {
591         SHADOW_NEXT(LISTXATTR,
592                     (handle, cpath ?: path, list, size),
593                     ssize_t);
594 }
595
596 static ssize_t
597 onefs_shadow_copy_llistxattr(vfs_handle_struct *handle, const char *path,
598                              char *list, size_t size)
599 {
600         SHADOW_NEXT(LLISTXATTR,
601                     (handle, cpath ?: path, list, size),
602                     ssize_t);
603 }
604
605 static int
606 onefs_shadow_copy_removexattr(vfs_handle_struct *handle, const char *path,
607                               const char *name)
608 {
609         SHADOW_NEXT(REMOVEXATTR,
610                     (handle, cpath ?: path, name),
611                     int);
612 }
613
614 static int
615 onefs_shadow_copy_lremovexattr(vfs_handle_struct *handle, const char *path,
616                                const char *name)
617 {
618         SHADOW_NEXT(LREMOVEXATTR,
619                     (handle, cpath ?: path, name),
620                     int);
621 }
622
623 static int
624 onefs_shadow_copy_setxattr(vfs_handle_struct *handle, const char *path,
625                            const char *name, const void *value, size_t size,
626                            int flags)
627 {
628         SHADOW_NEXT(SETXATTR,
629                     (handle, cpath ?: path, name, value, size, flags),
630                     int);
631 }
632
633 static int
634 onefs_shadow_copy_lsetxattr(vfs_handle_struct *handle, const char *path,
635                             const char *name, const void *value, size_t size,
636                             int flags)
637 {
638         SHADOW_NEXT(LSETXATTR,
639                     (handle, cpath ?: path, name, value, size, flags),
640                     int);
641 }
642
643 static bool
644 onefs_shadow_copy_is_offline(struct vfs_handle_struct *handle,
645                              const char *path, SMB_STRUCT_STAT *sbuf)
646 {
647         SHADOW_NEXT(IS_OFFLINE,
648                     (handle, cpath ?: path, sbuf),
649                     bool);
650 }
651
652 static int
653 onefs_shadow_copy_set_offline(struct vfs_handle_struct *handle,
654                               const char *path)
655 {
656         SHADOW_NEXT(SET_OFFLINE,
657                     (handle, cpath ?: path),
658                     int);
659 }
660
661 /* VFS operations structure */
662
663 static vfs_op_tuple onefs_shadow_copy_ops[] = {
664
665         /* Disk operations */
666
667         {SMB_VFS_OP(onefs_shadow_copy_disk_free), SMB_VFS_OP_DISK_FREE,
668          SMB_VFS_LAYER_TRANSPARENT},
669         {SMB_VFS_OP(onefs_shadow_copy_get_shadow_copy_data),
670          SMB_VFS_OP_GET_SHADOW_COPY_DATA, SMB_VFS_LAYER_OPAQUE},
671         {SMB_VFS_OP(onefs_shadow_copy_statvfs), SMB_VFS_OP_STATVFS,
672          SMB_VFS_LAYER_TRANSPARENT},
673
674         /* Directory operations */
675
676         {SMB_VFS_OP(onefs_shadow_copy_opendir), SMB_VFS_OP_OPENDIR,
677          SMB_VFS_LAYER_TRANSPARENT},
678         {SMB_VFS_OP(onefs_shadow_copy_mkdir), SMB_VFS_OP_MKDIR,
679          SMB_VFS_LAYER_TRANSPARENT},
680         {SMB_VFS_OP(onefs_shadow_copy_rmdir), SMB_VFS_OP_RMDIR,
681          SMB_VFS_LAYER_TRANSPARENT},
682
683         /* File operations */
684
685         {SMB_VFS_OP(onefs_shadow_copy_open), SMB_VFS_OP_OPEN,
686          SMB_VFS_LAYER_TRANSPARENT},
687         {SMB_VFS_OP(onefs_shadow_copy_create_file), SMB_VFS_OP_CREATE_FILE,
688          SMB_VFS_LAYER_TRANSPARENT},
689         {SMB_VFS_OP(onefs_shadow_copy_rename), SMB_VFS_OP_RENAME,
690          SMB_VFS_LAYER_TRANSPARENT},
691         {SMB_VFS_OP(onefs_shadow_copy_stat), SMB_VFS_OP_STAT,
692          SMB_VFS_LAYER_TRANSPARENT},
693         {SMB_VFS_OP(onefs_shadow_copy_stat), SMB_VFS_OP_STAT,
694          SMB_VFS_LAYER_TRANSPARENT},
695         {SMB_VFS_OP(onefs_shadow_copy_lstat), SMB_VFS_OP_LSTAT,
696          SMB_VFS_LAYER_TRANSPARENT},
697         {SMB_VFS_OP(onefs_shadow_copy_unlink), SMB_VFS_OP_UNLINK,
698          SMB_VFS_LAYER_TRANSPARENT},
699         {SMB_VFS_OP(onefs_shadow_copy_chmod), SMB_VFS_OP_CHMOD,
700          SMB_VFS_LAYER_TRANSPARENT},
701         {SMB_VFS_OP(onefs_shadow_copy_chown), SMB_VFS_OP_CHOWN,
702          SMB_VFS_LAYER_TRANSPARENT},
703         {SMB_VFS_OP(onefs_shadow_copy_lchown), SMB_VFS_OP_LCHOWN,
704          SMB_VFS_LAYER_TRANSPARENT},
705         {SMB_VFS_OP(onefs_shadow_copy_chdir), SMB_VFS_OP_CHDIR,
706          SMB_VFS_LAYER_TRANSPARENT},
707         {SMB_VFS_OP(onefs_shadow_copy_ntimes), SMB_VFS_OP_NTIMES,
708          SMB_VFS_LAYER_TRANSPARENT},
709         {SMB_VFS_OP(onefs_shadow_copy_symlink), SMB_VFS_OP_SYMLINK,
710          SMB_VFS_LAYER_TRANSPARENT},
711         {SMB_VFS_OP(onefs_shadow_copy_readlink), SMB_VFS_OP_READLINK,
712          SMB_VFS_LAYER_TRANSPARENT},
713         {SMB_VFS_OP(onefs_shadow_copy_link), SMB_VFS_OP_LINK,
714          SMB_VFS_LAYER_TRANSPARENT},
715         {SMB_VFS_OP(onefs_shadow_copy_mknod), SMB_VFS_OP_MKNOD,
716          SMB_VFS_LAYER_TRANSPARENT},
717         {SMB_VFS_OP(onefs_shadow_copy_realpath), SMB_VFS_OP_REALPATH,
718          SMB_VFS_LAYER_TRANSPARENT},
719         {SMB_VFS_OP(onefs_shadow_copy_chflags), SMB_VFS_OP_CHFLAGS,
720          SMB_VFS_LAYER_TRANSPARENT},
721         {SMB_VFS_OP(onefs_shadow_copy_streaminfo), SMB_VFS_OP_STREAMINFO,
722          SMB_VFS_LAYER_TRANSPARENT},
723         {SMB_VFS_OP(onefs_shadow_copy_get_real_filename),
724          SMB_VFS_OP_GET_REAL_FILENAME, SMB_VFS_LAYER_TRANSPARENT},
725
726         /* NT File ACL operations */
727
728         {SMB_VFS_OP(onefs_shadow_copy_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
729          SMB_VFS_LAYER_TRANSPARENT},
730
731         /* POSIX ACL operations */
732
733         {SMB_VFS_OP(onefs_shadow_copy_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
734          SMB_VFS_LAYER_TRANSPARENT},
735         {SMB_VFS_OP(onefs_shadow_copy_sys_acl_get_file),
736          SMB_VFS_OP_SYS_ACL_GET_FILE, SMB_VFS_LAYER_TRANSPARENT},
737         {SMB_VFS_OP(onefs_shadow_copy_sys_acl_set_file),
738          SMB_VFS_OP_SYS_ACL_SET_FILE, SMB_VFS_LAYER_TRANSPARENT},
739         {SMB_VFS_OP(onefs_shadow_copy_sys_acl_delete_def_file),
740          SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, SMB_VFS_LAYER_TRANSPARENT},
741
742         /* EA operations. */
743
744         {SMB_VFS_OP(onefs_shadow_copy_getxattr), SMB_VFS_OP_GETXATTR,
745          SMB_VFS_LAYER_TRANSPARENT},
746         {SMB_VFS_OP(onefs_shadow_copy_lgetxattr), SMB_VFS_OP_LGETXATTR,
747          SMB_VFS_LAYER_TRANSPARENT},
748         {SMB_VFS_OP(onefs_shadow_copy_listxattr), SMB_VFS_OP_LISTXATTR,
749          SMB_VFS_LAYER_TRANSPARENT},
750         {SMB_VFS_OP(onefs_shadow_copy_llistxattr), SMB_VFS_OP_LLISTXATTR,
751          SMB_VFS_LAYER_TRANSPARENT},
752         {SMB_VFS_OP(onefs_shadow_copy_removexattr), SMB_VFS_OP_REMOVEXATTR,
753          SMB_VFS_LAYER_TRANSPARENT},
754         {SMB_VFS_OP(onefs_shadow_copy_lremovexattr), SMB_VFS_OP_LREMOVEXATTR,
755          SMB_VFS_LAYER_TRANSPARENT},
756         {SMB_VFS_OP(onefs_shadow_copy_setxattr), SMB_VFS_OP_SETXATTR,
757          SMB_VFS_LAYER_TRANSPARENT},
758         {SMB_VFS_OP(onefs_shadow_copy_lsetxattr), SMB_VFS_OP_LSETXATTR,
759          SMB_VFS_LAYER_TRANSPARENT},
760
761         /* offline operations */
762         {SMB_VFS_OP(onefs_shadow_copy_is_offline), SMB_VFS_OP_IS_OFFLINE,
763          SMB_VFS_LAYER_TRANSPARENT},
764         {SMB_VFS_OP(onefs_shadow_copy_set_offline), SMB_VFS_OP_SET_OFFLINE,
765          SMB_VFS_LAYER_TRANSPARENT},
766
767         {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
768 };
769
770 NTSTATUS vfs_shadow_copy_init(void)
771 {
772         NTSTATUS ret;
773
774         ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
775                                "onefs_shadow_copy",
776                                onefs_shadow_copy_ops);
777
778         if (!NT_STATUS_IS_OK(ret))
779                 return ret;
780
781         vfs_onefs_shadow_copy_debug_level = debug_add_class("onefs_shadow_copy");
782
783         if (vfs_onefs_shadow_copy_debug_level == -1) {
784                 vfs_onefs_shadow_copy_debug_level = DBGC_VFS;
785                 DEBUG(0, ("Couldn't register custom debugging class!\n"));
786         } else {
787                 DEBUG(10, ("Debug class number of 'onefs_shadow_copy': %d\n",
788                            vfs_onefs_shadow_copy_debug_level));
789         }
790
791         return ret;
792 }