Commit Graph

15 Commits

Author SHA1 Message Date
Kirk McKusick
906c312bbf Document the mntopts(3) functions.
The mntopts(3) functions support operations associated with a mount
point. The main purpose of this commit is to document the mntopts(3)
functions that now appear in 18 utilities in the base system. See
mntopts(3) for the documentation details.

The getmntopts() function appeared in 4.4BSD. The build_iovec(),
build_iovec_argf(), free_iovec(), checkpath(), and rmslashes()
functions were added with nmount(8) in FreeBSD 5.0. The getmntpoint()
and chkdoreload() functions are being added in this commit.

These functions should be in a library but for historic reasons are
in a file in the sources for the mount(8) program. Thus, to access
them the following lines need to be added to the Makefile of the
program wanting to use them:

SRCS+= getmntopts.c
MOUNT= ${SRCTOP}/sbin/mount
CFLAGS+= -I${MOUNT}
.PATH: ${MOUNT}

Once these changes have been MFC'ed to 13 they may be made into
a library.

Reviewed by:  kib, gbe
MFC after:    2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37907
2023-01-15 10:21:31 -08:00
Warner Losh
7090cba410 fsutil: forward declare struct fstab
Fix the build by forward declaring struct fstab.

Sponsored by:		Netflix
2021-12-15 19:38:28 -07:00
Kirk McKusick
c72372c693 Update fsck(8) to ignore failures from a check program for a filesystem
when the fstab(5) entry for the filesystem has the "failok" attribute.

Reviewed by:  kib
PR:           246201
MFC after:    2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D33424
2021-12-15 16:53:46 -08:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Ulrich Spörlein
3bbc4438c9 Make fsck and fsck_msdosfs WARNS=6 clean
- sprinkle const
- add volatile qualifier to avoid vfork clobbering

Inspired by:	NetBSD
PR:		bin/139802
Reviewed by:	ed
2012-10-21 12:01:19 +00:00
Ulrich Spörlein
6cf357bc6c sbin/fsck: s/perror/perr/ to avoid shadowing
- rename some other vars too
- merge NetBSD license changes

Obtained from:	NetBSD
PR:		bin/139802
Reviewed by:	ed
2012-10-21 12:01:11 +00:00
David E. O'Brien
111a52201c Add the '-C' "check clean" flag. If the FS is marked clean, skip file
system checking.  However, if the file system is not clean, perform a
full fsck.

Reviewed by:	delphij
Obtained from:	Juniper Networks
2009-01-30 18:33:05 +00:00
Bruce Evans
0675647a4e Use __printflike() and __dead2 instead of hard-coded gccisms.
Declare perror().  We define and use a home made version of perror(3)
that can't simply be removed (although it has the same interface as
perror(3)) since it is very different (it prints on stdout, doesn't
always print the program name, and sometimes exits).  Declare it to
get a reminder of this brokenness when WARNS is increased enough.
2003-12-27 13:54:02 +00:00
Bruce Evans
894198ea56 Garbage-collected hotroot, rawname() and unrawname() again. These
became garbage when block devices were axed and were removed a few
months later, but they came back (with hotroot renamed to hot + hotroot())
when the NetBSD fsck was mismerged.
2003-12-27 13:29:49 +00:00
Bruce Evans
05a8df3c21 fsck_msdosfs/main.c:
- Don't use errexit() to (mis)implement usage().  Using errexit() just
  gave the bogus exit code 8.
- Fixed 3 other style bugs in usage().

fsck/fsutil.[ch]:
- Garbage-collected errexit().  It is essentially just one of NetBSD's
  fsck_ext2fs error printing functions, but we don't have fsck_ext2fs
  and the function is unsuitable for use there too (since pfatal() is
  also used and it printf to a different stream).
