Commit Graph

52 Commits

Author SHA1 Message Date
Kirk McKusick
68d7185b64 The fsdb(8) utility uses the fsck_ffs(8) disk I/O interfaces, so
switch from using libufs's bread() to using fsck_ffs's getdatablk()
when importing tools/diag/prtblnos's prtblknos().

Sponsored by: Netflix
2020-09-19 20:06:12 +00:00
Kyle Evans
c3e9752ea1 fsck_ffs/fsdb: fix -fno-common build
This one is also a small list:

- 3x duplicate definition (ufs2_zino, returntosingle, nflag)
- 5x 'needs extern', 3/5 of which are referenced in fsdb

-fno-common will become the default in GCC10/LLVM11.

MFC after:	1 week
2020-03-29 20:03:46 +00:00
Kirk McKusick
ac4b20a0a7 After a crash, a file that extends into indirect blocks may end up
shorter than its size resulting in a hole as its final block (which
is a violation of the invarients of the UFS filesystem).

Soft updates will always ensure that the file size is correct when
writing inodes to disk for files that contain only direct block
pointers. However soft updates does not roll back sizes for files
with indirect blocks that it has set to unallocated because their
contents have not yet been written to disk. Hence, the file can
appear to have a hole at its end because the block pointer has been
rolled back to zero when its inode was written to disk. Thus,
fsck_ffs calculates the last allocated block in the file. For files
that extend into indirect blocks, fsck_ffs checks for a size past
the last allocated block of the file and if that is found, shortens
the file to reference the last allocated block thus avoiding having
it reference a hole at its end.

Submitted by: Chuck Silvers <chs@netflix.com>
Tested by:    Chuck Silvers <chs@netflix.com>
MFC after:    1 week
Sponsored by: Netflix
2019-02-25 21:58:19 +00:00
Kirk McKusick
2c288c95d9 In preparation for adding inode check-hashes, change the fsck_ffs
inodirty() function to have a pointer to the inode being dirtied.
No functional change (as for now the parameter is ununsed).

Sponsored by: Netflix
2018-10-31 05:17:53 +00:00
Ed Maste
d8ba45e213 Revert r313780 (UFS_ prefix) 2018-03-17 12:59:55 +00:00
Ed Maste
1e2b9afca9 Prefix UFS symbols with UFS_ to reduce namespace pollution
Followup to r313780.  Also prefix ext2's and nandfs's versions with
EXT2_ and NANDFS_.

Reported by:	kib
Reviewed by:	kib, mckusick
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D9623
2018-03-17 01:48:27 +00:00
Dimitry Andric
2d3c3a5038 Fix buildworld after r328075, by also renaming cgget to cglookup in
fsdb.

Reported by:	ohartmann@walstatt.org,david@catwhisker.org
Pointy hat to:	mckusick
2018-01-17 13:19:37 +00:00
Xin LI
5a8ad265c9 The fix in r327273 turns a memory leak into freeing wild pointer.
Fix this by freeing only the initialized pointer.
2017-12-29 06:22:05 +00:00
Warner Losh
0bebba31d3 Plug memory leak by freeing wantedblk{32,64}.
CID: 273655, 273656
2017-12-28 05:34:08 +00: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
Ed Maste
1dc349ab95 prefix UFS symbols with UFS_ to reduce namespace pollution
Specifically:
  ROOTINO -> UFS_ROOTINO
  WINO -> UFS_WINO
  NXADDR -> UFS_NXADDR
  NDADDR -> UFS_NDADDR
  NIADDR -> UFS_NIADDR
  MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Also prefix ext2's and nandfs's NDADDR and NIADDR with EXT2_ and NANDFS_

Reviewed by:	kib, mckusick
Obtained from:	NetBSD
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D9536
2017-02-15 19:50:26 +00:00
Marcelo Araujo
02c8c1182b Use nitems() from sys/param.h.
Sponsored by:	gandi.net (BSD Day Taiwan)
2016-07-30 06:19:34 +00:00
Kirk McKusick
81fbded23f Revert 248634 and 248643 (e.g., restoring 248625 and 248639).
Build verified by: Glen Barber (gjb@)
2013-03-23 20:00:02 +00:00
Glen Barber
e1c7cfb200 Revert r248639 to fix build failure on head/ 2013-03-23 08:57:14 +00:00
Kirk McKusick
25bcd53216 Fix the build after addition of cylinder group cacheing (r248625)
Reported by:   Glen Barber (gjb@)
Pointy hat to: Kirk McKusick (mckusick@)
2013-03-23 07:57:30 +00:00
Matthew D Fleming
e25a029eb2 Fix sbin/ build with a 64-bit ino_t.
Original code by:	Gleb Kurtsou
2012-09-27 23:31:06 +00:00
Kirk McKusick
7649cb0043 The dump, fsck_ffs, fsdb, fsirand, newfs, makefs, and quot utilities
include sys/time.h instead of time.h. This include is incorrect as
per the manpages for the APIs and the POSIX definitions. This commit
replaces sys/time.h where necessary with time.h.

