Commit Graph

76 Commits

Author SHA1 Message Date
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
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
andvar 2fa7e14158 fix various typos, mainly in comments, but also log messages, docs, game text. 2022-04-08 10:17:52 +00:00
rillig ea80fa1d5b sbin: enable lint for almost all programs
The programs fsck_lfs and newfs_lfs both trigger a longstanding bug in
lint that is difficult to fix, so ignore them for now.

For resize_ffs, lint thinks that 'struct fs' is incomplete, but GCC and
Clang accept it.  Needs further investigation.
2021-09-14 20:13:03 +00:00
jmcneill 2cf653d8b7 Use getfsspecname and getrawdiskname so we can resize by NAME= label. 2020-05-24 14:41:26 +00:00
maya f93d65267a wether -> whether 2019-04-21 11:45:08 +00:00
mlelstv 9ffedbd04f Fix computation of left-over fragments also for ufs2.
Fixes PR 52600.
2017-10-09 05:24:26 +00:00
christos 7ebfc10b9a PR/52590: David H. Gutteridge: Minor documentation improvements 2017-10-01 22:59:19 +00:00
mlelstv fa4874d540 - More fixes to use 64bit offsets.
- Compute left-over fragments also for FFS2.
2017-10-01 07:18:39 +00:00
kre 9d73fa5606 Fix the syntax (pointed out by David H. Gutteridge on source-changes-d).
Fix the build...
2017-09-30 18:32:52 +00:00
riastradh 84bea879cb Use int64_t for loop index so we don't iterate forever/until trap. 2017-09-30 15:25:16 +00:00
sborrill 0e0ce305cc Fix the most obvious integer overflow errors which can lead to superblock
corruption. Thanks to riastradh@

For example:

# df /data
Filesystem    1K-blocks       Used      Avail %Cap Mounted on
/dev/ccd0d   -19974939099004 -19982708701532 -737868756431824584   0% /data

# dumpfs -s /dev/rccd0d
file system: /dev/rccd0d
format  FFSv2
endian  little-endian
location 65536  (-b 128)
magic   19540119        time    Thu Sep 28 13:18:10 2017
superblock location     65536   id      [ 595fa4a5 3363fe37 ]
cylgrp  dynamic inodes  FFSv2   sblock  FFSv2   fslevel 5
nbfree  242773148       ndir    211185  nifree  650798800       nffree
215448
ncg     13933   size    2647654400      blocks  -4993734774751
bsize   32768   shift   15      mask    0xffff8000
fsize   4096    shift   12      mask    0xfffff000
frag    8       shift   3       fsbtodb 3
bpg     23754   fpg     190032  ipg     46848
minfree 5%      optim   time    maxcontig 2     maxbpg  4096
symlinklen 120  contigsumsize 2
maxfilesize 0x000800800805ffff
nindir  4096    inopb   128
avgfilesize 16384       avgfpdir 64
sblkno  24      cblkno  32      iblkno  40      dblkno  2968
sbsize  4096    cgsize  32768
csaddr  35792   cssize  225280
cgrotor 0       fmod    0       ronly   0       clean   0x01
wapbl version 0x1       location 2      flags 0x0
wapbl loc0 6354693888   loc1 131072     loc2 512        loc3 3
flags   none
fsmnt   /data
volname         swuid   0
2017-09-28 17:07:20 +00:00
sevan 08e27e9733 Replace contractions. 2016-09-12 05:47:21 +00:00
dholland fbf3696950 Fix handling of ffsv2 inode initialization. Retires PR 51116. 2016-08-24 07:44:05 +00:00
christos c1673bd676 fix pasto 2016-03-17 01:41:54 +00:00
christos 9eac9537df Appease gcc-5 from phone@ 2016-03-17 00:54:53 +00:00
jmcneill d0b93bc844 if the -p flag is specified, display a progress bar while growing the file-system 2015-04-06 22:44:04 +00:00
mlelstv f3a445024e factor out geometry calculation and use this also in CheckOnly mode.
be a bit more verbose in Verbose mode.
2015-04-06 13:33:42 +00:00
mlelstv 4962b364b8 Handle case in grow() where last cylinder group is too small for ufs2.
Align with code in shrink().
2015-04-06 12:38:21 +00:00
wiz 5a1645e4da New sentence, new line. Sort option descriptions. 2015-03-29 19:42:15 +00:00
chopps ae3fcf098a - Add -c to check to see if grow/shrink is required
- Divide by DEV_BSIZE when returning size of file.
- Update manpage
2015-03-29 19:33:55 +00:00
riastradh 9ea98f4524 Use `!= -1' instead of `== 0' out of paranoia. 2015-03-28 17:25:33 +00:00
riastradh bb5cf371be Make get_dev_size work on regular files too. 2015-03-28 17:22:46 +00:00
riz 8dcf7f1af2 Add an item to the list (SIGINFO support). 2013-09-09 19:37:17 +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 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 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
christos 7c8eec143a fix cast in local macro 2012-04-20 13:20:39 +00:00
wiz f91d202feb Move a sentence to where it makes more sense. 2011-08-28 21:25:11 +00:00
wiz 6964284f70 New sentence, new line. 2011-08-28 17:15:16 +00:00
christos 17187885c3 PR/45301: Julian Fagir: make clear that the unit is sectors and fix a typo.
While there, use errx, and sizeof(*var) instead of sizeof(type)
2011-08-27 16:34:57 +00:00
dholland 64b8763551 Fix another dodgy switch-jump. 2011-08-15 02:22:46 +00:00
dholland 7a8d9bb430 WARNS = 4 2011-08-15 02:19:50 +00:00
dholland 66ed9af4d1 Add missing __RCSID(). 2011-08-15 00:30:25 +00:00
dholland fc91a8d8ae Whitespace. 2011-08-15 00:27:50 +00:00
dholland 2bf41d920c Avoid switch-jumping into the middle of an if. Compiler output is unchanged. 2011-08-15 00:26:16 +00:00
dholland 46eb69af0a Minor KNF. 2011-08-15 00:24:19 +00:00
riz d765f2d25b Add support for byteswapped file systems (big-endian on little-endian
host, and vice versa), to fix PR#44203.

