Commit Graph

184 Commits

Author SHA1 Message Date
hubertf df06563bc3 Remove more duplicate #includes,
from Slava Semushin <slava.semushin@gmail.com>
2007-01-17 21:59:49 +00:00
tls e1231b8650 Prompt before rolling forward, in interactive mode, so it's possible to fix
the filesystem but not roll forward possibly unwanted changes.
2006-12-01 06:38:39 +00:00
christos b6479e9fff Fix malloc/realloc/calloc issues: always check and exit, use EEXIT instead
of 8.
2006-11-09 19:36:36 +00:00
christos 8dd4b2bbb0 comment out/delete impossible code 2006-10-16 03:21:34 +00:00
christos 8cf4f4e359 c99 initializers 2006-10-16 03:21:05 +00:00
perseant cb2499ac6e Several fixes to improve the reliability of the roll-forward agent.
Also, note "properly orphaned" files as distinct from corrupted files.
2006-09-01 19:52:48 +00:00
christos 2a1607d040 Programs that use efun. 2006-08-26 18:14:28 +00:00
bjh21 952b42f672 Fix typos in messages: SHOULE -> SHOULD 2006-08-13 22:18:09 +00:00
perseant fabf2934ae On-disk inode accounting fix for roll-forward. 2006-07-19 22:48:11 +00:00
perseant a37f15f04c Don't doubly free an inode remove_ino() during roll-forward. 2006-07-19 02:45:10 +00:00
perseant a0a4c29df0 Quell uninitialized-variable warning that appeared when compiling for macppc. 2006-07-18 23:47:44 +00:00
perseant 29f1062b46 Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
  conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
  and use pwarn() instead of printf() so the messages include the device
  name when preening).
* Change superblock detection/avoidance to use the offset table in the
  primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
  especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
  sometimes write blocks from dirop vnodes.  Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
  it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
  inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
  forward.
* Fix segment accounting for blocks and inodes found during roll
  forward.
* Report statistics on roll forward: how many new/deleted/moved files
  and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
  been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
  rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
  Ifile inode and use that to calculate lfs_offset, lfs_curseg,
  lfs_nextseg.  (Again for automated testing.)
2006-07-18 23:37:13 +00:00
christos 657e8b0071 fsck_lfs does not us fsutil.c; perhaps it should? revert to perror for now. 2006-06-05 23:27:36 +00:00
christos 0268f6ea4e s/perror/perr 2006-06-05 16:53:14 +00:00
jnemeth 13eb323a11 Coverity CID 3447: Add extraneous checks to shut up Coverity. 2006-05-23 22:35:20 +00:00
yamt 69f5e94d4e define dummy NOCRED by ourselves, rather than assuming that kernel headers
provide it.
2006-05-03 15:04:51 +00:00
perseant 00d9f4be09 Avoid a core dump if ginode() returns NULL. Correct an error message
while we're here.
2006-04-28 00:07:54 +00:00
christos 23be85ae7f "struct ucred" should not be exposed to userland. Instead make it a "void *"
since it is not really used.
2006-04-19 15:52:58 +00:00
perseant 7700866e01 Remove the free list ordering/disordering code, since the kernel now keeps
the list in order (ordering it on mount).

Regularize error messages: these are now all in ALL CAPS, with all hex
numbers (not reported in caps) prefixed by 0x.  (The non-fsck-specific
messages are an exception to this all-caps rule.)
2006-04-17 19:05:16 +00:00
perseant 1f429c3724 Don't update the superblock if we were run with -n, regardless of whether
the "clean" bit is set.
2006-04-13 19:50:10 +00:00
christos 0794bfc81d Coverity CID 2551: Don't use LIST_FOREACH() if you are going to free the
current element (bp) in the body of the loop; the foreach does bp = bp->next;
2006-03-20 01:20:55 +00:00
perseant 16cb5d93b2 Make it compile again. 2006-03-17 19:24:08 +00:00
rumble e948e1b17f Check for allocation failures in malloc, calloc, realloc, asprintf, and
vasprintf and try to handle them.
2006-03-17 15:53:46 +00:00
jmc 49c83b8ea2 Put back removed initializer. gcc on sh3 still doesn't get it correct... 2005-10-13 21:14:45 +00:00
chs 6c50e54c82 avoid the need for a bogus initializer. 2005-10-08 03:21:17 +00:00
jmmv 2a3e5eeb7c Apply the NFS exports list rototill patch:
- Remove all NFS related stuff from file system specific code.
- Drop the vfs_checkexp hook and generalize it in the new nfs_check_export
  function, thus removing redundancy from all file systems.
