* amd/mapc.c (mapc_create): mapc find takes 4th arg, the mount
authorErez Zadok <ezk@cs.sunysb.edu>
Mon, 15 Aug 2005 21:49:44 +0000 (21:49 +0000)
committerErez Zadok <ezk@cs.sunysb.edu>
Mon, 15 Aug 2005 21:49:44 +0000 (21:49 +0000)
point.  Now, we can properly initialize the cfm structure of the
mnt_map, so we can have access to the flags (e.g., SUN_MAP_SYNTAX)
inside each info_*.c file.
(mapc_find): takes 4rd arg (mntpt) and passes it to calls to
mapc_create.
(root_newmap): pass NULL as 4th arg (mntpt).

* amd/amfs_generic.c (amfs_parse_defaults): remove ugly hack to
initialize map cfm structure (including flags) so late.

* amd/autil.c (amfs_mkcacheref): pass mount point as 4th arg to
mapc_find.

* amd/amfs_root.c (amfs_root_mount): pass NULL as new 4th arg to
mapc_find.

* amd/amd.h: extern for mapc_find changed to pass the mount point.

ChangeLog
amd/amd.h
amd/amfs_generic.c
amd/amfs_root.c
amd/autil.c
amd/mapc.c

index f9137ae7a6d779dd13797e4cb8c7fd28e8d1fb79..e2061ab506cf13933c86642f7bf456e252edbc15 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2005-08-15  Erez Zadok  <ezk@cs.sunysb.edu>
 
+       * amd/mapc.c (mapc_create): mapc find takes 4th arg, the mount
+       point.  Now, we can properly initialize the cfm structure of the
+       mnt_map, so we can have access to the flags (e.g., SUN_MAP_SYNTAX)
+       inside each info_*.c file.
+       (mapc_find): takes 4rd arg (mntpt) and passes it to calls to
+       mapc_create.
+       (root_newmap): pass NULL as 4th arg (mntpt).
+
+       * amd/amfs_generic.c (amfs_parse_defaults): remove ugly hack to
+       initialize map cfm structure (including flags) so late.
+
+       * amd/autil.c (amfs_mkcacheref): pass mount point as 4th arg to
+       mapc_find.
+
+       * amd/amfs_root.c (amfs_root_mount): pass NULL as new 4th arg to
+       mapc_find.
+
+       * amd/amd.h: extern for mapc_find changed to pass the mount point.
+
        * libamu/xutil.c: debug_flags should be unsigned.
        (dbg_opt): fix comments for updated debug_flags, add "defaults".
        (debug_option): Don't allow "immutable" (D_IMMUTABLE) flags to be
index f115fa0d2b986f60ecc508be01c9ee4fade51e40..8967323c014e22764382a23b5d94550312835454 100644 (file)
--- a/amd/amd.h
+++ b/amd/amd.h
@@ -590,7 +590,7 @@ extern int  make_nfs_auth(void);
 extern void make_root_node(void);
 extern void map_flush_srvr(fserver *);
 extern void mapc_add_kv(mnt_map *, char *, char *);
-extern mnt_map *mapc_find(char *, char *, const char *);
+extern mnt_map *mapc_find(char *, char *, const char *, const char *);
 extern void mapc_free(opaque_t);
 extern int  mapc_keyiter(mnt_map *, key_fun, opaque_t);
 extern void mapc_reload(void);
index 795232268077bd4cabd9014974dd9a5504fe3626..09e8d4ec814a127d272526dda479041d5f7f9b09 100644 (file)
@@ -955,16 +955,7 @@ amfs_parse_defaults(am_node *mp, mntfs *mf, char *def_opts)
 
   /*
    * Find out if amd.conf overrode any map-specific /defaults.
-   *
-   * HACK ALERT: there's no easy way to find out what the map mount point is
-   * at this point, so I am forced to initialize the mnt_map->cfm field here
-   * for the first time, upon the very first search for a /defaults entry in
-   * this map.  This initialization is much better done in mapc_create(),
-   * but it's impossible to do that there with the current code structure.
    */
