Commit Graph

363 Commits

Author SHA1 Message Date
riastradh 976fa97423 Revert "fsck_ffs(8): Ensure A divides S before aligned_alloc(A, S)."
C17 lifted this restriction.
2023-07-05 10:59:08 +00:00
riastradh 252616f8e4 fsck_ffs(8): Fix whitespace issues.
- Nix trailing whitespace.
- Omit excessive blank lines.
- Insert missing blank lines between $NetBSD$ and copyright.

No functional change intended.
2023-07-04 20:40:53 +00:00
riastradh 573d5c8231 fsck_ffs(8): Ensure A divides S before aligned_alloc(A, S).
Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2,
p. 348:

   The value of alignment shall be a valid alignment supported by the
   implementation and the value of size shall be an integral multiple
   of alignment.

XXX pullup-10
2023-07-04 20:40:22 +00:00
lukem f937c412f3 bsd.own.mk: rename to CC_WNO_ADDRESS_OF_PACKED_MEMBER
Provide a single variable
	CC_WNO_ADDRESS_OF_PACKED_MEMBER
with options for both clang and gcc, to replace
	CLANG_NO_ADDR_OF_PACKED_MEMBER
	CC_NO_ADDR_OF_PACKED_MEMBER
	GCC_NO_ADDR_OF_PACKED_MEMBER

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
2023-06-03 08:52:53 +00:00
chs 8f4d5a45a2 Apply this commit from FreeBSD:
commit 6bae6625e0e06816c80ac4971dfccf0643abe3f0
  Author: Kirk McKusick <mckusick@FreeBSD.org>
  Date:   Wed Aug 17 14:19:59 2022 -0700

    Improve handling of missing '.' and '..' in UFS directories.

    The UFS filesystem expects to find '.' and '..' as the first two entries
    in a directory. The kernel's UFS name cache can become quite confused
    when these two entries are not present as the first two entries.

    Prior to this change, when the fsck_ffs(8) utility detected that
    '.' and/or '..' were missing, it would report them, but only offered
    to replace them if the space at the beginning of the directory was
    available. Otherwise it was left to the system administrator to
    move the offending file(s) out of the way and then rerun fsck_ffs(8)
    to create the '.' and '..' entries.

    With this change, fsck_ffs(8) will always be able to create the '.'
    and/or '..' entries. It moves any files in the way elsewhere in the
    directory block. If there is no room in the directory block to which
    to move them, they are placed in the lost+found directory.

    Reported by:  Peter Holm
    Sponsored by: The FreeBSD Foundation
2023-03-27 22:53:37 +00:00
kre 4bc7e3cb63 Use %zu rather than %lu to print a size_t (should fix i386 build).
But, philosophical question, shouldn't the product of two size_t
variables really be an area_t, or something like that?
2023-01-14 17:01:10 +00:00
christos 4616d0425d catch up with sign changes in the fs.h 2023-01-14 12:12:50 +00:00
chs 908deb24fa ufs: more signed/unsigned fixes
Fix the previous signed/unsigned fixes to build on 32-bit,
including applying this commit from FreeBSD:

  commit 2d34afcd04207cf3fa3d5b7f467a890eae75da41
  Author: Kirk McKusick <mckusick@FreeBSD.org>
  Date:   Sun Oct 25 21:04:07 2020 +0000

    Use proper type (ino_t) for inode numbers to avoid improper sign extention
    in the Pass 5 checks. The manifestation was fsck_ffs exiting with this error:

      ** Phase 5 - Check Cyl groups
      fsck_ffs: inoinfo: inumber 18446744071562087424 out of range

    The error only manifests itself for filesystems bigger than about 100Tb.

    Reported by:  Nikita Grechikhin <ngrechikhin at yandex.ru>
    MFC after:    2 weeks
    Sponsored by: Netflix
