Commit Graph

44 Commits

Author SHA1 Message Date
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
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
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
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
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 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
riz 0b1ff958b5 As currently written, writeat() expects disk blocks, not fs blocks, so
when testing that the last sector of the new size is writeable, make
sure we're ACTUALLY writing in the new space, instead of possibly
overwriting something in the existing fs.

Discovered while writing tests - tests which uncovered file corruption at
certain block sizes.

XXX should rewrite writeat() to expect fs blocks instead of disk blocks.

OK mlelstv@
2010-12-07 23:29:55 +00:00
riz 9f2c8ccc2b Use howmany() instead of "/" to calculate the number of cylinders for
the changed file system, so as to not drop a partial cylinder at the
end.  Fixes PR bin/44177.
2010-12-02 22:00:27 +00:00
riz 6efa15a79a Do not look for a v1 file system at SBLOCK_UFS2, as this gets the wrong
superblock (first alternate) for a file system with 64k blocks.
Spotted by mhitch@.
2010-12-01 17:39:21 +00:00
riz 18174be827 Clean up this file:
- sync usage comment with current reality
- sort includes
- wrap lines
- use EXIT_FAILURE consistently
- make error messages consistent:  Cannot->Can't
- Remove "Old FFSv1 macros" in favor of system macros in ufs/ffs/fs.h .
  Leave dblksize() because it uses the on-disk dinode structure.

More cleanup is needed.
No functional changes intended.
2010-12-01 17:33:45 +00:00
riz 6f8b62aac7 Restore a couple of checks for updating the cg_old_ncyl value which
were commented out with XXX and a notation to "fix once fsck is fixed."
fsck seems to have been fixed for this particular issue sometime in the
7 years since the code was brought into the tree.

Update cg_old_niblk instead of cg_ni_blk, since this tool
currently supports ffsv1 only.

With these two changes, I can grow a file system and have the result
be clean according to fsck_ffs.  Shrinking still results in an unclean
file system.

OK mhitch@

While I'm here, fix a typo in an error message.
2010-11-29 19:54:10 +00:00
haad 1e89108160 Add resize_ffs tool to build, change default behaviour to grow filesystem
to device size. Add parameter -s to specify size if user want to shrink
filesystem.

Apply some KNF, remove dead unused code.

Oked by christos@.
2010-10-30 21:16:07 +00:00
perry 8b0f9554ff convert __attribute__s to applicable cdefs.h macros 2007-12-15 19:44:37 +00:00
perry 36c7456d7c include sys/cdefs.h so that __attribute__ can be fixed later 2007-12-15 16:32:05 +00:00
bouyer a59a9ef8db writeat() also expect offsets in DEV_BSIZE unit. This and the previous commit
should fix PR bin/35560. Thanks to Michael L. Hitch for pointing me at the
PR.
2007-07-08 16:54:40 +00:00
bouyer 2d9d4664a8 readat() expects the offset in DEV_BSIZE units. This made resize_ffs find the
filesystem on a vnd partition for me. It did grow the filesystem, and after
a fsck -f on the partition to fix a few superblock inconsistencies, all
looks good.
2007-07-05 21:38:20 +00:00
snj d3df836a71 Fix a typo in a comment. 2005-06-03 03:34:44 +00:00
dsl 05f998d8c6 Dunno why this code is playing 'hunt the superblock', but stop it
finding an ffsv1 sb at 64k.
Also stop it playing with fs that have 'FS_FLAGS_UPDATED' set.
It certainly doesn't act on that falg, and my guess is that it is
playing the pre-ffsv2 fs.
Fixes part of PR kern/24809
2004-03-21 21:02:01 +00:00
jmmv b635f565e7 Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
2004-01-05 23:23:32 +00:00
salo b75abedac4 netbsd.org->NetBSD.org 2003-07-26 19:38:45 +00:00
christos 628c00a0ec make this compile again. 2003-04-03 14:55:16 +00:00
wiz 84cb70148f Correct program name in comments. 2003-03-10 09:23:50 +00:00
martin 416cebb2dc This program deals with on-disk structures.
s/daddr_t/int32_t/g for now (UFS2 will need other changes as well).
2003-02-21 23:55:38 +00:00
jtk ec57cc7eb3 Preliminary version of resize_ffs, based on der Mouse's fsresize tool.
I didn't have time to clean it up completely before my legal status
w.r.t. open source projects goes into limbo for a while.  Other
developers are encouraged to play with the tool and get it into
release-worthy shape.

TODO list (see TODO file)

* verify it builds on -current, put it into release lists/etc. and src/sbin/Makefile
  (built & tested on 1.6.1)
* make it ask questions before doing any work (confirm)
* create regression test suite (see discussions on tech-kern and
  developers) and fix any bugs
* verify conversion to ANSI C didn't break anything
* port to UFS2
2003-02-21 04:08:54 +00:00