Commit Graph

247 Commits

Author SHA1 Message Date
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
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
zafer c3796b42cb Remove duplicate assignments.
Fixes PR bin/51512 by Jose Luis Rodriguez Garcia
2018-06-12 20:12:21 +00:00
christos 373dcdfac1 PR/51418: Jose Luis Rodriguez Garcia: Fix incore src/sbin/fsck_lfs/bufcache.c
XXX: pullup-8, pullup-7
2018-03-30 12:56:46 +00:00
pgoyette 94d854a4fc Update inode member i_flag --> i_state to keep up with kernel changes 2017-06-10 08:13:15 +00:00
chs 8903716be3 this file uses the <sys/queue.h> macros so it should include
that header itself, rather than relying on getting it indirectly
by including some other header.
2017-06-09 00:13:08 +00:00
christos a8664d176f PR/51478: Jose Luis Rodriguez Garcia: Fix leak mem fsck_lfs/lfs.c 2016-09-16 11:13:47 +00:00
christos 99accdc793 PR/51440: Jose Luis Rodriguez Garcia: Use the standard queue.h macro instead
of playing with the TAILQ's entrails.
2016-08-25 07:43:18 +00:00
christos 4d4594470b PR/51422: Jose Luis Rodriguez Garcia: completely remove B_NEEDCOMMIT 2016-08-18 08:08:02 +00:00
christos e9843116de PR/51422: Jose Luis Rodriguez Garcia: Remove unnecessary assignment. 2016-08-18 08:04:28 +00:00
dholland ed2ef35eef PR 51264 Jose Luis Rodriguez Garcia: lfs userland bufcache rehash is broken 2016-07-31 18:27:26 +00:00
dholland 89579fda21 Comment out unused logic. PR 50973 2016-03-20 04:24:46 +00:00
christos 1e4eeef8ef PR/50974: David Binderman: Remove unused code. 2016-03-17 18:56:14 +00:00
riastradh 9628679b27 Need <stdbool.h> for true/false. 2016-02-19 03:53:46 +00:00
dholland ae64c38ebb Enable lfs64 in fsck_lfs.
(and in everything else that uses this code)
2015-10-15 06:24:55 +00:00
dholland f3729261c1 Track down and fix two missing uses of SEGSUM_FINFOBASE(). 2015-10-10 22:34:09 +00:00
dholland da7186290f The per-inode state 'id_entryno' is used by pass1 for a block count,
so widen it to 'long long'. pass2 uses it for the number of entries in
a directory (IIUC) which does not need to be wider than int, but for
now let's not try to split into two fields. FUTURE...
2015-10-03 08:30:13 +00:00
dholland a07fd0a2a2 Use daddr_t instead of uint32_t for the in-memory copy of the inode
block pointers.
2015-10-03 08:30:02 +00:00
dholland 896006c986 Drop an explicit sign-extension in fsck that shouldn't be needed any
more.
2015-10-03 08:29:48 +00:00
dholland 93f2a7d5e8 Add lfs_checkword type for reading checksum data out of structures.
This is always uint32_t, but having a name for it both makes things
clearer and avoids confusion about whether it should be 32 or 64 bit.

Note: deployed in only one place (that was erroneously tagged
ondisk32) so far.
2015-10-03 08:29:34 +00:00
dholland db7a6054ae Fix hardwired 32-bit stuff in fsck:
- compute the maximum file size using LFS_BLKPTRSIZE()
   - use the new IINFO in pass 6 instead of uint32_t pointers
   - use accessors to read and write indirect blocks
2015-10-03 08:29:21 +00:00
dholland b82b54bc04 Remove a dead data structure. 2015-10-03 08:29:06 +00:00
dholland 7f7a5fa1e3 Apply IINFO in the other userland tools. 2015-10-03 08:28:46 +00:00
dholland a407c8d218 Use IINFO in lfs_writeinode().
(both the kernel and the userland copies)
2015-10-03 08:28:15 +00:00
dholland 947343ea0e Add 64-bit directory entry structures, and adjust accessors accordingly.
The LFS64 directory entry has a 64-bit inode number. This is stored as
two 32-bit values to avoid inducing 64-bit alignment requirements.

The exposed type for manipulating directory entries is now
LFS_DIRHEADER, following the same convention as e.g. IFILE and SEGUSE.
(But with LFS_ on it, because.)
2015-09-21 01:24:23 +00:00
dholland 80201f5aa5 Oops; LFS_DIRECTSIZ() is going to need the fs as an argument.
Also, it turns out that dirhash needs a compile-time-constant version
of LFS_DIRECTSIZ(LFS_MAXNAMLEN+1), independent of 64-vs-32, so create
LFS_MAXDIRENTRYSIZE for this. Sigh.
2015-09-21 01:22:18 +00:00
dholland 75caa729bb Clean up struct lfs_dirtemplate. 2015-09-20 04:51:43 +00:00
dholland 805a8504cb Pass around struct lfs_dirheader instead of struct lfs_direct. 2015-09-15 15:02:25 +00:00
dholland 98320dbc87 Add an accessor function for directory names. 2015-09-15 15:02:01 +00:00
dholland 653d6346b1 Add a function lfs_copydirname() to copy directory names in place; use
it in place of (variously) memcpy and strlcpy. (The latter isn't even
correct; was probably changed blindly from strncpy at some point.)

