1 --- source3/modules/vfs_samfs.c 2010-07-07 10:22:33.756895700 -0700 |
1 bug #5780 |
2 +++ source3/modules/vfs_samfs.c 2010-07-07 07:13:55.603441200 -0700 |
2 |
3 @@ -0,0 +1,172 @@ |
3 diff --git a/source3/Makefile.in b/source3/Makefile.in |
|
4 index 425aa2b..db1d809 100644 |
|
5 --- a/source3/Makefile.in |
|
6 +++ b/source3/Makefile.in |
|
7 @@ -715,6 +715,7 @@ VFS_AIXACL_OBJ = modules/vfs_aixacl.o modules/vfs_aixacl_util.o |
|
8 VFS_AIXACL2_OBJ = modules/vfs_aixacl2.o modules/vfs_aixacl_util.o modules/nfs4_acls.o |
|
9 VFS_SOLARISACL_OBJ = modules/vfs_solarisacl.o |
|
10 VFS_ZFSACL_OBJ = modules/vfs_zfsacl.o modules/nfs4_acls.o |
|
11 +VFS_SAMFS_OBJ = modules/vfs_samfs.o |
|
12 VFS_HPUXACL_OBJ = modules/vfs_hpuxacl.o |
|
13 VFS_IRIXACL_OBJ = modules/vfs_irixacl.o |
|
14 VFS_TRU64ACL_OBJ = modules/vfs_tru64acl.o |
|
15 @@ -2741,6 +2742,10 @@ bin/zfsacl.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_ZFSACL_OBJ) |
|
16 @echo "Building plugin $@" |
|
17 @$(SHLD_MODULE) $(VFS_ZFSACL_OBJ) |
|
18 |
|
19 +bin/samfs.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_SAMFS_OBJ) |
|
20 + @echo "Building plugin $@" |
|
21 + @$(SHLD_MODULE) $(VFS_SAMFS_OBJ) @SAMFS_LIBS@ |
|
22 + |
|
23 bin/irixacl.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_IRIXACL_OBJ) |
|
24 @echo "Building plugin $@" |
|
25 @$(SHLD_MODULE) $(VFS_IRIXACL_OBJ) |
|
26 diff --git a/source3/configure.in b/source3/configure.in |
|
27 index 2494593..8daa53f 100644 |
|
28 --- a/source3/configure.in |
|
29 +++ b/source3/configure.in |
|
30 @@ -6653,6 +6653,8 @@ SMB_MODULE(vfs_aio_fork, \$(VFS_AIO_FORK_OBJ), "bin/aio_fork.$SHLIBEXT", VFS) |
|
31 SMB_MODULE(vfs_preopen, \$(VFS_PREOPEN_OBJ), "bin/preopen.$SHLIBEXT", VFS) |
|
32 SMB_MODULE(vfs_syncops, \$(VFS_SYNCOPS_OBJ), "bin/syncops.$SHLIBEXT", VFS) |
|
33 SMB_MODULE(vfs_zfsacl, \$(VFS_ZFSACL_OBJ), "bin/zfsacl.$SHLIBEXT", VFS) |
|
34 +AC_SUBST(SAMFS_LIBS) |
|
35 +SMB_MODULE(vfs_samfs, \$(VFS_SAMFS_OBJ), "bin/samfs.$SHLIBEXT", VFS) |
|
36 SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS) |
|
37 SMB_MODULE(vfs_acl_xattr, \$(VFS_ACL_XATTR_OBJ), "bin/acl_xattr.$SHLIBEXT", VFS) |
|
38 SMB_MODULE(vfs_acl_tdb, \$(VFS_ACL_TDB_OBJ), "bin/acl_tdb.$SHLIBEXT", VFS) |
|
39 diff --git a/source3/modules/vfs_samfs.c b/source3/modules/vfs_samfs.c |
|
40 new file mode 100644 |
|
41 index 0000000..9370768 |
|
42 --- /dev/null |
|
43 +++ b/source3/modules/vfs_samfs.c |
|
44 @@ -0,0 +1,166 @@ |
4 +/* |
45 +/* |
5 + * Support for offline files with Sun SAM-QFS |
46 + * Support for offline files with Sun SAM-QFS |
6 + * |
47 + * |
7 + * Copyright (C) Dirk Nitschke, 2009 |
48 + * Copyright (C) Dirk Nitschke, 2009 |
8 + * |
49 + * |
74 + */ |
115 + */ |
75 + result = sam_stat(path, &file_info, sizeof(struct sam_stat)); |
116 + result = sam_stat(path, &file_info, sizeof(struct sam_stat)); |
76 + |
117 + |
77 + if (result != 0) { |
118 + if (result != 0) { |
78 + DEBUG(10,("samfs_is_offline: cannot sam_stat %s, %s\nAssuming file is offline.\n", \ |
119 + DEBUG(10,("samfs_is_offline: cannot sam_stat %s, %s\nAssuming file is offline.\n", \ |
79 + path, strerror(errno))); |
120 + path, strerror(errno))); |
80 + return true; |
121 + return true; |
81 + } |
122 + } |
82 + |
123 + |
83 + /* |
124 + /* |
84 + * Check if file is offline |
125 + * Check if file is offline |
91 + /* |
132 + /* |
92 + * Check for segmented file |
133 + * Check for segmented file |
93 + */ |
134 + */ |
94 + if (SS_ISSEGMENT_F(file_info.attr)) { |
135 + if (SS_ISSEGMENT_F(file_info.attr)) { |
95 + number_of_segments = NUM_SEGS(&file_info); |
136 + number_of_segments = NUM_SEGS(&file_info); |
96 + seg_info_ptr = (struct sam_stat *)malloc(number_of_segments * |
137 + seg_info_ptr = (struct sam_stat *)TALLOC_ZERO_ARRAY(talloc_tos(), |
97 + sizeof(struct sam_stat)); |
138 + struct sam_stat, number_of_segments); |
98 + if (seg_info_ptr != NULL) { |
139 + if (seg_info_ptr != NULL) { |
99 + /* |
140 + DEBUG(10,("samfs_is_offline: cannot talloc for " |
100 + * Initialize seg_info_ptr to be all zero bits |
141 + "segment stat info %s\nAssuming file is offline.\n", |
101 + */ |
142 + path)); |
102 + memset((void *)seg_info_ptr, 0, number_of_segments * |
143 + return true; |
103 + sizeof(struct sam_stat)); |
144 + } |
104 + /* |
145 + |
105 + * Stat all segments |
146 + /* |
106 + */ |
147 + * Stat all segments |
107 + result = sam_segment_stat(path, seg_info_ptr, |
148 + */ |
108 + number_of_segments * sizeof(struct sam_stat)); |
149 + result = sam_segment_stat(path, seg_info_ptr, |
109 + if (result != 0) { |
150 + number_of_segments * sizeof(struct sam_stat)); |
110 + DEBUG(10,("samfs_is_offline: cannot sam_segment_stat %s, %s\nAssuming file is offline.\n", \ |
151 + if (result != 0) { |
111 + path, strerror(errno))); |
152 + DEBUG(10,("samfs_is_offline: cannot sam_segment_stat %s, " |
112 + offline = true; |
153 + "%s\nAssuming file is offline.\n", |
|
154 + path, strerror(errno))); |
|
155 + TALLOC_FREE(seg_info_ptr); |
|
156 + return true; |
|
157 + } |
|
158 + /* |
|
159 + * Loop over segments until we have checked all segments |
|
160 + * or found one which is offline. |
|
161 + */ |
|
162 + for (i = 0; i < number_of_segments; i++) { |
|
163 + if (SS_ISOFFLINE(seg_info_ptr[i].attr)) { |
|
164 + DEBUG(10,("samfs_is_offline: file %s has offline segment %d\n", |
|
165 + path, i+1)); |
|
166 + break; |
113 + } |
167 + } |
114 + /* |
168 + } |
115 + * Loop over segments until we have checked all segments |
169 + TALLOC_FREE(seg_info_ptr); |
116 + * or found one which is offline. |
|
117 + */ |
|
118 + i = 0; |
|
119 + while (!offline && (i < number_of_segments)) { |
|
120 + if (SS_ISOFFLINE(seg_info_ptr[i].attr)) { |
|
121 + DEBUG(10,("samfs_is_offline: file %s has offline segment %d\n", \ |
|
122 + path, i+1)); |
|
123 + offline = true; |
|
124 + } |
|
125 + i++; |
|
126 + } |
|
127 + SAFE_FREE(seg_info_ptr); |
|
128 + } else { |
|
129 + DEBUG(10,("samfs_is_offline: cannot malloc for segment stat info %s\nAssuming file is offline.\n", \ |
|
130 + path)); |
|
131 + offline = true; |
|
132 + } |
|
133 + |
|
134 + } |
170 + } |
135 + return offline; |
171 + return offline; |
136 +} |
172 +} |
137 + |
173 + |
138 +/* |
174 +/* |
165 +static struct vfs_fn_pointers samfs_fns = { |
201 +static struct vfs_fn_pointers samfs_fns = { |
166 + .is_offline = samfs_is_offline, |
202 + .is_offline = samfs_is_offline, |
167 + .set_offline = samfs_set_offline |
203 + .set_offline = samfs_set_offline |
168 +}; |
204 +}; |
169 + |
205 + |
170 +NTSTATUS vfs_samfs_init(void); |
|
171 +NTSTATUS vfs_samfs_init(void) |
206 +NTSTATUS vfs_samfs_init(void) |
172 +{ |
207 +{ |
173 + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, SAMFS_MODULE_NAME, |
208 + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, SAMFS_MODULE_NAME, |
174 + &samfs_fns); |
209 + &samfs_fns); |
175 +} |
210 +} |