2001-01-26 20:37:16 +03:00
|
|
|
/* $NetBSD: main.c,v 1.36 2001/01/26 17:37:16 thorpej Exp $ */
|
1995-03-18 17:54:19 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-06-08 22:57:30 +04:00
|
|
|
* Copyright (c) 1980, 1986, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1997-09-14 18:36:29 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifndef lint
|
1997-09-14 18:36:29 +04:00
|
|
|
__COPYRIGHT("@(#) Copyright (c) 1980, 1986, 1993\n\
|
|
|
|
The Regents of the University of California. All rights reserved.\n");
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#ifndef lint
|
1995-03-18 17:54:19 +03:00
|
|
|
#if 0
|
1997-09-16 20:44:43 +04:00
|
|
|
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
|
1995-03-18 17:54:19 +03:00
|
|
|
#else
|
2001-01-26 20:37:16 +03:00
|
|
|
__RCSID("$NetBSD: main.c,v 1.36 2001/01/26 17:37:16 thorpej Exp $");
|
1995-03-18 17:54:19 +03:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
1994-04-25 22:23:19 +04:00
|
|
|
#include <sys/time.h>
|
1994-06-08 22:57:30 +04:00
|
|
|
#include <sys/mount.h>
|
1997-11-02 04:42:44 +03:00
|
|
|
#include <sys/resource.h>
|
1997-09-16 20:44:43 +04:00
|
|
|
|
1994-06-08 22:57:30 +04:00
|
|
|
#include <ufs/ufs/dinode.h>
|
1998-03-01 05:20:01 +03:00
|
|
|
#include <ufs/ufs/ufsmount.h>
|
1994-06-08 22:57:30 +04:00
|
|
|
#include <ufs/ffs/fs.h>
|
1998-03-18 20:01:23 +03:00
|
|
|
#include <ufs/ffs/ffs_extern.h>
|
1997-09-16 20:44:43 +04:00
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <err.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <fstab.h>
|
|
|
|
#include <string.h>
|
1998-04-01 19:55:43 +04:00
|
|
|
#include <time.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdio.h>
|
1997-09-20 10:16:23 +04:00
|
|
|
#include <stdlib.h>
|
1994-12-05 23:15:31 +03:00
|
|
|
#include <unistd.h>
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
#include "fsck.h"
|
1994-12-05 23:15:31 +03:00
|
|
|
#include "extern.h"
|
1996-09-28 02:45:10 +04:00
|
|
|
#include "fsutil.h"
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
int returntosingle;
|
1996-10-22 20:35:04 +04:00
|
|
|
|
1996-09-23 20:18:31 +04:00
|
|
|
int main __P((int, char *[]));
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1996-10-22 20:35:04 +04:00
|
|
|
static int argtoi __P((int, char *, char *, int));
|
1998-07-27 00:32:42 +04:00
|
|
|
static int checkfilesys __P((const char *, char *, long, int));
|
1996-10-22 20:35:04 +04:00
|
|
|
static void usage __P((void));
|
|
|
|
|
|
|
|
|
1994-12-05 23:15:31 +03:00
|
|
|
int
|
1993-03-21 12:45:37 +03:00
|
|
|
main(argc, argv)
|
|
|
|
int argc;
|
|
|
|
char *argv[];
|
|
|
|
{
|
1997-11-02 04:42:44 +03:00
|
|
|
struct rlimit r;
|
1993-03-21 12:45:37 +03:00
|
|
|
int ch;
|
1996-09-23 20:18:31 +04:00
|
|
|
int ret = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-11-02 04:42:44 +03:00
|
|
|
if (getrlimit(RLIMIT_DATA, &r) == 0) {
|
|
|
|
r.rlim_cur = r.rlim_max;
|
|
|
|
(void) setrlimit(RLIMIT_DATA, &r);
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
sync();
|
1995-04-13 01:24:07 +04:00
|
|
|
skipclean = 1;
|
1998-03-18 20:01:23 +03:00
|
|
|
markclean = 1;
|
|
|
|
endian = 0;
|
|
|
|
while ((ch = getopt(argc, argv, "B:b:c:dfm:npy")) != -1) {
|
1993-03-21 12:45:37 +03:00
|
|
|
switch (ch) {
|
1998-03-18 20:01:23 +03:00
|
|
|
case 'B':
|
|
|
|
if (strcmp(optarg, "be") == 0)
|
|
|
|
endian = BIG_ENDIAN;
|
|
|
|
else if (strcmp(optarg, "le") == 0)
|
|
|
|
endian = LITTLE_ENDIAN;
|
|
|
|
else usage();
|
|
|
|
break;
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
case 'b':
|
1995-04-13 01:24:07 +04:00
|
|
|
skipclean = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
bflag = argtoi('b', "number", optarg, 10);
|
|
|
|
printf("Alternate super block location: %d\n", bflag);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'c':
|
1995-04-13 01:24:07 +04:00
|
|
|
skipclean = 0;
|
1994-06-08 22:57:30 +04:00
|
|
|
cvtlevel = argtoi('c', "conversion level", optarg, 10);
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1994-06-08 22:57:30 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
case 'd':
|
|
|
|
debug++;
|
|
|
|
break;
|
|
|
|
|
implement a 'force check' flag, '-f'. I used the SunOS name, but the Digital
semantics. now:
(1) dirty file systems will always be checked; nothing new there.
(2) if not '-f' clean file systems will _NEVER_ be checked,
i.e. they won't be checked even if -p isn't specified. This
allows one to 'fsck -p ; fsck' to preen, then clean up
anything that 'fsck -p' barfs on, without waiting for the
clean file systems to be checked again.
(3) if '-f' clean file systems will ALWAYS be checked. This
allows people to put 'fsck -fp' into /etc/rc on systems
where they're leery of the FS clean flag state, need
the extra reliability, and can afford time 'wasted'
in checks.
The assumption made here is that if a file system is marked clean, it
_IS CLEAN_, really, and shouldn't be checked unless fsck is explicitly
told to (with -f). This should be a valid assumption, but may not be in
the presence of file system bugs. Documentation updated to note '-f'.
1995-07-12 05:49:16 +04:00
|
|
|
case 'f':
|
|
|
|
skipclean = 0;
|
|
|
|
break;
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
case 'm':
|
|
|
|
lfmode = argtoi('m', "mode", optarg, 8);
|
|
|
|
if (lfmode &~ 07777)
|
1997-09-16 20:44:43 +04:00
|
|
|
errx(EEXIT, "bad mode to -m: %o", lfmode);
|
1993-03-21 12:45:37 +03:00
|
|
|
printf("** lost+found creation mode %o\n", lfmode);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'n':
|
|
|
|
nflag++;
|
|
|
|
yflag = 0;
|
|
|
|
break;
|
|
|
|
|
1996-10-22 20:35:04 +04:00
|
|
|
case 'p':
|
|
|
|
preen++;
|
|
|
|
break;
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
case 'y':
|
|
|
|
yflag++;
|
|
|
|
nflag = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1996-10-22 20:35:04 +04:00
|
|
|
usage();
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
1996-10-22 20:35:04 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
1996-10-22 20:35:04 +04:00
|
|
|
|
|
|
|
if (!argc)
|
|
|
|
usage();
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
|
|
|
(void)signal(SIGINT, catch);
|
|
|
|
if (preen)
|
|
|
|
(void)signal(SIGQUIT, catchquit);
|
1996-09-23 20:18:31 +04:00
|
|
|
|
1996-10-22 20:35:04 +04:00
|
|
|
while (argc-- > 0)
|
|
|
|
(void)checkfilesys(blockcheck(*argv++), 0, 0L, 0);
|
1996-09-23 20:18:31 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
if (returntosingle)
|
1996-09-23 20:18:31 +04:00
|
|
|
ret = 2;
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(ret);
|
|
|
|
}
|
|
|
|
|
1996-10-22 20:35:04 +04:00
|
|
|
static int
|
1993-03-21 12:45:37 +03:00
|
|
|
argtoi(flag, req, str, base)
|
|
|
|
int flag;
|
|
|
|
char *req, *str;
|
|
|
|
int base;
|
|
|
|
{
|
|
|
|
char *cp;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = (int)strtol(str, &cp, base);
|
|
|
|
if (cp == str || *cp)
|
1997-09-16 20:44:43 +04:00
|
|
|
errx(EEXIT, "-%c flag requires a %s", flag, req);
|
1993-03-21 12:45:37 +03:00
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check the specified filesystem.
|
|
|
|
*/
|
|
|
|
/* ARGSUSED */
|
1996-10-22 20:35:04 +04:00
|
|
|
static int
|
1993-03-21 12:45:37 +03:00
|
|
|
checkfilesys(filesys, mntpt, auxdata, child)
|
1998-07-27 00:32:42 +04:00
|
|
|
const char *filesys;
|
|
|
|
char *mntpt;
|
1993-03-21 12:45:37 +03:00
|
|
|
long auxdata;
|
1994-12-05 23:15:31 +03:00
|
|
|
int child;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-09-16 20:44:43 +04:00
|
|
|
ufs_daddr_t n_ffree, n_bfree;
|
1993-03-21 12:45:37 +03:00
|
|
|
struct dups *dp;
|
|
|
|
struct zlncnt *zlnp;
|
1997-09-24 13:24:21 +04:00
|
|
|
#ifdef LITE2BORKEN
|
2001-01-26 20:37:16 +03:00
|
|
|
int flags;
|
1997-09-24 13:24:21 +04:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
if (preen && child)
|
|
|
|
(void)signal(SIGQUIT, voidquit);
|
1996-09-23 20:18:31 +04:00
|
|
|
setcdevname(filesys, preen);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (debug && preen)
|
|
|
|
pwarn("starting\n");
|
1995-04-13 01:24:07 +04:00
|
|
|
switch (setup(filesys)) {
|
|
|
|
case 0:
|
1993-03-21 12:45:37 +03:00
|
|
|
if (preen)
|
|
|
|
pfatal("CAN'T CHECK FILE SYSTEM.");
|
1997-09-16 20:44:43 +04:00
|
|
|
/* fall through */
|
1995-04-13 01:24:07 +04:00
|
|
|
case -1:
|
1993-03-21 12:45:37 +03:00
|
|
|
return (0);
|
|
|
|
}
|
1999-11-15 22:18:24 +03:00
|
|
|
/*
|
|
|
|
* Cleared if any questions answered no. Used to decide if
|
|
|
|
* the superblock should be marked clean.
|
|
|
|
*/
|
|
|
|
resolved = 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-06-08 22:57:30 +04:00
|
|
|
* 1: scan inodes tallying blocks used
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1994-06-08 22:57:30 +04:00
|
|
|
if (preen == 0) {
|
1998-03-18 20:01:23 +03:00
|
|
|
printf("** Last Mounted on %s\n", sblock->fs_fsmnt);
|
1996-09-23 20:18:31 +04:00
|
|
|
if (hotroot())
|
1994-06-08 22:57:30 +04:00
|
|
|
printf("** Root file system\n");
|
|
|
|
printf("** Phase 1 - Check Blocks and Sizes\n");
|
|
|
|
}
|
|
|
|
pass1();
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-06-08 22:57:30 +04:00
|
|
|
/*
|
|
|
|
* 1b: locate first references to duplicates, if any
|
|
|
|
*/
|
|
|
|
if (duplist) {
|
2000-12-13 06:04:51 +03:00
|
|
|
if (preen)
|
|
|
|
pfatal("INTERNAL ERROR: dups with -p\n");
|
|
|
|
if (usedsoftdep)
|
|
|
|
pfatal("INTERNAL ERROR: dups with softdep\n");
|
1994-06-08 22:57:30 +04:00
|
|
|
printf("** Phase 1b - Rescan For More DUPS\n");
|
|
|
|
pass1b();
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-06-08 22:57:30 +04:00
|
|
|
/*
|
|
|
|
* 2: traverse directories from root to mark all connected directories
|
|
|
|
*/
|
|
|
|
if (preen == 0)
|
|
|
|
printf("** Phase 2 - Check Pathnames\n");
|
|
|
|
pass2();
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-06-08 22:57:30 +04:00
|
|
|
/*
|
|
|
|
* 3: scan inodes looking for disconnected directories
|
|
|
|
*/
|
|
|
|
if (preen == 0)
|
|
|
|
printf("** Phase 3 - Check Connectivity\n");
|
|
|
|
pass3();
|
1993-10-01 04:45:30 +03:00
|
|
|
|
1994-06-08 22:57:30 +04:00
|
|
|
/*
|
|
|
|
* 4: scan inodes looking for disconnected files; check reference counts
|
|
|
|
*/
|
|
|
|
if (preen == 0)
|
|
|
|
printf("** Phase 4 - Check Reference Counts\n");
|
|
|
|
pass4();
|
1993-10-01 04:45:30 +03:00
|
|
|
|
1994-06-08 22:57:30 +04:00
|
|
|
/*
|
|
|
|
* 5: check and repair resource counts in cylinder groups
|
|
|
|
*/
|
|
|
|
if (preen == 0)
|
|
|
|
printf("** Phase 5 - Check Cyl groups\n");
|
|
|
|
pass5();
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* print out summary statistics
|
|
|
|
*/
|
1998-03-18 20:01:23 +03:00
|
|
|
n_ffree = sblock->fs_cstotal.cs_nffree;
|
|
|
|
n_bfree = sblock->fs_cstotal.cs_nbfree;
|
1996-09-23 20:18:31 +04:00
|
|
|
pwarn("%d files, %d used, %d free ",
|
1998-03-18 20:01:23 +03:00
|
|
|
n_files, n_blks, n_ffree + sblock->fs_frag * n_bfree);
|
1996-09-23 20:18:31 +04:00
|
|
|
printf("(%d frags, %d blocks, %d.%d%% fragmentation)\n",
|
1998-03-18 20:01:23 +03:00
|
|
|
n_ffree, n_bfree, (n_ffree * 100) / sblock->fs_dsize,
|
|
|
|
((n_ffree * 1000 + sblock->fs_dsize / 2) / sblock->fs_dsize) % 10);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (debug &&
|
1998-03-18 20:01:23 +03:00
|
|
|
(n_files -= maxino - ROOTINO - sblock->fs_cstotal.cs_nifree))
|
1996-09-23 20:18:31 +04:00
|
|
|
printf("%d files missing\n", n_files);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (debug) {
|
1998-03-18 20:01:23 +03:00
|
|
|
n_blks += sblock->fs_ncg *
|
|
|
|
(cgdmin(sblock, 0) - cgsblock(sblock, 0));
|
|
|
|
n_blks += cgsblock(sblock, 0) - cgbase(sblock, 0);
|
|
|
|
n_blks += howmany(sblock->fs_cssize, sblock->fs_fsize);
|
|
|
|
if (n_blks -= maxfsblock - (n_ffree + sblock->fs_frag * n_bfree))
|
1996-09-23 20:18:31 +04:00
|
|
|
printf("%d blocks missing\n", n_blks);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (duplist != NULL) {
|
|
|
|
printf("The following duplicate blocks remain:");
|
|
|
|
for (dp = duplist; dp; dp = dp->next)
|
1996-09-23 20:18:31 +04:00
|
|
|
printf(" %d,", dp->dup);
|
1993-03-21 12:45:37 +03:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
if (zlnhead != NULL) {
|
|
|
|
printf("The following zero link count inodes remain:");
|
|
|
|
for (zlnp = zlnhead; zlnp; zlnp = zlnp->next)
|
1996-09-23 20:18:31 +04:00
|
|
|
printf(" %u,", zlnp->zlncnt);
|
1993-03-21 12:45:37 +03:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
zlnhead = (struct zlncnt *)0;
|
|
|
|
duplist = (struct dups *)0;
|
1994-06-08 22:57:30 +04:00
|
|
|
muldup = (struct dups *)0;
|
1993-03-21 12:45:37 +03:00
|
|
|
inocleanup();
|
|
|
|
if (fsmodified) {
|
1998-03-18 20:01:23 +03:00
|
|
|
(void)time(&sblock->fs_time);
|
1993-03-21 12:45:37 +03:00
|
|
|
sbdirty();
|
|
|
|
}
|
1999-11-15 22:18:24 +03:00
|
|
|
if (rerun)
|
|
|
|
markclean = 0;
|
1997-09-24 13:24:21 +04:00
|
|
|
#if LITE2BORKEN
|
1997-09-16 20:44:43 +04:00
|
|
|
if (!hotroot()) {
|
1998-03-18 20:01:23 +03:00
|
|
|
ckfini();
|
1997-09-16 20:44:43 +04:00
|
|
|
} else {
|
|
|
|
struct statfs stfs_buf;
|
|
|
|
/*
|
|
|
|
* Check to see if root is mounted read-write.
|
|
|
|
*/
|
|
|
|
if (statfs("/", &stfs_buf) == 0)
|
|
|
|
flags = stfs_buf.f_flags;
|
|
|
|
else
|
|
|
|
flags = 0;
|
1998-03-18 20:01:23 +03:00
|
|
|
if (markclean)
|
|
|
|
markclean = flags & MNT_RDONLY;
|
|
|
|
ckfini();
|
1997-09-16 20:44:43 +04:00
|
|
|
}
|
1997-09-24 13:24:21 +04:00
|
|
|
#else
|
1998-03-18 20:01:23 +03:00
|
|
|
ckfini();
|
1997-09-24 13:24:21 +04:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
free(blockmap);
|
|
|
|
free(statemap);
|
|
|
|
free((char *)lncntp);
|
|
|
|
if (!fsmodified)
|
|
|
|
return (0);
|
1994-06-08 22:57:30 +04:00
|
|
|
if (!preen)
|
1993-03-21 12:45:37 +03:00
|
|
|
printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
|
1996-10-12 00:15:46 +04:00
|
|
|
if (rerun)
|
|
|
|
printf("\n***** PLEASE RERUN FSCK *****\n");
|
1996-09-23 20:18:31 +04:00
|
|
|
if (hotroot()) {
|
1994-06-08 22:57:30 +04:00
|
|
|
struct statfs stfs_buf;
|
|
|
|
/*
|
|
|
|
* We modified the root. Do a mount update on
|
|
|
|
* it, unless it is read-write, so we can continue.
|
|
|
|
*/
|
|
|
|
if (statfs("/", &stfs_buf) == 0) {
|
|
|
|
long flags = stfs_buf.f_flags;
|
|
|
|
struct ufs_args args;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (flags & MNT_RDONLY) {
|
|
|
|
args.fspec = 0;
|
|
|
|
args.export.ex_flags = 0;
|
|
|
|
args.export.ex_root = 0;
|
|
|
|
flags |= MNT_UPDATE | MNT_RELOAD;
|
1995-11-28 08:25:28 +03:00
|
|
|
ret = mount(MOUNT_FFS, "/", flags, &args);
|
1994-06-08 22:57:30 +04:00
|
|
|
if (ret == 0)
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!preen)
|
|
|
|
printf("\n***** REBOOT NOW *****\n");
|
1993-03-21 12:45:37 +03:00
|
|
|
sync();
|
|
|
|
return (4);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
1996-10-22 20:35:04 +04:00
|
|
|
|
|
|
|
static void
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
extern char *__progname;
|
|
|
|
|
|
|
|
(void) fprintf(stderr,
|
1998-03-18 20:01:23 +03:00
|
|
|
"Usage: %s [-dfnpy] [-B be|le] [-b block] [-c level] [-m mode]"
|
|
|
|
"filesystem ...\n",
|
1996-10-22 20:35:04 +04:00
|
|
|
__progname);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|