From 279f79460f58779e1f53db18e6b5226fd593cf62 Mon Sep 17 00:00:00 2001 From: Ion Badulescu Date: Tue, 5 Aug 2003 04:27:44 +0000 Subject: [PATCH] * 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 --- ChangeLog | 11 +++++++++++ amd/amd.h | 4 +++- amd/amfs_union.c | 12 ++++++------ amd/map.c | 27 ++++++++++++++++++++++++++- conf/autofs/autofs_solaris_v2_v3.c | 9 ++++----- 5 files changed, 50 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index ed74879..ad2dba2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2003-08-05 Ion Badulescu + + * 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 * configure.in: check if system stores mount tables in files diff --git a/amd/amd.h b/amd/amd.h index 4f95d73..01cdbc5 100644 --- 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 *); diff --git a/amd/amfs_union.c b/amd/amfs_union.c index b2a680c..2fd8b9c 100644 --- a/amd/amfs_union.c +++ b/amd/amfs_union.c @@ -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, diff --git a/amd/map.c b/amd/map.c index 8fddb50..8d291f4 100644 --- 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 */ diff --git a/conf/autofs/autofs_solaris_v2_v3.c b/conf/autofs/autofs_solaris_v2_v3.c index a39f4e9..3118b1d 100644 --- a/conf/autofs/autofs_solaris_v2_v3.c +++ b/conf/autofs/autofs_solaris_v2_v3.c @@ -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; -- 2.43.0