The new function zeroes the padding in the directory entry instead of
leaving trash behind.
2015-09-15 15:01:38 +00:00
dholland 06be19e226 Tidyups/fixes preparatory to making d_name[] in struct lfs_direct size
0 instead of size LFS_MAXNAMLEN+1, and preparatory to having accessor
functions for d_name. In particular, don't create prototype entries
and copy them, and access the name field only for directory structures
that are in buffers with space for the name to exist.
2015-09-15 15:01:22 +00:00
dholland 5a97d9e5b6 Add and use accessor functions for more of the directory entry fields. 2015-09-15 14:58:05 +00:00
dholland ec175d5025 Add new accessors for the d_type and d_namlen fields of struct lfs_direct.
Napalm the old byteswap access logic for these.
2015-09-01 06:16:58 +00:00
dholland 5f1180cf85 Remove ulfs_daddr_t. 2015-09-01 06:15:16 +00:00
dholland 08dc10dc96 Use daddr_t, not ulfs_daddr_t, as the latter's 32 bits wide.
Don't use either for on-disk items.
Declare external data in header files.
Part 3 of 3.
2015-09-01 06:15:02 +00:00
dholland 481db95097 Use daddr_t, not ulfs_daddr_t, as the latter's 32 bits wide.
Don't use either for on-disk items.
Part 2 of 3.
2015-09-01 06:13:57 +00:00
dholland dfb99dfd3e Use daddr_t, not ulfs_daddr_t, as the latter's 32 bits wide.
Don't use either for on-disk items.
Part 1 of 3.
2015-09-01 06:13:33 +00:00
dholland 30c3aa6e8a Tidy the MAXSYMLINKLEN macros. 2015-09-01 06:12:33 +00:00
dholland eb2560adae The ifile's inode number is constant. (it is always 1)
Therefore, storing the value in the superblock and reading it out
again is silly and offers the opportunity for it to become corrupted.
So, don't do that (most of the code already didn't) and use the
existing constant instead. Initialize new 32-bit superblocks with
the value for the sake of old userland programs, but don't keep the
value in the 64-bit superblock at all.

(approved by Margo Seltzer)
2015-09-01 06:12:04 +00:00
dholland 4b344787e1 Make the inode fields in the 64-bit superblock 64 bits wide.
Reasoning as before.

Note that I am not going through and checking for 64->32 truncations
in inode numbers; I'm sure there are quite a few, but that's a project
for later.
2015-09-01 06:11:06 +00:00
dholland 4d398b859d Add byteswapping to the dinode accessors.
This prevents regressions in the ulfs code when switching to the new
accessors. Note that while adding byteswapping to the other accessors
is straightforward, I haven't done it yet; and that also is not enough
to make LFS_EI work, because there are places lying around that bypass
the accessors for one reason and another and all of them need to be
updated. That is going to have to wait for a later day as LFS_EI is
not on the critical path right now.
2015-09-01 06:10:16 +00:00
dholland da32f22c2a Use the lfs dinode accessors in place of the ufs-derived ones.
(Mostly.)

The ufs-derived ones are fake structure member macros, which are gross
and not very safe. Also, it seems that a lot of places in the lfs code
were using the ffsv1 branch of them unconditionally, and this way it's
guaranteed all those places have been updated.

Found while doing this: for non-devices, have getattr produce NODEV
in the rdev field instead of leaking the address of the first direct
block.
2015-09-01 06:08:37 +00:00
christos cf0ea7fe31 swap the formats too, not just the args. 2015-08-23 16:00:23 +00:00
dholland 336a1ae812 Fix reversed arguments to a print. nice and confusing... 2015-08-23 09:29:46 +00:00
dholland c9cfc4bd98 Part two of dinodes; use the same union everywhere.
(previously the ufs-derived code had things set up slightly different)

Remove a bunch of associated mess.
2015-08-19 20:33:29 +00:00
dholland b1828e0ba3 Hack up dinode usage to be 64 vs. 32 as needed. Part 1.
(This part changes the native lfs code; the ufs-derived code already
has 64 vs. 32 logic, but as aspects of it are unsafe, and don't
entirely interoperate cleanly with the lfs 64/32 stuff, pass 2 will be
rehashing that.)
2015-08-12 18:28:00 +00:00
dholland e54b457c15 Provide 32-bit and 64-bit versions of FINFO.
This also entailed sorting out part of struct segment, as that
contains a pointer into the current FINFO data.
2015-08-12 18:27:01 +00:00
dholland 2e090556c4 Make 32-bit and 64-bit versions of SEGSUM.
Also fix some of the FINFO handling as it's closely entangled.
2015-08-12 18:26:26 +00:00
dholland 32577c4f1c Add IFILE32 and IFILE64 structures for the on-disk ifile entries.
Add and use accessors. There are also a bunch of places that cast and
I hope I've found them all...
2015-08-12 18:25:51 +00:00
dholland f11e4edeba Make 32-bit and 64-bit versions of CLEANERINFO.
XXX: while this is written to disk, it seems like much of it would
XXX: be better set up as a commpage shared with the cleaner.
2015-08-12 18:25:03 +00:00