]> arthur.barton.de Git - netatalk.git/commitdiff
Rewrite ad_open arg order and style: require flags and mode to be specified for every...
authorFrank Lahm <franklahm@googlemail.com>
Fri, 7 Jan 2011 16:40:24 +0000 (17:40 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Fri, 7 Jan 2011 16:40:24 +0000 (17:40 +0100)
Cleanup.
Remove adv1tov2.

49 files changed:
bin/Makefile.am
bin/ad/ad.h
bin/ad/ad_cp.c
bin/ad/ad_mv.c
bin/adv1tov2/.gitignore [deleted file]
bin/adv1tov2/Makefile.am [deleted file]
bin/adv1tov2/adv1tov2.c [deleted file]
etc/afpd/afp_options.c
etc/afpd/desktop.c
etc/afpd/directory.c
etc/afpd/file.c
etc/afpd/fork.c
etc/afpd/status.c
etc/afpd/volume.c
etc/cnid_dbd/cmd_dbd_scanvol.c
etc/cnid_dbd/comm.c
etc/cnid_dbd/dbd_search.c
include/atalk/adouble.h
include/atalk/cnid.h
include/atalk/cnid_dbd_private.h
include/atalk/paths.h
include/atalk/uuid.h
include/atalk/volinfo.h
include/atalk/volume.h
libatalk/acl/cache.c
libatalk/acl/cache.h
libatalk/acl/uuid.c
libatalk/adouble/ad_open.c
libatalk/adouble/ad_read.c
libatalk/cnid/cdb/cnid_cdb.h
libatalk/cnid/cdb/cnid_cdb_add.c
libatalk/cnid/cdb/cnid_cdb_get.c
libatalk/cnid/cdb/cnid_cdb_lookup.c
libatalk/cnid/cdb/cnid_cdb_open.c
libatalk/cnid/cdb/cnid_cdb_rebuild_add.c
libatalk/cnid/cdb/cnid_cdb_update.c
libatalk/cnid/dbd/cnid_dbd.c
libatalk/cnid/dbd/cnid_dbd.h
libatalk/cnid/last/cnid_last.c
libatalk/cnid/last/cnid_last.h
libatalk/cnid/tdb/cnid_tdb.h
libatalk/cnid/tdb/cnid_tdb_add.c
libatalk/cnid/tdb/cnid_tdb_get.c
libatalk/cnid/tdb/cnid_tdb_lookup.c
libatalk/cnid/tdb/cnid_tdb_open.c
libatalk/cnid/tdb/cnid_tdb_update.c
libatalk/compat/Makefile.am
libatalk/vfs/ea_ad.c
libatalk/vfs/vfs.c

index 423e7e84621bca9bc9a667bc7e1046352c0c8418..a857cca3d3e312b490138c61d02099639d36bf7f 100644 (file)
@@ -1,6 +1,6 @@
 # Makefile.am for bin/
 
-SUBDIRS = ad adv1tov2 afppasswd cnid megatron uniconv misc
+SUBDIRS = ad afppasswd cnid megatron uniconv misc
 
 if USE_APPLETALK
 SUBDIRS += aecho getzones nbp pap psorder
index 1b484e671d35cc1f650e6917f5e27d485d4fb50e..9f8fd4b5ae0dcb3692751d6d480cf71ca0fc17a0 100644 (file)
@@ -59,6 +59,7 @@ extern int ad_ls(int argc, char **argv);
 extern int ad_cp(int argc, char **argv);
 extern int ad_rm(int argc, char **argv);
 extern int ad_mv(int argc, char **argv);
+extern int ad_find(int argc, char **argv);
 
 /* ad_util.c */
 extern int openvol(const char *path, afpvol_t *vol);
index 97b30610080ac111b85ab9a5b4139ac1069fed85..0ee0f405947717ff9e801c53d02310d5e72746d7 100644 (file)
@@ -540,7 +540,7 @@ static int copy(const char *path,
                 break;
             }
             ad_init(&ad, dvolume.volinfo.v_adouble, dvolume.volinfo.v_ad_options);
-            if (ad_open_metadata(to.p_path, ADFLAGS_DIR, O_RDWR | O_CREAT, &ad) != 0) {
+            if (ad_open(&ad, to.p_path, ADFLAGS_HF | ADFLAGS_DIR, O_RDWR | O_CREAT, 0666) != 0) {
                 ERROR("Error opening adouble for: %s", to.p_path);
             }
             ad_setid( &ad, st.st_dev, st.st_ino, did, pdid, dvolume.db_stamp);
@@ -607,7 +607,7 @@ static int copy(const char *path,
                 break;
             }
             ad_init(&ad, dvolume.volinfo.v_adouble, dvolume.volinfo.v_ad_options);
-            if (ad_open_metadata(to.p_path, 0, O_RDWR | O_CREAT, &ad) != 0) {
+            if (ad_open(&ad, to.p_path, ADFLAGS_HF, O_RDWR | O_CREAT) != 0) {
                 ERROR("Error opening adouble for: %s", to.p_path);
             }
             ad_setid( &ad, st.st_dev, st.st_ino, cnid, did, dvolume.db_stamp);
index 342f22211d04e662ef9022601ef6df101a3bf764..0355364398e81183e566f040ee1a53e0d16d7265 100644 (file)
@@ -377,7 +377,7 @@ static int do_move(const char *from, const char *to)
 
         struct adouble ad;
         ad_init(&ad, dvolume.volinfo.v_adouble, dvolume.volinfo.v_ad_options);
-        if (ad_open_metadata(to, S_ISDIR(sb.st_mode) ? ADFLAGS_DIR : 0, O_RDWR, &ad) != 0) {
+        if (ad_open(&ad, to, S_ISDIR(sb.st_mode) ? (ADFLAGS_DIR | ADFLAGS_HF) : ADFLAGS_HF, O_RDWR) != 0) {
             SLOG("Error opening adouble for: %s", to);
             return 1;
         }
diff --git a/bin/adv1tov2/.gitignore b/bin/adv1tov2/.gitignore
deleted file mode 100644 (file)
index 4fada59..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-Makefile
-Makefile.in
-adv1tov2
-.deps
-.libs
-.gitignore
-adv1tov2.o
diff --git a/bin/adv1tov2/Makefile.am b/bin/adv1tov2/Makefile.am
deleted file mode 100644 (file)
index 1bfc6ca..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# Makefile.am for bin/adv1tov2/
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/sys
-
-bin_PROGRAMS = adv1tov2
-
-adv1tov2_SOURCES = adv1tov2.c
-adv1tov2_LDADD = $(top_builddir)/libatalk/libatalk.la
diff --git a/bin/adv1tov2/adv1tov2.c b/bin/adv1tov2/adv1tov2.c
deleted file mode 100644 (file)
index d4a66fb..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * $Id: adv1tov2.c,v 1.5 2009-10-14 01:38:28 didg Exp $
- * v1tov2: given a root directory, run down and convert all the
- * files/directories into appledouble v2.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#include <atalk/adouble.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <dirent.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif /* HAVE_FCNTL_H */
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <errno.h>
-#include <string.h>
-
-#include <atalk/util.h>
-
-#if AD_VERSION == AD_VERSION2
-#if 0
-/* translate characters */
-static void xlate(char *name, int flags) {
-  static const char hexdig[] = "0123456789abcdef";
-  char upath[MAXPATHLEN + 1];
-  char *m, *u;
-  int doit = 0;
-
-  m = name;
-  u = upath;
-  while (*m != '\0') {
-    if (isascii(*m) && !isprint(*m)) {
-      doit = 1;
-      *u++ = ':';
-      *u++ = hexdig[(*m & 0xf0) >> 4];
-      *u++ = hexdig[*m & 0x0f];
-    } else
-      *u++ = *m;
-    m++;
-  }
-  
-  if (doit) {
-    *u = '\0';
-    rename(name, upath);
-    if ((flags & ADFLAGS_DIR) == 0)
-      rename(ad_path(name, flags), ad_path(upath, flags)); /* rename rfork */
-  }
-}
-#endif
-
-/* ----------------------------- */
-char *fullpathname(const char *name)
-{
-    static char wd[ MAXPATHLEN + 1];
-
-    if ( getcwd( wd , MAXPATHLEN) ) {
-        strlcat(wd, "/", MAXPATHLEN);
-        strlcat(wd, name, MAXPATHLEN);
-    }
-    else {
-        strlcpy(wd, name, MAXPATHLEN);
-    }
-    return wd;
-}
-
-#define MAXDESCEND 0xFFFF
-/* recursively descend subdirectories. 
- * oh the stack space we use up! */
-static void descend(DIR *dp)
-{
-  DIR *dpnew;
-  struct dirent *de;
-  struct stat st;
-  struct adouble ad;
-  int flags;
-  static int count = 0;
-
-  ad_init(&ad, AD_VERSION2, 0);
-  if (count++ > MAXDESCEND) {
-    fprintf(stderr, "FAILURE: too many subdirectories! possible infinite recursion.");
-    return;
-  }
-    
-  putc('(', stderr);
-  for (de = readdir(dp); de; de = readdir(dp)) {
-    if (de->d_name[0] == '.') 
-      continue;
-
-    if (stat(de->d_name, &st) < 0) {
-      fprintf(stderr, "FAILURE: can't stat %s\n", de->d_name);
-      continue;
-    }
-
-    /* go down subdirectory */
-    flags = ADFLAGS_HF;
-    if (S_ISDIR(st.st_mode) && (dpnew = opendir(de->d_name))) {
-      chdir(de->d_name);
-      descend(dpnew);
-      closedir(dpnew);
-      chdir("..");
-      flags |= ADFLAGS_DIR;
-    }
-
-    if (ad_open(de->d_name, flags, O_RDWR, 0, &ad) < 0) {
-      if (errno != ENOENT)
-          fprintf(stderr, "\nFAILURE: can't convert %s, %s\n", fullpathname(de->d_name), strerror(errno));
-      continue;
-    }
-    ad_close(&ad, ADFLAGS_HF);
-    fputc('.', stderr);
-  }
-  putc(')', stderr);
-}
-
-
-int main(int argc, char **argv)
-{
-  DIR           *dp;
-  struct adouble ad;
-  ad_init(&ad, AD_VERSION2, 0);
-  if (argc != 2) {
-    fprintf(stderr, "%s <directory>\n", *argv);
-    return -1;
-  }
-    
-  /* convert main directory */
-  if (ad_open(argv[1], ADFLAGS_HF | ADFLAGS_DIR, O_RDWR, 0, 
-             &ad) < 0) {
-    fprintf(stderr, "FAILURE: can't convert %s\n", argv[1]);
-    return -1;
-  }
-
-  ad_close(&ad, ADFLAGS_HF);
-  if ((dp = opendir(argv[1])) == NULL) {
-    fprintf(stderr, "%s: unable to open %s\n", *argv, argv[1]);
-    return -1;
-  }
-
-  chdir(argv[1]);
-  descend(dp);
-  closedir(dp);
-  chdir("..");
-
-  putc('\n', stderr);
-  return 0;
-}
-
-#else /* AD_VERSION == AD_VERSION2 */
-int main(int argc, char **argv)
-{
-  fprintf(stderr, "%s not built for v2 AppleDouble files.\n", *argv);
-  return -1;
-}
-#endif /* AD_VERSION == AD_VERSION2 */
index 95c31c851c16a11dbbcbbb2bdb9036358c5ee4c5..87817abd06e0774588032144af378f9395c6c4ba 100644 (file)
@@ -406,8 +406,10 @@ int afp_options_parseline(char *buf, struct afp_options *options)
 
     if ((c = getoption(buf, "-port")))
         options->port = strdup(c);
+#ifndef NO_DDP
     if ((c = getoption(buf, "-ddpaddr")))
         atalk_aton(c, &options->ddpaddr);
+#endif
     if ((c = getoption(buf, "-signature")) && (opt = strdup(c)))
         options->signatureopt = opt;
 
index fde6fef14245a363c9341a88862200b560bc6d0d..369b4aaa4ab7b8bc5d0ae11c71a7a12513726799 100644 (file)
@@ -692,11 +692,10 @@ static int ad_addcomment(struct vol *vol, struct path *path, char *ibuf)
     } else
         adp = of->of_ad;
 
-    if (ad_open(upath,
+    if (ad_open(adp, upath,
                 ADFLAGS_HF | ( (isadir) ? ADFLAGS_DIR : 0),
                 O_CREAT | O_RDWR,
-                0666,
-                adp) < 0 ) {
+                0666) < 0 ) {
         return( AFPERR_ACCESS );
     }
 
@@ -847,7 +846,7 @@ static int ad_rmvcomment(struct vol *vol, struct path *path)
     } else
         adp = of->of_ad;
 
-    if ( ad_open_metadata( upath, (isadir) ? ADFLAGS_DIR : 0, 0, adp) < 0 ) {
+    if ( ad_open(adp, upath, ADFLAGS_HF | (isadir) ? ADFLAGS_DIR : 0, 0) < 0 ) {
         switch ( errno ) {
         case ENOENT :
             return( AFPERR_NOITEM );
index 5f683a48d29001b4d45f0ed12638ec846485a407..1bf8592276c1a970af5221418d9e5a072e22c4fb 100644 (file)
@@ -802,7 +802,7 @@ struct dir *dir_add(struct vol *vol, const struct dir *dir, struct path *path, i
 
     /* get_id needs adp for reading CNID from adouble file */
     ad_init(&ad, vol->v_adouble, vol->v_ad_options);
-    if ((ad_open_metadata(path->u_name, ADFLAGS_DIR, 0, &ad)) == 0) /* 1 */
+    if ((ad_open(&ad, path->u_name, ADFLAGS_HF | ADFLAGS_DIR)) == 0) /* 1 */
         adp = &ad;
 
     /* Get CNID */
@@ -1787,7 +1787,7 @@ int setdirparams(struct vol *vol, struct path *path, u_int16_t d_bitmap, char *b
     }
     ad_init(&ad, vol->v_adouble, vol->v_ad_options);
 
-    if (ad_open_metadata( upath, ADFLAGS_DIR, O_CREAT, &ad) < 0) {
+    if (ad_open(&ad, upath, ADFLAGS_HF | ADFLAGS_DIR, O_CREAT, 0777) != 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
@@ -2140,7 +2140,7 @@ int afp_createdir(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_
     }
 
     ad_init(&ad, vol->v_adouble, vol->v_ad_options);
-    if (ad_open_metadata( ".", ADFLAGS_DIR, O_CREAT, &ad ) < 0)  {
+    if (ad_open(&ad, ".", ADFLAGS_HF | ADFLAGS_DIR, O_CREAT, 0777) < 0)  {
         if (vol_noadouble(vol))
             goto createdir_done;
         return( AFPERR_ACCESS );
@@ -2206,7 +2206,7 @@ int renamedir(const struct vol *vol,
 
     ad_init(&ad, vol->v_adouble, vol->v_ad_options);
 
-    if (!ad_open_metadata( dst, ADFLAGS_DIR, 0, &ad)) {
+    if (ad_open(&ad, dst, ADFLAGS_HF | ADFLAGS_DIR) == 0) {
         ad_setname(&ad, newname);
         ad_flush( &ad);
         ad_close_metadata( &ad);
index bef386b77a2a258eb91e4a6cd2be10ba45394b4f..dc01ee60ed0c1a7b626c87f551bce40c9fe08903 100644 (file)
@@ -702,8 +702,8 @@ int afp_createfile(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_,
           because open syscall is not called */
         openf = O_RDWR|O_CREAT|O_EXCL;
 
-    if ( ad_open( upath, ADFLAGS_DF|ADFLAGS_HF|ADFLAGS_NOHF,
-                  openf, 0666, &ad) < 0 ) {
+    if ( ad_open(&ad, upath, ADFLAGS_DF | ADFLAGS_HF | ADFLAGS_NOHF,
+                 openf, 0666, openf, 0666) < 0 ) {
         switch ( errno ) {
         case EROFS:
             return AFPERR_VLOCK;
@@ -962,7 +962,7 @@ int setfilparams(struct vol *vol,
 
     /* second try with adouble open 
     */
-    if ( ad_open_metadata( upath, 0, O_CREAT, adp) < 0) {
+    if ( ad_open(adp, upath, ADFLAGS_HF, O_RDWR | O_CREAT, 0666) < 0) {
         LOG(log_debug, logtype_afpd, "setfilparams: ad_open_metadata error");
         /*
          * For some things, we don't need an adouble header:
@@ -1141,7 +1141,7 @@ int renamefile(const struct vol *vol, int sdir_fd, char *src, char *dst, char *n
 
     /* don't care if we can't open the newly renamed ressource fork
      */
-    if (!ad_open( dst, ADFLAGS_HF, O_RDWR, 0666, adp)) {
+    if (ad_open(adp, dst, ADFLAGS_HF, O_RDWR) == 0) {
         ad_setname(adp, newname);
         ad_flush( adp );
         ad_close( adp, ADFLAGS_HF );
@@ -1269,7 +1269,7 @@ int afp_copyfile(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, si
 
     adp = of_ad(s_vol, s_path, &ad);
 
-    if (ad_open(s_path->u_name , ADFLAGS_DF |ADFLAGS_HF | ADFLAGS_NOHF, O_RDONLY, 0, adp) < 0) {
+    if (ad_open(adp, s_path->u_name, ADFLAGS_DF | ADFLAGS_HF | ADFLAGS_NOHF, O_RDONLY, O_RDONLY) < 0) {
         return AFPERR_DENYCONF;
     }
     denyreadset = (getforkmode(adp, ADEID_DFORK, AD_FILELOCK_DENY_RD) != 0 || 
@@ -1481,7 +1481,7 @@ int copyfile(const struct vol *s_vol,
         adflags |= ADFLAGS_HF;
     }
 
-    if (ad_openat(sfd, src, adflags | ADFLAGS_NOHF, O_RDONLY, 0, adp) < 0) {
+    if (ad_openat(adp, sfd, src, adflags | ADFLAGS_NOHF, O_RDONLY) < 0) {
         ret_err = errno;
         goto done;
     }
@@ -1499,7 +1499,7 @@ int copyfile(const struct vol *s_vol,
     }
 
     ad_init(&add, d_vol->v_adouble, d_vol->v_ad_options);
-    if (ad_open(dst , adflags, O_RDWR|O_CREAT|O_EXCL, st.st_mode, &add) < 0) {
+    if (ad_open(&add, dst, adflags, O_RDWR|O_CREAT|O_EXCL, st.st_mode, O_RDWR|O_CREAT|O_EXCL, st.st_mode) < 0) {
         ret_err = errno;
         ad_close( adp, adflags );
         if (EEXIST != ret_err) {
@@ -1625,7 +1625,7 @@ int deletefile(const struct vol *vol, int dirfd, char *file, int checkAttrib)
  
     /* try to open both forks at once */
     adflags = ADFLAGS_DF;
-    if ( ad_openat(dirfd, file, adflags |ADFLAGS_HF|ADFLAGS_NOHF, O_RDONLY, 0, &ad ) < 0 ) {
+    if ( ad_openat(&ad, dirfd, file, adflags |ADFLAGS_HF|ADFLAGS_NOHF, O_RDONLY) < 0 ) {
         switch (errno) {
         case ENOENT:
             err = AFPERR_NOOBJ;
@@ -2035,7 +2035,7 @@ static struct adouble *find_adouble(struct path *path, struct ofork **of, struct
         adp = (*of)->of_ad;
     }
     else {
-        ret = ad_open( path->u_name, ADFLAGS_HF, O_RDONLY, 0, adp);
+        ret = ad_open(adp, path->u_name, ADFLAGS_HF, O_RDONLY);
         /* META and HF */
         if ( !ret && ad_reso_fileno(adp) != -1 && !(adp->ad_resource_fork.adf_flags & ( O_RDWR | O_WRONLY))) {
             /* from AFP spec.
index 6bd04672712c1bd7ca336834f18753ee2c1bb8c5..1ad11e4ef6a56a52cdbca89bd9076a89054ba227 100644 (file)
@@ -354,7 +354,7 @@ int afp_openfork(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, si
     ret = AFPERR_NOOBJ;
     if (access & OPENACC_WR) {
         /* try opening in read-write mode */
-        if (ad_open(upath, adflags, O_RDWR, 0, ofork->of_ad) < 0) {
+        if (ad_open(ofork->of_ad, upath, adflags, O_RDWR, O_RDWR) < 0) {
             switch ( errno ) {
             case EROFS:
                 ret = AFPERR_VLOCK;
@@ -364,14 +364,14 @@ int afp_openfork(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, si
             case ENOENT:
                 if (fork == OPENFORK_DATA) {
                     /* try to open only the data fork */
-                    if (ad_open(upath, ADFLAGS_DF, O_RDWR, 0, ofork->of_ad) < 0) {
+                    if (ad_open(ofork->of_ad, upath, ADFLAGS_DF, O_RDWR) < 0) {
                         goto openfork_err;
                     }
                     adflags = ADFLAGS_DF;
                 } else {
                     /* here's the deal. we only try to create the resource
                      * fork if the user wants to open it for write acess. */
-                    if (ad_open(upath, adflags, O_RDWR | O_CREAT, 0666, ofork->of_ad) < 0)
+                    if (ad_open(ofork->of_ad, upath, adflags, O_RDWR | O_CREAT, 0666, O_RDWR | O_CREAT, 0666) < 0)
                         goto openfork_err;
                     ofork->of_flags |= AFPFORK_OPEN;
                 }
@@ -399,7 +399,7 @@ int afp_openfork(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, si
     } else {
         /* try opening in read-only mode */
         ret = AFPERR_NOOBJ;
-        if (ad_open(upath, adflags, O_RDONLY, 0, ofork->of_ad) < 0) {
+        if (ad_open(ofork->of_ad, upath, adflags, O_RDONLY, O_RDONLY) < 0) {
             switch ( errno ) {
             case EROFS:
                 ret = AFPERR_VLOCK;
@@ -409,7 +409,7 @@ int afp_openfork(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, si
             case ENOENT:
                 /* see if client asked for a read only data fork */
                 if (fork == OPENFORK_DATA) {
-                    if (ad_open(upath, ADFLAGS_DF, O_RDONLY, 0, ofork->of_ad) < 0) {
+                    if (ad_open(ofork->of_ad, upath, ADFLAGS_DF, O_RDONLY) < 0) {
                         goto openfork_err;
                     }
                     adflags = ADFLAGS_DF;
index 7468e4646be1b8c1cc8a96ee36e6ea2ee0868d9a..456b86f433aef3cedbfc977225ff0e5e5eb20c68 100644 (file)
@@ -35,6 +35,7 @@
 #include <atalk/asp.h>
 #include <atalk/nbp.h>
 #include <atalk/unicode.h>
+#include <atalk/util.h>
 
 #include "globals.h"  /* includes <netdb.h> */
 #include "status.h"
index 3775a816cd8ab79906aee3898c5c382203179230..d5c0fba84b6cdd426f11458571509ed813f83162 100644 (file)
@@ -1487,7 +1487,7 @@ static int getvolparams( u_int16_t bitmap, struct vol *vol, struct stat *st, cha
      * .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, ADFLAGS_DIR, O_CREAT, &ad) < 0 ) {
+    if (ad_open(&ad, vol->v_path, ADFLAGS_HF | ADFLAGS_DIR, O_RDWR | O_CREAT, 0666) != 0 ) {
         isad = 0;
         vol->v_ctime = AD_DATE_FROM_UNIX(st->st_mtime);
 
@@ -2497,8 +2497,7 @@ int afp_setvolparams(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf
         return AFPERR_BITMAP;
 
     ad_init(&ad, vol->v_adouble, vol->v_ad_options);
-    if ( ad_open( vol->v_path, ADFLAGS_HF|ADFLAGS_DIR, O_RDWR,
-                  0666, &ad) < 0 ) {
+    if ( ad_open(&ad,  vol->v_path, ADFLAGS_HF|ADFLAGS_DIR, O_RDWR) < 0 ) {
         if (errno == EROFS)
             return AFPERR_VLOCK;
 
@@ -2593,8 +2592,8 @@ static int create_special_folder (const struct vol *vol, const struct _special_f
     if ( !ret && folder->hide) {
         /* Hide it */
         ad_init(&ad, vol->v_adouble, vol->v_ad_options);
-        if (ad_open_metadata( p, ADFLAGS_DIR, O_CREAT, &ad) < 0) {
-            free (p);
+        if (ad_open(&ad, p, ADFLAGS_DIR, O_RDWR | O_CREAT, 0666) != 0) {
+            free(p);
             free(q);
             return (-1);
         }
index 240d4150d3312ef2dec686526e541f9b1a3ed0f3..7883268f2ced87ff12116cedf385d14b260cdf4c 100644 (file)
@@ -292,17 +292,16 @@ static const char *check_special_dirs(const char *name)
 */
 static int check_adfile(const char *fname, const struct stat *st)
 {
-    int ret, adflags;
+    int ret;
+    int adflags = ADFLAGS_HF;
     struct adouble ad;
-    char *adname;
+    const char *adname;
 
     if (dbd_flags & DBD_FLAGS_CLEANUP)
         return 0;
 
     if (S_ISREG(st->st_mode))
-        adflags = 0;
-    else
-        adflags = ADFLAGS_DIR;
+        adflags |= ADFLAGS_DIR;
 
     adname = myvolinfo->ad_path(fname, adflags);
 
@@ -322,7 +321,7 @@ static int check_adfile(const char *fname, const struct stat *st)
         /* Create ad file */
         ad_init(&ad, myvolinfo->v_adouble, myvolinfo->v_ad_options);
 
-        if ((ret = ad_open_metadata( fname, adflags, O_CREAT, &ad)) != 0) {
+        if ((ret = ad_open(&ad,  fname, adflags, O_CREAT | O_RDWR, 0666)) != 0) {
             dbd_log( LOGSTD, "Error creating AppleDouble file '%s/%s': %s",
                      cwdbuf, adname, strerror(errno));
 
@@ -341,7 +340,7 @@ static int check_adfile(const char *fname, const struct stat *st)
 #endif
     } else {
         ad_init(&ad, myvolinfo->v_adouble, myvolinfo->v_ad_options);
-        if (ad_open_metadata( fname, adflags, O_RDONLY, &ad) != 0) {
+        if (ad_open(&ad, fname, adflags, O_RDONLY) != 0) {
             dbd_log( LOGSTD, "Error opening AppleDouble file for '%s/%s'", cwdbuf, fname);
             return -1;
         }
@@ -494,7 +493,7 @@ static int check_addir(int volroot)
         /* Create ad dir and set name */
         ad_init(&ad, myvolinfo->v_adouble, myvolinfo->v_ad_options);
 
-        if (ad_open_metadata( ".", ADFLAGS_DIR, O_CREAT, &ad) != 0) {
+        if (ad_open(&ad, ".", ADFLAGS_HF | ADFLAGS_DIR, O_CREAT | O_RDWR, 0777) != 0) {
             dbd_log( LOGSTD, "Error creating AppleDouble dir in %s: %s", cwdbuf, strerror(errno));
             return -1;
         }
@@ -677,7 +676,7 @@ static cnid_t check_cnid(const char *name, cnid_t did, struct stat *st, int adfi
     ad_cnid = 0;
     if ( (myvolinfo->v_flags & AFPVOL_CACHE) && ADFILE_OK) {
         ad_init(&ad, myvolinfo->v_adouble, myvolinfo->v_ad_options);
-        if (ad_open_metadata( name, adflags, O_RDWR, &ad) != 0) {
+        if (ad_open(&ad, name, adflags, O_RDWR) != 0) {
             
             if (dbd_flags & DBD_FLAGS_CLEANUP)
                 return 0;
@@ -773,7 +772,7 @@ static cnid_t check_cnid(const char *name, cnid_t did, struct stat *st, int adfi
                     dbd_log(LOGSTD, "Writing CNID data for '%s/%s' to AppleDouble file",
                             cwdbuf, name, ntohl(db_cnid));
                     ad_init(&ad, myvolinfo->v_adouble, myvolinfo->v_ad_options);
-                    if (ad_open_metadata( name, adflags, O_RDWR, &ad) != 0) {
+                    if (ad_open(&ad, name, adflags, O_RDWR) != 0) {
                         dbd_log(LOGSTD, "Error opening AppleDouble file for '%s/%s': %s",
                                 cwdbuf, name, strerror(errno));
                         return 0;
@@ -811,7 +810,7 @@ static cnid_t check_cnid(const char *name, cnid_t did, struct stat *st, int adfi
                 dbd_log(LOGSTD, "Writing CNID data for '%s/%s' to AppleDouble file",
                         cwdbuf, name, ntohl(db_cnid));
                 ad_init(&ad, myvolinfo->v_adouble, myvolinfo->v_ad_options);
-                if (ad_open_metadata( name, adflags, O_RDWR, &ad) != 0) {
+                if (ad_open(&ad, name, adflags, O_RDWR) != 0) {
                     dbd_log(LOGSTD, "Error opening AppleDouble file for '%s/%s': %s",
                             cwdbuf, name, strerror(errno));
                     return 0;
index 89355d767b8c0072a01d42763a935850b03e5a9c..e92adf03535970953743642c82ce0af29360a96c 100644 (file)
@@ -254,7 +254,7 @@ int comm_rcv(struct cnid_dbd_rqst *rqst, time_t timeout, const sigset_t *sigmask
         return -1;
     }
 
-    nametmp = rqst->name;
+    nametmp = (char *)rqst->name;
     if ((b = readt(cur_fd, rqst, sizeof(struct cnid_dbd_rqst), 1, CNID_DBD_TIMEOUT))
         != sizeof(struct cnid_dbd_rqst)) {
         if (b)
@@ -264,7 +264,7 @@ int comm_rcv(struct cnid_dbd_rqst *rqst, time_t timeout, const sigset_t *sigmask
         return 0;
     }
     rqst->name = nametmp;
-    if (rqst->namelen && readt(cur_fd, rqst->name, rqst->namelen, 1, CNID_DBD_TIMEOUT)
+    if (rqst->namelen && readt(cur_fd, (char *)rqst->name, rqst->namelen, 1, CNID_DBD_TIMEOUT)
         != rqst->namelen) {
         LOG(log_error, logtype_cnid, "error reading message name: %s", strerror(errno));
         invalidate_fd(cur_fd);
@@ -272,7 +272,7 @@ int comm_rcv(struct cnid_dbd_rqst *rqst, time_t timeout, const sigset_t *sigmask
     }
     /* We set this to make life easier for logging. None of the other stuff
        needs zero terminated strings. */
-    rqst->name[rqst->namelen] = '\0';
+    ((char *)(rqst->name))[rqst->namelen] = '\0';
 
     LOG(log_maxdebug, logtype_cnid, "comm_rcv: got %u bytes", b + rqst->namelen);
 
index a2efc33cfa6520071f302ee1f4947c4793638bf0..d932732d6c51238146a319479af2c7a93514c6eb 100644 (file)
@@ -29,7 +29,7 @@ int dbd_search(DBD *dbd, struct cnid_dbd_rqst *rqst, struct cnid_dbd_rply *rply)
     rply->name = resbuf;
     rply->namelen = 0;
 
-    key.data = rqst->name;
+    key.data = (char *)rqst->name;
     key.size = rqst->namelen;
 
     if ((results = dbif_search(dbd, &key, resbuf)) < 0) {
index a0b423eecd7f2ca4690fad5ada560666dfe0bd15..d0813083dd8b359951edf0e8ac0fc253aa012d7a 100644 (file)
@@ -175,11 +175,11 @@ struct ad_fd {
 struct adouble;
 
 struct adouble_fops {
-    char *(*ad_path)(const char *, int);
-    int  (*ad_mkrf)(char *);
+    const char *(*ad_path)(const char *, int);
+    int  (*ad_mkrf)(const char *);
     int  (*ad_rebuild_header)(struct adouble *);
     int  (*ad_header_read)(struct adouble *, struct stat *);
-    int  (*ad_header_upgrade)(struct adouble *, char *);
+    int  (*ad_header_upgrade)(struct adouble *, const char *);
 };
 
 struct adouble {
@@ -210,8 +210,7 @@ struct adouble {
 #define ADFLAGS_HF        (1<<2)
 #define ADFLAGS_DIR       (1<<3)
 #define ADFLAGS_NOHF      (1<<4)  /* not an error if no ressource fork */
-#define ADFLAGS_RDONLY    (1<<5)  /* don't try readwrite */
-#define ADFLAGS_OPENFORKS (1<<6)  /* check for open fork in ad_metadata function */
+#define ADFLAGS_OPENFORKS (1<<5)  /* check for open fork in ad_metadata function */
 
 #define ADVOL_NODEV      (1 << 0)
 #define ADVOL_CACHE      (1 << 1)
@@ -368,20 +367,22 @@ extern const char *adflags2logstr(int adflags);
 extern int ad_setfuid     (const uid_t );
 extern uid_t ad_getfuid   (void );
 extern char *ad_dir       (const char *);
-extern char *ad_path      (const char *, int);
-extern char *ad_path_ea   (const char *, int);
+extern const char *ad_path      (const char *, int);
+extern const char *ad_path_ea   (const char *, int);
 extern int ad_mode        (const char *, int);
 extern int ad_mkdir       (const char *, int);
 extern void ad_init       (struct adouble *, int, int );
-extern int ad_open        (const char *, int, int, int, struct adouble *);
-extern int ad_openat      (int dirfd, const char *, int, int, int, struct adouble *);
+extern int ad_open        (struct adouble *ad, const char *path, int adflags, ...);
+extern int ad_openat      (struct adouble *, int dirfd, const char *path, int adflags, ...);
 extern int ad_refresh     (struct adouble *);
 extern int ad_stat        (const char *, struct stat *);
 extern int ad_metadata    (const char *, int, struct adouble *);
 extern int ad_metadataat  (int, const char *, int, struct adouble *);
 
+#if 0
 #define ad_open_metadata(name, flags, mode, adp)\
    ad_open(name, ADFLAGS_HF | (flags), O_RDWR |(mode), 0666, (adp))
+#endif
 
 #define ad_close_metadata(adp) ad_close( (adp), ADFLAGS_HF)
 
index d7df70e1d164ddd82c5c61f44f9e07996500607a..2c673fbcccf2c63e77d088982e1203ae3e13e90c 100644 (file)
@@ -53,21 +53,21 @@ struct _cnid_db {
     char *volpath;               /* Volume path this particular CNID db refers to. */
     void *_private;              /* back-end speficic data */
 
-    cnid_t (*cnid_add)         (struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
-                                char *name, const size_t, cnid_t hint);
+    cnid_t (*cnid_add)         (struct _cnid_db *cdb, const struct stat *st, cnid_t did,
+                                const char *name, size_t, cnid_t hint);
     int    (*cnid_delete)      (struct _cnid_db *cdb, cnid_t id);
-    cnid_t (*cnid_get)         (struct _cnid_db *cdb, const cnid_t did, char *name, const  size_t);
-    cnid_t (*cnid_lookup)      (struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
-                                char *name, const size_t);
+    cnid_t (*cnid_get)         (struct _cnid_db *cdb, cnid_t did, const char *name, size_t);
+    cnid_t (*cnid_lookup)      (struct _cnid_db *cdb, const struct stat *st, cnid_t did,
+                                const char *name, size_t);
     cnid_t (*cnid_nextid)      (struct _cnid_db *cdb);
     char * (*cnid_resolve)     (struct _cnid_db *cdb, cnid_t *id, void *buffer, size_t len);
-    int    (*cnid_update)      (struct _cnid_db *cdb, const cnid_t id, const struct stat *st,
-                                const cnid_t did, char *name, const size_t len);
+    int    (*cnid_update)      (struct _cnid_db *cdb, cnid_t id, const struct stat *st,
+                                cnid_t did, const char *name, size_t len);
     void   (*cnid_close)       (struct _cnid_db *cdb);
     int    (*cnid_getstamp)    (struct _cnid_db *cdb, void *buffer, const size_t len);
-    cnid_t (*cnid_rebuild_add) (struct _cnid_db *, const struct stat *, const cnid_t,
-                                char *, const size_t, cnid_t);
-    int    (*cnid_find)        (struct _cnid_db *cdb, char *name, size_t namelen,
+    cnid_t (*cnid_rebuild_add) (struct _cnid_db *, const struct stat *, cnid_t,
+                                const char *, size_t, cnid_t);
+    int    (*cnid_find)        (struct _cnid_db *cdb, const char *name, size_t namelen,
                                 void *buffer, size_t buflen);
 };
 typedef struct _cnid_db cnid_db;
index 36dee3d8264890402fa6cc7b0f7d233c08efa706..e1464125559be481d431168b3541f29394bc4200 100644 (file)
@@ -43,7 +43,7 @@ struct cnid_dbd_rqst {
     ino_t   ino;
     uint32_t type;
     cnid_t  did;
-    char    *name;
+    const char *name;
     size_t  namelen;
 };
 
index 2e75b461b53c0ab198b2a8f44aecf08057c32ea3..bd4bed72ae0add8502896f900619021fa45e22f3 100644 (file)
 /* lock file path. this should be re-organized a bit. */
 #if ! defined (_PATH_LOCKDIR)
 #  if defined (FHS_COMPATIBILITY) || defined (__NetBSD__)
-#    define _PATH_LOCKDIR      "/var/run/"
+#    define _PATH_LOCKDIR      /var/run/
 #  elif defined (BSD4_4)
 #    ifdef MACOSX_SERVER
-#      define _PATH_LOCKDIR    "/var/run/"
+#      define _PATH_LOCKDIR    /var/run/
 #    else
-#      define _PATH_LOCKDIR    "/var/spool/lock/"
+#      define _PATH_LOCKDIR    /var/spool/lock/
 #    endif
 #  elif defined (linux)
-#    define _PATH_LOCKDIR      "/var/lock/"
+#    define _PATH_LOCKDIR      /var/lock/
 #  else
-#    define _PATH_LOCKDIR      "/var/spool/locks/"
+#    define _PATH_LOCKDIR      /var/spool/locks/
 #  endif
 #endif
 
@@ -52,9 +52,9 @@
 #define _PATH_ATALKDEBUG       "/tmp/atalkd.debug"
 #define _PATH_ATALKDTMP                "atalkd.tmp"
 #if defined (FHS_COMPATIBILITY) || defined (__NetBSD__)
-#  define _PATH_ATALKDLOCK     ATALKPATHCAT(_PATH_LOCKDIR,"atalkd.pid")
+#  define _PATH_ATALKDLOCK     ATALKPATHCAT("_PATH_LOCKDIR","atalkd.pid")
 #else
-#  define _PATH_ATALKDLOCK     ATALKPATHCAT(_PATH_LOCKDIR,"atalkd")
+#  define _PATH_ATALKDLOCK     ATALKPATHCAT("_PATH_LOCKDIR","atalkd")
 #endif
 
 /*
@@ -62,9 +62,9 @@
  */
 #define _PATH_TMPPAGEORDER     "/tmp/psorderXXXXXX"
 #if defined (FHS_COMPATIBILITY) || defined (__NetBSD__)
-#  define _PATH_PAPDLOCK       ATALKPATHCAT(_PATH_LOCKDIR,"papd.pid")
+#  define _PATH_PAPDLOCK       ATALKPATHCAT("_PATH_LOCKDIR","papd.pid")
 #else
-#  define _PATH_PAPDLOCK       ATALKPATHCAT(_PATH_LOCKDIR,"papd")
+#  define _PATH_PAPDLOCK       ATALKPATHCAT("_PATH_LOCKDIR","papd")
 #endif
 
 /*
  */
 #define _PATH_AFPTKT           "/tmp/AFPtktXXXXXX"
 #if defined (FHS_COMPATIBILITY) || defined (__NetBSD__)
-#  define _PATH_AFPDLOCK       ATALKPATHCAT(_PATH_LOCKDIR,"afpd.pid")
+#  define _PATH_AFPDLOCK       ATALKPATHCAT("_PATH_LOCKDIR","afpd.pid")
 #else
-#  define _PATH_AFPDLOCK       ATALKPATHCAT(_PATH_LOCKDIR,"afpd")
+#  define _PATH_AFPDLOCK       ATALKPATHCAT("_PATH_LOCKDIR","afpd")
 #endif
 
 /*
  * cnid_metad paths
  */
 #if defined (FHS_COMPATIBILITY) || defined (__NetBSD__)
-#  define _PATH_CNID_METAD_LOCK        ATALKPATHCAT(_PATH_LOCKDIR,"cnid_metad.pid")
+#  define _PATH_CNID_METAD_LOCK        ATALKPATHCAT("_PATH_LOCKDIR","cnid_metad.pid")
 #else
-#  define _PATH_CNID_METAD_LOCK        ATALKPATHCAT(_PATH_LOCKDIR,"cnid_metad")
+#  define _PATH_CNID_METAD_LOCK        ATALKPATHCAT("_PATH_LOCKDIR","cnid_metad")
 #endif
 
 #endif /* atalk/paths.h */
index e3b2be118b19cb317694cad350e55c158809c8a5..ddc2e3bd5e8be73f989015a748a706d0f8eaf08e 100644 (file)
@@ -18,7 +18,7 @@
 #define UUID_BINSIZE 16
 #define UUID_STRINGSIZE 36
 
-typedef unsigned char *uuidp_t;
+typedef const unsigned char *uuidp_t;
 typedef unsigned char atalk_uuid_t[UUID_BINSIZE];
 
 typedef enum {UUID_USER = 1, UUID_GROUP, UUID_LOCAL} uuidtype_t;
@@ -40,9 +40,9 @@ extern char *ldap_uid_attr;
  * Interface
  ********************************************************/
 
-extern int getuuidfromname( const char *name, uuidtype_t type, uuidp_t uuid);
-extern int getnamefromuuid( const uuidp_t uuidp, char **name, uuidtype_t *type);
-extern const char *uuid_bin2string(unsigned char *uuid);
-extern void uuid_string2bin( const char *uuidstring, uuidp_t uuid);
+extern int getuuidfromname( const char *name, uuidtype_t type, unsigned char *uuid);
+extern int getnamefromuuid( uuidp_t uuidp, char **name, uuidtype_t *type);
+extern const char *uuid_bin2string(const unsigned char *uuid);
+extern void uuid_string2bin( const char *uuidstring, unsigned char *uuid);
 
 #endif /* AFP_UUID_H */
index 0f3a4024a6a36faedc4993783a731369e56237b3..1124b1391171689042544a6985fb872424521bde 100644 (file)
@@ -30,7 +30,7 @@ struct volinfo {
     int                 v_adouble;  /* default adouble format */
     int                 v_ad_options;
     int                 v_vfs_ea;
-    char                *(*ad_path)(const char *, int);
+    const char          *(*ad_path)(const char *, int);
     char                *v_dbd_host;
     char                *v_dbd_port;
 };
index 77966459b2618f69d3cff16faeae7680a00bb9e0..f213502d7111bb9dc97352d7b17f452c82ecafa0 100644 (file)
@@ -40,7 +40,7 @@ struct vol {
     char            *v_veto;
     int             v_adouble;    /* adouble format: v1, v2, sfm ... */
     int             v_ad_options; /* adouble option NODEV, NOCACHE, etc.. */
-    char            *(*ad_path)(const char *, int);
+    const char      *(*ad_path)(const char *, int);
     struct _cnid_db *v_cdb;
     char            v_stamp[ADEDLEN_PRIVSYN];
     VolSpace        v_limitsize; /* Size limit, if any, in MiB */
index 4c640ac25ff425a0e27724e804749fd93ceed916..60ae653a44b6cd1e832565d344f3c3455395dfc7 100644 (file)
@@ -30,7 +30,7 @@
 typedef struct cacheduser {
     unsigned long uid;      /* for future use */
     uuidtype_t type;
-    uuidp_t uuid;
+    unsigned char *uuid;
     char *name;
     time_t creationtime;
     struct cacheduser *prev;
@@ -117,7 +117,7 @@ static unsigned char hashuuid(uuidp_t uuid) {
 int add_cachebyname( const char *inname, const uuidp_t inuuid, const uuidtype_t type, const unsigned long uid _U_) {
     int ret = 0;
     char *name = NULL;
-    uuidp_t uuid;
+    unsigned char *uuid;
     cacheduser_t *cacheduser = NULL;
     cacheduser_t *entry;
     unsigned char hash;
@@ -193,7 +193,7 @@ cleanup:
 /* 
  * Caller provides buffer uuid for result
  */
-int search_cachebyname( const char *name, uuidtype_t type, uuidp_t uuid) {
+int search_cachebyname( const char *name, uuidtype_t type, unsigned char *uuid) {
     int ret;
     unsigned char hash;
     cacheduser_t *entry;
@@ -307,7 +307,7 @@ int search_cachebyuuid( uuidp_t uuidp, char **name, uuidtype_t *type) {
 int add_cachebyuuid( uuidp_t inuuid, const char *inname, uuidtype_t type, const unsigned long uid _U_) {
     int ret = 0;
     char *name = NULL;
-    uuidp_t uuid;
+    unsigned char *uuid;
     cacheduser_t *cacheduser = NULL;
     cacheduser_t *entry;
     unsigned char hash;
index 7db8ecdc92453930e721232fba2d82db32652d78..c83be1cd16dbd4a2152724c2343838b6a0f15d90 100644 (file)
@@ -38,7 +38,7 @@
  *   uuid: if found copies uuid into this buffer
  * returns 0 on success, !=0 if not found or on errors
  */
-extern int search_cachebyname( const char *name, uuidtype_t type, uuidp_t uuid);
+extern int search_cachebyname( const char *name, uuidtype_t type, unsigned char *uuid);
 
 /* 
  *   inname: name
index 8993acc21f61fa38bc0c58dda11bd720eebc0cf4..fb085b2379997283b9649ca3aed383d944192e3a 100644 (file)
@@ -43,7 +43,7 @@ char *uuidtype[] = {"NULL","USER", "GROUP", "LOCAL"};
  * convert ascii string that can include dashes to binary uuid.
  * caller must provide a buffer.
  */
-void uuid_string2bin( const char *uuidstring, uuidp_t uuid) {
+void uuid_string2bin( const char *uuidstring, unsigned char *uuid) {
     int nibble = 1;
     int i = 0;
     unsigned char c, val = 0;
@@ -77,7 +77,7 @@ void uuid_string2bin( const char *uuidstring, uuidp_t uuid) {
  * 
  * Returns pointer to static buffer.
  */
-const char *uuid_bin2string(unsigned char *uuid) {
+const char *uuid_bin2string(const unsigned char *uuid) {
     static char uuidstring[UUID_STRINGSIZE + 1];
 
     int i = 0;
@@ -113,7 +113,7 @@ static unsigned char local_user_uuid[] = {0xff, 0xff, 0xee, 0xee, 0xdd, 0xdd,
  *   uuid: pointer to uuid_t storage that the caller must provide
  * returns 0 on success !=0 on errror
  */  
-int getuuidfromname( const char *name, uuidtype_t type, uuidp_t uuid) {
+int getuuidfromname( const char *name, uuidtype_t type, unsigned char *uuid) {
     int ret = 0;
 #ifdef HAVE_LDAP
     char *uuid_string = NULL;
@@ -183,7 +183,7 @@ cleanup:
  *
  * Caller must free name appropiately.
  */
-int getnamefromuuid(const uuidp_t uuidp, char **name, uuidtype_t *type) {
+int getnamefromuuid(uuidp_t uuidp, char **name, uuidtype_t *type) {
     int ret;
 
     ret = search_cachebyuuid( uuidp, name, type);
index 074a193f2bc68566f0dfb1b082d095d975b05d1e..6bc1b3305b17060e610801326b1bf34f135884d7 100644 (file)
@@ -41,6 +41,7 @@
 #include <sys/param.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdarg.h>
 
 #include <atalk/logger.h>
 #include <atalk/adouble.h>
@@ -106,13 +107,13 @@ struct entry {
 static uid_t default_uid = -1;
 
 /* Forward declarations */
-static int ad_mkrf(char *path);
+static int ad_mkrf(const char *path);
 static int ad_header_read(struct adouble *ad, struct stat *hst);
-static int ad_header_upgrade(struct adouble *ad, char *name);
+static int ad_header_upgrade(struct adouble *ad, const char *name);
 
-static int ad_mkrf_ea(char *path);
+static int ad_mkrf_ea(const char *path);
 static int ad_header_read_ea(struct adouble *ad, struct stat *hst);
-static int ad_header_upgrade_ea(struct adouble *ad, char *name);
+static int ad_header_upgrade_ea(struct adouble *ad, const char *name);
 
 static struct adouble_fops ad_adouble = {
     &ad_path,
@@ -395,7 +396,7 @@ static int ad_header_read_ea(struct adouble *ad, struct stat *hst _U_)
     return 0;
 }
 
-static int ad_mkrf(char *path)
+static int ad_mkrf(const char *path)
 {
     char *slash;
     /*
@@ -413,7 +414,7 @@ static int ad_mkrf(char *path)
     return 0;
 }
 
-static int ad_mkrf_ea(char *path _U_)
+static int ad_mkrf_ea(const char *path _U_)
 {
     AFP_PANIC("ad_mkrf_ea: dont use");
     return 0;
@@ -463,12 +464,12 @@ static int ad_mode_st(const char *path, int *mode, struct stat *stbuf)
 }
 
 /* --------------------------- */
-static int ad_header_upgrade(struct adouble *ad _U_, char *name _U_)
+static int ad_header_upgrade(struct adouble *ad _U_, const char *name _U_)
 {
     return 0;
 }
 
-static int ad_header_upgrade_ea(struct adouble *ad _U_, char *name _U_)
+static int ad_header_upgrade_ea(struct adouble *ad _U_, const char *name _U_)
 {
     AFP_PANIC("ad_header_upgrade_ea: dont use");
     return 0;
@@ -549,23 +550,15 @@ static int ad_open_hf_v2(const char *path, int adflags, int oflags, int mode, st
     struct stat st_dir;
     struct stat st_meta;
     struct stat *pst = NULL;
-    char        *ad_p;
+    const char  *ad_p;
     int         hoflags, admode;
     int         st_invalid = -1;
 
     ad_p = ad->ad_ops->ad_path( path, adflags );
 
-    hoflags = oflags & ~(O_CREAT | O_EXCL);
-    if (!(adflags & ADFLAGS_RDONLY)) {
-        hoflags = (hoflags & ~(O_RDONLY | O_WRONLY)) | O_RDWR;
-    }
-    ad->ad_md->adf_fd = open( ad_p, hoflags | O_NOFOLLOW, 0 );
-    if (ad->ad_md->adf_fd < 0 ) {
-        if ((errno == EACCES || errno == EROFS) && !(oflags & O_RDWR)) {
-            hoflags = oflags & ~(O_CREAT | O_EXCL);
-            ad->ad_md->adf_fd = open( ad_p, hoflags | O_NOFOLLOW, 0 );
-        }
-    }
+    hoflags = (oflags & ~(O_CREAT | O_EXCL)) | O_NOFOLLOW;
+
+    ad->ad_md->adf_fd = open(ad_p, hoflags, 0);
 
     if ( ad->ad_md->adf_fd < 0 ) {
         if (errno == ENOENT && (oflags & O_CREAT) ) {
@@ -573,8 +566,8 @@ static int ad_open_hf_v2(const char *path, int adflags, int oflags, int mode, st
              * We're expecting to create a new adouble header file here
              * if ((oflags & O_CREAT) ==> (oflags & O_RDWR)
              */
-            LOG(log_debug, logtype_default, "ad_open(\"%s/%s\"): creating adouble file",
-                getcwdpath(), ad_p);
+            LOG(log_debug, logtype_default, "ad_open(\"%s\"): creating adouble file",
+                abspath(path));
             admode = mode;
             errno = 0;
             st_invalid = ad_mode_st(ad_p, &admode, &st_dir);
@@ -594,7 +587,7 @@ static int ad_open_hf_v2(const char *path, int adflags, int oflags, int mode, st
                 admode = ad_hf_mode(admode);
             }
             /* retry with O_CREAT */
-            ad->ad_md->adf_fd = open( ad_p, oflags,admode );
+            ad->ad_md->adf_fd = open(ad_p, oflags, admode);
             if ( ad->ad_md->adf_fd < 0 ) {
                 return -1;
             }
@@ -768,7 +761,7 @@ exit:
  * API functions
  ********************************************************************************* */
 
-char *ad_path_ea( const char *path, int adflags _U_)
+const char *ad_path_ea( const char *path, int adflags _U_)
 {
     return path;
 }
@@ -782,7 +775,7 @@ char *ad_path_ea( const char *path, int adflags _U_)
  *
  * FIXME: should do something for pathname > MAXPATHLEN
  */
-char *ad_path( const char *path, int adflags)
+const char *ad_path( const char *path, int adflags)
 {
     static char pathbuf[ MAXPATHLEN + 1];
     const char *slash;
@@ -982,12 +975,6 @@ const char *adflags2logstr(int adflags)
         strlcat(buf, "DIR", 64);
         first = 0;
     }
-    if (adflags & ADFLAGS_RDONLY) {
-        if (!first)
-            strlcat(buf, "|", 64);
-        strlcat(buf, "RDONLY", 64);
-        first = 0;
-    }
     if (adflags & ADFLAGS_OPENFORKS) {
         if (!first)
             strlcat(buf, "|", 64);
@@ -1038,28 +1025,34 @@ const char *oflags2logstr(int oflags)
  *      ad_init(&ad, vol->v_adouble, vol->v_ad_options);
  * @endcode
  *
- * @param path    Path to file or directory
- *
- * @param adflags ADFLAGS_DF:        open data fork \n
- *                ADFLAGS_RF:        open ressource fork \n
- *                ADFLAGS_HF:        open header (metadata) file \n
- *                ADFLAGS_NOHF:      it's not an error if header file couldn't be created \n
- *                ADFLAGS_DIR:       if path is a directory you MUST or ADFLAGS_DIR to adflags \n
- *                ADFLAGS_RDONLY:    open read only \n
- *                ADFLAGS_OPENFORKS: check for open forks from other processes
+ * Open a files data fork, metadata fork or ressource fork.
+ * For each fork to be opened specify the open flags and mode in case you want to create it
+ * (O_CREAT in open flags). The order in which forks are opened is:
+ * 1. ADFLAGS_DF
+ * 2. ADFLAGS_HF
+ * 3. ADFLAGS_RF
+ * The variable arguments must be passed according to this order.
  *
- * @param oflags  flags passed through to open syscall
- * @param mode    passed to open with O_CREAT
- * @param ad      pointer to struct adouble
+ * @param ad        (rw) pointer to struct adouble
+ * @param path      (r)  Path to file or directory
+ * @param adflags   (r)  ADFLAGS_DF:        open data fork \n
+ *                       ADFLAGS_RF:        open ressource fork \n
+ *                       ADFLAGS_HF:        open header (metadata) file \n
+ *                       ADFLAGS_NOHF:      it's not an error if header file couldn't be created \n
+ *                       ADFLAGS_DIR:       if path is a directory you MUST or ADFLAGS_DIR to adflags \n
+ *                       ADFLAGS_RDONLY:    dont upgrade mode from r to rw with adouble:v2 headerfile \n
+ *                       ADFLAGS_OPENFORKS: check for open forks from other processes
  *
  * @returns 0 on success, any other value indicates an error
  */
-int ad_open(const char *path, int adflags, int oflags, int mode, struct adouble  *ad)
+static int vad_open(struct adouble *ad, const char *path, int adflags, va_list args)
 {
     int ret = 0;
+    int oflags;
+    int mode;
     
-    LOG(log_debug, logtype_default, "ad_open(\"%s\", %s, %s, 0%04o)",
-        abspath(path), adflags2logstr(adflags), oflags2logstr(oflags), mode);
+    LOG(log_debug, logtype_default, "ad_open(\"%s\", %s)",
+        abspath(path), adflags2logstr(adflags));
 
     if (ad->ad_inited != AD_INITED)
         AFP_PANIC("ad_open: not initialized");
@@ -1072,6 +1065,9 @@ int ad_open(const char *path, int adflags, int oflags, int mode, struct adouble
     }
 
     if ((adflags & ADFLAGS_DF) && !(ad->ad_adflags & ADFLAGS_DF)) {
+        oflags = va_arg(args, int);
+        if (oflags & O_CREAT)
+            mode = va_arg(args, int);
         if (ad_open_df(path, adflags, oflags, mode, ad) != 0) {
             ret = -1;
             goto exit;
@@ -1080,6 +1076,9 @@ int ad_open(const char *path, int adflags, int oflags, int mode, struct adouble
     }
 
     if ((adflags & ADFLAGS_HF) && !(ad->ad_adflags & ADFLAGS_HF)) {
+        oflags = va_arg(args, int);
+        if (oflags & O_CREAT)
+            mode = va_arg(args, int);
         if (ad_open_hf(path, adflags, oflags, mode, ad) != 0) {
             ret = -1;
             goto exit;
@@ -1088,6 +1087,9 @@ int ad_open(const char *path, int adflags, int oflags, int mode, struct adouble
     }
 
     if ((adflags & ADFLAGS_RF) && !(ad->ad_adflags & ADFLAGS_RF)) {
+        oflags = va_arg(args, int);
+        if (oflags & O_CREAT)
+            mode = va_arg(args, int);
         if (ad_open_rf(path, adflags, oflags, mode, ad) != 0) {
             ret = -1;
             goto exit;
@@ -1109,11 +1111,21 @@ exit:
     return ret;
 }
 
+int ad_open(struct adouble *ad, const char *path, int adflags, ...)
+{
+    int ret;
+    va_list args;
+
+    va_start(args, adflags);
+    ret = vad_open(ad, path, adflags, args);
+    va_end(args);
+    return ret;
+}
+
 /*!
  * @brief open metadata, possibly as root
  *
  * Return only metadata but try very hard ie at first try as user, then try as root.
- * Caller must pass ADFLAGS_DIR for directories.
  *
  * @param name  name of file/dir
  * @param flags ADFLAGS_DIR: name is a directory \n
@@ -1125,11 +1137,10 @@ int ad_metadata(const char *name, int flags, struct adouble *adp)
 {
     uid_t uid;
     int   ret, err, dir;
-    int   create = O_RDONLY;
 
     dir = flags & ADFLAGS_DIR;
 
-    if ((ret = ad_open(name, ADFLAGS_HF | dir, create, 0666, adp)) < 0 && errno == EACCES) {
+    if ((ret = ad_open(adp, name, ADFLAGS_HF | dir, O_RDONLY)) < 0 && errno == EACCES) {
         uid = geteuid();
         if (seteuid(0)) {
             LOG(log_error, logtype_default, "ad_metadata(%s): seteuid failed %s", name, strerror(errno));
@@ -1137,7 +1148,7 @@ int ad_metadata(const char *name, int flags, struct adouble *adp)
             return -1;
         }
         /* we are root open read only */
-        ret = ad_open(name, ADFLAGS_HF|ADFLAGS_RDONLY| dir, O_RDONLY, 0, adp);
+        ret = ad_open(adp, name, ADFLAGS_HF | dir, O_RDONLY);
         err = errno;
         if ( seteuid(uid) < 0) {
             LOG(log_error, logtype_default, "ad_metadata: can't seteuid back");
@@ -1202,15 +1213,14 @@ int ad_refresh(struct adouble *ad)
     return ad->ad_ops->ad_header_read(ad, NULL);
 }
 
-int ad_openat(int dirfd,  /* dir fd openat like */
+int ad_openat(struct adouble  *ad,
+              int dirfd,  /* dir fd openat like */
               const char *path,
-              int adflags,
-              int oflags,
-              int mode,
-              struct adouble  *ad)
+              int adflags, ...)
 {
     int ret = 0;
     int cwdfd = -1;
+    va_list args;
 
     if (dirfd != -1) {
         if ((cwdfd = open(".", O_RDONLY) == -1) || (fchdir(dirfd) != 0)) {
@@ -1219,15 +1229,18 @@ int ad_openat(int dirfd,  /* dir fd openat like */
         }
     }
 
-    if (ad_open(path, adflags, oflags, mode, ad) < 0) {
+    va_start(args, adflags);
+
+    if (vad_open(ad, path, adflags, args) < 0) {
         ret = -1;
         goto exit;
     }
 
+    va_end(args);
+
     if (dirfd != -1) {
         if (fchdir(cwdfd) != 0) {
-            LOG(log_error, logtype_afpd, "ad_openat: cant chdir back, exiting");
-            exit(EXITERR_SYS);
+            AFP_PANIC("ad_openat: cant chdir back");
         }
     }
 
index 911138aa5946934c76e1690e48296a0120309b64..877ab574cff326dc3b70750572fa2577d4bec1ab 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <string.h>
 #include <sys/param.h>
+#include <errno.h>
 
 #include <atalk/adouble.h>
 #include <atalk/ea.h>
index 97649a7cb2b589f289a6aa7ea0062670b0b65de7..6b7ab4fcdf0b079234ba5f488a70c2b8ea1d60af 100644 (file)
@@ -22,19 +22,19 @@ extern struct _cnid_db *cnid_cdb_open (struct cnid_open_args *args);
 extern void cnid_cdb_close (struct _cnid_db *);
 
 /* cnid_add.c */
-extern cnid_t cnid_cdb_add (struct _cnid_db *, const struct stat *, const cnid_t,
-                           char *, const size_t, cnid_t);
+extern cnid_t cnid_cdb_add (struct _cnid_db *, const struct stat *, cnid_t,
+                            const char *, size_t, cnid_t);
 extern int cnid_cdb_getstamp (struct _cnid_db *, void *, const size_t );
 
 /* cnid_get.c */
-extern cnid_t cnid_cdb_get (struct _cnid_db *, const cnid_t, char *, const size_t); 
+extern cnid_t cnid_cdb_get (struct _cnid_db *, cnid_t, const char *, size_t); 
 extern char *cnid_cdb_resolve (struct _cnid_db *, cnid_t *, void *, size_t ); 
-extern cnid_t cnid_cdb_lookup (struct _cnid_db *, const struct stat *, const cnid_t,
-                              char *, const size_t);
+extern cnid_t cnid_cdb_lookup (struct _cnid_db *, const struct stat *, cnid_t,
+                               const char *, size_t);
 
 /* cnid_update.c */
-extern int cnid_cdb_update (struct _cnid_db *, const cnid_t, const struct stat *,
-                           const cnid_t, char *, size_t);
+extern int cnid_cdb_update (struct _cnid_db *, cnid_t, const struct stat *,
+                            cnid_t, const char *, size_t);
 
 /* cnid_delete.c */
 extern int cnid_cdb_delete (struct _cnid_db *, const cnid_t);
@@ -46,7 +46,7 @@ extern int cnid_cdb_lock   (void *);
 extern int cnid_cdb_unlock (void *);
 
 extern cnid_t cnid_cdb_rebuild_add (struct _cnid_db *, const struct stat *,
-                const cnid_t, char *, const size_t, cnid_t);
+                                    cnid_t, const char *, size_t, cnid_t);
 
 
 #endif /* include/atalk/cnid_cdb.h */
index 418f68cd647cf1fabf777963ef95b71a96537ad5..ff82c52cd6ebcb12be7eb64556c1f57f9cd3ae92 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: cnid_cdb_add.c,v 1.8 2009-11-20 17:22:11 didg Exp $
- *
  * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved. See COPYRIGHT.
  *
@@ -16,9 +14,8 @@
 #ifdef CNID_BACKEND_CDB
 #include "cnid_cdb_private.h"
 
-extern int cnid_cdb_update(struct _cnid_db *cdb, const cnid_t id, const struct stat *st,
-                const cnid_t did, char *name, const size_t len);
-
+extern int cnid_cdb_update(struct _cnid_db *cdb, cnid_t id, const struct stat *st,
+                           cnid_t did, const char *name, size_t len);
 
 #define tid    NULL
 
@@ -168,8 +165,7 @@ cleanup:
 
 /* ------------------------ */
 cnid_t cnid_cdb_add(struct _cnid_db *cdb, const struct stat *st,
-                const cnid_t did, char *name, const size_t len,
-                cnid_t hint)
+                    cnid_t did, const char *name, size_t len, cnid_t hint)
 {
     CNID_private *db;
     DBT key, data;
index 5ae4ea02f0ef29fd6de9971f7e19967f83b111fa..d4e090550eab6f85e3de0aa6671f7aa7d6006453 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * $Id: cnid_cdb_get.c,v 1.5 2009-10-29 13:38:16 didg Exp $
- */
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif /* HAVE_CONFIG_H */
@@ -10,8 +6,7 @@
 #include "cnid_cdb_private.h"
 
 /* Return CNID for a given did/name. */
-cnid_t cnid_cdb_get(struct _cnid_db *cdb, const cnid_t did, char *name,
-                const size_t len)
+cnid_t cnid_cdb_get(struct _cnid_db *cdb, cnid_t did, const char *name, size_t len)
 {
     char start[CNID_DID_LEN + MAXPATHLEN + 1], *buf;
     CNID_private *db;
index 07de091067fb3b561925e4003f5f2d3831d353b1..7b2f933c5182b4e1c4d4974f5a46c3bd7aa695ac 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * $Id: cnid_cdb_lookup.c,v 1.6 2009-11-20 17:22:11 didg Exp $
- */
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif /* HAVE_CONFIG_H */
@@ -14,8 +10,8 @@
 
 /* This returns the CNID corresponding to a particular file.  It will
  * also fix up the various databases if there's a problem. */
-cnid_t cnid_cdb_lookup(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
-                   char *name, const size_t len)
+cnid_t cnid_cdb_lookup(struct _cnid_db *cdb, const struct stat *st, cnid_t did,
+                       const char *name, size_t len)
 {
     unsigned char *buf;
     CNID_private *db;
index 10ecc78d8c34efaf51365820954b1ff5d06c0f6a..056420dad099f1123a6e514f98630055d285fa3a 100644 (file)
 
 static char *old_dbfiles[] = {"cnid.db", NULL};
 
-/* -----------------------
- * bandaid for LanTest performance pb. for now not used, cf. ifdef 0 below
-*/
-static int my_yield(void)
-{
-    struct timeval t;
-    int ret;
-
-    t.tv_sec = 0;
-    t.tv_usec = 1000;
-    ret = select(0, NULL, NULL, NULL, &t);
-    return 0;
-}
-
 /* --------------- */
 static int didname(DB *dbp _U_, const DBT *pkey _U_, const DBT *pdata, DBT *skey)
 {
@@ -368,7 +354,6 @@ struct _cnid_db *cnid_cdb_open(struct cnid_open_args *args)
         }
     }
 
-    db_env_set_func_yield(my_yield);
     return cdb;
 
   fail_appinit:
index 351f31536073982a4b3f08be5e1b40f61fec8f21..be2db1023692be7e7d966b76e23d1773b37ee1a0 100644 (file)
@@ -73,10 +73,8 @@ cleanup:
     return CNID_INVALID;
 }
 
-/* ------------------------ */
 cnid_t cnid_cdb_rebuild_add(struct _cnid_db *cdb, const struct stat *st,
-                const cnid_t did, char *name, const size_t len, 
-               cnid_t hint)
+                            cnid_t did, const char *name, size_t len, cnid_t hint)
 {
     CNID_private *db;
     DBT key, data;
index f1a4a30dc48b24f6bedbbca48d7d034f81d57615..f7676c840054516c10be062dae3e874719b7e23e 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * $Id: cnid_cdb_update.c,v 1.4 2009-11-20 17:22:11 didg Exp $
- */
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif /* HAVE_CONFIG_H */
@@ -14,9 +10,8 @@
 /* cnid_update: takes the given cnid and updates the metadata.  To
  * handle the did/name data, there are a bunch of functions to get
  * and set the various fields. */
-int cnid_cdb_update(struct _cnid_db *cdb, const cnid_t id, const struct stat *st,
-                const cnid_t did, char *name, const size_t len
-                /*, const char *info, const int infolen*/)
+int cnid_cdb_update(struct _cnid_db *cdb, cnid_t id, const struct stat *st,
+                    cnid_t did, const char *name, size_t len)
 {
     unsigned char *buf;
     CNID_private *db;
index 990248e45e439a22bc4de87377ae8fbe7e1e95f7..ab5a20f267af0850e979cbf5c10dc9afc66a1813 100644 (file)
@@ -273,7 +273,7 @@ static int send_packet(CNID_private *db, struct cnid_dbd_rqst *rqst)
     vecs = 1;
 
     if (rqst->namelen) {
-        iov[1].iov_base = rqst->name;
+        iov[1].iov_base = (char *)rqst->name;
         iov[1].iov_len  = rqst->namelen;
         towrite += rqst->namelen;
         vecs++;
@@ -538,8 +538,7 @@ void cnid_dbd_close(struct _cnid_db *cdb)
 
 /* ---------------------- */
 cnid_t cnid_dbd_add(struct _cnid_db *cdb, const struct stat *st,
-                    const cnid_t did, char *name, const size_t len,
-                    cnid_t hint)
+                    cnid_t did, const char *name, size_t len, cnid_t hint)
 {
     CNID_private *db;
     struct cnid_dbd_rqst rqst;
@@ -603,7 +602,7 @@ cnid_t cnid_dbd_add(struct _cnid_db *cdb, const struct stat *st,
 }
 
 /* ---------------------- */
-cnid_t cnid_dbd_get(struct _cnid_db *cdb, const cnid_t did, char *name, const size_t len)
+cnid_t cnid_dbd_get(struct _cnid_db *cdb, cnid_t did, const char *name, size_t len)
 {
     CNID_private *db;
     struct cnid_dbd_rqst rqst;
@@ -729,8 +728,8 @@ int cnid_dbd_getstamp(struct _cnid_db *cdb, void *buffer, const size_t len)
 }
 
 /* ---------------------- */
-cnid_t cnid_dbd_lookup(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
-                       char *name, const size_t len)
+cnid_t cnid_dbd_lookup(struct _cnid_db *cdb, const struct stat *st, cnid_t did,
+                       const char *name, size_t len)
 {
     CNID_private *db;
     struct cnid_dbd_rqst rqst;
@@ -791,7 +790,7 @@ cnid_t cnid_dbd_lookup(struct _cnid_db *cdb, const struct stat *st, const cnid_t
 }
 
 /* ---------------------- */
-int cnid_dbd_find(struct _cnid_db *cdb, char *name, size_t namelen, void *buffer, size_t buflen)
+int cnid_dbd_find(struct _cnid_db *cdb, const char *name, size_t namelen, void *buffer, size_t buflen)
 {
     CNID_private *db;
     struct cnid_dbd_rqst rqst;
@@ -846,8 +845,8 @@ int cnid_dbd_find(struct _cnid_db *cdb, char *name, size_t namelen, void *buffer
 }
 
 /* ---------------------- */
-int cnid_dbd_update(struct _cnid_db *cdb, const cnid_t id, const struct stat *st,
-                    const cnid_t did, char *name, const size_t len)
+int cnid_dbd_update(struct _cnid_db *cdb, cnid_t id, const struct stat *st,
+                    cnid_t did, const char *name, size_t len)
 {
     CNID_private *db;
     struct cnid_dbd_rqst rqst;
@@ -901,8 +900,7 @@ int cnid_dbd_update(struct _cnid_db *cdb, const cnid_t id, const struct stat *st
 
 /* ---------------------- */
 cnid_t cnid_dbd_rebuild_add(struct _cnid_db *cdb, const struct stat *st,
-                            const cnid_t did, char *name, const size_t len,
-                            cnid_t hint)
+                            cnid_t did, const char *name, size_t len, cnid_t hint)
 {
     CNID_private *db;
     struct cnid_dbd_rqst rqst;
index 1f645908358b442633beae7e730e9789be690975..be8659d6cdfdac596019d661d8a73e3cd3549460 100644 (file)
 extern struct _cnid_module cnid_dbd_module;
 extern struct _cnid_db *cnid_dbd_open (struct cnid_open_args *args);
 extern void   cnid_dbd_close      (struct _cnid_db *);
-extern cnid_t cnid_dbd_add        (struct _cnid_db *, const struct stat *, const cnid_t,
-                                   char *, const size_t, cnid_t);
-extern cnid_t cnid_dbd_get        (struct _cnid_db *, const cnid_t, char *, const size_t); 
+extern cnid_t cnid_dbd_add        (struct _cnid_db *, const struct stat *, cnid_t,
+                                   const char *, size_t, cnid_t);
+extern cnid_t cnid_dbd_get        (struct _cnid_db *, cnid_t, const char *, size_t); 
 extern char  *cnid_dbd_resolve    (struct _cnid_db *, cnid_t *, void *, size_t ); 
 extern int    cnid_dbd_getstamp   (struct _cnid_db *, void *, const size_t ); 
-extern cnid_t cnid_dbd_lookup     (struct _cnid_db *, const struct stat *, const cnid_t,
-                                   char *, const size_t);
-extern int    cnid_dbd_find       (struct _cnid_db *cdb, char *name, size_t namelen,
+extern cnid_t cnid_dbd_lookup     (struct _cnid_db *, const struct stat *, cnid_t,
+                                   const char *, size_t);
+extern int    cnid_dbd_find       (struct _cnid_db *cdb, const char *name, size_t namelen,
                                    void *buffer, size_t buflen);
-extern int    cnid_dbd_update     (struct _cnid_db *, const cnid_t, const struct stat *,
-                                   const cnid_t, char *, size_t);
+extern int    cnid_dbd_update     (struct _cnid_db *, cnid_t, const struct stat *,
+                                   cnid_t, const char *, size_t);
 extern int    cnid_dbd_delete     (struct _cnid_db *, const cnid_t);
 extern cnid_t cnid_dbd_rebuild_add(struct _cnid_db *, const struct stat *,
-                                   const cnid_t, char *, const size_t, cnid_t);
+                                   cnid_t, const char *, size_t, cnid_t);
 
 /* FIXME: These functions could be static in cnid_dbd.c */
 
index 5502fb60f94c49836b9de1cd62005ebdeec7f841..1ed78b4628e6fab46083488af4f7697c64d10e0e 100644 (file)
@@ -23,7 +23,7 @@
 
 /* ------------------------ */
 cnid_t cnid_last_add(struct _cnid_db *cdb, const struct stat *st,
-                     const cnid_t did _U_, char *name _U_, const size_t len _U_, cnid_t hint _U_)
+                     cnid_t did _U_, const char *name _U_, size_t len _U_, cnid_t hint _U_)
 {
 
     /* FIXME: it relies on fact, that this is never called twice for the same file/dir. */
@@ -86,9 +86,8 @@ int cnid_last_delete(struct _cnid_db *cdb _U_, const cnid_t id _U_)
 }
 
 
-
 /* Return CNID for a given did/name. */
-cnid_t cnid_last_get(struct _cnid_db *cdb _U_, const cnid_t did _U_, char *name _U_, const size_t len _U_)
+cnid_t cnid_last_get(struct _cnid_db *cdb _U_, cnid_t did _U_, const char *name _U_, size_t len _U_)
 {
     /* FIXME: it relies on fact, that this is never called twice for the same file/dir. */
     /* Propably we should look through DID tree. */
@@ -96,10 +95,9 @@ cnid_t cnid_last_get(struct _cnid_db *cdb _U_, const cnid_t did _U_, char *name
 }
 
 
-
 /* */
-cnid_t cnid_last_lookup(struct _cnid_db *cdb _U_, const struct stat *st _U_, const cnid_t did _U_, 
-    char *name _U_, const size_t len _U_)
+cnid_t cnid_last_lookup(struct _cnid_db *cdb _U_, const struct stat *st _U_, cnid_t did _U_, 
+                        const char *name _U_, size_t len _U_)
 {
     /* FIXME: this function doesn't work in [last] scheme ! */
     /* Should be never called or CNID should be somewhat refactored again. */
@@ -175,8 +173,8 @@ char *cnid_last_resolve(struct _cnid_db *cdb _U_, cnid_t * id _U_, void *buffer
 }
 
 
-int cnid_last_update(struct _cnid_db *cdb _U_, const cnid_t id _U_, const struct stat *st _U_,
-                     const cnid_t did  _U_, char *name  _U_, const size_t len _U_)
+int cnid_last_update(struct _cnid_db *cdb _U_, cnid_t id _U_, const struct stat *st _U_,
+                     cnid_t did  _U_, const char *name  _U_, size_t len _U_)
 {
     return 0;
 }
index fdcf32a5cc524fc74e4abba68670d4ef792b20a4..9f944dda51f82f679a37a354e1a3f96bdbf1ebfb 100644 (file)
@@ -22,13 +22,13 @@ struct _cnid_last_private {
 extern struct _cnid_module cnid_last_module;
 extern struct _cnid_db *cnid_last_open (struct cnid_open_args *args);
 extern void cnid_last_close (struct _cnid_db *);
-extern cnid_t cnid_last_add (struct _cnid_db *, const struct stat *, const cnid_t,
-                                 char *, const size_t, cnid_t);
-extern cnid_t cnid_last_get (struct _cnid_db *, const cnid_t, char *, const size_t);
+extern cnid_t cnid_last_add (struct _cnid_db *, const struct stat *, cnid_t,
+                             const char *, size_t, cnid_t);
+extern cnid_t cnid_last_get (struct _cnid_db *, cnid_t, const char *, size_t);
 extern char *cnid_last_resolve (struct _cnid_db *, cnid_t *, void *, size_t);
-extern cnid_t cnid_last_lookup (struct _cnid_db *, const struct stat *, const cnid_t, char *, const size_t);
-extern int cnid_last_update (struct _cnid_db *, const cnid_t, const struct stat *,
-                                 const cnid_t, char *, size_t);
-extern int cnid_last_delete (struct _cnid_db *, const cnid_t);
+extern cnid_t cnid_last_lookup (struct _cnid_db *, const struct stat *, cnid_t, const char *, size_t);
+extern int cnid_last_update (struct _cnid_db *, cnid_t, const struct stat *,
+                             cnid_t, const char *, size_t);
+extern int cnid_last_delete (struct _cnid_db *, cnid_t);
 
 #endif /* include/atalk/cnid_last.h */
index 1f7a08e6336dfb2ad6274dbac77c165c0e9fd11d..0bf978a587501a382b968fada89a9d640a8e0288 100644 (file)
@@ -53,17 +53,17 @@ extern struct _cnid_db *cnid_tdb_open (struct cnid_open_args *args);
 extern void cnid_tdb_close (struct _cnid_db *);
 
 /* cnid_add.c */
-extern cnid_t cnid_tdb_add (struct _cnid_db *, const struct stat *, const cnid_t,
-                                 char *, const size_t, cnid_t);
+extern cnid_t cnid_tdb_add (struct _cnid_db *, const struct stat *, cnid_t,
+                            const char *, size_t, cnid_t);
 
 /* cnid_get.c */
-extern cnid_t cnid_tdb_get (struct _cnid_db *, const cnid_t, char *, const size_t);
+extern cnid_t cnid_tdb_get (struct _cnid_db *, cnid_t, const char *, size_t);
 extern char *cnid_tdb_resolve (struct _cnid_db *, cnid_t *, void *, size_t);
-extern cnid_t cnid_tdb_lookup (struct _cnid_db *, const struct stat *, const cnid_t, char *, const size_t);
+extern cnid_t cnid_tdb_lookup (struct _cnid_db *, const struct stat *, cnid_t, const char *, size_t);
 
 /* cnid_update.c */
-extern int cnid_tdb_update (struct _cnid_db *, const cnid_t, const struct stat *,
-                                 const cnid_t, char *, size_t);
+extern int cnid_tdb_update (struct _cnid_db *, cnid_t, const struct stat *,
+                            cnid_t, const char *, size_t);
 
 /* cnid_delete.c */
 extern int cnid_tdb_delete (struct _cnid_db *, const cnid_t);
index 5758300c2e528c6b8a513b086fb8a4fb4a43e1e9..e49fdd30cc6ddfa52ce967f99ad014d662f63b84 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: cnid_tdb_add.c,v 1.4 2009-11-20 17:37:14 didg Exp $
- *
  * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved. See COPYRIGHT.
  *
@@ -154,7 +152,7 @@ cleanup:
 
 /* ------------------------ */
 cnid_t cnid_tdb_add(struct _cnid_db *cdb, const struct stat *st,
-                     const cnid_t did, char *name, const size_t len, cnid_t hint)
+                    cnid_t did, const char *name, size_t len, cnid_t hint)
 {
     const struct stat *lstp;
     cnid_t id;
index 019eea5287567c7a024f2f038f0a7c6f0f4de360..8321d04e868eb20469c061bd08c0057c7dacc7ae 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * $Id: cnid_tdb_get.c,v 1.4 2009-11-20 17:37:14 didg Exp $
- */
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -11,7 +7,7 @@
 #include "cnid_tdb.h"
 
 /* Return CNID for a given did/name. */
-cnid_t cnid_tdb_get(struct _cnid_db *cdb, const cnid_t did, char *name, const size_t len)
+cnid_t cnid_tdb_get(struct _cnid_db *cdb, cnid_t did, const char *name, size_t len)
 {
     char start[CNID_DID_LEN + MAXPATHLEN + 1], *buf;
     struct _cnid_tdb_private *db;
index ba47e36837f197c42f6b302f0a22ed78ca68e77c..457362bf1b5fc536ebceb445b8e524a3df44fe55 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * $Id: cnid_tdb_lookup.c,v 1.6 2009-11-21 11:12:49 didg Exp $
- */
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -11,7 +7,7 @@
 #include "cnid_tdb.h"
 #include <atalk/logger.h>
 
-cnid_t cnid_tdb_lookup(struct _cnid_db *cdb, const struct stat *st, const cnid_t did, char *name, const size_t len)
+cnid_t cnid_tdb_lookup(struct _cnid_db *cdb, const struct stat *st, cnid_t did, const char *name, size_t len)
 {
     char *buf;
     struct _cnid_tdb_private *db;
index d658b94ae25f785399da7175bd3cc67a5f206d69..4c2e050b10e348181db7f07a86b66789e0755f5d 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: cnid_tdb_open.c,v 1.8 2010-03-31 09:47:32 franklahm Exp $
- *
  * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved. See COPYRIGHT.
  *
index 8c4d35e379dd535b7085719df8c6eb783c719d1e..d367334e06126c8f903fe8bea20d1a0d7efea0b1 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * $Id: cnid_tdb_update.c,v 1.6 2009-11-21 11:12:49 didg Exp $
- */
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -11,9 +7,8 @@
 #include "cnid_tdb.h"
 #include <atalk/logger.h>
 
-int cnid_tdb_update(struct _cnid_db *cdb, const cnid_t id, const struct stat *st,
-                     const cnid_t did, char *name, const size_t len
-                     /*, const char *info, const int infolen */ )
+int cnid_tdb_update(struct _cnid_db *cdb, cnid_t id, const struct stat *st,
+                    cnid_t did, const char *name, size_t len)
 {
     struct _cnid_tdb_private *db;
     TDB_DATA key, data, altdata;
index ebe54b21a8b0d2b52213b3a352fe495af37a319a..515681d38daf59c11643e094a4136b523599bb13 100644 (file)
@@ -3,12 +3,6 @@
 noinst_LTLIBRARIES = libcompat.la
 
 libcompat_la_SOURCES = \
-       mktemp.c        \
        getusershell.c  \
-       strcasecmp.c    \
-       strstr.c        \
-       strdup.c        \
-       inet_aton.c     \
        rquota_xdr.c    \
-       pselect.c       \
-       snprintf.c
+       pselect.c
index fa3a010926c898ff1a1688d0e631e5cf13f64f47..032c045d3973a7eb9b358a33416eeb595f0a1261 100644 (file)
@@ -597,7 +597,7 @@ static int delete_ea_file(const struct ea * restrict ea, const char *eaname)
  */
 char *ea_path(const struct ea * restrict ea, const char * restrict eaname, int macname)
 {
-    char *adname;
+    const char *adname;
     static char pathbuf[MAXPATHLEN + 1];
 
     /* get name of a adouble file from uname */
@@ -1394,7 +1394,7 @@ int ea_renamefile(VFS_FUNC_ARGS_RENAMEFILE)
         if (errno == ENOENT) {
             /* Possibly the .AppleDouble folder didn't exist, we create it and try again */
             ad_init(&ad, vol->v_adouble, vol->v_ad_options); 
-            if ((ad_open(dst, ADFLAGS_HF, O_RDWR | O_CREAT, 0666, &ad)) != 0) {
+            if ((ad_open(&ad, dst, ADFLAGS_HF, O_RDWR | O_CREAT, 0666)) != 0) {
                 LOG(log_error, logtype_afpd, "ea_renamefile('%s/%s'): ad_open error: '%s'", src, dst, dst);
                 ret = AFPERR_MISC;
                 goto exit;
@@ -1491,7 +1491,7 @@ int ea_copyfile(VFS_FUNC_ARGS_COPYFILE)
         if (errno == ENOENT) {
             /* Possibly the .AppleDouble folder didn't exist, we create it and try again */
             ad_init(&ad, vol->v_adouble, vol->v_ad_options); 
-            if ((ad_open(dst, ADFLAGS_HF, O_RDWR | O_CREAT, 0666, &ad)) != 0) {
+            if ((ad_open(&ad, dst, ADFLAGS_HF, O_RDWR | O_CREAT, 0666)) != 0) {
                 LOG(log_error, logtype_afpd, "ea_copyfile('%s/%s'): ad_open error: '%s'", src, dst, dst);
                 ret = AFPERR_MISC;
                 goto exit;
index 57a4e0c2cb1bcd28237a3dce9735ce64138b4060..15492a5d62a1edea8390423ae1167e2bb5c709e8 100644 (file)
@@ -114,7 +114,7 @@ static int validupath_adouble(VFS_FUNC_ARGS_VALIDUPATH)
 static int RF_chown_adouble(VFS_FUNC_ARGS_CHOWN)
 {
     struct stat st;
-    char        *ad_p;
+    const char *ad_p;
 
     ad_p = vol->ad_path(path, ADFLAGS_HF );
 
@@ -173,7 +173,7 @@ static int RF_setfilmode_adouble(VFS_FUNC_ARGS_SETFILEMODE)
 /* ----------------- */
 static int RF_setdirunixmode_adouble(VFS_FUNC_ARGS_SETDIRUNIXMODE)
 {
-    char *adouble = vol->ad_path(name, ADFLAGS_DIR );
+    const char *adouble = vol->ad_path(name, ADFLAGS_DIR );
     int  dropbox = vol->v_flags;
 
     if (dir_rx_set(mode)) {
@@ -214,8 +214,8 @@ static int RF_setdirmode_adouble(VFS_FUNC_ARGS_SETDIRMODE)
 {
     int   dropbox = vol->v_flags;
     mode_t hf_mode = ad_hf_mode(mode);
-    char  *adouble = vol->ad_path(name, ADFLAGS_DIR );
-    char  *adouble_p = ad_dir(adouble);
+    const char  *adouble = vol->ad_path(name, ADFLAGS_DIR );
+    const char  *adouble_p = ad_dir(adouble);
 
     if (dir_rx_set(mode)) {
         if (stickydirmode(ad_dir(adouble), DIRBITS | mode, dropbox, vol->v_umask) < 0) 
@@ -308,7 +308,7 @@ static int RF_renamefile_adouble(VFS_FUNC_ARGS_RENAMEFILE)
              * use a diff one, it's not a pb,ie it's not the same file, yet.
              */
             ad_init(&ad, vol->v_adouble, vol->v_ad_options); 
-            if (!ad_open(dst, ADFLAGS_HF, O_RDWR | O_CREAT, 0666, &ad)) {
+            if (ad_open(&ad, dst, ADFLAGS_HF, O_RDWR | O_CREAT, 0666) == 0) {
                ad_close(&ad, ADFLAGS_HF);
                if (!unix_rename(dirfd, adsrc, -1, vol->ad_path(dst, 0 )) ) 
                    err = 0;