-  if (mm->cfm == NULL) {       /* then initialize it for first time */
-    mm->cfm = find_cf_map(mf->mf_mount);
-  }
   if (mm->cfm && mm->cfm->cfm_defaults) {
     dlog("map %s map_defaults override: %s", mf->mf_mount, mm->cfm->cfm_defaults);
     dflts = strdup(mm->cfm->cfm_defaults);
index e5b4457aeb5d80cffd6efcaa0c5dfaba958949f3..1f7530cb06f4ecf12ae3732fea6984da37bfe124 100644 (file)
@@ -92,7 +92,7 @@ static int
 amfs_root_mount(am_node *mp, mntfs *mf)
 {
   mf->mf_mount = strealloc(mf->mf_mount, pid_fsname);
-  mf->mf_private = (opaque_t) mapc_find(mf->mf_info, "", NULL);
+  mf->mf_private = (opaque_t) mapc_find(mf->mf_info, "", NULL, NULL);
   mf->mf_prfree = mapc_free;
 
   return 0;
index fc67117ade1d2e31c6ed6bc0220ad93fd8fb5695..2f06a996b4d53628d4e8f489e1ff45cdf4e3435b 100644 (file)
@@ -390,8 +390,10 @@ amfs_mkcacheref(mntfs *mf)
     cache = mf->mf_fo->opt_cache;
   else
     cache = "none";
-  mf->mf_private = (opaque_t) mapc_find(mf->mf_info, cache,
-                                    mf->mf_fo->opt_maptype);
+  mf->mf_private = (opaque_t) mapc_find(mf->mf_info,
+                                       cache,
+                                       mf->mf_fo->opt_maptype,
+                                       mf->mf_mount);
   mf->mf_prfree = mapc_free;
 }
 
index 578a2926031649914f173247dd030748e042ecd2..a159cb702d057b280af08226ebfaa38a3ef127f1 100644 (file)
@@ -595,7 +595,7 @@ mapc_reload_map(mnt_map *m)
  * Create a new map
  */
 static mnt_map *
-mapc_create(char *map, char *opt, const char *type)
+mapc_create(char *map, char *opt, const char *type, const char *mntpt)
 {
   mnt_map *m = ALLOC(struct mnt_map);
   map_type *mt;
@@ -695,8 +695,8 @@ mapc_create(char *map, char *opt, const char *type)
   m->refc = 1;
   m->wildcard = NULL;
   m->reloads = 0;
-  /* Unfortunately with current code structure, this cannot be initialized here */
-  m->cfm = NULL;
+  /* initialize per-map information (flags, etc.) */
+  m->cfm = find_cf_map(mntpt);
 
   /*
    * synchronize cache with reality
@@ -748,7 +748,7 @@ mapc_clear(mnt_map *m)
  * Find a map, or create one if it does not exist
  */
 mnt_map *
-mapc_find(char *map, char *opt, const char *maptype)
+mapc_find(char *map, char *opt, const char *maptype, const char *mntpt)
 {
   mnt_map *m;
 
@@ -762,7 +762,7 @@ mapc_find(char *map, char *opt, const char *maptype)
   ITER(m, mnt_map, &map_list_head)
     if (STREQ(m->map_name, map))
       return mapc_dup(m);
-  m = mapc_create(map, opt, maptype);
+  m = mapc_create(map, opt, maptype, mntpt);
   ins_que(&m->hdr, &map_list_head);
 
   return m;
@@ -1020,7 +1020,7 @@ root_newmap(const char *dir, const char *opts, const char *map, const cf_map_t *
    * First make sure we have a root map to talk about...
    */
   if (!root_map)
-    root_map = mapc_find(ROOT_MAP, "mapdefault", NULL);
+    root_map = mapc_find(ROOT_MAP, "mapdefault", NULL, NULL);
 
   /*
    * Then add the entry...