2023-01-08 05:25:24 +00:00
chs f298a94b73 ufs: fixed signed/unsigned bugs affecting large file systems
Apply these commits from FreeBSD:

  commit e870d1e6f97cc73308c11c40684b775bcfa906a2
  Author: Kirk McKusick <mckusick@FreeBSD.org>
  Date:   Wed Feb 10 20:10:35 2010 +0000

    This fix corrects a problem in the file system that treats large
    inode numbers as negative rather than unsigned. For a default
    (16K block) file system, this bug began to show up at a file system
    size above about 16Tb.

    To fully handle this problem, newfs must be updated to ensure that
    it will never create a filesystem with more than 2^32 inodes. That
    patch will be forthcoming soon.

    Reported by: Scott Burns, John Kilburg, Bruce Evans
    Followup by: Jeff Roberson
    PR:          133980
    MFC after:   2 weeks

  commit 81479e688b0f643ffacd3f335b4b4bba460b769d
  Author: Kirk McKusick <mckusick@FreeBSD.org>
  Date:   Thu Feb 11 18:14:53 2010 +0000

    One last pass to get all the unsigned comparisons correct.


In additional to the changes from FreeBSD, this commit includes quite a few
related changes to appease -Wsign-compare.
2023-01-07 19:41:29 +00:00
martin 1b5f3a1b0a Fix clearing of permissions when finding unexpected extended attributs
for swapped endian file systems. Ok: chs
2022-11-18 07:41:31 +00:00
martin 2627930cb6 Make the "non-zero exattr fields" message show the inode number. 2022-11-17 18:57:16 +00:00
chs 87ba0e2a31 Restore backward compatibility of UFS2 with previous NetBSD releases by
disabling support in UFS2 for extended attributes (including ACLs).
Add a new variant of UFS2 called "UFS2ea" that does support extended attributes.
Add new	fsck_ffs operations "-c	ea" and	"-c no-ea" to convert file systems
from UFS2 to UFS2ea and	vice-versa (both of which delete all existing extended
attributes in the process).
2022-11-17 06:40:38 +00:00
dholland 3ad018779f Fix misleading fsck_ffs messages about wapbl journal replay.
Apparently fsck doesn't have a way to replay it to its internal memory
only. (Someone(TM) should implement this...)

This means that if you use -n, it can't replay the journal. But the
sequence of prints is such that it looks like it did. This is quite
misleading. Add an additional specific warning.
2022-07-25 05:15:08 +00:00
mrg cb93b81028 add support for new GCC 9 warnings that may be too much to fix
right now.  new address-of-packed-member and format-overflow
warnings have new GCC_NO_ADDR_OF_PACKED_MEMBER amd
GCC_NO_FORMAT_OVERFLOW variables to remove these warnings.

apply to a bunch of the tree.  mostly, these are real bugs that
should be fixed, but in many cases, only by removing the 'packed'
attribute from some structure that doesn't really need it.  (i
looked at many different ones, and while perhaps 60-80% were
already properly aligned, it wasn't clear to me that the uses
were always coming from sane data vs network alignment, so it
doesn't seem safe to remove packed without careful research for
each affect struct.)  clang already warned (and was not erroring)
for many of these cases, but gcc picked up dozens more.
2020-09-06 07:20:26 +00:00
christos 7df60872d5 Enable the code to clean the extattr blocks 2020-04-19 19:37:06 +00:00
jdolecek 1ef16aec19 add NO_IOBUF_ALIGNED to not pull aligned_alloc() for really constrained
boot media
2020-04-18 12:54:38 +00:00
jdolecek 93217591a2 align buffers used for I/O to DEV_BSIZE so it's executed more optimally
when run for xbd(4) raw (character) device
2020-04-17 09:42:27 +00:00
martin b187e11174 Sync "common" declarations with ifdefs in header. 2020-04-06 09:54:24 +00:00
mrg d26fa7dbd1 dion't define endian as well as try to declare it as a variable. 2020-04-06 06:41:34 +00:00
joerg 6ce4f404a1 Fix depenency on common symbols in sbin. 2020-04-05 15:25:39 +00:00
christos 6d3bef8dbf inode.c needs -O0 for vax 2019-10-28 22:52:43 +00:00
kamil 1f7b844ec7 fsck: Stop defining the same variable concurrently in bss and data
returntosingle was defined in multiple places:

 - fsck_lfs/main.c
 - fsck_ffs/main.c
 - fsck_ext2fs/main.c
 - fsck/fsutil.c

