From f3f8400c3736a7c5c1e5b3a5d5d2e186c860ac85 Mon Sep 17 00:00:00 2001 From: didg Date: Tue, 19 Sep 2006 02:24:03 +0000 Subject: [PATCH] Make dot files visible by default with usedots, add invisibledots for the old behavior, for OS9 (OSX hide dot files on its own) --- config/AppleVolumes.default.tmpl | 4 ++++ etc/afpd/catsearch.c | 17 +++++++---------- etc/afpd/directory.c | 19 +++++++++++-------- etc/afpd/file.c | 10 +++++----- etc/afpd/file.h | 4 ++-- etc/afpd/volume.c | 6 +++++- etc/afpd/volume.h | 7 +++++-- include/atalk/adouble.h | 4 +++- libatalk/adouble/ad_open.c | 7 +++---- 9 files changed, 45 insertions(+), 33 deletions(-) diff --git a/config/AppleVolumes.default.tmpl b/config/AppleVolumes.default.tmpl index 9d8c098d..0980ef08 100644 --- a/config/AppleVolumes.default.tmpl +++ b/config/AppleVolumes.default.tmpl @@ -78,6 +78,10 @@ # usedots -> don't do :hex translation for dot files. note: when # this option gets set, certain file names # become illegal. these are .Parent and +# anything that starts with .Apple. +# invisibledots -> don't do :hex translation for dot files. note: when +# this option gets set, certain file names +# become illegal. these are .Parent and # anything that starts with .Apple. also, dot # files created on the unix side are marked # invisible. diff --git a/etc/afpd/catsearch.c b/etc/afpd/catsearch.c index 2c0a6a3d..d4476628 100644 --- a/etc/afpd/catsearch.c +++ b/etc/afpd/catsearch.c @@ -233,12 +233,13 @@ static struct finderinfo *unpack_buffer(struct finderinfo *finfo, char *buffer) /* -------------------- */ static struct finderinfo * -unpack_finderinfo(char *upath, struct adouble *adp, struct finderinfo *finfo) +unpack_finderinfo(struct vol *vol, struct path *path, struct adouble **adp, struct finderinfo *finfo) { packed_finder buf; void *ptr; - ptr = get_finderinfo(upath, adp, &buf); + *adp = adl_lkup(vol, path, *adp); + ptr = get_finderinfo(vol, path->u_name, *adp, &buf); return unpack_buffer(finfo, ptr); } @@ -372,8 +373,7 @@ static int crit_check(struct vol *vol, struct path *path) { /* Check file type ID */ if ((c1.rbitmap & (1<u_name, adp, &finderinfo); + finfo = unpack_finderinfo(vol, path, &adp, &finderinfo); if (finfo->f_type != c1.finfo.f_type) goto crit_check_ret; } @@ -381,8 +381,7 @@ static int crit_check(struct vol *vol, struct path *path) { /* Check creator ID */ if ((c1.rbitmap & (1<u_name, adp, &finderinfo); + finfo = unpack_finderinfo(vol, path, &adp, &finderinfo); } if (finfo->creator != c1.finfo.creator) goto crit_check_ret; @@ -391,8 +390,7 @@ static int crit_check(struct vol *vol, struct path *path) { /* Check finder info attributes */ if ((c1.rbitmap & (1<u_name, adp, &finderinfo); + finfo = unpack_finderinfo(vol, path, &adp, &finderinfo); } if ((finfo->attrs & c2.finfo.attrs) != c1.finfo.attrs) @@ -402,8 +400,7 @@ static int crit_check(struct vol *vol, struct path *path) { /* Check label */ if ((c1.rbitmap & (1<u_name, adp, &finderinfo); + finfo = unpack_finderinfo(vol, path, &adp, &finderinfo); } if ((finfo->label & c2.finfo.label) != c1.finfo.label) goto crit_check_ret; diff --git a/etc/afpd/directory.c b/etc/afpd/directory.c index af57b417..82539580 100644 --- a/etc/afpd/directory.c +++ b/etc/afpd/directory.c @@ -1,5 +1,5 @@ /* - * $Id: directory.c,v 1.71.2.4.2.15.2.8 2005-09-27 10:40:41 didg Exp $ + * $Id: directory.c,v 1.71.2.4.2.15.2.9 2006-09-19 02:24:04 didg Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -1290,6 +1290,12 @@ struct maccess ma; } +/* --------------------- */ +static int invisible_dots(const struct vol *vol, const char *name) +{ + return vol_inv_dots(vol) && *name == '.' && strcmp(name, ".") && strcmp(name, ".."); +} + /* ------------------------------ (".", curdir) (name, dir) with curdir:name == dir, from afp_enumerate @@ -1343,8 +1349,7 @@ int getdirparams(const struct vol *vol, case DIRPBIT_ATTR : if ( isad ) { ad_getattr(&ad, &ashort); - } else if (*dir->d_u_name == '.' && strcmp(dir->d_u_name, ".") - && strcmp(dir->d_u_name, "..")) { + } else if (invisible_dots(vol, dir->d_u_name)) { ashort = htons(ATTRBIT_INVISIBLE); } else ashort = 0; @@ -1387,12 +1392,10 @@ int getdirparams(const struct vol *vol, ashort = htons(FINDERINFO_CLOSEDVIEW); memcpy(data + FINDERINFO_FRVIEWOFF, &ashort, sizeof(ashort)); - /* dot files are by default invisible */ - if (*dir->d_u_name == '.' && strcmp(dir->d_u_name , ".") && - strcmp(dir->d_u_name , "..")) { + /* dot files are by default visible */ + if (invisible_dots(vol, dir->d_u_name)) { ashort = htons(FINDERINFO_INVISIBLE); - memcpy(data + FINDERINFO_FRFLAGOFF, - &ashort, sizeof(ashort)); + memcpy(data + FINDERINFO_FRFLAGOFF, &ashort, sizeof(ashort)); } } data += 32; diff --git a/etc/afpd/file.c b/etc/afpd/file.c index 83f6e49a..c7130b8d 100644 --- a/etc/afpd/file.c +++ b/etc/afpd/file.c @@ -1,5 +1,5 @@ /* - * $Id: file.c,v 1.92.2.2.2.31.2.17 2006-09-11 18:54:13 didg Exp $ + * $Id: file.c,v 1.92.2.2.2.31.2.18 2006-09-19 02:24:04 didg Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -89,7 +89,7 @@ static int default_type(void *finder) } /* FIXME path : unix or mac name ? (for now it's unix name ) */ -void *get_finderinfo(const char *upath, struct adouble *adp, void *data) +void *get_finderinfo(const struct vol *vol, const char *upath, struct adouble *adp, void *data) { struct extmap *em; void *ad_finder = NULL; @@ -107,7 +107,7 @@ void *get_finderinfo(const char *upath, struct adouble *adp, void *data) else { memcpy(data, ufinderi, ADEDLEN_FINDERI); chk_ext = 1; - if (*upath == '.') { /* make it invisible */ + if (vol_inv_dots(vol) && *upath == '.') { /* make it invisible */ u_int16_t ashort; ashort = htons(FINDERINFO_INVISIBLE); @@ -282,7 +282,7 @@ int getmetadata(struct vol *vol, case FILPBIT_ATTR : if ( adp ) { ad_getattr(adp, &ashort); - } else if (*upath == '.') { + } else if (vol_inv_dots(vol) && *upath == '.') { ashort = htons(ATTRBIT_INVISIBLE); } else ashort = 0; @@ -336,7 +336,7 @@ int getmetadata(struct vol *vol, break; case FILPBIT_FINFO : - get_finderinfo(upath, adp, (char *)data); + get_finderinfo(vol, upath, adp, (char *)data); data += ADEDLEN_FINDERI; break; diff --git a/etc/afpd/file.h b/etc/afpd/file.h index 68df03e1..80600998 100644 --- a/etc/afpd/file.h +++ b/etc/afpd/file.h @@ -1,5 +1,5 @@ /* - * $Id: file.h,v 1.16.2.2.2.3.2.3 2005-01-30 20:56:21 didg Exp $ + * $Id: file.h,v 1.16.2.2.2.3.2.4 2006-09-19 02:24:05 didg Exp $ * * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. @@ -133,7 +133,7 @@ extern int renamefile __P((const struct vol *, char *, char *, char *, struct extern int copyfile __P((const struct vol *, const struct vol *, char *, char *, char *, struct adouble *)); extern int deletefile __P((const struct vol *, char *, int)); -extern void *get_finderinfo __P((const char *, struct adouble *, void *)); +extern void *get_finderinfo __P((const struct vol *, const char *, struct adouble *, void *)); extern size_t mtoUTF8 __P((const struct vol *, const char *, size_t , char *, size_t )); extern int copy_path_name __P((const struct vol *, char *, char *i)); diff --git a/etc/afpd/volume.c b/etc/afpd/volume.c index c6547086..b5728628 100644 --- a/etc/afpd/volume.c +++ b/etc/afpd/volume.c @@ -1,5 +1,5 @@ /* - * $Id: volume.c,v 1.51.2.7.2.33.2.12 2006-09-11 07:47:14 didg Exp $ + * $Id: volume.c,v 1.51.2.7.2.33.2.13 2006-09-19 02:24:05 didg Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -452,6 +452,8 @@ static void volset(struct vol_option *options, struct vol_option *save, options[VOLOPT_FLAGS].i_value |= AFPVOL_NOHEX; else if (strcasecmp(p, "usedots") == 0) options[VOLOPT_FLAGS].i_value |= AFPVOL_USEDOTS; + else if (strcasecmp(p, "invisibledots") == 0) + options[VOLOPT_FLAGS].i_value |= AFPVOL_USEDOTS | AFPVOL_INV_DOTS; else if (strcasecmp(p, "limitsize") == 0) options[VOLOPT_FLAGS].i_value |= AFPVOL_LIMITSIZE; /* support for either "dropbox" or "dropkludge" */ @@ -642,6 +644,8 @@ static int creatvol(AFPObj *obj, struct passwd *pwd, volume->v_ad_options |= ADVOL_CACHE; if ((volume->v_flags & AFPVOL_UNIX_PRIV)) volume->v_ad_options |= ADVOL_UNIXPRIV; + if ((volume->v_flags & AFPVOL_INV_DOTS)) + volume->v_ad_options |= ADVOL_INVDOTS; if (options[VOLOPT_PASSWORD].c_value) volume->v_password = strdup(options[VOLOPT_PASSWORD].c_value); diff --git a/etc/afpd/volume.h b/etc/afpd/volume.h index 35dcab17..71400f85 100644 --- a/etc/afpd/volume.h +++ b/etc/afpd/volume.h @@ -1,5 +1,5 @@ /* - * $Id: volume.h,v 1.19.2.5.2.7.2.2 2005-06-02 12:49:41 didg Exp $ + * $Id: volume.h,v 1.19.2.5.2.7.2.3 2006-09-19 02:24:06 didg Exp $ * * Copyright (c) 1990,1994 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -88,8 +88,8 @@ typedef u_int64_t VolSpace; #endif /* NO_LARGE_VOL_SUPPORT */ #define AFPVOL_OPEN (1<<0) -#define AFPVOL_DT (1<<1) +/* flags for AFS and quota 0xxx0 */ #define AFPVOL_GVSMASK (7<<2) #define AFPVOL_NONE (0<<2) #define AFPVOL_AFSGVS (1<<2) @@ -117,6 +117,7 @@ this is going away. */ * NOTE symlink to a different device will return an ACCESS error */ #define AFPVOL_CACHE (1 << 19) /* Use adouble v2 CNID caching, default don't use it */ +#define AFPVOL_INV_DOTS (1 << 20) /* dots files are invisible */ /* FPGetSrvrParms options */ #define AFPSRVR_CONFIGINFO (1 << 0) @@ -178,6 +179,8 @@ int wincheck(const struct vol *vol, const char *path); #define vol_unix_priv(vol) (afp_version >= 30 && ((vol)->v_flags & AFPVOL_UNIX_PRIV)) +#define vol_inv_dots(vol) (((vol)->v_flags & AFPVOL_INV_DOTS) ? 1 : 0) + extern struct vol *getvolbyvid __P((const u_int16_t)); extern int ustatfs_getvolspace __P((const struct vol *, VolSpace *, VolSpace *, diff --git a/include/atalk/adouble.h b/include/atalk/adouble.h index 13451cf0..b4a3ec0c 100644 --- a/include/atalk/adouble.h +++ b/include/atalk/adouble.h @@ -1,5 +1,5 @@ /* - * $Id: adouble.h,v 1.21.6.20.2.5 2005-09-28 09:38:57 didg Exp $ + * $Id: adouble.h,v 1.21.6.20.2.6 2006-09-19 02:24:06 didg Exp $ * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. * @@ -277,6 +277,8 @@ struct adouble { #define ADVOL_CACHE (1 << 1) /* adouble unix priv */ #define ADVOL_UNIXPRIV (1 << 2) +/* dot files (.DS_Store) are invisible) */ +#define ADVOL_INVDOTS (1 << 3) /* lock flags */ #define ADLOCK_CLR (0) diff --git a/libatalk/adouble/ad_open.c b/libatalk/adouble/ad_open.c index 0e3b0751..20cfcbb3 100644 --- a/libatalk/adouble/ad_open.c +++ b/libatalk/adouble/ad_open.c @@ -1,5 +1,5 @@ /* - * $Id: ad_open.c,v 1.30.6.18.2.5 2005-05-26 11:49:56 didg Exp $ + * $Id: ad_open.c,v 1.30.6.18.2.6 2006-09-19 02:24:06 didg Exp $ * * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) * Copyright (c) 1990,1991 Regents of The University of Michigan. @@ -1194,12 +1194,11 @@ static int new_rfork(const char *path, struct adouble *ad, int adflags) } /* make things invisible */ - if ((*path == '.') && strcmp(path, ".") && strcmp(path, "..")) { + if ((ad->ad_options & ADVOL_INVDOTS) && (*path == '.') && strcmp(path, ".") && strcmp(path, "..")) { ashort = htons(ATTRBIT_INVISIBLE); ad_setattr(ad, ashort); ashort = htons(FINDERINFO_INVISIBLE); - memcpy(ad_entry(ad, ADEID_FINDERI) + FINDERINFO_FRFLAGOFF, - &ashort, sizeof(ashort)); + memcpy(ad_entry(ad, ADEID_FINDERI) + FINDERINFO_FRFLAGOFF, &ashort, sizeof(ashort)); } if (stat(path, &st) < 0) { -- 2.39.2