1 /*
2 * Copyright (c) 1989 Jan-Simon Pendry
3 * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
4 * Copyright (c) 1989, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Jan-Simon Pendry at Imperial College, London.
9 *
10 * %sccs.include.redist.c%
11 *
12 * @(#)mtab.c 8.1 (Berkeley) 06/06/93
13 *
14 * $Id: mtab.c,v 5.2.2.1 1992/02/09 15:08:45 jsp beta $
15 *
16 */
17
18 #include "am.h"
19
20 /*
21 * Firewall /etc/mtab entries
22 */
23 void mnt_free P((struct mntent *mp));
mnt_free(mp)24 void mnt_free(mp)
25 struct mntent *mp;
26 {
27 free(mp->mnt_fsname);
28 free(mp->mnt_dir);
29 free(mp->mnt_type);
30 free(mp->mnt_opts);
31 free((voidp) mp);
32 }
33
34 /*
35 * Discard memory allocated for mount list
36 */
37 void discard_mntlist P((mntlist *mp));
discard_mntlist(mp)38 void discard_mntlist(mp)
39 mntlist *mp;
40 {
41 mntlist *mp2;
42
43 while (mp2 = mp) {
44 mp = mp->mnext;
45 if (mp2->mnt)
46 mnt_free(mp2->mnt);
47 free((voidp) mp2);
48 }
49 }
50
51 /*
52 * Throw away a mount list
53 */
54 void free_mntlist P((mntlist *mp));
free_mntlist(mp)55 void free_mntlist(mp)
56 mntlist *mp;
57 {
58 discard_mntlist(mp);
59 unlock_mntlist();
60 }
61
62 /*
63 * Utility routine which determines the value of a
64 * numeric option in the mount options (such as port=%d).
65 * Returns 0 if the option is not specified.
66 */
67 int hasmntval P((struct mntent *mnt, char *opt));
hasmntval(mnt,opt)68 int hasmntval(mnt, opt)
69 struct mntent *mnt;
70 char *opt;
71 {
72 char *str = hasmntopt(mnt, opt);
73 if (str) {
74 char *eq = strchr(str, '=');
75 if (eq)
76 return atoi(eq+1);
77 else
78 plog(XLOG_USER, "bad numeric option \"%s\" in \"%s\"", opt, str);
79 }
80
81 return 0;
82 }
83