Keep the fsutil.c definition as the only one.

Detected during the build of telned with Address Sanitizer (MKSANITIZER).
2019-08-15 03:10:42 +00:00
christos dfb7cec746 Add a -z flag to zero out the up to 4 bytes of padding in directory entry
names (including the terminating NUL), as well as directory entries with
extra free space (d->d_reclen > UFS_DIRSIZ(d)).

Inspired from FreeBSD:
    https://svnweb.freebsd.org/base?view=revision&revision=347066

While the kernel has been fixed to deal with the padding bytes (new
kernels will correctly zero out all the padding after the name), it
appears that there is still an issue with directory entries with extra
free space, since a newly created and populated filesystem gets modified
with "fsck_ffs -z".
2019-05-05 14:59:06 +00:00
christos b131cb44b1 simplify the endian byte-swapping code. 2019-05-05 13:24:19 +00:00
mrg fbffadb9f8 - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
  this case, and thus can't be marked __dead easily
2019-02-03 03:19:25 +00:00
msaitoh 54c9821e53 "s/ are are / are /" in comment. No functional change. 2018-11-08 06:34:40 +00:00
hannken 74ee23a34f Add a test for duplicate inodes on the persistent snapshot list. 2018-10-05 09:49:23 +00:00
kamil 1c426e1841 Restore the MKGROFF=bo MKCXX=yes build
Mark the documentation in dc(1), gprof(1), rogue(6) and fsck_ffs(8) with
the .roff flag in SUBDIR.

Sponsored by <The NetBSD Foundation>
2018-06-11 14:18:16 +00:00
hannken 6e4615fb0f Treat an inode with "mode == 0" and "blocks != 0" as partially allocated
and clear it as ffs_newvnode() tests for "blocks == 0".
2018-02-13 11:20:08 +00:00
rin ce7fa6f1d3 __empty -> __nothing 2017-02-08 18:05:25 +00:00
christos 58acfeb884 use __empty 2017-02-08 16:23:24 +00:00
rin ccc9d98e52 Add smaller versions of fsck_ffs(8) and newfs(8) for install media, where
support for Endian-Independent FFS and Apple UFS is disabled unless FFS_EI=1
and APPLE_UFS=1 are added to CRUNCHENV, respectively.

This reduces the size of ramdisk image for atari by over 15KB.

Thanks tsutsui and christos for their useful comments.
2017-02-08 16:11:39 +00:00
rin 872902e1dd Do not compile in progress.c when SMALLPROG is defined. 2017-02-07 16:14:47 +00:00
sevan 645829aa66 Document the version fsck_ffs first appeared.
Bump date.
2016-09-11 04:07:38 +00:00
christos f4ab1bba27 -O0 for pass1.c and vax 2016-03-23 21:43:33 +00:00
christos 5bf62a09d2 a few more \n's in errors 2015-06-16 23:58:30 +00:00
christos d3037dba83 fix error messages containing \n 2015-06-16 23:18:54 +00:00
dholland 0580599ec4 Reorg docs, part 3:
Move the documents that are papers to /usr/share/doc/papers.
Give them suitable names (including the author and year).

The key property of papers that distinguishes them from documentation
is that they're historical: they're published at a particular time and
aren't updated or maintained. (Except cosmetically.)

We should only ship papers that are of interest to users, either for
historical perspective or because they're the original research
writeup of stuff that went into the system and is still pertinent.

The ffs papers clearly meet this standard; the other one here (about
passwords, in 1978) is probably past its sell-by date.
2014-07-05 19:23:15 +00:00
dholland c3ab26950f Rework /usr/share/doc.
Update the <bsd.doc.mk> infrastructure, and update the docs to match
the new infrastructure.

- Build and install text, ps, pdf, and/or html, not roff sources.

- Don't wire the chapter numbers into the build system, or use them in
the installed pathnames. This didn't matter much when the docs were a
museum, but now that we're theoretically going to start maintaining
them again, we're going to add and remove documents periodically and
having the chapter numbers baked in creates a lot of thrashing for no
purpose.

- Specify the document name explicitly, rather than implicitly in a
path. Use this name (instead of other random strings) as the name
of the installed files.

