From 0af785317766d0faaff34c6b83d0435951ff3788 Mon Sep 17 00:00:00 2001 From: franklahm Date: Fri, 11 Dec 2009 13:26:44 +0000 Subject: [PATCH] New default for ea volume option is "sys". Fallback to "ad" if volume doesn't support EAs. Checked at volume mount time. --- etc/afpd/volume.c | 31 ++++++++++++++++++++++------ libatalk/vfs/vfs.c | 1 - man/man5/AppleVolumes.default.5.tmpl | 12 ++++------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/etc/afpd/volume.c b/etc/afpd/volume.c index 32159a9d..6a7c982f 100644 --- a/etc/afpd/volume.c +++ b/etc/afpd/volume.c @@ -1,5 +1,5 @@ /* - * $Id: volume.c,v 1.109 2009-12-11 10:14:02 franklahm Exp $ + * $Id: volume.c,v 1.110 2009-12-11 13:26:44 franklahm Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -45,6 +45,7 @@ char *strchr (), *strrchr (); #include #include #include +#include #ifdef CNID_DB #include #endif /* CNID_DB*/ @@ -513,10 +514,8 @@ static void volset(struct vol_option *options, struct vol_option *save, setoption(options, save, VOLOPT_DENIED_HOSTS, val); } else if (optionok(tmp, "ea:", val)) { - if (strcasecmp(val + 1, "ad") == 0) /* the default anyway */ + if (strcasecmp(val + 1, "ad") == 0) options[VOLOPT_EA_VFS].i_value = AFPVOL_EA_AD; - else if (strcasecmp(val + 1, "sys") == 0) - options[VOLOPT_EA_VFS].i_value = AFPVOL_EA_SYS; } else { /* ignore unknown options */ @@ -671,7 +670,7 @@ static int creatvol(AFPObj *obj, struct passwd *pwd, /* os X start at 1 and use network order ie. 1 2 3 */ volume->v_vid = ++lastvid; volume->v_vid = htons(volume->v_vid); - volume->v_vfs_ea = AFPVOL_EA_AD; + volume->v_vfs_ea = AFPVOL_EA_SYS; /* handle options */ if (options) { @@ -681,7 +680,7 @@ static int creatvol(AFPObj *obj, struct passwd *pwd, /* shift in some flags */ volume->v_flags = options[VOLOPT_FLAGS].i_value; - if (options[VOLOPT_EA_VFS].i_value != AFPVOL_EA_AD) + if (options[VOLOPT_EA_VFS].i_value) volume->v_vfs_ea = options[VOLOPT_EA_VFS].i_value; volume->v_ad_options = 0; @@ -1827,6 +1826,25 @@ static int volume_openDB(struct vol *volume) return (!volume->v_cdb)?-1:0; } +/* + Check if the underlying filesystem supports EAs for ea:sys volumes. + If not, switch to ea:ad. +*/ +static void check_ea_sys_support(struct vol *vol) +{ + char buf[ATTRNAMEBUFSIZ]; + + if (vol->v_vfs_ea == AFPVOL_EA_SYS) { + if ((sys_llistxattr(".AppleDesktop", buf, ATTRNAMEBUFSIZ)) == -1 +) { + LOG(log_warning, logtype_afpd, "Volume \"%s\" does not support Extended Attributes. Using ad format instead.", + vol->v_localname); + vol->v_vfs_ea = AFPVOL_EA_AD; + initvol_vfs(vol); + } + } +} + /* ------------------------- * we are the user here */ @@ -1997,6 +2015,7 @@ int afp_openvol(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t if (!(volume->v_flags & AFPVOL_RO)) { handle_special_folders( volume ); + check_ea_sys_support(volume); savevolinfo(volume, Cnid_srv, Cnid_port); } diff --git a/libatalk/vfs/vfs.c b/libatalk/vfs/vfs.c index 09684192..ebdf75e2 100644 --- a/libatalk/vfs/vfs.c +++ b/libatalk/vfs/vfs.c @@ -993,7 +993,6 @@ void initvol_vfs(struct vol *vol) LOG(log_debug, logtype_afpd, "initvol_vfs: Enabling EA support with native EAs."); vol->vfs_modules[1] = &netatalk_ea_sys; } else { - /* default: AFPVOL_EA_AD */ LOG(log_debug, logtype_afpd, "initvol_vfs: Enabling EA support with adouble files."); vol->vfs_modules[1] = &netatalk_ea_adouble; } diff --git a/man/man5/AppleVolumes.default.5.tmpl b/man/man5/AppleVolumes.default.5.tmpl index c24c0aa9..104b3f3e 100644 --- a/man/man5/AppleVolumes.default.5.tmpl +++ b/man/man5/AppleVolumes.default.5.tmpl @@ -110,17 +110,13 @@ dbpath:\fI[path]\fR Sets the database information to be stored in path\&. You have to specifiy a writable location, even if the volume is read only\&. .RE .PP -ea:\fI[ad|solaris]\fR +ea:\fI[sys|ad]\fR .RS 4 Specify the format of the metadata files which are used for saving Extended Attributes\&. +\fBsys\fR +is the default and stores the EAs in native filesystem Extended Attributes\&. \fBad\fR -is the default and stores the EAs inside the -\&.AppleDouble -directories\&. -\fBsolaris\fR -uses native -\fI[Open]Solaris\fR -EAs if available\&. +uses ordinary files inside the \&.AppleDouble directories\&. .RE .PP maccharset:\fI[charset]\fR -- 2.39.2