Commit Graph

2327 Commits

Author SHA1 Message Date
riastradh f818fa6833 Explicitly cast between char and unsigned char here. 2016-02-19 04:18:32 +00:00
riastradh 1a5afb31a5 Various housekeeping.
- Include <ufs/lfs/lfs.h> for union lfs_dinode &c.
- Include <string.h> or <sys/systm.h> for memcpy.
- Avoid signedness mismatch in lfs dino accessor for `rdev'.
- Avoid shadowing global `index'.
2016-02-19 03:43:42 +00:00
dholland 4bace1433b u_int{16,32,64}_t -> uint{16,32,64}_t, for the benefit of userland. 2016-01-22 23:06:10 +00:00
riastradh 057229a494 Use buffer cache, not page cache, to expand directories in ext2fs.
Candidate fix for PR kern/50607, PR port-evbmips/50059.

Formerly VOP_WRITE-->ext2fs_write would automatically dispatch to
this code path for writes to directories, but I broke that in
ext2fs_lookup.c rev. 1.78 when disentangling page-cached and
buffer-cached writes.

This was not a problem in ufs, and I didn't notice it in ext2fs,
because ufs consistently used buffercache(9) directly instead of
using VOP_WRITE sometimes as ext2fs did.
2016-01-12 21:29:29 +00:00
christos 1f9364cf7e there is no reason to use __unused here. 2016-01-10 16:14:27 +00:00
dholland 0dba431807 Fix two functions that were accidentally "static __unused" instead of
"static __unused inline". Oops; but probably not actually harmful.
2016-01-10 02:40:21 +00:00
christos 7c83b624ee We need to check if the inode is initialized for ffsv2 when we translate a
filehandle to a vnode. This can come from nfs and it could be out of range.
In that case we read garbage from the disk, end up trying to free bogus data
when we put the vnode back and we crash.
XXX: pullup-7
2015-12-23 23:31:28 +00:00
dholland a2dfdcb6f0 Update now-lying comment. 2015-11-26 19:25:54 +00:00
mlelstv 20725a9902 fix assertion checking that bufrd function is used only for large symlinks
that aren't embedded in the inode.
2015-11-23 08:00:45 +00:00
pgoyette 4873380492 If file system ffs is built with WAPBL defined, make sure that the
module depends on the wapbl module.

No impact to users of built-in ffs file system code, as the WAPBL
#define will cause inclusion of the code in the kernel.

A standard build of the modular ffs file system code will #define
WAPBL, so the module will only work on a kernel which was also
built with WAPBL defined (or, once I commit it, with a dynamically-
loaded wapbl module).
2015-11-15 01:39:23 +00:00
pgoyette 4746239292 Remove historic references to wapbl. 2015-11-14 22:03:54 +00:00
maxv 0bd06ee797 Fix PR 50070. From hannken@. 2015-10-22 11:31:31 +00:00
dholland f942ea8941 fix stupid typo in the 64-bit branch of the d_namlen accessor 2015-10-19 04:22:28 +00:00
dholland b53aa31418 Set the legacy ulfs fstype field to ULFS2 when mounting lfs64. Oops. 2015-10-19 04:22:18 +00:00
dholland b7c7abea00 improve some panic messages 2015-10-19 04:21:48 +00:00
dholland 19d34e9eca Enable mounting lfs64 volumes. 2015-10-15 06:25:34 +00:00
dholland 960bd58eff Remove stray #define of lfs_magic
(the last of the fake superblock structure field macros)
2015-10-15 06:24:21 +00:00
dholland ce301f42e4 For now bitflip the lfs64 magic number.
This will be unflipped when the format is finalized - right now I
still have pending changes to the superblock in mind (to reduce the
number of redundant fields) so anything created now is not future-
proof. However, the code's also nearing being ready for testing; so
I'm doing this before turning it on as a precaution.
2015-10-15 06:24:08 +00:00
dholland 1655608c85 Move stuff from struct ulfsmount to struct lfs. 2015-10-15 06:15:48 +00:00
dholland ae8888723f Fix minor bitrot in #if 0 or otherwise disabled code. 2015-10-10 22:34:33 +00:00
dholland 7e31609f91 Remove no longer needed explicit 32->64 sign extension.
This is the last 32-bit-on-disk item among those that were either
already tagged or readily discoverable.
2015-10-10 22:33:57 +00:00
dholland 791b636204 Add byteswapping to the inode block-pointer accessors. 2015-10-10 22:33:44 +00:00
dholland 5cc5e3bd23 Use accessors for some more indirect block manipulations. 2015-10-10 22:33:31 +00:00
hannken 7de3300bb9 Remove dubious vhold()/holdrele() from lfs_reserve().
The vnodes are always referenced on entry.

