2 Copyright (c) 2004 Didier Gautheron
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #endif /* HAVE_CONFIG_H */
26 #include <atalk/afp.h>
27 #include <atalk/adouble.h>
28 #include <atalk/vfs.h>
30 #include <atalk/acl.h>
31 #include <atalk/logger.h>
32 #include <atalk/util.h>
33 #include <atalk/volume.h>
34 #include <atalk/directory.h>
41 typedef int (*rf_loop)(struct dirent *, char *, void *, int , mode_t );
43 /* ----------------------------- */
45 for_each_adouble(const char *from, const char *name, rf_loop fn, void *data, int flag, mode_t v_umask)
47 char buf[ MAXPATHLEN + 1];
54 if (NULL == ( dp = opendir( name)) ) {
56 LOG(log_error, logtype_afpd, "%s: opendir %s: %s", from, fullpathname(name),strerror(errno) );
61 strlcpy( buf, name, sizeof(buf));
62 strlcat( buf, "/", sizeof(buf) );
63 m = strchr( buf, '\0' );
65 while ((de = readdir(dp))) {
66 if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) {
70 strlcat(buf, de->d_name, sizeof(buf));
71 if (fn && (ret = fn(de, buf, data, flag, v_umask))) {
81 /*******************************************************************************
82 * classic adouble format
83 *******************************************************************************/
85 static int netatalk_name(const char *name)
87 return strcasecmp(name,".AppleDB") &&
88 strcasecmp(name,".AppleDouble") &&
89 strcasecmp(name,".AppleDesktop");
92 static int validupath_adouble(VFS_FUNC_ARGS_VALIDUPATH)
94 return (vol->v_flags & AFPVOL_USEDOTS) ?
95 netatalk_name(name) && strcasecmp(name,".Parent"): name[0] != '.';
98 /* ----------------- */
99 static int RF_chown_adouble(VFS_FUNC_ARGS_CHOWN)
104 ad_p = vol->vfs->ad_path(path, ADFLAGS_HF );
106 if ( stat( ad_p, &st ) < 0 )
107 return 0; /* ignore */
109 return chown( ad_p, uid, gid );
112 /* ----------------- */
113 static int RF_renamedir_adouble(VFS_FUNC_ARGS_RENAMEDIR)
118 /* ----------------- */
119 static int deletecurdir_adouble_loop(struct dirent *de, char *name, void *data _U_, int flag _U_, mode_t v_umask)
124 /* bail if the file exists in the current directory.
125 * note: this will not fail with dangling symlinks */
127 if (stat(de->d_name, &st) == 0)
128 return AFPERR_DIRNEMPT;
130 if ((err = netatalk_unlink(name)))
136 static int RF_deletecurdir_adouble(VFS_FUNC_ARGS_DELETECURDIR)
140 /* delete stray .AppleDouble files. this happens to get .Parent files
142 if ((err = for_each_adouble("deletecurdir", ".AppleDouble", deletecurdir_adouble_loop, NULL, 1, vol->v_umask)))
144 return netatalk_rmdir( ".AppleDouble" );
147 /* ----------------- */
148 static int adouble_setfilmode(const char * name, mode_t mode, struct stat *st, mode_t v_umask)
150 return setfilmode(name, ad_hf_mode(mode), st, v_umask);
153 static int RF_setfilmode_adouble(VFS_FUNC_ARGS_SETFILEMODE)
155 return adouble_setfilmode(vol->vfs->ad_path( name, ADFLAGS_HF ), mode, st, vol->v_umask);
158 /* ----------------- */
159 static int RF_setdirunixmode_adouble(VFS_FUNC_ARGS_SETDIRUNIXMODE)
161 char *adouble = vol->vfs->ad_path( name, ADFLAGS_DIR );
162 int dropbox = vol->v_flags;
164 if (dir_rx_set(mode)) {
165 if (stickydirmode(ad_dir(adouble), DIRBITS | mode, dropbox, vol->v_umask) < 0 )
169 if (adouble_setfilmode(vol->vfs->ad_path( name, ADFLAGS_DIR ), mode, st, vol->v_umask) < 0)
172 if (!dir_rx_set(mode)) {
173 if (stickydirmode(ad_dir(adouble), DIRBITS | mode, dropbox, vol->v_umask) < 0 )
179 /* ----------------- */
180 static int setdirmode_adouble_loop(struct dirent *de _U_, char *name, void *data, int flag, mode_t v_umask)
182 mode_t hf_mode = *(mode_t *)data;
185 if ( stat( name, &st ) < 0 ) {
188 LOG(log_error, logtype_afpd, "setdirmode: stat %s: %s", name, strerror(errno) );
190 else if (!S_ISDIR(st.st_mode)) {
191 if (setfilmode(name, hf_mode , &st, v_umask) < 0) {
192 /* FIXME what do we do then? */
198 static int RF_setdirmode_adouble(VFS_FUNC_ARGS_SETDIRMODE)
200 int dropbox = vol->v_flags;
201 mode_t hf_mode = ad_hf_mode(mode);
202 char *adouble = vol->vfs->ad_path( name, ADFLAGS_DIR );
203 char *adouble_p = ad_dir(adouble);
205 if (dir_rx_set(mode)) {
206 if (stickydirmode(ad_dir(adouble), DIRBITS | mode, dropbox, vol->v_umask) < 0)
210 if (for_each_adouble("setdirmode", adouble_p, setdirmode_adouble_loop, &hf_mode, vol_noadouble(vol), vol->v_umask))
213 if (!dir_rx_set(mode)) {
214 if (stickydirmode(ad_dir(adouble), DIRBITS | mode, dropbox, vol->v_umask) < 0)
220 /* ----------------- */
221 static int setdirowner_adouble_loop(struct dirent *de _U_, char *name, void *data, int flag _U_, mode_t v_umask _U_)
223 struct perm *owner = data;
225 if ( chown( name, owner->uid, owner->gid ) < 0 && errno != EPERM ) {
226 LOG(log_debug, logtype_afpd, "setdirowner: chown %d/%d %s: %s",
227 owner->uid, owner->gid, fullpathname(name), strerror(errno) );
228 /* return ( -1 ); Sometimes this is okay */
233 static int RF_setdirowner_adouble(VFS_FUNC_ARGS_SETDIROWNER)
235 int noadouble = vol_noadouble(vol);
243 adouble_p = ad_dir(vol->vfs->ad_path( name, ADFLAGS_DIR ));
245 if (for_each_adouble("setdirowner", adouble_p, setdirowner_adouble_loop, &owner, noadouble, vol->v_umask))
249 * We cheat: we know that chown doesn't do anything.
251 if ( stat( ".AppleDouble", &st ) < 0) {
252 if (errno == ENOENT && noadouble)
254 LOG(log_error, logtype_afpd, "setdirowner: stat %s: %s", fullpathname(".AppleDouble"), strerror(errno) );
257 if ( gid && gid != st.st_gid && chown( ".AppleDouble", uid, gid ) < 0 && errno != EPERM ) {
258 LOG(log_debug, logtype_afpd, "setdirowner: chown %d/%d %s: %s",
259 uid, gid,fullpathname(".AppleDouble"), strerror(errno) );
260 /* return ( -1 ); Sometimes this is okay */
265 /* ----------------- */
266 static int RF_deletefile_adouble(VFS_FUNC_ARGS_DELETEFILE)
268 return netatalk_unlink(vol->vfs->ad_path( file, ADFLAGS_HF));
271 /* ----------------- */
272 static int RF_renamefile_adouble(VFS_FUNC_ARGS_RENAMEFILE)
274 char adsrc[ MAXPATHLEN + 1];
277 strcpy( adsrc, vol->vfs->ad_path( src, 0 ));
278 if (unix_rename( adsrc, vol->vfs->ad_path( dst, 0 )) < 0) {
282 if (errno == ENOENT) {
285 if (stat(adsrc, &st)) /* source has no ressource fork, */
288 /* We are here because :
289 * -there's no dest folder.
290 * -there's no .AppleDouble in the dest folder.
291 * if we use the struct adouble passed in parameter it will not
292 * create .AppleDouble if the file is already opened, so we
293 * use a diff one, it's not a pb,ie it's not the same file, yet.
295 ad_init(&ad, vol->v_adouble, vol->v_ad_options);
296 if (!ad_open(dst, ADFLAGS_HF, O_RDWR | O_CREAT, 0666, &ad)) {
297 ad_close(&ad, ADFLAGS_HF);
298 if (!unix_rename( adsrc, vol->vfs->ad_path( dst, 0 )) )
303 else { /* it's something else, bail out */
315 #ifdef HAVE_NFSv4_ACLS
316 static int RF_solaris_acl(VFS_FUNC_ARGS_ACL)
318 static char buf[ MAXPATHLEN + 1];
321 if ((stat(path, &st)) != 0)
323 if (S_ISDIR(st.st_mode)) {
324 if ((snprintf(buf, MAXPATHLEN, "%s/.AppleDouble",path)) < 0)
326 /* set acl on .AppleDouble dir first */
327 if ((acl(buf, cmd, count, aces)) != 0)
329 /* now set ACL on ressource fork */
330 if ((acl(vol->vfs->ad_path(path, ADFLAGS_DIR), cmd, count, aces)) != 0)
333 /* set ACL on ressource fork */
334 if ((acl(vol->vfs->ad_path(path, ADFLAGS_HF), cmd, count, aces)) != 0)
340 static int RF_solaris_remove_acl(VFS_FUNC_ARGS_REMOVE_ACL)
343 static char buf[ MAXPATHLEN + 1];
346 if ((snprintf(buf, MAXPATHLEN, "%s/.AppleDouble",path)) < 0)
348 /* remove ACL from .AppleDouble/.Parent first */
349 if ((ret = remove_acl(vol->vfs->ad_path(path, ADFLAGS_DIR))) != AFP_OK)
351 /* now remove from .AppleDouble dir */
352 if ((ret = remove_acl(buf)) != AFP_OK)
355 /* remove ACL from ressource fork */
356 if ((ret = remove_acl(vol->vfs->ad_path(path, ADFLAGS_HF))) != AFP_OK)
363 /*********************************************************************************
365 *********************************************************************************/
366 static int ads_chown_loop(struct dirent *de _U_, char *name, void *data, int flag _U_, mode_t v_umask _U_)
368 struct perm *owner = data;
370 if (chown( name , owner->uid, owner->gid ) < 0) {
376 static int RF_chown_ads(VFS_FUNC_ARGS_CHOWN)
386 ad_p = ad_dir(vol->vfs->ad_path(path, ADFLAGS_HF ));
388 if ( stat( ad_p, &st ) < 0 ) {
393 if (chown( ad_p, uid, gid ) < 0) {
396 return for_each_adouble("chown_ads", ad_p, ads_chown_loop, &owner, 1, vol->v_umask);
399 /* --------------------------------- */
400 static int deletecurdir_ads1_loop(struct dirent *de _U_, char *name, void *data _U_, int flag _U_, mode_t v_umask _U_)
402 return netatalk_unlink(name);
405 static int ads_delete_rf(char *name)
409 if ((err = for_each_adouble("deletecurdir", name, deletecurdir_ads1_loop, NULL, 1, 0)))
412 * it's a problem for a nfs mounted folder, there's .nfsxxx around
413 * for linux the following line solve it.
414 * but it could fail if rm .nfsxxx create a new .nfsyyy :(
416 if ((err = for_each_adouble("deletecurdir", name, deletecurdir_ads1_loop, NULL, 1, 0)))
418 return netatalk_rmdir(name);
421 static int deletecurdir_ads_loop(struct dirent *de, char *name, void *data _U_, int flag _U_, mode_t v_umask _U_)
425 /* bail if the file exists in the current directory.
426 * note: this will not fail with dangling symlinks */
428 if (stat(de->d_name, &st) == 0) {
429 return AFPERR_DIRNEMPT;
431 return ads_delete_rf(name);
434 static int RF_deletecurdir_ads(VFS_FUNC_ARGS_DELETECURDIR)
438 /* delete stray .AppleDouble files. this happens to get .Parent files as well. */
439 if ((err = for_each_adouble("deletecurdir", ".AppleDouble", deletecurdir_ads_loop, NULL, 1, 0)))
441 return netatalk_rmdir( ".AppleDouble" );
444 /* ------------------- */
450 static int ads_setfilmode_loop(struct dirent *de _U_, char *name, void *data, int flag _U_, mode_t v_umask)
452 struct set_mode *param = data;
454 return setfilmode(name, param->mode, param->st, v_umask);
457 static int ads_setfilmode(const char * name, mode_t mode, struct stat *st, mode_t v_umask)
459 mode_t file_mode = ad_hf_mode(mode);
460 mode_t dir_mode = file_mode;
461 struct set_mode param;
463 if ((dir_mode & (S_IRUSR | S_IWUSR )))
465 if ((dir_mode & (S_IRGRP | S_IWGRP )))
467 if ((dir_mode & (S_IROTH | S_IWOTH )))
472 if (dir_rx_set(dir_mode)) {
473 if (chmod( name, dir_mode ) < 0)
477 param.mode = file_mode;
478 if (for_each_adouble("setfilmode_ads", name, ads_setfilmode_loop, ¶m, 0, v_umask) < 0)
481 if (!dir_rx_set(dir_mode)) {
482 if (chmod( name, dir_mode ) < 0)
489 static int RF_setfilmode_ads(VFS_FUNC_ARGS_SETFILEMODE)
491 return ads_setfilmode(ad_dir(vol->vfs->ad_path( name, ADFLAGS_HF )), mode, st, vol->v_umask);
494 /* ------------------- */
495 static int RF_setdirunixmode_ads(VFS_FUNC_ARGS_SETDIRUNIXMODE)
497 char *adouble = vol->vfs->ad_path( name, ADFLAGS_DIR );
498 char ad_p[ MAXPATHLEN + 1];
499 int dropbox = vol->v_flags;
501 strlcpy(ad_p,ad_dir(adouble), MAXPATHLEN + 1);
503 if (dir_rx_set(mode)) {
506 if (stickydirmode(ad_dir(ad_p), DIRBITS | mode, dropbox, vol->v_umask) < 0)
509 /* .AppleDouble/.Parent */
510 if (stickydirmode(ad_p, DIRBITS | mode, dropbox, vol->v_umask) < 0)
514 if (ads_setfilmode(ad_dir(vol->vfs->ad_path( name, ADFLAGS_DIR)), mode, st, vol->v_umask) < 0)
517 if (!dir_rx_set(mode)) {
518 if (stickydirmode(ad_p, DIRBITS | mode, dropbox, vol->v_umask) < 0)
520 if (stickydirmode(ad_dir(ad_p), DIRBITS | mode, dropbox, vol->v_umask) < 0)
526 /* ------------------- */
532 static int setdirmode_ads_loop(struct dirent *de _U_, char *name, void *data, int flag, mode_t v_umask)
535 struct dir_mode *param = data;
536 int ret = 0; /* 0 ignore error, -1 */
538 if (dir_rx_set(param->mode)) {
539 if (stickydirmode(name, DIRBITS | param->mode, param->dropbox, v_umask) < 0) {
546 if (ads_setfilmode(name, param->mode, NULL, v_umask) < 0)
549 if (!dir_rx_set(param->mode)) {
550 if (stickydirmode(name, DIRBITS | param->mode, param->dropbox, v_umask) < 0) {
560 static int RF_setdirmode_ads(VFS_FUNC_ARGS_SETDIRMODE)
562 char *adouble = vol->vfs->ad_path( name, ADFLAGS_DIR );
563 char ad_p[ MAXPATHLEN + 1];
564 struct dir_mode param;
567 param.dropbox = vol->v_flags;
569 strlcpy(ad_p,ad_dir(adouble), sizeof(ad_p));
571 if (dir_rx_set(mode)) {
573 if (stickydirmode(ad_dir(ad_p), DIRBITS | mode, param.dropbox, vol->v_umask) < 0)
577 if (for_each_adouble("setdirmode_ads", ad_dir(ad_p), setdirmode_ads_loop, ¶m, vol_noadouble(vol), vol->v_umask))
580 if (!dir_rx_set(mode)) {
581 if (stickydirmode(ad_dir(ad_p), DIRBITS | mode, param.dropbox, vol->v_umask) < 0 )
587 /* ------------------- */
588 static int setdirowner_ads1_loop(struct dirent *de _U_, char *name, void *data, int flag _U_, mode_t v_umask _U_)
590 struct perm *owner = data;
592 if ( chown( name, owner->uid, owner->gid ) < 0 && errno != EPERM ) {
593 LOG(log_debug, logtype_afpd, "setdirowner: chown %d/%d %s: %s",
594 owner->uid, owner->gid, fullpathname(name), strerror(errno) );
595 /* return ( -1 ); Sometimes this is okay */
600 static int setdirowner_ads_loop(struct dirent *de _U_, char *name, void *data, int flag, mode_t v_umask _U_)
602 struct perm *owner = data;
604 if (for_each_adouble("setdirowner", name, setdirowner_ads1_loop, data, flag, 0) < 0)
607 if ( chown( name, owner->uid, owner->gid ) < 0 && errno != EPERM ) {
608 LOG(log_debug, logtype_afpd, "setdirowner: chown %d/%d %s: %s",
609 owner->uid, owner->gid, fullpathname(name), strerror(errno) );
610 /* return ( -1 ); Sometimes this is okay */
615 static int RF_setdirowner_ads(VFS_FUNC_ARGS_SETDIROWNER)
617 int noadouble = vol_noadouble(vol);
618 char adouble_p[ MAXPATHLEN + 1];
625 strlcpy(adouble_p, ad_dir(vol->vfs->ad_path( name, ADFLAGS_DIR )), sizeof(adouble_p));
627 if (for_each_adouble("setdirowner", ad_dir(adouble_p), setdirowner_ads_loop, &owner, noadouble, 0))
631 * We cheat: we know that chown doesn't do anything.
633 if ( stat( ".AppleDouble", &st ) < 0) {
634 if (errno == ENOENT && noadouble)
636 LOG(log_error, logtype_afpd, "setdirowner: stat %s: %s", fullpathname(".AppleDouble"), strerror(errno) );
639 if ( gid && gid != st.st_gid && chown( ".AppleDouble", uid, gid ) < 0 && errno != EPERM ) {
640 LOG(log_debug, logtype_afpd, "setdirowner: chown %d/%d %s: %s",
641 uid, gid,fullpathname(".AppleDouble"), strerror(errno) );
642 /* return ( -1 ); Sometimes this is okay */
647 /* ------------------- */
648 static int RF_deletefile_ads(VFS_FUNC_ARGS_DELETEFILE)
650 char *ad_p = ad_dir(vol->vfs->ad_path(file, ADFLAGS_HF ));
652 return ads_delete_rf(ad_p);
655 /* --------------------------- */
656 static int RF_renamefile_ads(VFS_FUNC_ARGS_RENAMEFILE)
658 char adsrc[ MAXPATHLEN + 1];
661 strcpy( adsrc, ad_dir(vol->vfs->ad_path( src, 0 )));
662 if (unix_rename( adsrc, ad_dir(vol->vfs->ad_path( dst, 0 ))) < 0) {
666 if (errno == ENOENT) {
669 if (stat(adsrc, &st)) /* source has no ressource fork, */
672 /* We are here because :
673 * -there's no dest folder.
674 * -there's no .AppleDouble in the dest folder.
675 * if we use the struct adouble passed in parameter it will not
676 * create .AppleDouble if the file is already opened, so we
677 * use a diff one, it's not a pb,ie it's not the same file, yet.
679 ad_init(&ad, vol->v_adouble, vol->v_ad_options);
680 if (!ad_open(dst, ADFLAGS_HF, O_RDWR | O_CREAT, 0666, &ad)) {
681 ad_close(&ad, ADFLAGS_HF);
683 /* We must delete it */
684 RF_deletefile_ads(vol, dst );
685 if (!unix_rename( adsrc, ad_dir(vol->vfs->ad_path( dst, 0 ))) )
690 else { /* it's something else, bail out */
702 /*************************************************************************
704 ************************************************************************/
705 static int validupath_osx(VFS_FUNC_ARGS_VALIDUPATH)
707 return strncmp(name,"._", 2) && (
708 (vol->v_flags & AFPVOL_USEDOTS) ? netatalk_name(name): name[0] != '.');
711 /* ---------------- */
712 static int RF_renamedir_osx(VFS_FUNC_ARGS_RENAMEDIR)
714 /* We simply move the corresponding ad file as well */
715 char tempbuf[258]="._";
716 return rename(vol->vfs->ad_path(oldpath,0),strcat(tempbuf,newpath));
719 /* ---------------- */
720 static int RF_deletecurdir_osx(VFS_FUNC_ARGS_DELETECURDIR)
722 return netatalk_unlink( vol->vfs->ad_path(".",0) );
725 /* ---------------- */
726 static int RF_setdirunixmode_osx(VFS_FUNC_ARGS_SETDIRUNIXMODE)
728 return adouble_setfilmode(vol->vfs->ad_path( name, ADFLAGS_DIR ), mode, st, vol->v_umask);
731 /* ---------------- */
732 static int RF_setdirmode_osx(VFS_FUNC_ARGS_SETDIRMODE)
737 /* ---------------- */
738 static int RF_setdirowner_osx(VFS_FUNC_ARGS_SETDIROWNER)
743 /* ---------------- */
744 static int RF_renamefile_osx(VFS_FUNC_ARGS_RENAMEFILE)
746 char adsrc[ MAXPATHLEN + 1];
749 strcpy( adsrc, vol->vfs->ad_path( src, 0 ));
751 if (unix_rename( adsrc, vol->vfs->ad_path( dst, 0 )) < 0) {
755 if (errno == ENOENT && stat(adsrc, &st)) /* source has no ressource fork, */
763 /********************************************************************************************
765 ********************************************************************************************/
768 * Up until we really start stacking many VFS modules on top of one another or use
769 * dynamic module loading like we do for UAMs, up until then we just stack VFS modules
770 * via an fixed size array.
771 * All VFS funcs must return AFP_ERR codes. When a func in the chain returns an error
772 * this error code will be returned to the caller, BUT the chain in followed and all
773 * following funcs are called in order to give them a chance.
777 * Currently the maximum will be:
778 * main adouble module + EA module + ACL module + NULL = 4.
779 * NULL is an end of array marker.
781 static struct vfs_ops *vfs[4] = { NULL };
784 * Define most VFS funcs with macros as they all do the same.
785 * Only "ad_path" and "validupath" will NOT do stacking and only
786 * call the func from the first module.
788 #define VFS_MFUNC(name, args, vars) \
789 static int vfs_ ## name(args) \
791 int i = 0, ret = AFP_OK, err; \
793 if (vfs[i]->vfs_ ## name) { \
794 err = vfs[i]->vfs_ ## name (vars); \
795 if ((ret == AFP_OK) && (err != AFP_OK)) \
803 VFS_MFUNC(chown, VFS_FUNC_ARGS_CHOWN, VFS_FUNC_VARS_CHOWN)
804 VFS_MFUNC(renamedir, VFS_FUNC_ARGS_RENAMEDIR, VFS_FUNC_VARS_RENAMEDIR)
805 VFS_MFUNC(deletecurdir, VFS_FUNC_ARGS_DELETECURDIR, VFS_FUNC_VARS_DELETECURDIR)
806 VFS_MFUNC(setfilmode, VFS_FUNC_ARGS_SETFILEMODE, VFS_FUNC_VARS_SETFILEMODE)
807 VFS_MFUNC(setdirmode, VFS_FUNC_ARGS_SETDIRMODE, VFS_FUNC_VARS_SETDIRMODE)
808 VFS_MFUNC(setdirunixmode, VFS_FUNC_ARGS_SETDIRUNIXMODE, VFS_FUNC_VARS_SETDIRUNIXMODE)
809 VFS_MFUNC(setdirowner, VFS_FUNC_ARGS_SETDIROWNER, VFS_FUNC_VARS_SETDIROWNER)
810 VFS_MFUNC(deletefile, VFS_FUNC_ARGS_DELETEFILE, VFS_FUNC_VARS_DELETEFILE)
811 VFS_MFUNC(renamefile, VFS_FUNC_ARGS_RENAMEFILE, VFS_FUNC_VARS_RENAMEFILE)
812 VFS_MFUNC(acl, VFS_FUNC_ARGS_ACL, VFS_FUNC_VARS_ACL)
813 VFS_MFUNC(remove_acl, VFS_FUNC_ARGS_REMOVE_ACL, VFS_FUNC_VARS_REMOVE_ACL)
814 VFS_MFUNC(ea_getsize, VFS_FUNC_ARGS_EA_GETSIZE, VFS_FUNC_VARS_EA_GETSIZE)
815 VFS_MFUNC(ea_getcontent, VFS_FUNC_ARGS_EA_GETCONTENT, VFS_FUNC_VARS_EA_GETCONTENT)
816 VFS_MFUNC(ea_list, VFS_FUNC_ARGS_EA_LIST, VFS_FUNC_VARS_EA_LIST)
817 VFS_MFUNC(ea_set, VFS_FUNC_ARGS_EA_SET, VFS_FUNC_VARS_EA_SET)
818 VFS_MFUNC(ea_remove, VFS_FUNC_ARGS_EA_REMOVE, VFS_FUNC_VARS_EA_REMOVE)
820 static char *vfs_path(const char *path, int flags)
822 return vfs[0]->ad_path(path, flags);
825 static int vfs_validupath(VFS_FUNC_ARGS_VALIDUPATH)
827 return vfs[0]->vfs_validupath(VFS_FUNC_VARS_VALIDUPATH);
831 * These function pointers get called from the lib users via vol->vfs->func.
832 * These funcs are defined via the macros above.
834 struct vfs_ops vfs_master_funcs = {
856 * Primary adouble modules: default, osx, sfm
859 static struct vfs_ops netatalk_adouble = {
860 /* ad_path: */ ad_path,
861 /* validupath: */ validupath_adouble,
862 /* rf_chown: */ RF_chown_adouble,
863 /* rf_renamedir: */ RF_renamedir_adouble,
864 /* rf_deletecurdir: */ RF_deletecurdir_adouble,
865 /* rf_setfilmode: */ RF_setfilmode_adouble,
866 /* rf_setdirmode: */ RF_setdirmode_adouble,
867 /* rf_setdirunixmode: */ RF_setdirunixmode_adouble,
868 /* rf_setdirowner: */ RF_setdirowner_adouble,
869 /* rf_deletefile: */ RF_deletefile_adouble,
870 /* rf_renamefile: */ RF_renamefile_adouble,
873 static struct vfs_ops netatalk_adouble_osx = {
874 /* ad_path: */ ad_path_osx,
875 /* validupath: */ validupath_osx,
876 /* rf_chown: */ RF_chown_adouble,
877 /* rf_renamedir: */ RF_renamedir_osx,
878 /* rf_deletecurdir: */ RF_deletecurdir_osx,
879 /* rf_setfilmode: */ RF_setfilmode_adouble,
880 /* rf_setdirmode: */ RF_setdirmode_osx,
881 /* rf_setdirunixmode:*/ RF_setdirunixmode_osx,
882 /* rf_setdirowner: */ RF_setdirowner_osx,
883 /* rf_deletefile: */ RF_deletefile_adouble,
884 /* rf_renamefile: */ RF_renamefile_osx,
887 /* samba sfm format. ad_path shouldn't be set her */
888 static struct vfs_ops netatalk_adouble_sfm = {
889 /* ad_path: */ ad_path_sfm,
890 /* validupath: */ validupath_adouble,
891 /* rf_chown: */ RF_chown_ads,
892 /* rf_renamedir: */ RF_renamedir_adouble,
893 /* rf_deletecurdir: */ RF_deletecurdir_ads,
894 /* rf_setfilmode: */ RF_setfilmode_ads,
895 /* rf_setdirmode: */ RF_setdirmode_ads,
896 /* rf_setdirunixmode:*/ RF_setdirunixmode_ads,
897 /* rf_setdirowner: */ RF_setdirowner_ads,
898 /* rf_deletefile: */ RF_deletefile_ads,
899 /* rf_renamefile: */ RF_renamefile_ads,
903 * Secondary vfs modules for Extended Attributes
906 struct vfs_ops netatalk_ea_adouble = {
908 /* validupath: */ NULL,
909 /* rf_chown: */ NULL,
910 /* rf_renamedir: */ NULL,
911 /* rf_deletecurdir: */ NULL,
912 /* rf_setfilmode: */ NULL,
913 /* rf_setdirmode: */ NULL,
914 /* rf_setdirunixmode: */ NULL,
915 /* rf_setdirowner: */ NULL,
916 /* rf_deletefile: */ ea_deletefile,
917 /* rf_renamefile: */ ea_renamefile,
919 /* rf_remove_acl */ NULL,
920 /* ea_getsize */ get_easize,
921 /* ea_getcontent */ get_eacontent,
922 /* ea_list */ list_eas,
924 /* ea_remove */ remove_ea
927 #ifdef HAVE_SOLARIS_EAS
928 struct vfs_ops netatalk_ea_solaris = {
930 /* validupath: */ NULL,
931 /* rf_chown: */ NULL,
932 /* rf_renamedir: */ NULL,
933 /* rf_deletecurdir: */ NULL,
934 /* rf_setfilmode: */ NULL,
935 /* rf_setdirmode: */ NULL,
936 /* rf_setdirunixmode: */ NULL,
937 /* rf_setdirowner: */ NULL,
938 /* rf_deletefile: */ NULL,
939 /* rf_renamefile: */ NULL,
941 /* rf_remove_acl */ NULL,
942 /* ea_getsize */ sol_get_easize,
943 /* ea_getcontent */ sol_get_eacontent,
944 /* ea_list */ sol_list_eas,
945 /* ea_set */ sol_set_ea,
946 /* ea_remove */ sol_remove_ea
951 * Tertiary attributes for ACLs
954 #ifdef HAVE_NFSv4_ACLS
955 struct vfs_ops netatalk_solaris_acl_adouble = {
957 /* validupath: */ NULL,
958 /* rf_chown: */ NULL,
959 /* rf_renamedir: */ NULL,
960 /* rf_deletecurdir: */ NULL,
961 /* rf_setfilmode: */ NULL,
962 /* rf_setdirmode: */ NULL,
963 /* rf_setdirunixmode: */ NULL,
964 /* rf_setdirowner: */ NULL,
965 /* rf_deletefile: */ NULL,
966 /* rf_renamefile: */ NULL,
967 /* rf_acl: */ RF_solaris_acl,
968 /* rf_remove_acl */ RF_remove_acl
972 /* ---------------- */
973 void initvol_vfs(struct vol *vol)
975 vol->vfs = &vfs_master_funcs;
977 /* Default adouble stuff */
978 if (vol->v_adouble == AD_VERSION2_OSX) {
979 vfs[0] = &netatalk_adouble_osx;
981 else if (vol->v_adouble == AD_VERSION1_SFM) {
982 vfs[0] = &netatalk_adouble_sfm;
985 vfs[0] = &netatalk_adouble;
988 /* Extended Attributes */
989 if (vol->v_vfs_ea == AFPVOL_EA_SOLARIS) {
991 #ifdef HAVE_SOLARIS_EAS
992 LOG(log_debug, logtype_afpd, "initvol_vfs: Enabling EA support with Solaris native EAs.");
993 vfs[1] = &netatalk_ea_solaris;
995 LOG(log_error, logtype_afpd, "initvol_vfs: Can't enable Solaris EA support.");
1000 /* default: AFPVOL_EA_AD */
1001 LOG(log_debug, logtype_afpd, "initvol_vfs: Enabling EA support with adouble files.");
1002 vfs[1] = &netatalk_ea_adouble;
1006 #ifdef HAVE_NFSv4_ACLS
1007 vfs[2] = &netatalk_solaris_acl_adouble;