The commit also includes some minor style(9) header fixup in newfs.

This commit is part of a larger effort by Garrett Cooper started in
//depot/user/gcooper/posix-conformance-work/ -- to make FreeBSD more
POSIX compliant.

Submitted by:  Garrett Cooper   yanegomi at gmail dot com
2011-01-24 06:17:05 +00:00
Jeff Roberson
113db2dddb - Merge soft-updates journaling from projects/suj/head into head. This
brings in support for an optional intent log which eliminates the need
   for background fsck on unclean shutdown.

Sponsored by:   iXsystems, Yahoo!, and Juniper.
With help from: McKusick and Peter Holm
2010-04-24 07:05:35 +00:00
Pawel Jakub Dawidek
fffbc2a500 Update after function renames.
Sponsored by:	home.pl
2006-10-31 22:07:29 +00:00
Ceri Davies
96dd636028 Allow fsdb to manipulate the birthtime entries on UFS2.
Approved by:	jhb
MFC after:	1 month
2006-08-23 22:44:00 +00:00
Maxim Konovalov
82d9b14e16 o Implement findblk command: find the inode(s) owning the specified
disk block(s) number(s).

Obtained from:	NetBSD
MFC after:	2 months
2006-06-02 12:55:26 +00:00
Maxim Konovalov
1bc508492a o Do recrack(arguments) for commands which actually take NAME as
arguments so we do not coredump at "help foo", "back bar" and such.

o Be consistent and print argc - 1 as a command arguments number in
all cases.

PR:		bin/37096
Submitted by:	Joshua Goodall
MFC after:	1 month
2006-04-21 20:33:16 +00:00
Stefan Farfeleder
2110d9c31a Use the new name H_SETSIZE instead of the old H_EVENT to set the history
size.

PR:	86355
2005-10-19 15:37:43 +00:00
Stefan Farfeleder
515faf2fbe The libedit update made a const cast necessary. 2005-08-07 20:53:33 +00:00
Lukas Ertl
c9eaf2265c Make fsck WARNS=2 clean. 2004-10-09 15:56:34 +00:00
Johan Karlsson
8b5e064d28 Make this WARNS=2 clean by
- #include <timeconv.h> for _time_to_time32 et al
	- use (uintmax_t) and %j
	- remove unused variable 'j' (from PR 39866)

PR:		39866
Submitted by:	Dan Lukes <dan@obluda.cz>
Tested by:	make universe
2003-11-13 19:08:43 +00:00
Tom Rhodes
ce66ddb763 s/filesystem/file system/g as discussed on -developers 2002-08-21 18:11:48 +00:00
Kirk McKusick
1c85e6a35d This commit adds basic support for the UFS2 filesystem. The UFS2
filesystem expands the inode to 256 bytes to make space for 64-bit
block pointers. It also adds a file-creation time field, an ability
to use jumbo blocks per inode to allow extent like pointer density,
and space for extended attributes (up to twice the filesystem block
size worth of attributes, e.g., on a 16K filesystem, there is space
for 32K of attributes). UFS2 fully supports and runs existing UFS1
filesystems. New filesystems built using newfs can be built in either
UFS1 or UFS2 format using the -O option. In this commit UFS1 is
the default format, so if you want to build UFS2 format filesystems,
you must specify -O 2. This default will be changed to UFS2 when
UFS2 proves itself to be stable. In this commit the boot code for
reading UFS2 filesystems is not compiled (see /sys/boot/common/ufsread.c)
as there is insufficient space in the boot block. Once the size of the
boot block is increased, this code can be defined.

Things to note: the definition of SBSIZE has changed to SBLOCKSIZE.
The header file <ufs/ufs/dinode.h> must be included before
<ufs/ffs/fs.h> so as to get the definitions of ufs2_daddr_t and
ufs_lbn_t.

Still TODO:
Verify that the first level bootstraps work for all the architectures.
Convert the utility ffsinfo to understand UFS2 and test growfs.
Add support for the extended attribute storage. Update soft updates
to ensure integrity of extended attribute storage. Switch the
current extended attribute interfaces to use the extended attribute
storage. Add the extent like functionality (framework is there,
but is currently never used).