- Move all NFS export-related stuff from kern/vfs_subr.c to the new
  file sys/nfs/nfs_export.c.  The former was becoming large and its code
  is always compiled, regardless of the build options.  Using the latter,
  the code is only compiled in when NFSSERVER is enabled.  While doing this,
  also make some functions in nfs_subs.c conditional to NFSSERVER.
- Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST, that takes a
  path and a set of export entries.  At the moment it can only clear the
  exports list or append entries, one by one, but it is done in a way that
  allows setting the whole set of entries atomically in the future (see the
  comment in mountd_set_exports_list or in doc/TODO).
- Change mountd(8) to use the nfssvc(2) system call instead of mount(2) so
  that it becomes file system agnostic.  In fact, all this whole thing was
  done to remove a 'XXX' block from this utility!
- Change the mount*, newfs and fsck* userland utilities to not deal with NFS
  exports initialization; done internally by the kernel when initializing
  the NFS support for each file system.
- Implement an interface for VFS (called VFS hooks) so that several kernel
  subsystems can run arbitrary code upon receipt of specific VFS events.
  At the moment, this only provides support for unmount and is used to
  destroy NFS exports lists from the file systems being unmounted, though it
  has room for extension.

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.
2005-09-23 12:10:31 +00:00
christos 100801ed72 rename lfs.h to lfs_user.h so that it does not conflict. 2005-09-13 04:14:17 +00:00
christos 8a2ba8f0f7 This should be LFS_MAXNAMLEN 2005-08-23 11:44:25 +00:00
tron 0989a73965 Use FFS_MAXNAMLEN instead of MAXNAMLEN. 2005-08-23 11:26:59 +00:00
kent 2fd38e91a5 fix a compilation problem on LP64 2005-08-20 14:59:20 +00:00
christos c4ee9f6d2e 64 bit inode changes 2005-08-19 02:07:18 +00:00
christos 9be35a638f more const. 2005-06-27 02:49:32 +00:00
christos e0dd0ca293 constify 2005-06-27 02:48:28 +00:00
perseant 4b8db8388e Use the correct method to create a new inode, when we allocate lost+found.
Correct uninitialized variable issues in pass6.c and dir.c (PR#30411 and
PR#30394, respectively).
2005-06-08 19:09:55 +00:00
he e82dc5dc94 Initialize metalbn in ufs_getlbns to appease -Wuninitialized.
Marked with XXXGCC for dreamcast (found while compiling for it).

Reviewed by lukem.
2005-06-07 09:08:07 +00:00
lukem 1ab5811713 Disable -Wuninitialized on dir.c (until PR 30394 is addressed)
and pass6.c (until PR 30411 is addressed)
2005-06-03 18:02:03 +00:00
lukem 2b11c546a4 appease gcc -Wuninitialized 2005-06-02 01:02:21 +00:00
agc d5a81777aa Make this build on arm platforms by using the correct printf formats. 2005-05-24 06:51:49 +00:00
perseant b1dbcbaa26 Check some error conditions that would otherwise cause fsck_lfs to dump core.
Pointed out by Pavel Cahyna in a follow-on to PR #29151.
2005-05-23 22:17:20 +00:00
perseant 9bf7a991c5 Fail gracefully if we are asked to expand the buffer cache hash table size
when there is no memory available to do so.  Use the uvnode's strategy
routine to retrieve data from the device, rather than always using pread().
Add a buffer header flag that specifies external management of the buffer's
data area.

All of this in support of a new cleaner, which is not included in this commit.
2005-05-20 18:59:36 +00:00
perseant a73b3b19ea Check parts of pass 5 even if only rolling forward. We can't check the true
segment holdings against the blocks held by the inodes, but we can still
check the cleanerinfo data against the segment table.
2005-04-23 20:21:03 +00:00
wiz 049635f546 Sync usage with man page. 2005-04-14 21:30:11 +00:00
wiz 21a2722f35 Quote a word that would otherwise be interpreted as macro;
increase width argument to .Bl so that all options fit.
2005-04-14 21:29:29 +00:00
wiz b4508f65fb Bump date for new -q; use Dq; capitalize NetBSD
in the usual way; new sentence, new line; some nits.
2005-04-14 21:26:11 +00:00
perseant 68db799864 Document "-f" (force check) flag. Implement and document "-q" (quiet). 2005-04-14 21:15:59 +00:00
perseant b0a56e6928 Take care preserving the integrity of the free list during roll forward.
Also, avoid freeing a deleted vnode twice when a file is remove during
roll forward.
2005-04-12 23:14:18 +00:00
martin 9edc493234 When creating an int hash value from pointer, go via intptr_t.
Fixes PR 29953.
2005-04-12 12:42:02 +00:00
perseant 1d4cc6a17b Be more efficient with the hash tables for the buffer and vnode caches.
Note that roll-forward can add more inodes to the filesystem; don't overflow
the tables but reallocate them.
2005-04-11 23:19:24 +00:00
perseant e6e33f374d Correct phase 0 message 2005-04-06 04:32:59 +00:00
perseant aafc65baa9 Note that fsck_lfs may not know beforehand whether a given block is a
superblock or a segment summary, and tries both.  These may be different
sizes.  Fix a broken assertion that they are the same size.

Fixes PR # 29151.
2005-04-06 02:38:17 +00:00
he 2d66b2737e Move the definition of simple_lock() and simple_unlock() to a common
header, since more of the LFS macros now use these functions.  Since
we're outside of the kernel, these are defined to be empty.
2005-04-01 23:45:59 +00:00
perseant dcba0206d6 "#define lfs_devvp lfs_unlockvp" for readability, since that's what we
use it for in fsck_lfs/newfs_lfs.
2005-03-25 20:16:37 +00:00
perseant 3118a7b178 Make fsck_lfs optimize the inode free list, if it appears to have become
too disordered.  This should improve file creation speed on aged filesystems.
Include code to disorder the list for debugging purposes, though this is
of course not compiled in by default.
2005-03-25 20:14:43 +00:00
perseant 9740d8d0b2 Buffer cache fixes: make sure we initialize all the hash lists, and allow
the cache to grow in size irrespective of how many buffers may be in the
locked queue, since we can't write those in any case.  Prevents fsck_lfs
from spinning when it has too much to write.
2005-03-19 00:43:17 +00:00
perseant 5d2f3e4908 Various minor LFS improvements:
* Extend the lfs library from fsck_lfs(8) so that it can be used with a
  not-yet-existent LFS.  Make newfs_lfs(8) use this library, so it can
  create LFSs whose Ifile is larger than one segment.
* Make newfs_lfs(8) use strsuftoi64() for its arguments, a la newfs(8).
* Make fsck_lfs(8) respect the "file system is clean" flag.
* Don't let fsck_lfs(8) think it has dirty blocks when invoked with the
  -n flag.
2005-02-26 05:45:54 +00:00
perry 5c9f370160 remove obsolete "register" declarations. 2005-02-06 06:13:47 +00:00
perry 251f7f5990 ANSIfy a function declaration, remove obsolete "register" declarations. 2005-02-06 06:13:12 +00:00
xtraeme 76500fc2f9 WARNS=2 is the default defined in sbin/Makefile.inc. (thanks wiz) 2005-01-20 16:39:22 +00:00
xtraeme 0f821b7962 ANSIfy, WARNS=2 2005-01-19 19:41:59 +00:00
christos a73c2bd574 Add a progress meter to fsck_ffs based on the work by thorpej presented
to the mailing lists last January. This is optional.
2005-01-13 15:22:35 +00:00
minoura da5384833d Changes from rev 1.34 and 1.35 of sbin/newfs_lfs/lfs.c. 2004-09-15 03:24:09 +00:00
yamt 17d264b6df zero-out dinode is not a proper way to 'clear' an lfs inode. 2004-07-18 20:51:30 +00:00
yamt 078a5e0d1f remove a prototype of a non-exist function. 2004-07-18 20:03:12 +00:00
wiz e770b57941 Improve description of -b and -m. 2004-07-06 16:51:18 +00:00
wiz 05d7d5d421 Document -m. It was already there, only commented out.
Bump date.

Addresses PR 26067 by Kouichirou Hiratsuka.
2004-07-06 16:49:10 +00:00
yamt deea834892 pass5: dereference of an uninitialized pointer. 2004-05-14 10:41:12 +00:00
christos 6bd1d6d4db Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
2004-04-21 01:05:31 +00:00
perseant 5aaab72dd6 change KES license to standard NetBSD license 2004-03-20 22:31:13 +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
heas 43894fc5ac Check result of malloc().
reviewed by Martin.
2003-12-24 01:39:27 +00:00
dsl e69ce3e4bf Add a -q (quiet) option to print nothing for clean filesystems.
Support in fsck_ffs and stub in fsck_xxx.
Push a few more messages through pwarn() instead of printf() to ensure
disk name is shown.
2003-10-20 12:04:38 +00:00
jdolecek 91b453f2db fix NULL pointer pointer dereference in fileerror() when ino is NULL
problem reported and fix provided in PR kern/23065 by Gary Duzan, only
slightly adjusted to only do the VTOI() when needed
2003-10-05 17:11:23 +00:00
yamt f271a34ced write out modified directory entries to the correct place. 2003-10-03 12:23:22 +00:00
yamt 6e547a61f9 make this work for big (ie. with indirect blocks) directories
without spurious 'EXTRA ..' errors.
2003-10-03 12:22:15 +00:00
itojun 6379e11194 realloc pedant 2003-09-19 08:29:58 +00:00
agc 276d62f603 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22308, verified by myself.
2003-08-07 10:04:22 +00:00
itojun 8883e1fb40 use bounded string op 2003-07-13 08:05:58 +00:00
yamt 884f970fae in ckinode(), use idesc->id_number instead of dino.di_u.inumber
since the latter is invalid for pass2 and vget can return invalid vnode
for inode number 0.
2003-07-12 16:13:38 +00:00
yamt a7f5ddbf64 in lfs_raw_vget(),
- don't leave references into free'ed memory region. (fix SIGBUSes)
- plug a memory leak.
2003-07-12 12:28:23 +00:00
yamt e01ace1f2e - don't assume that malloc'ed memory is zero-filled.
- LIST_INIT {dirty,clean} block lists.
2003-07-12 11:57:59 +00:00
yamt 1d5f020689 fix a null dereference on stale inode. 2003-07-12 11:49:04 +00:00
yamt c992c60208 only read superblock (ie. struct dlfs) from disk and
initialize rest of struct lfs by hand.
(this shouldn't cause a real problem since if superblock is valid,
LFS_SBPAD-sizeof(struct dlfs) bytes after it is always zero-filled, though)

PR/22123 (Izumi Tsutsui)
2003-07-12 11:47:05 +00:00
yamt 96782bb1fd don't use uninitialized variables.
PR/22123 (Izumi Tsutsui)
2003-07-12 11:41:15 +00:00
petrov 552633af59 Fix format string. (no % in PRIx..). 2003-05-08 18:39:09 +00:00
wiz 3b71168fc8 Bump date for last. 2003-04-16 11:58:43 +00:00
fvdl 42614ed3f3 Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
2003-04-02 10:39:19 +00:00
perseant acddf8ff0b Check inode free list tail pointer as well as head pointer, and write both
into the CLEANERINFO block of the Ifile as well as into the superblock.
Make preen update both superblocks.
2003-03-31 19:56:59 +00:00
wiz 0acfa3bb9e Consistently spell occurrence with two rs. 2003-03-29 22:48:37 +00:00
perseant f8b4df4569 Fix some accounting problems when preening, since preening skips phases
1-4 entirely.  Make preen run phase 0, since the Ifile is so important
and the test so quick.
2003-03-29 00:09:43 +00:00
perseant ba10361ab2 Add working writing ability to fsck_lfs, including roll-forward, based on
a partial-segment writer ported from the kernel.
2003-03-28 08:09:52 +00:00
wiz 990562bfef .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
2003-02-25 10:34:36 +00:00
perseant 8685c52d63 Make the "-O" (start filesystem offset) flag to newfs_lfs work correctly,
and update fsck_lfs and dumplfs to deal with it.  Note that while the argument
to -O is given in disk sectors, it must be a multiple of the fragment size,
and although it can be lower than the label or superblock, it can't intersect
either.
2003-02-23 04:32:05 +00:00
perseant b397c875ae Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon.  To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:

* Create a writer daemon kernel thread whose purpose is to handle page
  writes for the pagedaemon, but which also takes over some of the
  functions of lfs_check().  This thread is started the first time an
  LFS is mounted.

* Add a "flags" parameter to GOP_SIZE.  Current values are
  GOP_SIZE_READ, meaning that the call should return the size of the
  in-core version of the file, and GOP_SIZE_WRITE, meaning that it
  should return the on-disk size.  One of GOP_SIZE_READ or
  GOP_SIZE_WRITE must be specified.

* Instead of using malloc(...M_WAITOK) for everything, reserve enough
  resources to get by and use malloc(...M_NOWAIT), using the reserves if
  necessary.  Use the pool subsystem for structures small enough that
  this is feasible.  This also obsoletes LFS_THROTTLE.

And a few that are not strictly necessary:

* Moves the LFS inode extensions off onto a separately allocated
  structure; getting closer to LFS as an LKM.  "Welcome to 1.6O."

* Unified GOP_ALLOC between FFS and LFS.

* Update LFS copyright headers to correct values.

* Actually cast to unsigned in lfs_shellsort, like the comment says.

* Keep track of which segments were empty before the previous
  checkpoint; any segments that pass two checkpoints both dirty and
  empty can be summarily cleaned.  Do this.  Right now lfs_segclean
  still works, but this should be turned into an effectless
  compatibility syscall.
2003-02-17 23:48:08 +00:00
mrg cf9ff87a3a make this build on alpha after daddr_t->64bit 2003-01-28 05:17:12 +00:00
fvdl a3ff3a3038 Bump daddr_t to 64 bits. Replace it with int32_t in all places where
it was used on-disk, so that on-disk formats remain the same.
Remove ufs_daddr_t and ufs_lbn_t for the time being.
2003-01-24 21:55:02 +00:00
wiz b08dad00b7 Use An, Aq for author markup. 2002-10-01 14:23:38 +00:00
wiz 2fb4b1db52 New sentence, new line. By Robert Elz with minimal fixes. 2002-10-01 13:40:23 +00:00
lukem 7360d7b6ae Use ${NETBSDSRCDIR}/some/path instead of ${.CURDIR}/../../some/path 2002-08-19 10:16:51 +00:00
perseant de3d200cd0 Re-checksum the superblock whenever it is marked dirty.
Tested on alpha.
2002-05-23 04:05:11 +00:00
simonb 1d08e313ae Don't bother testing if a uint8_t is > 256 -- that test is always false. 2002-05-09 02:55:49 +00:00