]> arthur.barton.de Git - netatalk.git/commitdiff
New volume option "eject" for eg CD-ROM. Forces in-memory tdb CNID backend.
authorfranklahm <franklahm>
Tue, 9 Feb 2010 14:56:30 +0000 (14:56 +0000)
committerfranklahm <franklahm>
Tue, 9 Feb 2010 14:56:30 +0000 (14:56 +0000)
etc/afpd/dircache.c
etc/afpd/directory.c
etc/afpd/ofork.c
etc/afpd/volume.c
include/atalk/volume.h
libatalk/util/volinfo.c

index 31ef760914a524b6856134acb401531eb91df9b7..d0b02da0aac555d1c67717a30751f3f4b0f5b0c3 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  $Id: dircache.c,v 1.1.2.5 2010-02-05 12:56:13 franklahm Exp $
+  $Id: dircache.c,v 1.1.2.6 2010-02-09 14:56:30 franklahm Exp $
   Copyright (c) 2010 Frank Lahm <franklahm@gmail.com>
 
   This program is free software; you can redistribute it and/or modify
@@ -348,11 +348,8 @@ int dircache_add(struct dir *dir)
 /*!
   * @brief Remove an entry from the dircache
   *
-  * FIXME what about opened forks with refs to it?
-  * it's an afp specs violation because you can't delete
-  * an opened forks. Now afpd doesn't care about forks opened by other
-  * process. It's fixable within afpd if fnctl_lock, doable with smb and
-  * next to impossible for nfs and local filesystem access.
+  * Callers outside of dircache.c should call this with
+  * flags = QUEUE_INDEX | DIDNAME_INDEX | DIRCACHE.
   */
 void dircache_remove(const struct vol *vol _U_, struct dir *dir, int flags)
 {
index 7439c2bfe3b703af93a0061ec4a62737020e801b..d6f6bd50ce3cb6257ca6d40b9e30f85cf4931b7d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.131.2.11 2010-02-05 12:56:13 franklahm Exp $
+ * $Id: directory.c,v 1.131.2.12 2010-02-09 14:56:30 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -51,9 +51,6 @@ extern void addir_inherit_acl(const struct vol *vol);
  * FIXMEs, loose ends after the dircache rewrite:
  * o merge dircache_search_by_name and dir_add ??
  * o case-insensitivity is gone from cname
- * o directory offspring count calculation probably broken
- * o doesn't work with CNID backend last and the like,
- *   CNID backend must support persistent CNIDs.
  */
 
 
index d5862a5ab9d9650e10749a7bc67b1548395e5274..687809e3e5ad7262c5d615d519adcead56dc2be2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ofork.c,v 1.30.4.3 2010-02-05 10:38:53 franklahm Exp $
+ * $Id: ofork.c,v 1.30.4.4 2010-02-09 14:56:30 franklahm Exp $
  *
  * Copyright (c) 1996 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -290,7 +290,7 @@ int of_stat(struct path *path)
     path->st_valid = 1;
     if ((ret = stat(path->u_name, &path->st)) < 0) {
         LOG(log_debug, logtype_afpd, "of_stat: {'%s/%s': %s}",
-            getcwdpath(), path->u_name, strerror(errno));
+            cfrombstring(curdir->d_fullpath), path->u_name, strerror(errno));
         path->st_errno = errno;
     }
     return ret;
index 2b6b24c27fa25305eff0f359f4b478834f72c1c7..368dd50c0c8c355c2d987318533e957796765d01 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.115.2.1 2010-02-01 10:56:08 franklahm Exp $
+ * $Id: volume.c,v 1.115.2.2 2010-02-09 14:56:30 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -466,6 +466,8 @@ static void volset(struct vol_option *options, struct vol_option *save,
                 options[VOLOPT_FLAGS].i_value &= ~AFPVOL_CACHE;
             else if (strcasecmp(p, "tm") == 0)
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_TM;
+            else if (strcasecmp(p, "eject") == 0)
+                options[VOLOPT_FLAGS].i_value |= AFPVOL_EJECT | AFPVOL_RO;
 
             p = strtok(NULL, ",");
         }
