* amd/map.c (get_first_exported_ap, get_next_exported_ap): new
authorIon Badulescu <ib42@cs.columbia.edu>
Tue, 5 Aug 2003 04:27:44 +0000 (04:27 +0000)
committerIon Badulescu <ib42@cs.columbia.edu>
Tue, 5 Aug 2003 04:27:44 +0000 (04:27 +0000)
functions that facilitate iterating through the list of
mountpoints

* amd/amfs_union.c (amfs_union_mounted): use get_first_exported_ap
and get_next_exported_ap

* conf/autofs/autofs_solaris_v2_v3.c (autofs_unmount_2_req): ditto

ChangeLog
amd/amd.h
amd/amfs_union.c
amd/map.c
conf/autofs/autofs_solaris_v2_v3.c

index ed74879b302d79c42a3d6a9ec61a20a2617f1747..ad2dba22f85eae0ee79cffb1fae37d60e9e6aa7d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2003-08-05  Ion Badulescu  <ionut@moisil.badula.org>
+
+       * amd/map.c (get_first_exported_ap, get_next_exported_ap): new
+       functions that facilitate iterating through the list of
+       mountpoints
+
+       * amd/amfs_union.c (amfs_union_mounted): use get_first_exported_ap
+       and get_next_exported_ap
+
+       * conf/autofs/autofs_solaris_v2_v3.c (autofs_unmount_2_req): ditto
+
 2003-08-04  Erez Zadok  <ezk@ulkesh.dyn.optonline.net>
 
        * configure.in: check if system stores mount tables in files
index 4f95d73e90726890bdd25a1beb7ba97f4c514426..01cdbc516c7c6404905ef98190808f955b74c2be 100644 (file)
--- a/amd/amd.h
+++ b/amd/amd.h
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: amd.h,v 1.41 2003/08/01 19:16:57 ib42 Exp $
+ * $Id: amd.h,v 1.42 2003/08/05 04:27:45 ib42 Exp $
  *
  */
 
@@ -518,6 +518,8 @@ extern void am_mounted(am_node *);
 extern void mf_mounted(mntfs *mf);
 extern void am_unmounted(am_node *);
 extern am_node *get_exported_ap(int index);
+extern am_node *get_first_exported_ap(int *index);
+extern am_node *get_next_exported_ap(int *index);
 extern am_node *exported_ap_alloc(void);
 extern am_node *find_mf(mntfs *);
 extern am_node *next_map(int *);
index b2a680c046b0656f5ff6333f08d09da49d3e9f35..2fd8b9ce913268340d12844065601c32823d73cb 100644 (file)
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: amfs_union.c,v 1.14 2003/07/30 06:56:07 ib42 Exp $
+ * $Id: amfs_union.c,v 1.15 2003/08/05 04:27:45 ib42 Exp $
  *
  */
 
@@ -108,7 +108,8 @@ create_amfs_union_node(char *dir, voidp arg)
 static void
 amfs_union_mounted(mntfs *mf)
 {
-  int i;
+  int index;
+  am_node *mp;
 
   amfs_mkcacheref(mf);
 
@@ -116,10 +117,9 @@ amfs_union_mounted(mntfs *mf)
    * Having made the union mount point,
    * populate all the entries...
    */
-  for (i = 0; ;i++) {
-    am_node *mp = get_exported_ap(i);
-    if (!mp)
-      break;
+  for (mp = get_first_exported_ap(&index);
+       mp;
+       mp = get_next_exported_ap(&index)) {
     if (mp->am_mnt == mf) {
       /* return value from create_amfs_union_node is ignored by mapc_keyiter */
       (void) mapc_keyiter((mnt_map *) mp->am_mnt->mf_private,
index 8fddb507d4765441b3292cb34778937ce1d71dbd..8d291f46da2a9b8abd68bfa6b8f488e3f32335b9 100644 (file)
--- a/amd/map.c
+++ b/amd/map.c
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: map.c,v 1.42 2003/08/04 20:49:58 ib42 Exp $
+ * $Id: map.c,v 1.43 2003/08/05 04:27:45 ib42 Exp $
  *
  */
 
@@ -107,6 +107,30 @@ static void remove_am(am_node *mp);
 static am_node *get_root_ap(char *dir);
 
 
+/*
+ * Iterator functions for exported_ap[]
+ */
+am_node *
+get_first_exported_ap(int *index)
+{
+  *index = -1;
+  return get_next_exported_ap(index);
+}
+
+
+am_node *
+get_next_exported_ap(int *index)
+{
+  (*index)++;
+  while (exported_ap[*index] == NULL) {
+    if (*index >= exported_ap_size)
+      return NULL;
+    (*index)++;
+  }
+  return exported_ap[*index];
+}
+
+
 /*
  * Get exported_ap by index
  */
@@ -118,6 +142,7 @@ get_exported_ap(int index)
   return exported_ap[index];
 }
 
+
 /*
  * Resize exported_ap map
  */
index a39f4e9bbaf469c4566cd237bba560d2ff63491f..3118b1d42fcae569cf1a2355dc00c1c6638c34e3 100644 (file)
@@ -38,7 +38,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: autofs_solaris_v2_v3.c,v 1.33 2003/08/04 23:51:59 ib42 Exp $
+ * $Id: autofs_solaris_v2_v3.c,v 1.34 2003/08/05 04:27:46 ib42 Exp $
  *
  */
 
@@ -694,10 +694,9 @@ autofs_unmount_2_req(umntrequest *ul,
   res->status = 0;
 
 #ifdef HAVE_STRUCT_UMNTREQUEST_DEVID
-  for (mapno = 0; ; mapno++) {
-    mp = get_exported_ap(mapno);
-    if (!mp)
-      break;
+  for (mp = get_first_exported_ap(&mapno);
+       mp;
+       mp = get_next_exported_ap(&mapno)) {
     if (mp->am_dev == ul->devid &&
        mp->am_rdev == ul->rdevid)
       break;