summaryrefslogtreecommitdiff
path: root/sys/lib/libsa/minixfs3.c
diff options
context:
space:
mode:
authormlelstv <mlelstv@NetBSD.org>2022-04-24 06:48:15 +0000
committermlelstv <mlelstv@NetBSD.org>2022-04-24 06:48:15 +0000
commita17aed3befa70ff13d8e8d3ef4340fcecdcd445a (patch)
treed6ce678d885587967b940269faa2d7ef9543ffac /sys/lib/libsa/minixfs3.c
parent1640aad2b8e4339f34784a4bc14e52fb6a068cb4 (diff)
Ask driver about sector size to support reading superblocks from fixed
byte offsets.
Diffstat (limited to 'sys/lib/libsa/minixfs3.c')
-rw-r--r--sys/lib/libsa/minixfs3.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/lib/libsa/minixfs3.c b/sys/lib/libsa/minixfs3.c
index e1622c2e623..9903f12d4fd 100644
--- a/sys/lib/libsa/minixfs3.c
+++ b/sys/lib/libsa/minixfs3.c
@@ -1,4 +1,4 @@
-/* $NetBSD: minixfs3.c,v 1.9 2022/04/19 09:25:38 skrll Exp $ */
+/* $NetBSD: minixfs3.c,v 1.10 2022/04/24 06:48:15 mlelstv Exp $ */
/*-
* Copyright (c) 2012
@@ -449,6 +449,7 @@ read_sblock(struct open_file *f, struct mfs_sblock *fs)
static uint8_t sbbuf[MINBSIZE];
size_t buf_size;
int rc;
+ u_int secsize;
/* We must read amount multiple of sector size, hence we can't
* read SBSIZE and read MINBSIZE.
@@ -456,8 +457,13 @@ read_sblock(struct open_file *f, struct mfs_sblock *fs)
if (SBSIZE > MINBSIZE)
return EINVAL;
+ secsize = 0;
+ rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, &secsize);
+ if (rc != 0 || secsize == 0)
+ secsize = DEV_BSIZE;
+
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
- SUPER_BLOCK_OFF / DEV_BSIZE, MINBSIZE, sbbuf, &buf_size);
+ SUPER_BLOCK_OFF / secsize, MINBSIZE, sbbuf, &buf_size);
if (rc)
return rc;