| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | $NetBSD: patch-ap,v 1.12 2007/07/08 22:22:29 minskim Exp $ | | 1 | $NetBSD: patch-ap,v 1.13 2008/11/09 14:32:28 schwarz Exp $ |
2 | | | 2 | |
3 | --- src/mntent_compat.c++.orig Sun Jul 8 08:16:38 2007 | | 3 | --- src/mntent_compat.c++.orig Sun Jul 8 08:16:38 2007 |
4 | +++ src/mntent_compat.c++ | | 4 | +++ src/mntent_compat.c++ |
5 | @@ -0,0 +1,193 @@ | | 5 | @@ -0,0 +1,193 @@ |
6 | +/* | | 6 | +/* |
7 | + * Copyright (c) 1980, 1989, 1993, 1994 | | 7 | + * Copyright (c) 1980, 1989, 1993, 1994 |
8 | + * The Regents of the University of California. All rights reserved. | | 8 | + * The Regents of the University of California. All rights reserved. |
9 | + * Copyright (c) 2001 | | 9 | + * Copyright (c) 2001 |
10 | + * David Rufino <daverufino@btinternet.com> | | 10 | + * David Rufino <daverufino@btinternet.com> |
11 | + * | | 11 | + * |
12 | + * Redistribution and use in source and binary forms, with or without | | 12 | + * Redistribution and use in source and binary forms, with or without |
13 | + * modification, are permitted provided that the following conditions | | 13 | + * modification, are permitted provided that the following conditions |
14 | + * are met: | | 14 | + * are met: |
| @@ -38,27 +38,27 @@ $NetBSD: patch-ap,v 1.12 2007/07/08 22:2 | | | @@ -38,27 +38,27 @@ $NetBSD: patch-ap,v 1.12 2007/07/08 22:2 |
38 | + * SUCH DAMAGE. | | 38 | + * SUCH DAMAGE. |
39 | + */ | | 39 | + */ |
40 | + | | 40 | + |
41 | +/* most of this was ripped from the mount(3) source */ | | 41 | +/* most of this was ripped from the mount(3) source */ |
42 | + | | 42 | + |
43 | +#include "config.h" | | 43 | +#include "config.h" |
44 | +#include "fam-mntent.h" | | 44 | +#include "fam-mntent.h" |
45 | +#if !defined(HAVE_MNTENT_H) && !defined(HAVE_SYS_MNTTAB_H) | | 45 | +#if !defined(HAVE_MNTENT_H) && !defined(HAVE_SYS_MNTTAB_H) |
46 | +#include <stdlib.h> | | 46 | +#include <stdlib.h> |
47 | +#include <string.h> | | 47 | +#include <string.h> |
48 | +#include <sys/param.h> | | 48 | +#include <sys/param.h> |
49 | +#include <sys/ucred.h> | | 49 | +#include <sys/ucred.h> |
50 | +#include <sys/mount.h> | | 50 | +#include <sys/mount.h> |
51 | +#if defined(HAVE_SYS_STATVFS_H) && !defined(__APPLE__) && !defined(__DragonFly__) && !defined(__FreeBSD__) | | 51 | +#if defined(HAVE_SYS_STATVFS_H) && !defined(__APPLE__) && !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) |
52 | +# include <sys/statvfs.h> | | 52 | +# include <sys/statvfs.h> |
53 | +#endif | | 53 | +#endif |
54 | + | | 54 | + |
55 | +static int pos = -1; | | 55 | +static int pos = -1; |
56 | +static int mntsize = -1; | | 56 | +static int mntsize = -1; |
57 | +static struct mntent _mntent; | | 57 | +static struct mntent _mntent; |
58 | + | | 58 | + |
59 | +char * | | 59 | +char * |
60 | +hasmntopt (const struct mntent *mnt, const char *option) | | 60 | +hasmntopt (const struct mntent *mnt, const char *option) |
61 | +{ | | 61 | +{ |
62 | + int found; | | 62 | + int found; |
63 | + char *opt, *optbuf; | | 63 | + char *opt, *optbuf; |
64 | + | | 64 | + |
| @@ -136,58 +136,58 @@ $NetBSD: patch-ap,v 1.12 2007/07/08 22:2 | | | @@ -136,58 +136,58 @@ $NetBSD: patch-ap,v 1.12 2007/07/08 22:2 |
136 | + if (flags & MNT_SYMPERM) res = catopt(res, "symperm"); | | 136 | + if (flags & MNT_SYMPERM) res = catopt(res, "symperm"); |
137 | +#endif | | 137 | +#endif |
138 | +#ifdef MNT_NODEVMTIME | | 138 | +#ifdef MNT_NODEVMTIME |
139 | + if (flags & MNT_NODEVMTIME) res = catopt(res, "nodevmtime"); | | 139 | + if (flags & MNT_NODEVMTIME) res = catopt(res, "nodevmtime"); |
140 | +#endif | | 140 | +#endif |
141 | +#ifdef MNT_SOFTDEP | | 141 | +#ifdef MNT_SOFTDEP |
142 | + if (flags & MNT_SOFTDEP) res = catopt(res, "softdep"); | | 142 | + if (flags & MNT_SOFTDEP) res = catopt(res, "softdep"); |
143 | +#endif | | 143 | +#endif |
144 | + | | 144 | + |
145 | + return res; | | 145 | + return res; |
146 | +} | | 146 | +} |
147 | + | | 147 | + |
148 | +static struct mntent * | | 148 | +static struct mntent * |
149 | +#if defined(HAVE_SYS_STATVFS_H) && !defined(__APPLE__) && !defined(__DragonFly__) && !defined(__FreeBSD__) | | 149 | +#if defined(HAVE_SYS_STATVFS_H) && !defined(__APPLE__) && !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) |
150 | +statfs_to_mntent (struct statvfs *mntbuf) | | 150 | +statfs_to_mntent (struct statvfs *mntbuf) |
151 | +#else | | 151 | +#else |
152 | +statfs_to_mntent (struct statfs *mntbuf) | | 152 | +statfs_to_mntent (struct statfs *mntbuf) |
153 | +#endif | | 153 | +#endif |
154 | +{ | | 154 | +{ |
155 | + static char opts_buf[40], *tmp; | | 155 | + static char opts_buf[40], *tmp; |
156 | + | | 156 | + |
157 | + _mntent.mnt_fsname = mntbuf->f_mntfromname; | | 157 | + _mntent.mnt_fsname = mntbuf->f_mntfromname; |
158 | + _mntent.mnt_dir = mntbuf->f_mntonname; | | 158 | + _mntent.mnt_dir = mntbuf->f_mntonname; |
159 | + _mntent.mnt_type = mntbuf->f_fstypename; | | 159 | + _mntent.mnt_type = mntbuf->f_fstypename; |
160 | +#if defined(HAVE_SYS_STATVFS_H) && !defined(__APPLE__) && !defined(__DragonFly__) && !defined(__FreeBSD__) | | 160 | +#if defined(HAVE_SYS_STATVFS_H) && !defined(__APPLE__) && !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) |
161 | + tmp = flags2opts (mntbuf->f_flag); | | 161 | + tmp = flags2opts (mntbuf->f_flag); |
162 | +#else | | 162 | +#else |
163 | + tmp = flags2opts (mntbuf->f_flags); | | 163 | + tmp = flags2opts (mntbuf->f_flags); |
164 | +#endif | | 164 | +#endif |
165 | + if (tmp) { | | 165 | + if (tmp) { |
166 | + opts_buf[sizeof(opts_buf)-1] = '\0'; | | 166 | + opts_buf[sizeof(opts_buf)-1] = '\0'; |
167 | + strncpy (opts_buf, tmp, sizeof(opts_buf)-1); | | 167 | + strncpy (opts_buf, tmp, sizeof(opts_buf)-1); |
168 | + free (tmp); | | 168 | + free (tmp); |
169 | + } else { | | 169 | + } else { |
170 | + *opts_buf = '\0'; | | 170 | + *opts_buf = '\0'; |
171 | + } | | 171 | + } |
172 | + _mntent.mnt_opts = opts_buf; | | 172 | + _mntent.mnt_opts = opts_buf; |
173 | + _mntent.mnt_freq = _mntent.mnt_passno = 0; | | 173 | + _mntent.mnt_freq = _mntent.mnt_passno = 0; |
174 | + return (&_mntent); | | 174 | + return (&_mntent); |
175 | +} | | 175 | +} |
176 | + | | 176 | + |
177 | +struct mntent * | | 177 | +struct mntent * |
178 | +getmntent (FILE *fp) | | 178 | +getmntent (FILE *fp) |
179 | +{ | | 179 | +{ |
180 | +#if defined(HAVE_SYS_STATVFS_H) && !defined(__APPLE__) && !defined(__DragonFly__) && !defined(__FreeBSD__) | | 180 | +#if defined(HAVE_SYS_STATVFS_H) && !defined(__APPLE__) && !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) |
181 | + static struct statvfs *mntbuf; | | 181 | + static struct statvfs *mntbuf; |
182 | +#else | | 182 | +#else |
183 | + static struct statfs *mntbuf; | | 183 | + static struct statfs *mntbuf; |
184 | +#endif | | 184 | +#endif |
185 | + | | 185 | + |
186 | + if (pos == -1 || mntsize == -1) | | 186 | + if (pos == -1 || mntsize == -1) |
187 | + mntsize = getmntinfo (&mntbuf, MNT_NOWAIT); | | 187 | + mntsize = getmntinfo (&mntbuf, MNT_NOWAIT); |
188 | + | | 188 | + |
189 | + ++pos; | | 189 | + ++pos; |
190 | + if (pos == mntsize) { | | 190 | + if (pos == mntsize) { |
191 | + pos = mntsize = -1; | | 191 | + pos = mntsize = -1; |
192 | + return (NULL); | | 192 | + return (NULL); |
193 | + } | | 193 | + } |