struct adouble via ad_init. This eleminates the need to call vol_no_adouble(vol) every time
in ad_open in order to pass ADFLAGS_NOADOUBLE with adflags, instead inside ad_open the func checks
ad->ad_options.
Remove forced adouble file creation from ad_metadata, this broke the clean ad_* API semantics of
only creating files with O_CREATE. Instead do it explicitly in enumerate where the original force
adouble patch grew from.
adp = &ad;
}
- if ( ad_metadata( path->u_name, vol_noadouble(vol) | ((isdir)?ADFLAGS_DIR:0), adp) < 0 ) {
+ if ( ad_metadata( path->u_name, ((isdir) ? ADFLAGS_DIR : 0), adp) < 0 ) {
adp = NULL; /* FIXME without resource fork adl_lkup will be call again */
}
/*
- * $Id: desktop.c,v 1.47 2009-11-27 12:37:24 didg Exp $
+ * $Id: desktop.c,v 1.48 2010-01-05 12:06:33 franklahm Exp $
*
* See COPYRIGHT.
*
} else
adp = of->of_ad;
- if (ad_open_metadata( upath , vol_noadouble(vol) | ( (isadir) ? ADFLAGS_DIR :0),O_CREAT, adp) < 0 ) {
+ if (ad_open_metadata( upath , ( (isadir) ? ADFLAGS_DIR : 0), O_CREAT, adp) < 0 ) {
return( AFPERR_ACCESS );
}
} else
adp = of->of_ad;
- if ( ad_metadata( upath,vol_noadouble(vol) | ((isadir) ? ADFLAGS_DIR : 0), adp) < 0 ) {
+ if ( ad_metadata( upath, ((isadir) ? ADFLAGS_DIR : 0), adp) < 0 ) {
return( AFPERR_NOITEM );
}
/*
- * $Id: directory.c,v 1.121 2009-11-27 12:37:24 didg Exp $
+ * $Id: directory.c,v 1.122 2010-01-05 12:06:33 franklahm Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
(1 << DIRPBIT_FINFO)))) {
ad_init(&ad, vol->v_adouble, vol->v_ad_options);
- if ( !ad_metadata( upath, vol_noadouble(vol) | ADFLAGS_DIR, &ad) ) {
+ if ( !ad_metadata( upath, ADFLAGS_DIR, &ad) ) {
isad = 1;
}
}
}
ad_init(&ad, vol->v_adouble, vol->v_ad_options);
- if (ad_open_metadata( upath, vol_noadouble(vol)|ADFLAGS_DIR, O_CREAT, &ad) < 0) {
+ if (ad_open_metadata( upath, ADFLAGS_DIR, O_CREAT, &ad) < 0) {
/*
* Check to see what we're trying to set. If it's anything
* but ACCESS, UID, or GID, give an error. If it's any of those
ad_init(&ad, vol->v_adouble, vol->v_ad_options);
/* we never want to create a resource fork here, we are going to delete it */
- if ( ad_metadata( ".", ADFLAGS_NOADOUBLE | ADFLAGS_DIR, &ad) == 0 ) {
+ if ( ad_metadata( ".", ADFLAGS_DIR, &ad) == 0 ) {
ad_getattr(&ad, &ashort);
ad_close( &ad, ADFLAGS_HF );
/*
- $Id: extattrs.c,v 1.28 2009-11-27 12:37:24 didg Exp $
+ $Id: extattrs.c,v 1.29 2010-01-05 12:06:33 franklahm Exp $
Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
This program is free software; you can redistribute it and/or modify
}
adp = of_ad(vol, s_path, &ad);
- uname = s_path->u_name; /*
+ uname = s_path->u_name;
+ /*
We have to check the FinderInfo for the file, because if they aren't all 0
we must return the synthetic attribute "com.apple.FinderInfo".
Note: the client will never (never seen in traces) request that attribute
if (S_ISDIR(st->st_mode))
adflags = ADFLAGS_DIR;
- if ( ad_metadata( uname, vol_noadouble(vol) | adflags, adp) < 0 ) {
+ if ( ad_metadata( uname, adflags, adp) < 0 ) {
switch (errno) {
case ENOENT:
adp = NULL;
/*
- * $Id: file.c,v 1.126 2009-11-30 15:27:48 didg Exp $
+ * $Id: file.c,v 1.127 2010-01-05 12:06:33 franklahm Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
adp = of_ad(vol, path, &ad);
upath = path->u_name;
- if ( ad_metadata( upath, vol_noadouble(vol) | flags, adp) < 0 ) {
+ if ( ad_metadata( upath, flags, adp) < 0 ) {
switch (errno) {
case EACCES:
LOG(log_error, logtype_afpd, "getfilparams(%s): %s: check resource fork permission?",
openf = O_RDWR|O_CREAT|O_EXCL;
}
- if ( ad_open( upath, vol_noadouble(vol)|ADFLAGS_DF|ADFLAGS_HF|ADFLAGS_NOHF|ADFLAGS_CREATE,
+ if ( ad_open( upath, ADFLAGS_DF|ADFLAGS_HF|ADFLAGS_NOHF|ADFLAGS_CREATE,
openf, 0666, adp) < 0 ) {
switch ( errno ) {
case EROFS:
* moreover sometimes deletefile is called with a no existent file and
* ad_open would create a 0 byte resource fork
*/
- if ( ad_metadata( file , ADFLAGS_NOADOUBLE | ADFLAGS_OPENFORKS, &ad) == 0 ) {
+ if ( ad_metadata( file, ADFLAGS_OPENFORKS, &ad) == 0 ) {
ad_close( &ad, adflags );
if ((err = check_attrib(&ad))) {
return err;
/*
- * $Id: filedir.c,v 1.65 2009-11-27 12:37:24 didg Exp $
+ * $Id: filedir.c,v 1.66 2010-01-05 12:06:33 franklahm Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
* we are in the dest folder so we need to use p for ad_open
*/
- if (!ad_metadata(p, vol_noadouble(vol) | adflags, adp)) {
+ if (!ad_metadata(p, adflags, adp)) {
u_int16_t bshort;
ad_getattr(adp, &bshort);
/*
- * $Id: volume.c,v 1.112 2009-12-18 19:18:40 franklahm Exp $
+ * $Id: volume.c,v 1.113 2010-01-05 12:06:33 franklahm Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
volume->v_ad_options |= ADVOL_UNIXPRIV;
if ((volume->v_flags & AFPVOL_INV_DOTS))
volume->v_ad_options |= ADVOL_INVDOTS;
+ if ((volume->v_flags & AFPVOL_NOADOUBLE))
+ volume->v_ad_options |= ADVOL_NOADOUBLE;
if (options[VOLOPT_PASSWORD].c_value)
volume->v_password = strdup(options[VOLOPT_PASSWORD].c_value);
* .Parent file here if it doesn't exist. */
ad_init(&ad, vol->v_adouble, vol->v_ad_options);
- if ( ad_open_metadata( vol->v_path, vol_noadouble(vol) | ADFLAGS_DIR, O_CREAT, &ad) < 0 ) {
+ if ( ad_open_metadata( vol->v_path, ADFLAGS_DIR, O_CREAT, &ad) < 0 ) {
isad = 0;
vol->v_ctime = AD_DATE_FROM_UNIX(st->st_mtime);
if ( !ret && folder->hide) {
/* Hide it */
ad_init(&ad, vol->v_adouble, vol->v_ad_options);
- if (ad_open( p, vol_noadouble(vol) | ADFLAGS_HF|ADFLAGS_DIR,
- O_RDWR|O_CREAT, 0666, &ad) < 0) {
+ if (ad_open( p, ADFLAGS_HF|ADFLAGS_DIR, O_RDWR|O_CREAT, 0666, &ad) < 0) {
free (p);
free(q);
return (-1);
/*
- * $Id: adouble.h,v 1.51 2010-01-04 13:49:48 franklahm Exp $
+ * $Id: adouble.h,v 1.52 2010-01-05 12:06:34 franklahm Exp $
* Copyright (c) 1990,1991 Regents of The University of Michigan.
* All Rights Reserved.
*
#define ADFLAGS_DF (1<<0)
#define ADFLAGS_HF (1<<1)
#define ADFLAGS_DIR (1<<2)
+/*
#define ADFLAGS_NOADOUBLE (1<<3)
+*/
#define ADFLAGS_V1COMPAT (1<<4)
#define ADFLAGS_NOHF (1<<5) /* not an error if no ressource fork */
#define ADFLAGS_RDONLY (1<<6) /* don't try readwrite */
/* adouble v2 cnid cache */
#define ADVOL_NODEV (1 << 0)
#define ADVOL_CACHE (1 << 1)
-/* adouble unix priv */
-#define ADVOL_UNIXPRIV (1 << 2)
-/* dot files (.DS_Store) are invisible) */
-#define ADVOL_INVDOTS (1 << 3)
+#define ADVOL_UNIXPRIV (1 << 2) /* adouble unix priv */
+#define ADVOL_INVDOTS (1 << 3) /* dot files (.DS_Store) are invisible) */
+#define ADVOL_NOADOUBLE (1 << 4)
/* lock flags */
#define ADLOCK_CLR (0)
/*
- * $Id: volume.h,v 1.10 2010-01-05 10:37:29 franklahm Exp $
+ * $Id: volume.h,v 1.11 2010-01-05 12:06:34 franklahm Exp $
*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
#define VOLPBIT_XBTOTAL 10
#define VOLPBIT_BSIZE 11 /* block size */
-
-#define vol_noadouble(vol) (((vol)->v_flags & AFPVOL_NOADOUBLE) ? \
- ADFLAGS_NOADOUBLE : 0)
#ifdef AFP3x
#define utf8_encoding() (afp_version >= 30)
#else
#define utf8_encoding() (0)
#endif
+#define vol_noadouble(vol) (((vol)->v_flags & AFPVOL_NOADOUBLE) ? 1 : 0)
#define vol_nodev(vol) (((vol)->v_flags & AFPVOL_NODEV) ? 1 : 0)
#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)
/*
- * $Id: ad_open.c,v 1.61 2010-01-04 13:49:48 franklahm Exp $
+ * $Id: ad_open.c,v 1.62 2010-01-05 12:06:34 franklahm Exp $
*
* Copyright (c) 1999 Adrian Sun (asun@u.washington.edu)
* Copyright (c) 1990,1991 Regents of The University of Michigan.
* @returns 0 on success
*
* @note It's not possible to open the header file O_RDONLY -- the read
- * will fail and return an error. this refcounts things now.
+ * will fail and return an error. this refcounts things now.\n
+ * metadata(ressource)-fork only gets created with O_CREAT.
*/
int ad_open( const char *path, int adflags, int oflags, int mode, struct adouble *ad)
{
admode = mode;
}
admode = ad_hf_mode(admode);
- if ( errno == ENOENT && !(adflags & ADFLAGS_NOADOUBLE) && ad->ad_flags != AD_VERSION2_OSX) {
+ if ( errno == ENOENT && !(ad->ad_options & ADVOL_NOADOUBLE) && ad->ad_flags != AD_VERSION2_OSX) {
if (ad->ad_ops->ad_mkrf( ad_p) < 0) {
return ad_error(ad, adflags);
}
}
/* -----------------------------------
- * return only metadata but try very hard
+ * return only metadata but try very hard ie at first try as user, then try as root
*/
int ad_metadata(const char *name, int flags, struct adouble *adp)
{
uid_t uid;
int ret, err;
int dir = flags & ADFLAGS_DIR;
- int adouble = 0;
- if (!(flags & ADFLAGS_NOADOUBLE)) {
- adouble = O_CREAT;
- }
-
- /* Open with O_CREAT, thus enumarating a dir will create missing adouble files, see: */
- /* http://marc.info/?l=netatalk-devel&m=124039156832408&w=2 */
- if ((ret = ad_open(name, ADFLAGS_HF | dir, O_RDWR | adouble, 0666, adp)) < 0 && errno == EACCES) {
+ if ((ret = ad_open(name, ADFLAGS_HF | dir, O_RDWR, 0666, adp)) < 0 && errno == EACCES) {
uid = geteuid();
if (seteuid(0)) {
LOG(log_error, logtype_default, "ad_metadata(%s): seteuid failed %s", name, strerror(errno));