Add support for growing (but not yet shrinking) UFS2 file systems.  Partially
addresses PR#44205.

While I'm here, reformat the code for closer adherence to KNF.

Fairly extensive testing was performed, using the shortly-to-be-committed
updated ATF tests.  Patch posted to tech-userlevel on 21 December 2010,
no comments.
2011-01-05 02:18:15 +00:00
riz 98ddf5ec73 Revert previous - inadvertant commit to wrong repository. 2010-12-20 00:49:23 +00:00
riz 3123e6a7e0 Pull in change from njoly@ in -current 2010-12-20 00:44:53 +00:00
njoly e7c4f98be6 Add missing .Os macro. 2010-12-19 23:22:46 +00:00
wiz c93380eba7 filesystem -> file system. 2010-12-14 21:49:21 +00:00
riz a3a3268f75 Be explicit about byteswapped and ffsv2 file systems being currently
unsupported, while catching up to some changes in my local tree which
will hopefully support them at some time in the future.

Also, change "device" variable to "special", to reflect the fact
that resize_ffs will work on a plain file.
2010-12-14 20:45:22 +00:00
riz 16963047ea Don't special-case v1 superblocks - especially with an incorrect
calculation.
2010-12-14 04:04:20 +00:00
riz d365bee0c8 Remove bogus check which is not actually testing anything useful,
and depending on file system data, can actually be a false error.

Fixes what I was actually testing for in bin/44209, though the
actual problem was not what I originally described.
2010-12-12 22:48:59 +00:00
mhitch a7e78491e5 Add support for old ffsv1 superblocks. After reading an old superblock,
copy appropriate data to where they are expected in the updated superblock.
When writing the updated superblock, move the updated values back to the
old ffsv1 superblock locations.  Also check for old superblock format when
updating the last cylinder group and adjust cg_old_ncyl appropriately.
Derived from how mksf sets them.  Should address PR bin/44209.
2010-12-12 19:53:23 +00:00
riz 6a4bbd2cea Remove accidentally-resurrected TODO item. 2010-12-08 15:23:53 +00:00
riz 8966eced0b If we're operating on a plain file instead of a device, ftruncate() it
to ensure it's been properly extended.  Clears up some problems at certain
blocksizes which showed up during creation of atf tests, which is done
using file-backed file systems.
2010-12-08 00:25:54 +00:00