|
|
1.1 root 1: /*
2: * $Id: mtab_bsd.c,v 5.2 90/06/23 22:20:40 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_bsd.c 5.1 (Berkeley) 6/29/90
27: */
28:
29: #include "am.h"
30:
31: #ifdef READ_MTAB_BSD_STYLE
32:
33: #include <sys/mount.h>
34:
35: static struct mntent *mnt_dup(mp)
36: struct statfs *mp;
37: {
38: struct mntent *new_mp = ALLOC(mntent);
39: char *ty;
40:
41: new_mp->mnt_fsname = strdup(mp->f_mntfromname);
42: new_mp->mnt_dir = strdup(mp->f_mntonname);
43: switch (mp->f_type) {
44: case MOUNT_UFS: ty = MTAB_TYPE_UFS; break;
45: case MOUNT_NFS: ty = MTAB_TYPE_NFS; break;
46: case MOUNT_MFS: ty = MTAB_TYPE_MFS; break;
47: default: ty = "unknown"; break;
48: }
49: new_mp->mnt_type = strdup(ty);
50: new_mp->mnt_opts = strdup("unset");
51: new_mp->mnt_freq = 0;
52: new_mp->mnt_passno = 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: struct statfs *mntbufp, *mntp;
65:
66: int nloc = getmntinfo(&mntbufp, MNT_NOWAIT);
67:
68: if (nloc == 0) {
69: plog(XLOG_ERROR, "Can't read mount table");
70: return 0;
71: }
72:
73: mpp = &mhp;
74: for (mntp = mntbufp; mntp < mntbufp + nloc; mntp++) {
75: /*
76: * Allocate a new slot
77: */
78: *mpp = ALLOC(mntlist);
79:
80: /*
81: * Copy the data returned by getmntent
82: */
83: (*mpp)->mnt = mnt_dup(mntp);
84:
85: /*
86: * Move to next pointer
87: */
88: mpp = &(*mpp)->mnext;
89: }
90:
91: return mhp;
92: }
93:
94: #endif /* READ_MTAB_BSD_STYLE */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.