Sponsored by: DARPA & NAI Labs.
Reviewed by:	Poul-Henning Kamp <phk@freebsd.org>
2002-06-21 06:18:05 +00:00
Tom Rhodes
3468b317cb more file system > filesystem 2002-05-16 04:10:46 +00:00
Warner Losh
0638cc1a39 o __P removal.
o ansi function definitions.
o main prototype removal
o unifdef __STDC__
2002-03-21 13:10:52 +00:00
David E. O'Brien
3d438ad61f Remove 'register' keyword.
It does not help modern compilers, and some may take some hit from it.
(I also found several functions that listed *every* of its 10 local vars with
 "register" -- just how many free registers do people think machines have?)
2002-03-20 17:55:10 +00:00
Joerg Wunsch
280a49ec4b Something i always wanted to see: add a function to print the list of
blocks allocated by some inode.  Indirect blocks are printed
recursively, so beware :), the list could become lengthy...
(We should probably add some output pager to fsdb.)

MFC after:	1 month
2002-01-26 15:53:23 +00:00
Joerg Wunsch
b81ba372c5 Avoid pointless initialization of global variables to 0. This only
bloats the resulting binary file by forcing them out of .bss into
.data, while the C standard already guarantees them to become
initialized to 0 at program startup.

MFC after:	1 week
2002-01-26 15:47:24 +00:00
Joerg Wunsch
aaadf6882c Don't exit with -1 if the user typed "quit".
MFC after:	1 week
2002-01-26 11:21:19 +00:00
Brian Feldman
8660ce229c Allow fsdb the ability to work with entries named with whitespace embedded.
This works by retokenizing a line with a split limit so that if the
argument count for a command is greater than the number of arguments
formed by splitting apart the line of user input, the last argument
is instead all of the remainder of the input line.

Yes, I needed this capability at one point to fix a filesystem manually,
which happened to break with a problematic space-containing directory
entry.
2002-01-25 18:31:57 +00:00
Ian Dowse
75249b648a Check that the mode argument to fsdb's `chmod' command contains no
inode type bits set. Previously it would let you set IFMT bits (but
not clear them). The `chtype' command should be be used instead
for changing the inode type; having chmod half-work only causes
confusion.
2001-11-11 10:44:02 +00:00
David E. O'Brien
757eeda04b *** empty log message *** 2001-10-01 08:43:58 +00:00
Ian Dowse
d164d805c7 In fsdb, call sblock_init() which is now necessary to initialise
the global variable dev_bsize. Add a prototype for sblock_init()
to fsck.h, and set the return type correctly.
2001-04-23 21:39:14 +00:00
Jeroen Ruigrok van der Werven
2ec1f77190 Remove unused includes. 2000-05-01 20:01:16 +00:00
Peter Wemm
7f3dea244c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
Warner Losh
ebe70c8f68 More egcs warning fixes:
o main returns int not void
	o use braces to avoid potentially ambiguous else

Note: The fix to natd is potentially functional in nature since I used
the indentation as the right thing rather than the struct semantics.
Someone more familiar with the code should double check me on this one.

Reviewed by: obrien and chuckr
1999-04-25 22:33:30 +00:00
Don Lewis
508e55f5a4 Fix some calculations that use sizeof to attempt to find the end of an
array that were doing sizeof on an unrelated variable.  This just happened
to work right on the i386, but would not on the alpha.

PR: bin/8427
1998-11-09 03:43:55 +00:00
Philippe Charnier
0227048a1f Correct use of .Nm. Use .Bl/.El for enumerating options. Use .An. Correct
formatting of rcsid. Remove unused #includes. Do not use memory after
freeing it.
1998-06-15 07:12:20 +00:00
Philippe Charnier
617f1bc8c6 Remove __progname. Make -f a no-op flag as stated in the man page. Remove
unused variables.
1997-06-11 07:13:30 +00:00
Joerg Wunsch
36b8baa315 Implement a -r option to fsdb(8), ``read/only''. 1997-04-15 09:02:48 +00:00
Peter Wemm
fd24d57d05 Missing $Id$ 1997-03-13 12:44:53 +00:00
Peter Wemm
76863c5104 Make this compile. Mostly use the new names for the ctime/atime/mtime
stamps in the inodes and call one of fsck's utility funcs with a new arg.
1997-03-13 12:42:22 +00:00
Guido van Rooij
fe3a5bd458 Get rid of useless -f flag (though left for historical reasons). 1996-09-30 20:04:24 +00:00
Guido van Rooij
a9bb2677f6 Add chlen command so you can set the size of an inode. This was handy
in order to create sparse directory files that caused a panic of a
filesystem where fsck would not find anything. A fix for fsck is in the
make but still has to be reviewed by Kirk McKusick.
1996-09-26 19:40:04 +00:00
Nate Williams
b70db4c5d5 ts_sec -> tv_sec
ts_nsec -> tv_nsec
1996-09-20 04:33:57 +00:00