- Specify the document section, which is the subdirectory of
/usr/share/doc to install into.

- Allow multiple subdocuments. (That is, multiple documents in one
output directory.)

- Enumerate the .png files groff emits along with html so they can be
installed.

- Remove assorted hand-rolled rules for running roff and roff widgetry
and add enough variable settings to make these unnecessary. This
includes support for
   - explicit use of soelim
   - refer
   - tbl
   - pic
   - eqn

- Forcibly apply at least minimal amounts of sanity to certain
autogenerated roff files.

- Don't exclude USD.doc, SMM.doc, and PSD.doc directories from the
build, as they now actually do stuff.

Note: currently we can't generate pdf. This turns out to be a
nontrivial problem with no immediate solution forthcoming. So for now,
as a workaround, install compressed .ps as the printable form.
2014-07-05 19:22:02 +00:00
justin 802f624689 Iterate over fields of struct seperately to avoid warnings from pedantic compilers 2014-04-05 12:32:27 +00:00
bouyer 7e810dc605 Fix pasto in the !ufs2 case (use dp->dp1 and not of dp->dp2).
This would be a problem only when allocating a new data block and the
indir block is already allocated, which explains why automated tests didn't
find it.
Problem reported on tech-kern@ and fix tested by manu@.
2013-12-02 18:46:52 +00:00
christos 3e4993b396 fix unused variable warnings. 2013-10-19 01:09:58 +00:00
dholland 75571afd93 Stick ffs_ in front of the following macros:
fragstoblks()
   blkstofrags()
   fragnum()
   blknum()

to finish the job of distinguishing them from the lfs versions, which
Christos renamed the other day.

I believe this is the last of the overtly ambiguous exported symbols
from ffs... or at least, the last of the ones that conflicted with lfs.
ffs still pollutes the C namespace very broadly (as does ufs) and this
needs quite a bit more cleanup.

XXX: boo on macros with lowercase names. But I'm not tackling that just yet.
2013-06-23 22:03:34 +00:00
dholland e1610ba4cb Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

   lblkno
   lblktosize
   lfragtosize
   numfrags
   blkroundup
   fragroundup
2013-06-23 07:28:36 +00:00
dholland 2737439da3 fsbtodb() -> FFS_FSBTODB(), EXT2_FSBTODB(), or MFS_FSBTODB()
dbtofsb() -> FFS_DBTOFSB() or EXT2_DBTOFSB()

(Christos already did the lfs ones a few days back)
2013-06-23 02:06:04 +00:00
dholland de893df3a9 blkoff() -> ffs_blkoff() stragglers 2013-06-19 18:02:21 +00:00
dholland f1333577b5 Rename ambiguous macros:
MAXDIRSIZE -> UFS_MAXDIRSIZE or LFS_MAXDIRSIZE
   NINDIR -> FFS_NINDIR, EXT2_NINDIR, LFS_NINDIR, or MFS_NINDIR
   INOPB -> FFS_INOPB, LFS_INOPB
   INOPF -> FFS_INOPF, LFS_INOPF
   blksize -> ffs_blksize, ext2_blksize, or lfs_blksize
   sblksize -> ffs_blksize

These are not the only ambiguously defined filesystem macros, of
course, there's a pile more. I may not have found all the ambiguous
definitions of blksize(), too, as there are a lot of other things
called 'blksize' in the system.
2013-06-19 17:51:25 +00:00
dholland 5a420c1b9a Stick UFS_ in front of these symbols:
DIRBLKSIZ
   DIRECTSIZ
   DIRSIZ
   OLDDIRFMT
   NEWDIRFMT

Part of PR 47909.
2013-06-09 17:57:08 +00:00
dholland dcd34a91c5 Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
   ROOTINO -> UFS_ROOTINO
   WINO -> UFS_WINO
   NXADDR -> UFS_NXADDR
   NDADDR -> UFS_NDADDR
   NIADDR -> UFS_NIADDR
   MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
   MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.
2013-01-22 09:39:11 +00:00
riastradh ac9a343544 Show pass1 SIGINFO output on stderr like other passes, not on stdout. 2013-01-06 22:06:00 +00:00