Deleted Added
full compact
fstab.c (7327) fstab.c (11659)
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

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

41#include <stdlib.h>
42#include <string.h>
43#include <unistd.h>
44
45static FILE *_fs_fp;
46static struct fstab _fs_fstab;
47static int LineNo = 0;
48
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

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

41#include <stdlib.h>
42#include <string.h>
43#include <unistd.h>
44
45static FILE *_fs_fp;
46static struct fstab _fs_fstab;
47static int LineNo = 0;
48
49static error __P((int));
50static fstabscan __P((void));
49static void error __P((int));
50static int fstabscan __P((void));
51
51
52static
52static int
53fstabscan()
54{
55 char *cp, *p;
56#define MAXLINELENGTH 1024
57 static char line[MAXLINELENGTH];
58 char subline[MAXLINELENGTH];
59 int typexx;
60

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

72 _fs_fstab.fs_type = strsep(&p, ":\n");
73 if (_fs_fstab.fs_type) {
74 if (!strcmp(_fs_fstab.fs_type, FSTAB_XX))
75 continue;
76 _fs_fstab.fs_mntops = _fs_fstab.fs_type;
77 _fs_fstab.fs_vfstype =
78 strcmp(_fs_fstab.fs_type, FSTAB_SW) ?
79 "ufs" : "swap";
53fstabscan()
54{
55 char *cp, *p;
56#define MAXLINELENGTH 1024
57 static char line[MAXLINELENGTH];
58 char subline[MAXLINELENGTH];
59 int typexx;
60

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

72 _fs_fstab.fs_type = strsep(&p, ":\n");
73 if (_fs_fstab.fs_type) {
74 if (!strcmp(_fs_fstab.fs_type, FSTAB_XX))
75 continue;
76 _fs_fstab.fs_mntops = _fs_fstab.fs_type;
77 _fs_fstab.fs_vfstype =
78 strcmp(_fs_fstab.fs_type, FSTAB_SW) ?
79 "ufs" : "swap";
80 if (cp = strsep(&p, ":\n")) {
80 if ((cp = strsep(&p, ":\n")) != NULL) {
81 _fs_fstab.fs_freq = atoi(cp);
81 _fs_fstab.fs_freq = atoi(cp);
82 if (cp = strsep(&p, ":\n")) {
82 if ((cp = strsep(&p, ":\n")) != NULL) {
83 _fs_fstab.fs_passno = atoi(cp);
84 return(1);
85 }
86 }
87 }
88 goto bad;
89 }
90/* OLD_STYLE_FSTAB */

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

152 error(EFTYPE);
153 }
154 /* NOTREACHED */
155}
156
157struct fstab *
158getfsent()
159{
83 _fs_fstab.fs_passno = atoi(cp);
84 return(1);
85 }
86 }
87 }
88 goto bad;
89 }
90/* OLD_STYLE_FSTAB */

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

152 error(EFTYPE);
153 }
154 /* NOTREACHED */
155}
156
157struct fstab *
158getfsent()
159{
160 if (!_fs_fp && !setfsent() || !fstabscan())
160 if ((!_fs_fp && !setfsent()) || !fstabscan())
161 return((struct fstab *)NULL);
162 return(&_fs_fstab);
163}
164
165struct fstab *
166getfsspec(name)
167 register const char *name;
168{

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

179{
180 if (setfsent())
181 while (fstabscan())
182 if (!strcmp(_fs_fstab.fs_file, name))
183 return(&_fs_fstab);
184 return((struct fstab *)NULL);
185}
186
161 return((struct fstab *)NULL);
162 return(&_fs_fstab);
163}
164
165struct fstab *
166getfsspec(name)
167 register const char *name;
168{

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

179{
180 if (setfsent())
181 while (fstabscan())
182 if (!strcmp(_fs_fstab.fs_file, name))
183 return(&_fs_fstab);
184 return((struct fstab *)NULL);
185}
186
187int
187setfsent()
188{
189 if (_fs_fp) {
190 rewind(_fs_fp);
191 LineNo = 0;
192 return(1);
193 }
188setfsent()
189{
190 if (_fs_fp) {
191 rewind(_fs_fp);
192 LineNo = 0;
193 return(1);
194 }
194 if (_fs_fp = fopen(_PATH_FSTAB, "r")) {
195 if ((_fs_fp = fopen(_PATH_FSTAB, "r")) != NULL) {
195 LineNo = 0;
196 return(1);
197 }
198 error(errno);
199 return(0);
200}
201
202void
203endfsent()
204{
205 if (_fs_fp) {
206 (void)fclose(_fs_fp);
207 _fs_fp = NULL;
208 }
209}
210
196 LineNo = 0;
197 return(1);
198 }
199 error(errno);
200 return(0);
201}
202
203void
204endfsent()
205{
206 if (_fs_fp) {
207 (void)fclose(_fs_fp);
208 _fs_fp = NULL;
209 }
210}
211
211static
212static void
212error(err)
213 int err;
214{
215 char *p;
216 char num[30];
217
218 (void)write(STDERR_FILENO, "fstab: ", 7);
219 (void)write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1);
220 (void)write(STDERR_FILENO, ":", 1);
221 sprintf(num, "%d: ", LineNo);
222 (void)write(STDERR_FILENO, num, strlen(num));
223 p = strerror(err);
224 (void)write(STDERR_FILENO, p, strlen(p));
225 (void)write(STDERR_FILENO, "\n", 1);
226}
213error(err)
214 int err;
215{
216 char *p;
217 char num[30];
218
219 (void)write(STDERR_FILENO, "fstab: ", 7);
220 (void)write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1);
221 (void)write(STDERR_FILENO, ":", 1);
222 sprintf(num, "%d: ", LineNo);
223 (void)write(STDERR_FILENO, num, strlen(num));
224 p = strerror(err);
225 (void)write(STDERR_FILENO, p, strlen(p));
226 (void)write(STDERR_FILENO, "\n", 1);
227}