s3 onefs: Change onefs modules to use the new createfile api
[metze/samba/wip.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 /*
147  * XXX: Convert osc_canonicalize_path to use talloc instead of malloc.
148  */
149 #define SHADOW_NEXT_SMB_FNAME(op, args, rtype) do {                   \
150                 char *smb_base_name_tmp = NULL;                       \
151                 char *cpath = NULL;                                   \
152                 char *snap_component = NULL;                          \
153                 rtype ret;                                            \
154                 smb_base_name_tmp = smb_fname->base_name;             \
155                 if (shadow_copy_match_name(smb_fname->base_name,      \
156                         &snap_component)) {                             \
157                         cpath = osc_canonicalize_path(smb_fname->base_name, \
158                             snap_component);                            \
159                         smb_fname->base_name = cpath;                   \
160                 }                                                       \
161                 ret = SMB_VFS_NEXT_ ## op args;                         \
162                 smb_fname->base_name = smb_base_name_tmp;               \
163                 SAFE_FREE(cpath);                                       \
164                 return ret;                                             \
165         } while (0)                                                     \
166
167
168
169 static uint64_t
170 onefs_shadow_copy_disk_free(vfs_handle_struct *handle, const char *path,
171                             bool small_query, uint64_t *bsize, uint64_t *dfree,
172                             uint64_t *dsize)
173 {
174
175         SHADOW_NEXT(DISK_FREE,
176                     (handle, cpath ?: path, small_query, bsize, dfree, dsize),
177                     uint64_t);
178
179 }
180
181 static int
182 onefs_shadow_copy_statvfs(struct vfs_handle_struct *handle, const char *path,
183                           struct vfs_statvfs_struct *statbuf)
184 {
185         SHADOW_NEXT(STATVFS,
186                     (handle, cpath ?: path, statbuf),
187                     int);
188 }
189
190 static SMB_STRUCT_DIR *
191 onefs_shadow_copy_opendir(vfs_handle_struct *handle, const char *path,
192                           const char *mask, uint32_t attr)
193 {
194         SHADOW_NEXT(OPENDIR,
195                     (handle, cpath ?: path, mask, attr),
196                     SMB_STRUCT_DIR *);
197 }
198
199 static int
200 onefs_shadow_copy_mkdir(vfs_handle_struct *handle, const char *path,
201                         mode_t mode)
202 {
203         SHADOW_NEXT(MKDIR,
204                     (handle, cpath ?: path, mode),
205                     int);
206 }
207
208 static int
209 onefs_shadow_copy_rmdir(vfs_handle_struct *handle, const char *path)
210 {
211         SHADOW_NEXT(RMDIR,
212                     (handle, cpath ?: path),
213                     int);
214 }
215
216 static int
217 onefs_shadow_copy_open(vfs_handle_struct *handle, const char *path,
218                        files_struct *fsp, int flags, mode_t mode)
219 {
220         SHADOW_NEXT(OPEN,
221                     (handle, cpath ?: path, fsp, flags, mode),
222                     int);
223 }
224
225 static NTSTATUS
226 onefs_shadow_copy_create_file(vfs_handle_struct *handle,
227                               struct smb_request *req,
228                               uint16_t root_dir_fid,
229                               struct smb_filename *smb_fname,
230                               uint32_t access_mask,
231                               uint32_t share_access,
232                               uint32_t create_disposition,
233                               uint32_t create_options,
234                               uint32_t file_attributes,
235                               uint32_t oplock_request,
236                               uint64_t allocation_size,
237                               struct security_descriptor *sd,
238                               struct ea_list *ea_list,
239                               files_struct **result,
240                               int *pinfo)
241 {
242         SHADOW_NEXT_SMB_FNAME(CREATE_FILE,
243                               (handle, req, root_dir_fid, smb_fname,
244                                   access_mask, share_access,
245                                   create_disposition, create_options,
246                                   file_attributes, oplock_request,
247                                   allocation_size, sd, ea_list, result, pinfo),
248                               NTSTATUS);
249 }
250
251 /**
252  * XXX: macro-ize
253  */
254 static int
255 onefs_shadow_copy_rename(vfs_handle_struct *handle, const char *old_name,
256                          const char *new_name)
257 {
258         char *old_cpath = NULL;
259         char *old_snap_component = NULL;
260         char *new_cpath = NULL;
261         char *new_snap_component = NULL;
262         int ret;
263
264         if (shadow_copy_match_name(old_name, &old_snap_component))
265                 old_cpath = osc_canonicalize_path(old_name, old_snap_component);
266
267         if (shadow_copy_match_name(new_name, &new_snap_component))
268                 new_cpath = osc_canonicalize_path(new_name, new_snap_component);
269
270         ret = SMB_VFS_NEXT_RENAME(handle, old_cpath ?: old_name,
271             new_cpath ?: new_name);
272
273         SAFE_FREE(old_cpath);
274         SAFE_FREE(new_cpath);
275
276         return ret;
277 }
278
279 static int
280 onefs_shadow_copy_stat(vfs_handle_struct *handle, const char *path,
281                        SMB_STRUCT_STAT *sbuf)
282 {
283         SHADOW_NEXT(STAT,
284                     (handle, cpath ?: path, sbuf),
285                     int);
286 }
287
288 static int
289 onefs_shadow_copy_lstat(vfs_handle_struct *handle, const char *path,
290                         SMB_STRUCT_STAT *sbuf)
291 {
292         SHADOW_NEXT(LSTAT,
293                     (handle, cpath ?: path, sbuf),
294                     int);
295 }
296
297 static int
298 onefs_shadow_copy_unlink(vfs_handle_struct *handle, const char *path)
299 {
300         SHADOW_NEXT(UNLINK,
301                     (handle, cpath ?: path),
302                     int);
303 }
304
305 static int
306 onefs_shadow_copy_chmod(vfs_handle_struct *handle, const char *path,
307                         mode_t mode)
308 {
309         SHADOW_NEXT(CHMOD,
310                     (handle, cpath ?: path, mode),
311                     int);
312 }
313
314 static int
315 onefs_shadow_copy_chown(vfs_handle_struct *handle, const char *path,
316                         uid_t uid, gid_t gid)
317 {
318         SHADOW_NEXT(CHOWN,
319                     (handle, cpath ?: path, uid, gid),
320                     int);
321 }
322
323 static int
324 onefs_shadow_copy_lchown(vfs_handle_struct *handle, const char *path,
325                          uid_t uid, gid_t gid)
326 {
327         SHADOW_NEXT(LCHOWN,
328                     (handle, cpath ?: path, uid, gid),
329                     int);
330 }
331
332 static int
333 onefs_shadow_copy_chdir(vfs_handle_struct *handle, const char *path)
334 {
335         SHADOW_NEXT(CHDIR,
336                     (handle, cpath ?: path),
337                     int);
338 }
339
340 static int
341 onefs_shadow_copy_ntimes(vfs_handle_struct *handle, const char *path,
342                         struct smb_file_time *ft)
343 {
344         SHADOW_NEXT(NTIMES,
345                     (handle, cpath ?: path, ft),
346                     int);
347
348 }
349
350 /**
351  * XXX: macro-ize
352  */
353 static bool
354 onefs_shadow_copy_symlink(vfs_handle_struct *handle,
355     const char *oldpath, const char *newpath)
356 {
357         char *old_cpath = NULL;
358         char *old_snap_component = NULL;
359         char *new_cpath = NULL;
360         char *new_snap_component = NULL;
361         bool ret;
362
363         if (shadow_copy_match_name(oldpath, &old_snap_component))
364                 old_cpath = osc_canonicalize_path(oldpath, old_snap_component);
365
366         if (shadow_copy_match_name(newpath, &new_snap_component))
367                 new_cpath = osc_canonicalize_path(newpath, new_snap_component);
368
369         ret = SMB_VFS_NEXT_SYMLINK(handle, old_cpath ?: oldpath,
370             new_cpath ?: newpath);
371
372         SAFE_FREE(old_cpath);
373         SAFE_FREE(new_cpath);
374
375         return ret;
376 }
377
378 static bool
379 onefs_shadow_copy_readlink(vfs_handle_struct *handle, const char *path,
380                            char *buf, size_t bufsiz)
381 {
382         SHADOW_NEXT(READLINK,
383                     (handle, cpath ?: path, buf, bufsiz),
384                     bool);
385 }
386
387 /**
388  * XXX: macro-ize
389  */
390 static int
391 onefs_shadow_copy_link(vfs_handle_struct *handle, const char *oldpath,
392                        const char *newpath)
393 {
394         char *old_cpath = NULL;
395         char *old_snap_component = NULL;
396         char *new_cpath = NULL;
397         char *new_snap_component = NULL;
398         int ret;
399
400         if (shadow_copy_match_name(oldpath, &old_snap_component))
401                 old_cpath = osc_canonicalize_path(oldpath, old_snap_component);
402
403         if (shadow_copy_match_name(newpath, &new_snap_component))
404                 new_cpath = osc_canonicalize_path(newpath, new_snap_component);
405
406         ret = SMB_VFS_NEXT_LINK(handle, old_cpath ?: oldpath,
407             new_cpath ?: newpath);
408
409         SAFE_FREE(old_cpath);
410         SAFE_FREE(new_cpath);
411
412         return ret;
413 }
414
415 static int
416 onefs_shadow_copy_mknod(vfs_handle_struct *handle, const char *path,
417                         mode_t mode, SMB_DEV_T dev)
418 {
419         SHADOW_NEXT(MKNOD,
420                     (handle, cpath ?: path, mode, dev),
421                     int);
422 }
423
424 static char *
425 onefs_shadow_copy_realpath(vfs_handle_struct *handle, const char *path,
426                            char *resolved_path)
427 {
428         SHADOW_NEXT(REALPATH,
429                     (handle, cpath ?: path, resolved_path),
430                     char *);
431 }
432
433 static int onefs_shadow_copy_chflags(struct vfs_handle_struct *handle,
434                                      const char *path, unsigned int flags)
435 {
436         SHADOW_NEXT(CHFLAGS,
437                     (handle, cpath ?: path, flags),
438                     int);
439 }
440
441 static NTSTATUS
442 onefs_shadow_copy_streaminfo(struct vfs_handle_struct *handle,
443                              struct files_struct *fsp,
444                              const char *path,
445                              TALLOC_CTX *mem_ctx,
446                              unsigned int *num_streams,
447                              struct stream_struct **streams)
448 {
449         SHADOW_NEXT(STREAMINFO,
450                     (handle, fsp, cpath ?: path, mem_ctx, num_streams,
451                         streams),
452                     NTSTATUS);
453 }
454
455 static int
456 onefs_shadow_copy_get_real_filename(struct vfs_handle_struct *handle,
457                                     const char *full_path,
458                                     const char *path,
459                                     TALLOC_CTX *mem_ctx,
460                                     char **found_name)
461 {
462         SHADOW_NEXT(GET_REAL_FILENAME,
463                     (handle, full_path, cpath ?: path, mem_ctx, found_name),
464                     int);
465 }
466
467 static NTSTATUS
468 onefs_shadow_copy_get_nt_acl(struct vfs_handle_struct *handle,
469                             const char *path, uint32 security_info,
470                             struct security_descriptor **ppdesc)
471 {
472         SHADOW_NEXT(GET_NT_ACL,
473                     (handle, cpath ?: path, security_info, ppdesc),
474                     NTSTATUS);
475 }
476
477 static int
478 onefs_shadow_copy_chmod_acl(vfs_handle_struct *handle, const char *path,
479                             mode_t mode)
480 {
481         SHADOW_NEXT(CHMOD_ACL,
482                     (handle, cpath ?: path, mode),
483                     int);
484 }
485
486 static SMB_ACL_T
487 onefs_shadow_copy_sys_acl_get_file(vfs_handle_struct *handle,
488                                    const char *path, SMB_ACL_TYPE_T type)
489 {
490         SHADOW_NEXT(SYS_ACL_GET_FILE,
491                     (handle, cpath ?: path, type),
492                     SMB_ACL_T);
493 }
494
495 static int
496 onefs_shadow_copy_sys_acl_set_file(vfs_handle_struct *handle, const char *path,
497                                    SMB_ACL_TYPE_T type, SMB_ACL_T theacl)
498 {
499         SHADOW_NEXT(SYS_ACL_SET_FILE,
500                     (handle, cpath ?: path, type, theacl),
501                     int);
502 }
503
504 static int
505 onefs_shadow_copy_sys_acl_delete_def_file(vfs_handle_struct *handle,
506                                           const char *path)
507 {
508         SHADOW_NEXT(SYS_ACL_DELETE_DEF_FILE,
509                     (handle, cpath ?: path),
510                     int);
511 }
512
513 static ssize_t
514 onefs_shadow_copy_getxattr(vfs_handle_struct *handle, const char *path,
515                            const char *name, void *value, size_t size)
516 {
517         SHADOW_NEXT(GETXATTR,
518                     (handle, cpath ?: path, name, value, size),
519                     ssize_t);
520 }
521
522 static ssize_t
523 onefs_shadow_copy_lgetxattr(vfs_handle_struct *handle, const char *path,
524                             const char *name, void *value, size_t size)
525 {
526         SHADOW_NEXT(LGETXATTR,
527                     (handle, cpath ?: path, name, value, size),
528                     ssize_t);
529 }
530
531 static ssize_t
532 onefs_shadow_copy_listxattr(vfs_handle_struct *handle, const char *path,
533                             char *list, size_t size)
534 {
535         SHADOW_NEXT(LISTXATTR,
536                     (handle, cpath ?: path, list, size),
537                     ssize_t);
538 }
539
540 static ssize_t
541 onefs_shadow_copy_llistxattr(vfs_handle_struct *handle, const char *path,
542                              char *list, size_t size)
543 {
544         SHADOW_NEXT(LLISTXATTR,
545                     (handle, cpath ?: path, list, size),
546                     ssize_t);
547 }
548
549 static int
550 onefs_shadow_copy_removexattr(vfs_handle_struct *handle, const char *path,
551                               const char *name)
552 {
553         SHADOW_NEXT(REMOVEXATTR,
554                     (handle, cpath ?: path, name),
555                     int);
556 }
557
558 static int
559 onefs_shadow_copy_lremovexattr(vfs_handle_struct *handle, const char *path,
560                                const char *name)
561 {
562         SHADOW_NEXT(LREMOVEXATTR,
563                     (handle, cpath ?: path, name),
564                     int);
565 }
566
567 static int
568 onefs_shadow_copy_setxattr(vfs_handle_struct *handle, const char *path,
569                            const char *name, const void *value, size_t size,
570                            int flags)
571 {
572         SHADOW_NEXT(SETXATTR,
573                     (handle, cpath ?: path, name, value, size, flags),
574                     int);
575 }
576
577 static int
578 onefs_shadow_copy_lsetxattr(vfs_handle_struct *handle, const char *path,
579                             const char *name, const void *value, size_t size,
580                             int flags)
581 {
582         SHADOW_NEXT(LSETXATTR,
583                     (handle, cpath ?: path, name, value, size, flags),
584                     int);
585 }
586
587 static bool
588 onefs_shadow_copy_is_offline(struct vfs_handle_struct *handle,
589                              const char *path, SMB_STRUCT_STAT *sbuf)
590 {
591         SHADOW_NEXT(IS_OFFLINE,
592                     (handle, cpath ?: path, sbuf),
593                     bool);
594 }
595
596 static int
597 onefs_shadow_copy_set_offline(struct vfs_handle_struct *handle,
598                               const char *path)
599 {
600         SHADOW_NEXT(SET_OFFLINE,
601                     (handle, cpath ?: path),
602                     int);
603 }
604
605 /* VFS operations structure */
606
607 static vfs_op_tuple onefs_shadow_copy_ops[] = {
608
609         /* Disk operations */
610
611         {SMB_VFS_OP(onefs_shadow_copy_disk_free), SMB_VFS_OP_DISK_FREE,
612          SMB_VFS_LAYER_TRANSPARENT},
613         {SMB_VFS_OP(onefs_shadow_copy_get_shadow_copy_data),
614          SMB_VFS_OP_GET_SHADOW_COPY_DATA, SMB_VFS_LAYER_OPAQUE},
615         {SMB_VFS_OP(onefs_shadow_copy_statvfs), SMB_VFS_OP_STATVFS,
616          SMB_VFS_LAYER_TRANSPARENT},
617
618         /* Directory operations */
619
620         {SMB_VFS_OP(onefs_shadow_copy_opendir), SMB_VFS_OP_OPENDIR,
621          SMB_VFS_LAYER_TRANSPARENT},
622         {SMB_VFS_OP(onefs_shadow_copy_mkdir), SMB_VFS_OP_MKDIR,
623          SMB_VFS_LAYER_TRANSPARENT},
624         {SMB_VFS_OP(onefs_shadow_copy_rmdir), SMB_VFS_OP_RMDIR,
625          SMB_VFS_LAYER_TRANSPARENT},
626
627         /* File operations */
628
629         {SMB_VFS_OP(onefs_shadow_copy_open), SMB_VFS_OP_OPEN,
630          SMB_VFS_LAYER_TRANSPARENT},
631         {SMB_VFS_OP(onefs_shadow_copy_create_file), SMB_VFS_OP_CREATE_FILE,
632          SMB_VFS_LAYER_TRANSPARENT},
633         {SMB_VFS_OP(onefs_shadow_copy_rename), SMB_VFS_OP_RENAME,
634          SMB_VFS_LAYER_TRANSPARENT},
635         {SMB_VFS_OP(onefs_shadow_copy_stat), SMB_VFS_OP_STAT,
636          SMB_VFS_LAYER_TRANSPARENT},
637         {SMB_VFS_OP(onefs_shadow_copy_stat), SMB_VFS_OP_STAT,
638          SMB_VFS_LAYER_TRANSPARENT},
639         {SMB_VFS_OP(onefs_shadow_copy_lstat), SMB_VFS_OP_LSTAT,
640          SMB_VFS_LAYER_TRANSPARENT},
641         {SMB_VFS_OP(onefs_shadow_copy_unlink), SMB_VFS_OP_UNLINK,
642          SMB_VFS_LAYER_TRANSPARENT},
643         {SMB_VFS_OP(onefs_shadow_copy_chmod), SMB_VFS_OP_CHMOD,
644          SMB_VFS_LAYER_TRANSPARENT},
645         {SMB_VFS_OP(onefs_shadow_copy_chown), SMB_VFS_OP_CHOWN,
646          SMB_VFS_LAYER_TRANSPARENT},
647         {SMB_VFS_OP(onefs_shadow_copy_lchown), SMB_VFS_OP_LCHOWN,
648          SMB_VFS_LAYER_TRANSPARENT},
649         {SMB_VFS_OP(onefs_shadow_copy_chdir), SMB_VFS_OP_CHDIR,
650          SMB_VFS_LAYER_TRANSPARENT},
651         {SMB_VFS_OP(onefs_shadow_copy_ntimes), SMB_VFS_OP_NTIMES,
652          SMB_VFS_LAYER_TRANSPARENT},
653         {SMB_VFS_OP(onefs_shadow_copy_symlink), SMB_VFS_OP_SYMLINK,
654          SMB_VFS_LAYER_TRANSPARENT},
655         {SMB_VFS_OP(onefs_shadow_copy_readlink), SMB_VFS_OP_READLINK,
656          SMB_VFS_LAYER_TRANSPARENT},
657         {SMB_VFS_OP(onefs_shadow_copy_link), SMB_VFS_OP_LINK,
658          SMB_VFS_LAYER_TRANSPARENT},
659         {SMB_VFS_OP(onefs_shadow_copy_mknod), SMB_VFS_OP_MKNOD,
660          SMB_VFS_LAYER_TRANSPARENT},
661         {SMB_VFS_OP(onefs_shadow_copy_realpath), SMB_VFS_OP_REALPATH,
662          SMB_VFS_LAYER_TRANSPARENT},
663         {SMB_VFS_OP(onefs_shadow_copy_chflags), SMB_VFS_OP_CHFLAGS,
664          SMB_VFS_LAYER_TRANSPARENT},
665         {SMB_VFS_OP(onefs_shadow_copy_streaminfo), SMB_VFS_OP_STREAMINFO,
666          SMB_VFS_LAYER_TRANSPARENT},
667         {SMB_VFS_OP(onefs_shadow_copy_get_real_filename),
668          SMB_VFS_OP_GET_REAL_FILENAME, SMB_VFS_LAYER_TRANSPARENT},
669
670         /* NT File ACL operations */
671
672         {SMB_VFS_OP(onefs_shadow_copy_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
673          SMB_VFS_LAYER_TRANSPARENT},
674
675         /* POSIX ACL operations */
676
677         {SMB_VFS_OP(onefs_shadow_copy_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
678          SMB_VFS_LAYER_TRANSPARENT},
679         {SMB_VFS_OP(onefs_shadow_copy_sys_acl_get_file),
680          SMB_VFS_OP_SYS_ACL_GET_FILE, SMB_VFS_LAYER_TRANSPARENT},
681         {SMB_VFS_OP(onefs_shadow_copy_sys_acl_set_file),
682          SMB_VFS_OP_SYS_ACL_SET_FILE, SMB_VFS_LAYER_TRANSPARENT},
683         {SMB_VFS_OP(onefs_shadow_copy_sys_acl_delete_def_file),
684          SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, SMB_VFS_LAYER_TRANSPARENT},
685
686         /* EA operations. */
687
688         {SMB_VFS_OP(onefs_shadow_copy_getxattr), SMB_VFS_OP_GETXATTR,
689          SMB_VFS_LAYER_TRANSPARENT},
690         {SMB_VFS_OP(onefs_shadow_copy_lgetxattr), SMB_VFS_OP_LGETXATTR,
691          SMB_VFS_LAYER_TRANSPARENT},
692         {SMB_VFS_OP(onefs_shadow_copy_listxattr), SMB_VFS_OP_LISTXATTR,
693          SMB_VFS_LAYER_TRANSPARENT},
694         {SMB_VFS_OP(onefs_shadow_copy_llistxattr), SMB_VFS_OP_LLISTXATTR,
695          SMB_VFS_LAYER_TRANSPARENT},
696         {SMB_VFS_OP(onefs_shadow_copy_removexattr), SMB_VFS_OP_REMOVEXATTR,
697          SMB_VFS_LAYER_TRANSPARENT},
698         {SMB_VFS_OP(onefs_shadow_copy_lremovexattr), SMB_VFS_OP_LREMOVEXATTR,
699          SMB_VFS_LAYER_TRANSPARENT},
700         {SMB_VFS_OP(onefs_shadow_copy_setxattr), SMB_VFS_OP_SETXATTR,
701          SMB_VFS_LAYER_TRANSPARENT},
702         {SMB_VFS_OP(onefs_shadow_copy_lsetxattr), SMB_VFS_OP_LSETXATTR,
703          SMB_VFS_LAYER_TRANSPARENT},
704
705         /* offline operations */
706         {SMB_VFS_OP(onefs_shadow_copy_is_offline), SMB_VFS_OP_IS_OFFLINE,
707          SMB_VFS_LAYER_TRANSPARENT},
708         {SMB_VFS_OP(onefs_shadow_copy_set_offline), SMB_VFS_OP_SET_OFFLINE,
709          SMB_VFS_LAYER_TRANSPARENT},
710
711         {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
712 };
713
714 NTSTATUS vfs_shadow_copy_init(void)
715 {
716         NTSTATUS ret;
717
718         ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
719                                "onefs_shadow_copy",
720                                onefs_shadow_copy_ops);
721
722         if (!NT_STATUS_IS_OK(ret))
723                 return ret;
724
725         vfs_onefs_shadow_copy_debug_level = debug_add_class("onefs_shadow_copy");
726
727         if (vfs_onefs_shadow_copy_debug_level == -1) {
728                 vfs_onefs_shadow_copy_debug_level = DBGC_VFS;
729                 DEBUG(0, ("Couldn't register custom debugging class!\n"));
730         } else {
731                 DEBUG(10, ("Debug class number of 'onefs_shadow_copy': %d\n",
732                            vfs_onefs_shadow_copy_debug_level));
733         }
734
735         return ret;
736 }