2003-12-27 13:08:55 +00:00
Tom Rhodes
ff7e70a9ab Remove redundant declaration of the perror() function, it's provided by stdio.h.
Don't define DKTYPENAMES without using it.
2003-10-29 16:09:17 +00:00
Warner Losh
b70cd7ee68 o __P removed
o ansi function prototypes
o unifdef -D__STDC__
o __dead2 on usage prototype
o remove now-bogus main prototype
2002-03-20 22:57:10 +00:00
Kirk McKusick
a02a0079ca Add support for running foreground (-F) and background (-B) checks.
Traditionally, fsck is invoked before the filesystems are mounted
and all checks are done to completion at that time. If background
checking is available, fsck is invoked twice. It is first invoked
at the traditional time, before the filesystems are mounted, with
the -F flag to do checking on all the filesystems that cannot do
background checking. It is then invoked a second time, after the
system has completed going multiuser, with the -B flag to do checking
on all the filesystems that can do background checking. Unlike
the foreground checking, the background checking is started
asynchonously so that other system activity can proceed even on
the filesystems that are being checked.

At the moment, only the fast filesystem supports background checking.
To be able to do background checking, a filesystem must have been
running with soft updates, not have been marked as needing a
foreground check, and be mounted and writable when the background
check is to be done (i.e., not listed as `noauto' in /etc/fstab).

These changes are the final piece needed to support background
filesystem checking. They will not have any effect until you update
your /etc/rc to invoke fsck in its new mode of operation. I am
still playing around with exactly what those changes should be
and should be committing them later this week.
2001-04-25 07:18:22 +00:00
Poul-Henning Kamp
0af7bca250 This change sanitizes the way fsck deals with pass numbers.
Consider this /etc/fstab:

# Device         Mountpoint      FStype  Options    Dump    Pass#
/dev/ad1s1b      none            swap    sw         0       0
/dev/ad0s1b      none            swap    sw         0       0
/dev/ad0s1a      /               ufs     rw         1       1
/dev/ad0s1e      /home           ufs     rw         2       2
/dev/ad1s1e      /tmp            ufs     rw         2       2
/dev/ad1s1f      /usr            ufs     rw         2       2
/dev/ccd0c       /syv            ufs     rw         2       11
proc             /proc           procfs  rw         0       0

ccd0c is striped over /dev/ad0f and /dev/ad1g

Without this pass, fsck in preen mode will check ad0s1a first,
and then issue three processes in parallel:

One process doing ad0s1e
One process doing ad1s1e and ad1s1f
One process doing ccd0c

There is no way to tell it that ccd0c overlaps ad0 and ad1.

With the patch, it will do it this way:

pass 2:
One process doing ad0s1e
One process doing ad1s1e and ad1s1f

and when they are complete:

pass 11:
One process doing ccd0c

This is much faster and more sane.

Valid pass numbers are anything from 1 to INTMAX-1.

I retired the '-l' option which tried to allow people to do
something like this, but which didn't work and which complicated
the code an awful lot.
2001-03-30 08:01:34 +00:00
Adrian Chadd
da7e7114d1 Reviewed by: rwatson, bp
Approved by:	rwatson
Obtained from:	NetBSD source tree

Second part of the fsck wrappers commit. This commit enables the new fsck
code (removing the fsck/* code and replacing it with the netbsd fsck
wrapper code), and enabling some FFS-based utilities to compile.

Details:

* quotacheck, fsdb required modification to use the fsck_ffs/ code rather
  than fsck/ . This might change later since quotacheck requires preen.c
  which should exist in fsck/ rather than fsck_ffs/

* src/Makefile has fsck_ffs added to it so it it built as part of the tree
  now

* share/doc/smm/03.fsck/ uses the SMM.doc/ stuff from fsck_ffs, not fsck.

I've tested this, and it shouldn't require any changes on your machine.
The fsck wrapper reads /etc/fsck and is command-line-compatible enough
to not require rc changes (well, most changes unless you want to do
anything nifty by specifying the fs types explicityly, read the man page
if you want further details on what it can do.)

This now allows us to support multiple filesystem types during bootup.
2000-10-09 10:23:31 +00:00