Commit Graph

706 Commits

Author SHA1 Message Date
christos dc43f412b0 fix clang build 2022-12-01 18:06:09 +00:00
chs 87ba0e2a31 Restore backward compatibility of UFS2 with previous NetBSD releases by
disabling support in UFS2 for extended attributes (including ACLs).
Add a new variant of UFS2 called "UFS2ea" that does support extended attributes.
Add new	fsck_ffs operations "-c	ea" and	"-c no-ea" to convert file systems
from UFS2 to UFS2ea and	vice-versa (both of which delete all existing extended
attributes in the process).
2022-11-17 06:40:38 +00:00
rin eec9572cb1 Consistently use ntohs() instead of htons() when converting from
network to host byte order.

No binary changes both for big and little endian.
2022-08-07 05:51:55 +00:00
skrll afda606fbe alredy -> already 2022-07-08 07:02:47 +00:00
rin 2786ceb6bd Now, NULL is always defined correctly, as we include <sys/param.h> above. 2022-04-30 09:24:05 +00:00
rin 04dc166927 Re-introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
used instead of secsize obtained by SAIOSECSIZE ioctl.

This hack avoids divdi3 and friends from being linked, in order to
support variable secsize for some archs.

Should be useful for ancient archs, for which secsize is fixed.

Thanks christos@ for comment.
2022-04-29 07:42:07 +00:00
rin 7ca4ea5592 Revert previous at the moment.
This is wrong reasoning; 68020 and above (incl. 040 and 060) support
32-bit displacements for PC relative addressing (via "fully extension
addressing mode" with null index register).

I've still not figured out what goes wrong with amiga/boot(8) when
compiled without -l option for gas(1)...

On 2022/04/27 20:48, Rin Okuyama wrote:
> Module Name:	src
> Committed By:	rin
> Date:		Wed Apr 27 11:48:26 UTC 2022
>
> Modified Files:
> 	src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c
>
> Log Message:
> Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
> used instead of secsize obtained by SAIOSECSIZE ioctl.
>
> This hack avoids divdi3 and friends from being linked, in order to
> support variable secsize.
>
> This is useful for amiga/boot(8); it is loaded by firmware into
> unpredictable address, and therefore all symbols should be
> addressable by PC relative mode with only 16-bit displacements.
>
> See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for
> more details.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/ext2fs.c
> cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/minixfs3.c
> cvs rdiff -u -r1.83 -r1.84 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
2022-04-27 14:48:50 +00:00
rin e11b3c29a6 Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
used instead of secsize obtained by SAIOSECSIZE ioctl.

This hack avoids divdi3 and friends from being linked, in order to
support variable secsize.

This is useful for amiga/boot(8); it is loaded by firmware into
unpredictable address, and therefore all symbols should be
addressable by PC relative mode with only 16-bit displacements.

See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for
more details.
2022-04-27 11:48:26 +00:00
mlelstv 56b23fbb85 Don't load filessytem module for filesystem that was found but isn't used
for booting.
2022-04-24 06:52:59 +00:00
mlelstv 5290066ee5 Ask driver about sector size to support reading superblocks from fixed
byte offsets.
2022-04-24 06:48:15 +00:00
skrll a60573591b Typo in comment. avoinds -> avoids 2022-04-19 09:25:38 +00:00
andvar 62e7294679 fix typos, mainly s/comand/command/ 2022-01-05 16:01:54 +00:00
jmcneill e63dca36f8 Only define DEFAULT_TIMEOUT if it is not already defined. 2021-10-17 14:12:21 +00:00
nia b7fed38c88 Remove banner printing code from bootloaders, add it to libsa.
This harmonizes efiboot and the various x86 bootloaders to use shared
code for printing the banner. By friendly coincidence, it also adds
support for specifying 'banner=' in arm efiboot's boot.cfg, as on x86.
2021-09-07 11:41:31 +00:00
mlelstv 70b14a2a2d Add "root" command to provide a BTINFO_ROOTDEVICE parameter. 2021-05-30 05:59:22 +00:00
mrg 13c625776c add bi-endian support to the libsa ufs reader and enable it in efiboot.
ffs frontends to "ufs.c" now also define ufs_dinode_swap, ufs_indp_swap,
and FS_MAGIC (moved from ufs.c #if segments.)  these are used to call
the right (32/64 bit) ffsv1/v2 version.

ufs.c 'struct file' gains f_swapped member.  accessors for d_magic,
d_reclen, and d_ino are introduced (they need to be swapped.)  sfter
reading an inode from disk, read_inode() may call ufs_dinode_swap().
indirect block number and caches may be swapped.

error handling in ffs_find_superblock() is cleaned up.  (size is slightly
reduced on some ports with this part.)

defaults for new defines added to ufs.c.  (XXX: we build ufs.c but i think
all the consumers don't use it, and we can stop building it.)

LFS support is not included.

add a cut-down copy of ffs_bswap.c from the kernel.

also enable bi-endian disklabel support in efiboot.

most ports build and sizes compared for platforms that don't enable this
code and all but one saw reduced code size.  booted several platforms with
new boot code.
2021-05-27 06:54:44 +00:00
mrg ccb4458a63 in getdisklabel() swap the other-endian disklabel, #ifdef LIBSA_DISKLABEL_EI 2021-05-26 04:28:15 +00:00
jmcneill e6f176d843 Capture the endianness of the ELF file loaded in 'netbsd_elf_data', the
same way we do already for the class in 'netbsd_elf_class'.
2021-05-21 21:52:15 +00:00
mrg 7de9d97fa4 move bi-endian disklabel support from the kernel and libsa into libkern.
- dkcksum() and dkcksum_sized() move from subr_disk.c and from
  libsa into libkern/dkcksum.c (which is missing _sized() version),
  using the version from usr.sbin/disklabel.

- swap_disklabel() moves from subr_disk_mbr.c into libkern, now called
  disklabel_swap().  (the sh3 version should be updated to use this.)

- DISKLABEL_EI becomes a first-class option with opt_disklabel.h.

- add libkern.h to libsa/disklabel.c.

this enables future work for bi-endian libsa/ufs.c (relevant for ffsv1,
ffsv2, lfsv1, and lfsv2), as well as making it possible for ports not
using subr_disk_mbr.c to include bi-endian disklabel support (which,
afaict, includes any disk on mbr-supporting platforms that do not have
an mbr as well as disklabel.)

builds successsfully on: alpha, i386, amd64, sun2, sun3, evbarm64,
evbarm64-eb, sparc, and sparc64.  tested in anita on i386 and sparc,
testing in hardware on evbarm64*.
2021-05-17 08:50:36 +00:00
mrg 201465fecc push the FFSv1 superblock code into ffs_find_superblock() and
hide all the ugliness in this function, out of ufs_open().

NFC, objects same size if not identical.
2021-05-12 08:45:28 +00:00
rin 3bc8d4e817 Twiddle also for data transfer for seek. 2021-03-26 10:35:08 +00:00
rin ae5bdb2a50 Fix previous; define missing lfs_version. 2020-12-19 08:51:03 +00:00
rin eb10415da2 ufs_open(): Check fs->lfs_version ifdef LIBSA_*L*FS, not LIBSA_*F*FS.
This was harmless for FFS variants, that define LIBSA_FFSv[12], not LIBSA_FFS.
2020-12-19 07:19:30 +00:00
simonb 20d7b25b25 Add a slow twiddle option. This speeds up a pmax netboot by 15% and
is only 1% slower than no twiddle.
2020-09-29 00:13:12 +00:00
jmcneill 96b5c9e0fe Elf64_Phdr::p_offset is 64 bits, not 32 2020-09-13 13:31:36 +00:00
jmcneill 6fc9a861f9 Elf64_Phdr::p_flags is 32 bits, not 64 2020-09-13 11:09:01 +00:00
mrg c2082ece61 remove GCC_NO_ADDR_OF_PACKED_MEMBER for several subdir builds
that are now handled by lfs_accessors.h internally.
2020-09-07 03:09:53 +00:00
mrg 3b2eb8312b oops, move GCC_NO_ADDR_OF_PACKED_MEMBER into the right header. 2020-09-07 01:54:26 +00:00
mrg 8d620b78e2 apply GCC_NO_ADDR_OF_PACKED_MEMBER 2020-09-07 00:32:49 +00:00
jmcneill 1a7122d335 Support loading boot.cfg from non file-system based devices. 2020-06-27 17:22:12 +00:00
thorpej 30a26bde0a Make libsa's vsnprintf() work as expected when passed a NULL
destinatino buffer.
2020-06-06 15:45:47 +00:00
maxv d151321294 Update the comments. 2020-05-07 18:02:48 +00:00
skrll b3abdcbed7 Make a debug printf compile for all platforms 2020-01-26 10:13:10 +00:00
jakllsch e2703ffc13 Use dp->e2d_namlen rather than strlen(dp->e2d_name) in ext2fs_ls().
Prevents garbage beyond the end of the name from appearing on screen.
2020-01-24 13:20:33 +00:00
martin 39cd2eeea8 To support big partitions we need to make sure all byte offsets are calculated
in 64 bit arithmetic. Pointed out by Rob Newberry.
Unfortunately this causes a code size increase breaking some boot blocks,
so conditionalize it and use 32 bit arithmetic if SA_DOSFS_NO_BIG_PART_SUPPORT
is defined.
2020-01-22 06:11:28 +00:00
mrg 2a440dd580 apply the strncmp hack only to !clang. requested by tnn. 2019-11-21 21:45:34 +00:00
mrg 9631f22ff2 from the new comment:
* XXX Hack alert.  GCC 8.3 mis-compiles this function and calls
 * strncmp() with the wrong second pointer, as seen in PR#54703.
 *
 * Until the real cause is located, work around it by using -O1
 * for this function.

this hack is restricted to i386.
2019-11-21 07:34:39 +00:00
maxv ed6d73e306 Make sure we're dealing with a static binary. Otherwise we could crash if
the user mistakenly tries to boot a KASLR kernel with 'boot' instead of
'pkboot'. Now we fail cleanly. Reported by cryo@.
2019-10-17 14:00:28 +00:00
rin a1eeaadb07 Add SA_ENABLE_BIENDIAN option, which enable us to load kernel image of
opposite byte order (for arm EFI bootloader).

XXX
Currently, it is restricted to load_elf*.c. It would be nice if we can
recognize disklabel and filesystem of opposite byte order.
2019-07-21 16:53:17 +00:00
pgoyette 9ca404d49f Now that the ufs module has been split out from ffs and ext2fs, we need
to update the boot-loader to push all modules required to support the
booted filesystem.  We treat the fsmod string as a slash-separated list
of module names (relative to kern.module.path), rather than as a single
module path name.

Note that ffsv1 and ffsv2 are still exempted from the boot-loader's
auto-push, but the list of required filesystems is still noted in the
source.

Also note that arch/sandpoint needs a similar change.  I have not made
this change because I am totally unable to test it.

Tested on my kernel with _no_ built-in file-systems and with the ffs
bootloader settings of fsmod enabled.
2019-06-24 13:58:24 +00:00
maxv 61683f02cb Add KASLR support in UEFI. 2019-06-20 17:33:30 +00:00
christos b776acde1b Go back ot using 0x%x instead of %#x because we don't always support the
format. See subr_prf.c
2019-04-05 20:09:29 +00:00
christos 94ad267eb1 fix sign-compare and sign-passing errors. 2019-04-02 22:25:10 +00:00
christos 10497fd285 fix warnings, printf formats, etc. 2019-03-31 20:08:45 +00:00
mlelstv fff1131959 correct debug message, d->myport has network byte order. 2019-03-31 16:14:48 +00:00
mrg d64bb6b12a - remove unreachable code 2019-02-03 11:59:43 +00:00
jmcneill b655919a97 Support loading read-only data sections. ARM64 ELF kernels need this. ok skrll@ 2018-08-23 17:35:42 +00:00
christos de3955c3eb Use the standard build rules. 2018-06-05 00:57:47 +00:00
christos c50a4e606c - Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Revert :Q to work as before.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@
XXX: pullup 8
2018-05-27 01:14:50 +00:00
maxv 93eba481f5 Remove annoying things, style, and fix buffer overflows. 2018-05-09 06:49:48 +00:00