If we changed ulfs_remove() and ulfs_rmdir() to return the locked dvp
the vnodes were always locked on entry.

Remove an outdated comment from lfs_reserveavail(), unlocking/relocking
the vnode was removed in rev 1.49.
2015-10-03 09:31:29 +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 a407c8d218 Use IINFO in lfs_writeinode().
(both the kernel and the userland copies)
2015-10-03 08:28:15 +00:00
dholland 99646ab5f8 Use the new IINFO in the rfw code, eliminating hardwired 32-bit values. 2015-10-03 08:27:55 +00:00
dholland 8f0c85a18e Add an IINFO struct, which is like the FINFO struct but for the inode
blocks portion of the segment summary.

A segment summary block begins with a header (SEGSUM); the rest of the
block contains FINFO structures describing file blocks growing upward
from the bottom (after the header), and IINFO structures describing
inode blocks grown downward from the end of the block. (When they meet
the segment is full regardless of how many blocks might be left.)

IINFO contains just a block number, and until now this information was
handled by just using uint32_t*; switching to a structure will make
the code a lot easier to read, and also make it easier to have 32-bit
and 64-bit versions without making a mess.

This commit just adds the structures and accessors; they'll be
deployed into the code in subsequent commits.
2015-10-03 08:27:38 +00:00
dholland cfe9c0210f Fix some assorted 32-bit assumptions not yet otherwise handled.
Also apply patch to fix the overt problem in PR 50246: newfs was
calculating ifpb wrong for volumes with non-default block sizes.
2015-09-21 01:24:58 +00:00
dholland 7ac462185b Oops, I forgot to make the atime in the 64-bit IFILE 64 bits.
Correct that. Incompatible change, but no LFS64 volumes can have been
created yet.
2015-09-21 01:24:39 +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 105e003c9a Fix glaringly stupid overflow/sizing bug in -r1.25. The part I don't
get is how it passed testing...
2015-09-20 04:50:58 +00:00
dholland 7ad6b1a922 Remove struct lfs_direct (no longer used) and update the big block
comment about directories.
2015-09-15 15:02:40 +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 c96fd3a912 Kill off the ulfs_direct_cache pool.
We no longer allocate temporary struct directs, so we don't need a
pool for them.
2015-09-15 15:01:03 +00:00
dholland 53a3e07718 Tidy up ulfs_direnter: don't malloc a temporary struct lfs_direct
and double-copy it. Just write to the destination buffer.
2015-09-15 15:00:49 +00:00
dholland 54671fde93 Kill off ulfs_makedirentry; just pass the data to ulfs_direnter instead.
For now, move one copy of the code that allocates and fills in a
temporary struct lfs_direct to the top of ulfs_direnter; but it should
go away shortly.
2015-09-15 15:00:32 +00:00
dholland c2c4048b2d Move the header part of struct lfs_direct to its own structure.
(lfs_dirheader)

Take the opportunity to improve the directory generation code in
make_lfs.c. (Everything else was unaffected by virtue of using
accessor functions.)
2015-09-15 14:59:58 +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 8f73830c5d Fix wrong code in lfs_valloc_fixed(). It was overwriting the inode
number it was supposed to be allocating with the head of the inode
freelist, then applying the wrong test to that result. Net result:
unless the freelist was empty (in which case it would always fail),
it would in general drop a bunch of entries from the freelist.

This code seems to have been broken when the first version of lfsv2
was imported onto the perseant-lfsv2 branch in -r1.47.2.1, and
remained broken since, in spite of having been moved to lfs_rfw.c and
back and rearranged quite a bit in the meantime.

Sigh.

Found by Coverity in a rather confusing way as CID 1316545.
2015-09-13 07:53:37 +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 8b103a9c19 Pull over comments on struct direct's type/reclen byte swapping from LFS. 2015-09-01 06:16:03 +00:00
dholland 3911af9340 Comments on directories.
This includes a description of the struct direct byteswap horrors that
ought to be propagated to ufs/ufs.
2015-09-01 06:15:46 +00:00
dholland 98320d1917 Fix up indirect block handling in truncate to be 32/64 clean. 2015-09-01 06:13:09 +00:00