0efceb423407ac4a073612b1ee5ee146b53d5cf2
[kai/samba.git] / examples / VFS / shadow_copy_test.c
1 /* 
2  * TEST implementation of an Shadow Copy module
3  *
4  * Copyright (C) Stefan Metzmacher      2003
5  * Copyright (C) Jeremy Allison 2009.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *  
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *  
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include "includes.h"
22 #include "ntioctl.h"
23 #include "smbd/proto.h"
24
25 #undef DBGC_CLASS
26 #define DBGC_CLASS DBGC_VFS
27
28 /* USE THIS MODULE ONLY FOR TESTING!!!! */
29
30 /*    
31     For this share
32     Z:\
33
34     the ShadowCopies are in this directories
35
36     Z:\@GMT-2003.08.05-12.00.00\
37     Z:\@GMT-2003.08.05-12.01.00\
38     Z:\@GMT-2003.08.05-12.02.00\
39
40     e.g.
41     
42     Z:\testfile.txt
43     Z:\@GMT-2003.08.05-12.02.00\testfile.txt
44
45     or:
46
47     Z:\testdir\testfile.txt
48     Z:\@GMT-2003.08.05-12.02.00\testdir\testfile.txt
49
50
51     Note: Files must differ to be displayed via Windows Explorer!
52           Directories are always displayed...    
53 */
54
55 static int test_get_shadow_copy_data(vfs_handle_struct *handle,
56                                     files_struct *fsp,
57                                     struct shadow_copy_data *shadow_copy_data,
58                                     bool labels)
59 {
60         uint32 num = 3;
61         uint32 i;
62         
63         shadow_copy_data->num_volumes = num;
64         
65         if (labels) {   
66                 if (num) {
67                         shadow_copy_data->labels = talloc_zero_array(shadow_copy_data,SHADOW_COPY_LABEL,num);
68                 } else {
69                         shadow_copy_data->labels = NULL;
70                 }
71                 for (i=0;i<num;i++) {
72                         snprintf(shadow_copy_data->labels[i], sizeof(SHADOW_COPY_LABEL), "@GMT-2003.08.05-12.%02u.00",i);
73                 }
74         } else {
75                 shadow_copy_data->labels = NULL;
76         }
77
78         return 0;
79 }
80
81 /* VFS operations structure */
82
83 static struct vfs_fn_pointers vfs_test_shadow_copy_fns = {
84         .get_shadow_copy_data_fn = test_get_shadow_copy_data
85 };
86
87 NTSTATUS vfs_shadow_copy_test_init(void)
88 {
89         return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
90                                 "shadow_copy_test",
91                                 &vfs_test_shadow_copy_fns);
92 }