Annotation of 43BSDReno/usr.sbin/amd/config/mtab_aix.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * $Id: mtab_aix.c,v 5.2 90/06/23 22:20:36 jsp Rel $
                      3:  *
                      4:  * Copyright (c) 1990 Jan-Simon Pendry
                      5:  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
                      6:  * Copyright (c) 1990 The Regents of the University of California.
                      7:  * All rights reserved.
                      8:  *
                      9:  * This code is derived from software contributed to Berkeley by
                     10:  * Jan-Simon Pendry at Imperial College, London.
                     11:  *
                     12:  * Redistribution and use in source and binary forms are permitted provided
                     13:  * that: (1) source distributions retain this entire copyright notice and
                     14:  * comment, and (2) distributions including binaries display the following
                     15:  * acknowledgement:  ``This product includes software developed by the
                     16:  * University of California, Berkeley and its contributors'' in the
                     17:  * documentation or other materials provided with the distribution and in
                     18:  * all advertising materials mentioning features or use of this software.
                     19:  * Neither the name of the University nor the names of its contributors may
                     20:  * be used to endorse or promote products derived from this software without
                     21:  * specific prior written permission.
                     22:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     23:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     24:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     25:  *
                     26:  *     @(#)mtab_aix.c  5.1 (Berkeley) 6/29/90
                     27:  */
                     28: 
                     29: #include "am.h"
                     30: 
                     31: #ifdef READ_MTAB_AIX3_STYLE
                     32: 
                     33: #include <sys/mntctl.h>
                     34: #include <sys/vmount.h>
                     35: 
                     36: static struct mntent *mnt_dup(mp)
                     37: struct vmount *mp;
                     38: {
                     39:        struct mntent *new_mp = ALLOC(mntent);
                     40: 
                     41:        char *ty;
                     42:        new_mp->mnt_fsname = strdup(vmt2dataptr(mp, VMT_OBJECT));
                     43:        new_mp->mnt_dir = strdup(vmt2dataptr(mp, VMT_STUB));
                     44:        new_mp->mnt_opts = strdup(vmt2dataptr(mp, VMT_ARGS));
                     45:        switch (mp->vmt_gfstype) {
                     46:        case MNT_JFS:  ty = MTAB_TYPE_UFS; break;
                     47:        case MNT_NFS:  ty = MTAB_TYPE_NFS; break;
                     48:        default:  ty = "unknown"; break;
                     49:        }
                     50:        new_mp->mnt_type = strdup(ty);
                     51:        new_mp->mnt_passno = mp->vmt_vfsnumber;
                     52:        new_mp->mnt_freq = 0;
                     53: 
                     54:        return new_mp;
                     55: }
                     56: 
                     57: /*
                     58:  * Read a mount table into memory
                     59:  */
                     60: mntlist *read_mtab(fs)
                     61: char *fs;
                     62: {
                     63:        mntlist **mpp, *mhp;
                     64: 
                     65:        int i;
                     66:        char *mntinfo = 0, *cp;
                     67:        struct vmount *vp;
                     68:        int ret;
                     69: 
                     70:        /*
                     71:         * First figure out size of mount table
                     72:         * and allocate space for a copy...
                     73:         * Then get mount table for real.
                     74:         */
                     75:        ret = mntctl(MCTL_QUERY, sizeof(i), &i);
                     76:        if (ret == 0) {
                     77:                mntinfo = xmalloc(i);
                     78:                ret = mntctl(MCTL_QUERY, i, mntinfo);
                     79:        }
                     80: 
                     81:        if (ret <= 0) {
                     82:                plog(XLOG_ERROR, "mntctl: %m");
                     83:                goto out;
                     84:        }
                     85: #ifdef DEBUG
                     86:        /*dlog("mntctl returns %d structures", ret);*/
                     87: #endif /* DEBUG */
                     88: 
                     89:        mpp = &mhp;
                     90:        for (i = 0, cp = mntinfo; i < ret; i++, cp += vp->vmt_length) {
                     91:                vp = (struct vmount *) cp;
                     92: 
                     93:                /*
                     94:                 * Allocate a new slot
                     95:                 */
                     96:                *mpp = ALLOC(mntlist);
                     97: 
                     98:                /*
                     99:                 * Copy the data returned by mntctl
                    100:                 */
                    101:                (*mpp)->mnt = mnt_dup(vp);
                    102: 
                    103:                /*
                    104:                 * Move to next pointer
                    105:                 */
                    106:                mpp = &(*mpp)->mnext;
                    107:        }
                    108: 
                    109:        *mpp = 0;
                    110: 
                    111: out:
                    112:        if (mntinfo)
                    113:                free(mntinfo);
                    114:        return mhp;
                    115: }
                    116: 
                    117: #endif /* READ_MTAB_AIX3_STYLE */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.