Deleted Added
full compact
fstab.c (90045) fstab.c (113219)
1/*
2 * Copyright (c) 1980, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 21 unchanged lines hidden (view full) ---

30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char sccsid[] = "@(#)fstab.c 8.1 (Berkeley) 6/4/93";
36#endif /* LIBC_SCCS and not lint */
37#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1980, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 21 unchanged lines hidden (view full) ---

30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char sccsid[] = "@(#)fstab.c 8.1 (Berkeley) 6/4/93";
36#endif /* LIBC_SCCS and not lint */
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/lib/libc/gen/fstab.c 90045 2002-02-01 01:32:19Z obrien $");
38__FBSDID("$FreeBSD: head/lib/libc/gen/fstab.c 113219 2003-04-07 12:55:00Z mdodd $");
39
40#include "namespace.h"
41#include <sys/param.h>
42#include <sys/mount.h>
43#include <sys/stat.h>
44
45#include <errno.h>
46#include <fstab.h>
47#include <paths.h>
48#include <stdio.h>
49#include <stdlib.h>
50#include <string.h>
51#include <unistd.h>
52#include "un-namespace.h"
53
54static FILE *_fs_fp;
55static struct fstab _fs_fstab;
56static int LineNo = 0;
39
40#include "namespace.h"
41#include <sys/param.h>
42#include <sys/mount.h>
43#include <sys/stat.h>
44
45#include <errno.h>
46#include <fstab.h>
47#include <paths.h>
48#include <stdio.h>
49#include <stdlib.h>
50#include <string.h>
51#include <unistd.h>
52#include "un-namespace.h"
53
54static FILE *_fs_fp;
55static struct fstab _fs_fstab;
56static int LineNo = 0;
57static char *path_fstab;
58static char fstab_path[PATH_MAX];
59static int fsp_set = 0;
57
58static void error(int);
59static void fixfsfile(void);
60static int fstabscan(void);
61
60
61static void error(int);
62static void fixfsfile(void);
63static int fstabscan(void);
64
65void
66setfstab(const char *file)
67{
68
69 if (file == NULL) {
70 path_fstab = _PATH_FSTAB;
71 } else {
72 strncpy(fstab_path, file, PATH_MAX);
73 fstab_path[PATH_MAX - 1] = '\0';
74 path_fstab = fstab_path;
75 }
76 fsp_set = 1;
77
78 return;
79}
80
81const char *
82getfstab (void)
83{
84
85 if (fsp_set)
86 return (path_fstab);
87 else
88 return (_PATH_FSTAB);
89}
90
62static void
63fixfsfile()
64{
65 static char buf[sizeof(_PATH_DEV) + MNAMELEN];
66 struct stat sb;
67 struct statfs sf;
68
69 if (strcmp(_fs_fstab.fs_file, "/") != 0)

--- 151 unchanged lines hidden (view full) ---

221int
222setfsent()
223{
224 if (_fs_fp) {
225 rewind(_fs_fp);
226 LineNo = 0;
227 return(1);
228 }
91static void
92fixfsfile()
93{
94 static char buf[sizeof(_PATH_DEV) + MNAMELEN];
95 struct stat sb;
96 struct statfs sf;
97
98 if (strcmp(_fs_fstab.fs_file, "/") != 0)

--- 151 unchanged lines hidden (view full) ---

250int
251setfsent()
252{
253 if (_fs_fp) {
254 rewind(_fs_fp);
255 LineNo = 0;
256 return(1);
257 }
229 if ((_fs_fp = fopen(_PATH_FSTAB, "r")) != NULL) {
258 if (fsp_set == 0) {
259 if (issetugid())
260 setfstab(NULL);
261 else
262 setfstab(getenv("PATH_FSTAB"));
263 }
264 if ((_fs_fp = fopen(path_fstab, "r")) != NULL) {
230 LineNo = 0;
231 return(1);
232 }
233 error(errno);
234 return(0);
235}
236
237void
238endfsent()
239{
240 if (_fs_fp) {
241 (void)fclose(_fs_fp);
242 _fs_fp = NULL;
243 }
265 LineNo = 0;
266 return(1);
267 }
268 error(errno);
269 return(0);
270}
271
272void
273endfsent()
274{
275 if (_fs_fp) {
276 (void)fclose(_fs_fp);
277 _fs_fp = NULL;
278 }
279
280 fsp_set = 0;
244}
245
246static void
247error(err)
248 int err;
249{
250 char *p;
251 char num[30];
252
253 (void)_write(STDERR_FILENO, "fstab: ", 7);
281}
282
283static void
284error(err)
285 int err;
286{
287 char *p;
288 char num[30];
289
290 (void)_write(STDERR_FILENO, "fstab: ", 7);
254 (void)_write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1);
291 (void)_write(STDERR_FILENO, path_fstab, strlen(path_fstab));
255 (void)_write(STDERR_FILENO, ":", 1);
256 sprintf(num, "%d: ", LineNo);
257 (void)_write(STDERR_FILENO, num, strlen(num));
258 p = strerror(err);
259 (void)_write(STDERR_FILENO, p, strlen(p));
260 (void)_write(STDERR_FILENO, "\n", 1);
261}
292 (void)_write(STDERR_FILENO, ":", 1);
293 sprintf(num, "%d: ", LineNo);
294 (void)_write(STDERR_FILENO, num, strlen(num));
295 p = strerror(err);
296 (void)_write(STDERR_FILENO, p, strlen(p));
297 (void)_write(STDERR_FILENO, "\n", 1);
298}