@@ -1818,12 +1820,32 @@ static int volume_openDB(struct vol *volume)
         volume->v_cnidscheme = strdup(DEFAULT_CNID_SCHEME);
         LOG(log_info, logtype_afpd, "Volume %s use CNID scheme %s.", volume->v_path, volume->v_cnidscheme);
     }
+
+    /* Legacy pre 2.1 way of sharing eg CD-ROM */
+    if (strcmp(volume->v_cnidscheme, "last") == 0) {
+        /* "last" is gone. We support it by switching to in-memory "tdb" */
+        volume->v_cnidscheme = strdup("tdb");
+        flags |= CNID_FLAG_MEMORY;
+    }
+
+    /* New way of sharing CD-ROM */
+    if (volume->v_flags & AFPVOL_EJECT) {
+        flags |= CNID_FLAG_MEMORY;
+        if (strcmp(volume->v_cnidscheme, "tdb") != 0) {
+            free(volume->v_cnidscheme);
+            volume->v_cnidscheme = strdup("tdb");
+            LOG(log_info, logtype_afpd, "Volume %s is ejectable, switching to scheme %s.",
+                volume->v_path, volume->v_cnidscheme);
+        }
+    }
+
     if (volume->v_dbpath)
         volume->v_cdb = cnid_open (volume->v_dbpath, volume->v_umask, volume->v_cnidscheme, flags);
     else
         volume->v_cdb = cnid_open (volume->v_path, volume->v_umask, volume->v_cnidscheme, flags);
 
-    if (!volume->v_cdb) {
+    if ( ! volume->v_cdb && ! (flags & CNID_FLAG_MEMORY)) {
+        /* The first attempt failed and it wasn't yet an attempt to open in-memory */
         flags |= CNID_FLAG_MEMORY;
         LOG(log_error, logtype_afpd, "Reopen volume %s using in memory temporary CNID DB.", volume->v_path);
         volume->v_cdb = cnid_open (volume->v_path, volume->v_umask, "tdb", flags);
index 06bbe53b8fdcf6f0724fcd1606b47aff15501453..c0516a41495f4bcc8c8cfc60f688c2079a605a7e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.h,v 1.11.2.1 2010-02-01 10:56:08 franklahm Exp $
+ * $Id: volume.h,v 1.11.2.2 2010-02-09 14:56:30 franklahm Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -107,7 +107,7 @@ typedef u_int64_t VolSpace;
 
 /*
   Flags that alter volume behaviour.
-  Keep in sync with include/atalk/volinfo.h and libatalk/util/volinfo.c
+  Keep in sync with libatalk/util/volinfo.c
 */
 #define AFPVOL_A2VOL     (1 << 5)   /* prodos volume */
 #define AFPVOL_CRLF      (1 << 6)   /* cr/lf translation */
@@ -136,6 +136,7 @@ typedef u_int64_t VolSpace;
 #define AFPVOL_INV_DOTS  (1 << 22)   /* dots files are invisible */
 #define AFPVOL_TM        (1 << 24)   /* Supports TimeMachine */
 #define AFPVOL_ACLS      (1 << 25)   /* Volume supports ACLS */
+#define AFPVOL_EJECT     (1 << 25)   /* Ejectable media eg CD -> in memory CNID db */
 
 /* Extended Attributes vfs indirection  */
 #define AFPVOL_EA_NONE           0   /* No EAs */
index ef438c5d278f5b103a968e8e41953c9cad4d5021..c6c8250ffdf62367eb835a5d87543c87f47ab211 100644 (file)
@@ -66,6 +66,7 @@ static const vol_opt_name_t vol_opt_names[] = {
     {AFPVOL_INV_DOTS,   "INVISIBLEDOTS"}, 
     {AFPVOL_ACLS,       "ACLS"},        /* Vol supports ACLs */
     {AFPVOL_TM,         "TM"},          /* Set "kSupportsTMLockSteal" is volume attributes */
+    {AFPVOL_EJECT,      "EJECT"},       /* Ejectable media eg CD -> in memory CNID db */
     {0, NULL}
 };