diff options
Diffstat (limited to 'amd/amq_subr.c')
-rw-r--r-- | amd/amq_subr.c | 155 |
1 files changed, 136 insertions, 19 deletions
diff --git a/amd/amq_subr.c b/amd/amq_subr.c index 79ecafc3d9b3..878361105652 100644 --- a/amd/amq_subr.c +++ b/amd/amq_subr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2014 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -16,11 +16,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgment: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -80,16 +76,68 @@ amqproc_mnttree_1_svc(voidp argp, struct svc_req *rqstp) /* * Unmount a single node */ -voidp +int * amqproc_umnt_1_svc(voidp argp, struct svc_req *rqstp) { - static char res; + static int res = AMQ_UMNT_OK; am_node *mp = find_ap(*(char **) argp); if (mp) forcibly_timeout_mp(mp); - return (voidp) &res; + return &res; +} + + +/* + * Synchronously unmount a single node - parent side. + */ +int * +amqproc_sync_umnt_1_svc_parent(voidp argp, struct svc_req *rqstp) +{ + amqproc_umnt_1_svc(argp, rqstp); + return NULL; +} + + +/* + * Synchronously unmount a single node - child side. + */ +amq_sync_umnt * +amqproc_sync_umnt_1_svc_child(voidp argp, struct svc_req *rqstp) +{ + static amq_sync_umnt rv; + amq_sync_umnt buf; + ssize_t n; + + am_node *mp = find_ap(*(char **) argp); + + memset(&rv, 0, sizeof(rv)); + rv.au_etype = AMQ_UMNT_READ; + if (mp && mp->am_fd[0] >= 0) { + n = read(mp->am_fd[0], &buf, sizeof(buf)); + if (n == sizeof(buf)) + rv = buf; + } + return &rv; +} + + +/* + * Synchronously unmount a single node - use if we can't fork (asynchronous). + */ +amq_sync_umnt * +amqproc_sync_umnt_1_svc_async(voidp argp, struct svc_req *rqstp) +{ + static amq_sync_umnt rv; + + memset(&rv, 0, sizeof(rv)); + rv.au_etype = AMQ_UMNT_FORK; + rv.au_errno = errno; + + amqproc_umnt_1_svc(argp, rqstp); + + return &rv; } @@ -170,6 +218,12 @@ amqproc_getmntfs_1_svc(voidp argp, struct svc_req *rqstp) return (amq_mount_info_list *) ((void *)&mfhead); /* XXX */ } +extern qelem map_list_head; +amq_map_info_list * +amqproc_getmapinfo_1_svc(voidp argp, struct svc_req *rqstp) +{ + return (amq_map_info_list *) ((void *)&map_list_head); /* XXX */ +} amq_string * amqproc_getvers_1_svc(voidp argp, struct svc_req *rqstp) @@ -218,11 +272,11 @@ amqproc_pawd_1_svc(voidp argp, struct svc_req *rqstp) for (mp = get_first_exported_ap(&index); mp; mp = get_next_exported_ap(&index)) { - if (STREQ(mp->am_mnt->mf_ops->fs_type, "toplvl")) + if (STREQ(mp->am_al->al_mnt->mf_ops->fs_type, "toplvl")) continue; - if (STREQ(mp->am_mnt->mf_ops->fs_type, "auto")) + if (STREQ(mp->am_al->al_mnt->mf_ops->fs_type, "auto")) continue; - mountpoint = (mp->am_link ? mp->am_link : mp->am_mnt->mf_mount); + mountpoint = (mp->am_link ? mp->am_link : mp->am_al->al_mnt->mf_mount); len = strlen(mountpoint); if (len == 0) continue; @@ -277,16 +331,16 @@ xdr_amq_mount_tree_node(XDR *xdrs, amq_mount_tree *objp) am_node *mp = (am_node *) objp; long mtime; - if (!xdr_amq_string(xdrs, &mp->am_mnt->mf_info)) { + if (!xdr_amq_string(xdrs, &mp->am_al->al_mnt->mf_info)) { return (FALSE); } if (!xdr_amq_string(xdrs, &mp->am_path)) { return (FALSE); } - if (!xdr_amq_string(xdrs, mp->am_link ? &mp->am_link : &mp->am_mnt->mf_mount)) { + if (!xdr_amq_string(xdrs, mp->am_link ? &mp->am_link : &mp->am_al->al_mnt->mf_mount)) { return (FALSE); } - if (!xdr_amq_string(xdrs, &mp->am_mnt->mf_ops->fs_type)) { + if (!xdr_amq_string(xdrs, &mp->am_al->al_mnt->mf_ops->fs_type)) { return (FALSE); } mtime = mp->am_stats.s_mtime; @@ -412,16 +466,15 @@ xdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp) } - -/* - * Compute length of list - */ bool_t xdr_amq_mount_info_qelem(XDR *xdrs, qelem *qhead) { mntfs *mf; u_int len = 0; + /* + * Compute length of list + */ for (mf = AM_LAST(mntfs, qhead); mf != HEAD(mntfs, qhead); mf = PREV(mntfs, mf)) { if (!(mf->mf_fsflags & FS_AMQINFO)) continue; @@ -468,6 +521,70 @@ xdr_amq_mount_info_qelem(XDR *xdrs, qelem *qhead) return (TRUE); } +bool_t +xdr_amq_map_info_qelem(XDR *xdrs, qelem *qhead) +{ + mnt_map *m; + u_int len = 0; + int x; + char *n; + + /* + * Compute length of list + */ + ITER(m, mnt_map, qhead) { + len++; + } + + if (!xdr_u_int(xdrs, &len)) + return (FALSE); + + /* + * Send individual data items + */ + ITER(m, mnt_map, qhead) { + if (!xdr_amq_string(xdrs, &m->map_name)) { + return (FALSE); + } + + n = m->wildcard ? m->wildcard : ""; + if (!xdr_amq_string(xdrs, &n)) { + return (FALSE); + } + + if (!xdr_long(xdrs, &m->modify)) { + return (FALSE); + } + + x = m->flags; + if (!xdr_int(xdrs, &x)) { + return (FALSE); + } + + x = m->nentries; + if (!xdr_int(xdrs, &x)) { + return (FALSE); + } + + x = m->reloads; + if (!xdr_int(xdrs, &x)) { + return (FALSE); + } + + if (!xdr_int(xdrs, &m->refc)) { + return (FALSE); + } + + if (m->isup) + x = (*m->isup)(m, m->map_name); + else + x = -1; + if (!xdr_int(xdrs, &x)) { + return (FALSE); + } + } + return (TRUE); +} bool_t xdr_pri_free(XDRPROC_T_TYPE xdr_args, caddr_t args_ptr) |