u-boot/fs
mwleeds@mailtundra.com 730c69f133 zfs: Fix zfs_read() to actually work
Without this patch, the while loop being modified goes on infinitely,
but with the patch I am able to boot linux on zfs on a jetson tx2 nx.

It seems like this code was never tested because the logic is clearly
wrong. The function do_div(a,b) does a division that modifies the first
parameter to have a = a / b, and returns the remainder of the division.
So clearly in the usual case when file->offset = 0, the line
"blkid = do_div(blkid, blksz);" just results in blkid being set to zero
on every iteration of the loop, rather than being incremented as blocks
are read. Hence the zeroth block is read over and over and this becomes
an infinite loop.

So instead capture the remainder of the division in a "blkoff" variable,
and use that to properly calculate the memory address to move from in
memmove() below.

For example, if file->offset were 1337, on the first iteration of the
loop blkid would be 0 and blkoff would be 1337. If the blksz is 131072
(as it was for me), that amount of data would be copied into
data->file_buf. movesize would be 131072 - 1337 = 129735 so 129735 bytes
would be moved into buf. On the second iteration of the loop (assuming
there is one), red would be 129735, blkid would be 1, blkoff would be 0,
and 131072 bytes would be copied into buf. And so on...

Signed-off-by: Phaedrus Leeds <mwleeds@mailtundra.com>
2024-04-17 10:08:58 -06:00
..
btrfs global: Drop common.h inclusion 2023-12-21 08:54:37 -05:00
cbfs spl: Ensure all SPL symbols in Kconfig have some SPL dependency 2022-07-07 09:29:08 -04:00
cramfs cramfs: clean up some error messages 2023-08-08 17:41:52 -04:00
erofs fs/erofs: Quieten test for filesystem presence 2023-08-19 04:12:52 +02:00
ext4 ext4: detect directories in ext4fs_exists() 2024-03-04 10:25:47 -05:00
fat fs: fat: add bootsector validity check 2023-11-28 20:10:25 -05:00
jffs2 fs: jffs2: Move SYS_JFFS2_SORT_FRAGMENTS to Kconfig 2022-11-10 09:45:54 -05:00
sandbox bootstd: Use bootdev instead of bootdevice 2023-07-16 23:13:17 +08:00
squashfs fs/squashfs: enable LZ4 compression support 2023-11-16 18:53:09 -05:00
ubifs treewide: use linux/time.h for time conversion defines 2023-11-16 18:59:58 -05:00
yaffs2 global: Drop common.h inclusion 2023-12-21 08:54:37 -05:00
zfs zfs: Fix zfs_read() to actually work 2024-04-17 10:08:58 -06:00
fs_internal.c fs: Quieten down the filesystems more 2022-10-17 21:17:12 -06:00
fs.c fs: remove explicit efi configuration dependency 2024-01-17 08:40:25 +01:00
Kconfig fs: drop reiserfs 2024-03-04 10:25:47 -05:00
Makefile fs: drop reiserfs 2024-03-04 10:25:47 -05:00
semihostingfs.c semihosting: create file in smh_fs_write_at() 2023-05-31 17:23:01 -04:00