s3:vfs: change the xattr_tdb module to use dbwrap wrapper functions
[samba.git] / source3 / modules / vfs_xattr_tdb.c
1 /*
2  * Store posix-level xattrs in a tdb
3  *
4  * Copyright (C) Volker Lendecke, 2007
5  *
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 3 of the License, or
9  * (at your option) any later version.
10  *
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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #include "includes.h"
21 #include "system/filesys.h"
22 #include "smbd/smbd.h"
23 #include "librpc/gen_ndr/xattr.h"
24 #include "librpc/gen_ndr/ndr_xattr.h"
25 #include "../librpc/gen_ndr/ndr_netlogon.h"
26 #include "dbwrap/dbwrap.h"
27 #include "dbwrap/dbwrap_open.h"
28 #include "util_tdb.h"
29
30 #undef DBGC_CLASS
31 #define DBGC_CLASS DBGC_VFS
32
33 /*
34  * unmarshall tdb_xattrs
35  */
36
37 static NTSTATUS xattr_tdb_pull_attrs(TALLOC_CTX *mem_ctx,
38                                      const TDB_DATA *data,
39                                      struct tdb_xattrs **presult)
40 {
41         DATA_BLOB blob;
42         enum ndr_err_code ndr_err;
43         struct tdb_xattrs *result;
44
45         if (!(result = talloc_zero(mem_ctx, struct tdb_xattrs))) {
46                 return NT_STATUS_NO_MEMORY;
47         }
48
49         if (data->dsize == 0) {
50                 *presult = result;
51                 return NT_STATUS_OK;
52         }
53
54         blob = data_blob_const(data->dptr, data->dsize);
55
56         ndr_err = ndr_pull_struct_blob(&blob, result, result,
57                 (ndr_pull_flags_fn_t)ndr_pull_tdb_xattrs);
58
59         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
60                 DEBUG(0, ("ndr_pull_tdb_xattrs failed: %s\n",
61                           ndr_errstr(ndr_err)));
62                 TALLOC_FREE(result);
63                 return ndr_map_error2ntstatus(ndr_err);
64         }
65
66         *presult = result;
67         return NT_STATUS_OK;
68 }
69
70 /*
71  * marshall tdb_xattrs
72  */
73
74 static NTSTATUS xattr_tdb_push_attrs(TALLOC_CTX *mem_ctx,
75                                      const struct tdb_xattrs *attribs,
76                                      TDB_DATA *data)
77 {
78         DATA_BLOB blob;
79         enum ndr_err_code ndr_err;
80
81         ndr_err = ndr_push_struct_blob(&blob, mem_ctx, attribs,
82                 (ndr_push_flags_fn_t)ndr_push_tdb_xattrs);
83
84         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
85                 DEBUG(0, ("ndr_push_tdb_xattrs failed: %s\n",
86                           ndr_errstr(ndr_err)));
87                 return ndr_map_error2ntstatus(ndr_err);
88         }
89
90         *data = make_tdb_data(blob.data, blob.length);
91         return NT_STATUS_OK;
92 }
93
94 /*
95  * Load tdb_xattrs for a file from the tdb
96  */
97
98 static NTSTATUS xattr_tdb_load_attrs(TALLOC_CTX *mem_ctx,
99                                      struct db_context *db_ctx,
100                                      const struct file_id *id,
101                                      struct tdb_xattrs **presult)
102 {
103         uint8 id_buf[16];
104         NTSTATUS status;
105         TDB_DATA data;
106
107         /* For backwards compatibility only store the dev/inode. */
108         push_file_id_16((char *)id_buf, id);
109
110         status = dbwrap_fetch(db_ctx, mem_ctx,
111                               make_tdb_data(id_buf, sizeof(id_buf)),
112                               &data);
113         if (!NT_STATUS_IS_OK(status)) {
114                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
115         }
116
117         status = xattr_tdb_pull_attrs(mem_ctx, &data, presult);
118         TALLOC_FREE(data.dptr);
119         return status;
120 }
121
122 /*
123  * fetch_lock the tdb_ea record for a file
124  */
125
126 static struct db_record *xattr_tdb_lock_attrs(TALLOC_CTX *mem_ctx,
127                                               struct db_context *db_ctx,
128                                               const struct file_id *id)
129 {
130         uint8 id_buf[16];
131
132         /* For backwards compatibility only store the dev/inode. */
133         push_file_id_16((char *)id_buf, id);
134         return dbwrap_fetch_locked(db_ctx, mem_ctx,
135                                    make_tdb_data(id_buf, sizeof(id_buf)));
136 }
137
138 /*
139  * Save tdb_xattrs to a previously fetch_locked record
140  */
141
142 static NTSTATUS xattr_tdb_save_attrs(struct db_record *rec,
143                                      const struct tdb_xattrs *attribs)
144 {
145         TDB_DATA data = tdb_null;
146         NTSTATUS status;
147
148         status = xattr_tdb_push_attrs(talloc_tos(), attribs, &data);
149
150         if (!NT_STATUS_IS_OK(status)) {
151                 DEBUG(0, ("xattr_tdb_push_attrs failed: %s\n",
152                           nt_errstr(status)));
153                 return status;
154         }
155
156         status = dbwrap_record_store(rec, data, 0);
157
158         TALLOC_FREE(data.dptr);
159
160         return status;
161 }
162
163 /*
164  * Worker routine for getxattr and fgetxattr
165  */
166
167 static ssize_t xattr_tdb_getattr(struct db_context *db_ctx,
168                                  const struct file_id *id,
169                                  const char *name, void *value, size_t size)
170 {
171         struct tdb_xattrs *attribs;
172         uint32_t i;
173         ssize_t result = -1;
174         NTSTATUS status;
175
176         DEBUG(10, ("xattr_tdb_getattr called for file %s, name %s\n",
177                    file_id_string_tos(id), name));
178
179         status = xattr_tdb_load_attrs(talloc_tos(), db_ctx, id, &attribs);
180
181         if (!NT_STATUS_IS_OK(status)) {
182                 DEBUG(10, ("xattr_tdb_fetch_attrs failed: %s\n",
183                            nt_errstr(status)));
184                 errno = EINVAL;
185                 return -1;
186         }
187
188         for (i=0; i<attribs->num_eas; i++) {
189                 if (strcmp(attribs->eas[i].name, name) == 0) {
190                         break;
191                 }
192         }
193
194         if (i == attribs->num_eas) {
195                 errno = ENOATTR;
196                 goto fail;
197         }
198
199         if (attribs->eas[i].value.length > size) {
200                 errno = ERANGE;
201                 goto fail;
202         }
203
204         memcpy(value, attribs->eas[i].value.data,
205                attribs->eas[i].value.length);
206         result = attribs->eas[i].value.length;
207
208  fail:
209         TALLOC_FREE(attribs);
210         return result;
211 }
212
213 static ssize_t xattr_tdb_getxattr(struct vfs_handle_struct *handle,
214                                   const char *path, const char *name,
215                                   void *value, size_t size)
216 {
217         SMB_STRUCT_STAT sbuf;
218         struct file_id id;
219         struct db_context *db;
220
221         SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
222
223         if (vfs_stat_smb_fname(handle->conn, path, &sbuf) == -1) {
224                 return -1;
225         }
226
227         id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
228
229         return xattr_tdb_getattr(db, &id, name, value, size);
230 }
231
232 static ssize_t xattr_tdb_fgetxattr(struct vfs_handle_struct *handle,
233                                    struct files_struct *fsp,
234                                    const char *name, void *value, size_t size)
235 {
236         SMB_STRUCT_STAT sbuf;
237         struct file_id id;
238         struct db_context *db;
239
240         SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
241
242         if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) {
243                 return -1;
244         }
245
246         id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
247
248         return xattr_tdb_getattr(db, &id, name, value, size);
249 }
250
251 /*
252  * Worker routine for setxattr and fsetxattr
253  */
254
255 static int xattr_tdb_setattr(struct db_context *db_ctx,
256                              const struct file_id *id, const char *name,
257                              const void *value, size_t size, int flags)
258 {
259         NTSTATUS status;
260         struct db_record *rec;
261         struct tdb_xattrs *attribs;
262         uint32_t i;
263         TDB_DATA data;
264
265         DEBUG(10, ("xattr_tdb_setattr called for file %s, name %s\n",
266                    file_id_string_tos(id), name));
267
268         rec = xattr_tdb_lock_attrs(talloc_tos(), db_ctx, id);
269
270         if (rec == NULL) {
271                 DEBUG(0, ("xattr_tdb_lock_attrs failed\n"));
272                 errno = EINVAL;
273                 return -1;
274         }
275
276         data = dbwrap_record_get_value(rec);
277
278         status = xattr_tdb_pull_attrs(rec, &data, &attribs);
279
280         if (!NT_STATUS_IS_OK(status)) {
281                 DEBUG(10, ("xattr_tdb_fetch_attrs failed: %s\n",
282                            nt_errstr(status)));
283                 TALLOC_FREE(rec);
284                 return -1;
285         }
286
287         for (i=0; i<attribs->num_eas; i++) {
288                 if (strcmp(attribs->eas[i].name, name) == 0) {
289                         if (flags & XATTR_CREATE) {
290                                 TALLOC_FREE(rec);
291                                 errno = EEXIST;
292                                 return -1;
293                         }
294                         break;
295                 }
296         }
297
298         if (i == attribs->num_eas) {
299                 struct xattr_EA *tmp;
300
301                 if (flags & XATTR_REPLACE) {
302                         TALLOC_FREE(rec);
303                         errno = ENOATTR;
304                         return -1;
305                 }
306
307                 tmp = talloc_realloc(
308                         attribs, attribs->eas, struct xattr_EA,
309                         attribs->num_eas+ 1);
310
311                 if (tmp == NULL) {
312                         DEBUG(0, ("talloc_realloc failed\n"));
313                         TALLOC_FREE(rec);
314                         errno = ENOMEM;
315                         return -1;
316                 }
317
318                 attribs->eas = tmp;
319                 attribs->num_eas += 1;
320         }
321
322         attribs->eas[i].name = name;
323         attribs->eas[i].value.data = discard_const_p(uint8, value);
324         attribs->eas[i].value.length = size;
325
326         status = xattr_tdb_save_attrs(rec, attribs);
327
328         TALLOC_FREE(rec);
329
330         if (!NT_STATUS_IS_OK(status)) {
331                 DEBUG(1, ("save failed: %s\n", nt_errstr(status)));
332                 return -1;
333         }
334
335         return 0;
336 }
337
338 static int xattr_tdb_setxattr(struct vfs_handle_struct *handle,
339                               const char *path, const char *name,
340                               const void *value, size_t size, int flags)
341 {
342         SMB_STRUCT_STAT sbuf;
343         struct file_id id;
344         struct db_context *db;
345
346         SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
347
348         if (vfs_stat_smb_fname(handle->conn, path, &sbuf) == -1) {
349                 return -1;
350         }
351
352         id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
353
354         return xattr_tdb_setattr(db, &id, name, value, size, flags);
355 }
356
357 static int xattr_tdb_fsetxattr(struct vfs_handle_struct *handle,
358                                struct files_struct *fsp,
359                                const char *name, const void *value,
360                                size_t size, int flags)
361 {
362         SMB_STRUCT_STAT sbuf;
363         struct file_id id;
364         struct db_context *db;
365
366         SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
367
368         if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) {
369                 return -1;
370         }
371
372         id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
373
374         return xattr_tdb_setattr(db, &id, name, value, size, flags);
375 }
376
377 /*
378  * Worker routine for listxattr and flistxattr
379  */
380
381 static ssize_t xattr_tdb_listattr(struct db_context *db_ctx,
382                                   const struct file_id *id, char *list,
383                                   size_t size)
384 {
385         NTSTATUS status;
386         struct tdb_xattrs *attribs;
387         uint32_t i;
388         size_t len = 0;
389
390         status = xattr_tdb_load_attrs(talloc_tos(), db_ctx, id, &attribs);
391
392         if (!NT_STATUS_IS_OK(status)) {
393                 DEBUG(10, ("xattr_tdb_fetch_attrs failed: %s\n",
394                            nt_errstr(status)));
395                 errno = EINVAL;
396                 return -1;
397         }
398
399         DEBUG(10, ("xattr_tdb_listattr: Found %d xattrs\n",
400                    attribs->num_eas));
401
402         for (i=0; i<attribs->num_eas; i++) {
403                 size_t tmp;
404
405                 DEBUG(10, ("xattr_tdb_listattr: xattrs[i].name: %s\n",
406                            attribs->eas[i].name));
407
408                 tmp = strlen(attribs->eas[i].name);
409
410                 /*
411                  * Try to protect against overflow
412                  */
413
414                 if (len + (tmp+1) < len) {
415                         TALLOC_FREE(attribs);
416                         errno = EINVAL;
417                         return -1;
418                 }
419
420                 /*
421                  * Take care of the terminating NULL
422                  */
423                 len += (tmp + 1);
424         }
425
426         if (len > size) {
427                 TALLOC_FREE(attribs);
428                 errno = ERANGE;
429                 return -1;
430         }
431
432         len = 0;
433
434         for (i=0; i<attribs->num_eas; i++) {
435                 strlcpy(list+len, attribs->eas[i].name,
436                         size-len);
437                 len += (strlen(attribs->eas[i].name) + 1);
438         }
439
440         TALLOC_FREE(attribs);
441         return len;
442 }
443
444 static ssize_t xattr_tdb_listxattr(struct vfs_handle_struct *handle,
445                                    const char *path, char *list, size_t size)
446 {
447         SMB_STRUCT_STAT sbuf;
448         struct file_id id;
449         struct db_context *db;
450
451         SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
452
453         if (vfs_stat_smb_fname(handle->conn, path, &sbuf) == -1) {
454                 return -1;
455         }
456
457         id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
458
459         return xattr_tdb_listattr(db, &id, list, size);
460 }
461
462 static ssize_t xattr_tdb_flistxattr(struct vfs_handle_struct *handle,
463                                     struct files_struct *fsp, char *list,
464                                     size_t size)
465 {
466         SMB_STRUCT_STAT sbuf;
467         struct file_id id;
468         struct db_context *db;
469
470         SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
471
472         if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) {
473                 return -1;
474         }
475
476         id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
477
478         return xattr_tdb_listattr(db, &id, list, size);
479 }
480
481 /*
482  * Worker routine for removexattr and fremovexattr
483  */
484
485 static int xattr_tdb_removeattr(struct db_context *db_ctx,
486                                 const struct file_id *id, const char *name)
487 {
488         NTSTATUS status;
489         struct db_record *rec;
490         struct tdb_xattrs *attribs;
491         uint32_t i;
492         TDB_DATA value;
493
494         rec = xattr_tdb_lock_attrs(talloc_tos(), db_ctx, id);
495
496         if (rec == NULL) {
497                 DEBUG(0, ("xattr_tdb_lock_attrs failed\n"));
498                 errno = EINVAL;
499                 return -1;
500         }
501
502         value = dbwrap_record_get_value(rec);
503
504         status = xattr_tdb_pull_attrs(rec, &value, &attribs);
505
506         if (!NT_STATUS_IS_OK(status)) {
507                 DEBUG(10, ("xattr_tdb_fetch_attrs failed: %s\n",
508                            nt_errstr(status)));
509                 TALLOC_FREE(rec);
510                 return -1;
511         }
512
513         for (i=0; i<attribs->num_eas; i++) {
514                 if (strcmp(attribs->eas[i].name, name) == 0) {
515                         break;
516                 }
517         }
518
519         if (i == attribs->num_eas) {
520                 TALLOC_FREE(rec);
521                 errno = ENOATTR;
522                 return -1;
523         }
524
525         attribs->eas[i] =
526                 attribs->eas[attribs->num_eas-1];
527         attribs->num_eas -= 1;
528
529         if (attribs->num_eas == 0) {
530                 dbwrap_record_delete(rec);
531                 TALLOC_FREE(rec);
532                 return 0;
533         }
534
535         status = xattr_tdb_save_attrs(rec, attribs);
536
537         TALLOC_FREE(rec);
538
539         if (!NT_STATUS_IS_OK(status)) {
540                 DEBUG(1, ("save failed: %s\n", nt_errstr(status)));
541                 return -1;
542         }
543
544         return 0;
545 }
546
547 static int xattr_tdb_removexattr(struct vfs_handle_struct *handle,
548                                  const char *path, const char *name)
549 {
550         SMB_STRUCT_STAT sbuf;
551         struct file_id id;
552         struct db_context *db;
553
554         SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
555
556         if (vfs_stat_smb_fname(handle->conn, path, &sbuf) == -1) {
557                 return -1;
558         }
559
560         id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
561
562         return xattr_tdb_removeattr(db, &id, name);
563 }
564
565 static int xattr_tdb_fremovexattr(struct vfs_handle_struct *handle,
566                                   struct files_struct *fsp, const char *name)
567 {
568         SMB_STRUCT_STAT sbuf;
569         struct file_id id;
570         struct db_context *db;
571
572         SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
573
574         if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) {
575                 return -1;
576         }
577
578         id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
579
580         return xattr_tdb_removeattr(db, &id, name);
581 }
582
583 /*
584  * Open the tdb file upon VFS_CONNECT
585  */
586
587 static bool xattr_tdb_init(int snum, struct db_context **p_db)
588 {
589         struct db_context *db;
590         const char *dbname;
591         char *def_dbname;
592
593         def_dbname = state_path("xattr.tdb");
594         if (def_dbname == NULL) {
595                 errno = ENOSYS;
596                 return false;
597         }
598
599         dbname = lp_parm_const_string(snum, "xattr_tdb", "file", def_dbname);
600
601         /* now we know dbname is not NULL */
602
603         become_root();
604         db = db_open(NULL, dbname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
605         unbecome_root();
606
607         if (db == NULL) {
608 #if defined(ENOTSUP)
609                 errno = ENOTSUP;
610 #else
611                 errno = ENOSYS;
612 #endif
613                 TALLOC_FREE(def_dbname);
614                 return false;
615         }
616
617         *p_db = db;
618         TALLOC_FREE(def_dbname);
619         return true;
620 }
621
622 /*
623  * On unlink we need to delete the tdb record
624  */
625 static int xattr_tdb_unlink(vfs_handle_struct *handle,
626                             const struct smb_filename *smb_fname)
627 {
628         struct smb_filename *smb_fname_tmp = NULL;
629         struct file_id id;
630         struct db_context *db;
631         struct db_record *rec;
632         NTSTATUS status;
633         int ret = -1;
634         bool remove_record = false;
635
636         SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
637
638         status = copy_smb_filename(talloc_tos(), smb_fname, &smb_fname_tmp);
639         if (!NT_STATUS_IS_OK(status)) {
640                 errno = map_errno_from_nt_status(status);
641                 return -1;
642         }
643
644         if (lp_posix_pathnames()) {
645                 ret = SMB_VFS_LSTAT(handle->conn, smb_fname_tmp);
646         } else {
647                 ret = SMB_VFS_STAT(handle->conn, smb_fname_tmp);
648         }
649         if (ret == -1) {
650                 goto out;
651         }
652
653         if (smb_fname_tmp->st.st_ex_nlink == 1) {
654                 /* Only remove record on last link to file. */
655                 remove_record = true;
656         }
657
658         ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname_tmp);
659
660         if (ret == -1) {
661                 goto out;
662         }
663
664         if (!remove_record) {
665                 goto out;
666         }
667
668         id = SMB_VFS_FILE_ID_CREATE(handle->conn, &smb_fname_tmp->st);
669
670         rec = xattr_tdb_lock_attrs(talloc_tos(), db, &id);
671
672         /*
673          * If rec == NULL there's not much we can do about it
674          */
675
676         if (rec != NULL) {
677                 dbwrap_record_delete(rec);
678                 TALLOC_FREE(rec);
679         }
680
681  out:
682         TALLOC_FREE(smb_fname_tmp);
683         return ret;
684 }
685
686 /*
687  * On rmdir we need to delete the tdb record
688  */
689 static int xattr_tdb_rmdir(vfs_handle_struct *handle, const char *path)
690 {
691         SMB_STRUCT_STAT sbuf;
692         struct file_id id;
693         struct db_context *db;
694         struct db_record *rec;
695         int ret;
696
697         SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
698
699         if (vfs_stat_smb_fname(handle->conn, path, &sbuf) == -1) {
700                 return -1;
701         }
702
703         ret = SMB_VFS_NEXT_RMDIR(handle, path);
704
705         if (ret == -1) {
706                 return -1;
707         }
708
709         id = SMB_VFS_FILE_ID_CREATE(handle->conn, &sbuf);
710
711         rec = xattr_tdb_lock_attrs(talloc_tos(), db, &id);
712
713         /*
714          * If rec == NULL there's not much we can do about it
715          */
716
717         if (rec != NULL) {
718                 dbwrap_record_delete(rec);
719                 TALLOC_FREE(rec);
720         }
721
722         return 0;
723 }
724
725 /*
726  * Destructor for the VFS private data
727  */
728
729 static void close_xattr_db(void **data)
730 {
731         struct db_context **p_db = (struct db_context **)data;
732         TALLOC_FREE(*p_db);
733 }
734
735 static int xattr_tdb_connect(vfs_handle_struct *handle, const char *service,
736                           const char *user)
737 {
738         char *sname = NULL;
739         int res, snum;
740         struct db_context *db;
741
742         res = SMB_VFS_NEXT_CONNECT(handle, service, user);
743         if (res < 0) {
744                 return res;
745         }
746
747         snum = find_service(talloc_tos(), service, &sname);
748         if (snum == -1 || sname == NULL) {
749                 /*
750                  * Should not happen, but we should not fail just *here*.
751                  */
752                 return 0;
753         }
754
755         if (!xattr_tdb_init(snum, &db)) {
756                 DEBUG(5, ("Could not init xattr tdb\n"));
757                 lp_do_parameter(snum, "ea support", "False");
758                 return 0;
759         }
760
761         lp_do_parameter(snum, "ea support", "True");
762
763         SMB_VFS_HANDLE_SET_DATA(handle, db, close_xattr_db,
764                                 struct db_context, return -1);
765
766         return 0;
767 }
768
769 static struct vfs_fn_pointers vfs_xattr_tdb_fns = {
770         .getxattr = xattr_tdb_getxattr,
771         .fgetxattr = xattr_tdb_fgetxattr,
772         .setxattr = xattr_tdb_setxattr,
773         .fsetxattr = xattr_tdb_fsetxattr,
774         .listxattr = xattr_tdb_listxattr,
775         .flistxattr = xattr_tdb_flistxattr,
776         .removexattr = xattr_tdb_removexattr,
777         .fremovexattr = xattr_tdb_fremovexattr,
778         .unlink = xattr_tdb_unlink,
779         .rmdir = xattr_tdb_rmdir,
780         .connect_fn = xattr_tdb_connect,
781 };
782
783 NTSTATUS vfs_xattr_tdb_init(void);
784 NTSTATUS vfs_xattr_tdb_init(void)
785 {
786         return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "xattr_tdb",
787                                 &vfs_xattr_tdb_fns);
788 }