Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/lib/libsa Ask driver about sector size to support readin...
details: https://anonhg.NetBSD.org/src/rev/24b7699fe7b3
branches: trunk
changeset: 365764:24b7699fe7b3
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sun Apr 24 06:48:15 2022 +0000
description:
Ask driver about sector size to support reading superblocks from fixed
byte offsets.
diffstat:
sys/lib/libsa/ext2fs.c | 10 ++++++++--
sys/lib/libsa/minixfs3.c | 10 ++++++++--
sys/lib/libsa/saioctl.h | 4 +++-
sys/lib/libsa/ufs.c | 14 +++++++++++---
4 files changed, 30 insertions(+), 8 deletions(-)
diffs (114 lines):
diff -r a06dcf0d22ef -r 24b7699fe7b3 sys/lib/libsa/ext2fs.c
--- a/sys/lib/libsa/ext2fs.c Sat Apr 23 22:40:28 2022 +0000
+++ b/sys/lib/libsa/ext2fs.c Sun Apr 24 06:48:15 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs.c,v 1.30 2022/04/19 09:25:38 skrll Exp $ */
+/* $NetBSD: ext2fs.c,v 1.31 2022/04/24 06:48:15 mlelstv Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer.
@@ -415,9 +415,15 @@
struct ext2fs ext2fs;
size_t buf_size;
int rc;
+ u_int secsize;
+
+ 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,
- SBOFF / DEV_BSIZE, SBSIZE, sbbuf, &buf_size);
+ SBOFF / secsize, SBSIZE, sbbuf, &buf_size);
if (rc)
return rc;
diff -r a06dcf0d22ef -r 24b7699fe7b3 sys/lib/libsa/minixfs3.c
--- a/sys/lib/libsa/minixfs3.c Sat Apr 23 22:40:28 2022 +0000
+++ b/sys/lib/libsa/minixfs3.c Sun Apr 24 06:48:15 2022 +0000
@@ -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 @@
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 @@
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;
diff -r a06dcf0d22ef -r 24b7699fe7b3 sys/lib/libsa/saioctl.h
--- a/sys/lib/libsa/saioctl.h Sat Apr 23 22:40:28 2022 +0000
+++ b/sys/lib/libsa/saioctl.h Sun Apr 24 06:48:15 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: saioctl.h,v 1.4 2005/12/11 12:24:46 christos Exp $ */
+/* $NetBSD: saioctl.h,v 1.5 2022/04/24 06:48:15 mlelstv Exp $ */
/*-
* Copyright (c) 1993
@@ -46,3 +46,5 @@
#define SAIOSSDEV (('d'<<8)|12) /* is device skip sector type? */
#define SAIODEBUG (('d'<<8)|13) /* enable/disable debugging */
#define SAIOGBADINFO (('d'<<8)|14) /* get bad-sector table */
+
+#define SAIOSECSIZE (('d'<<8)|15) /* get sector size */
diff -r a06dcf0d22ef -r 24b7699fe7b3 sys/lib/libsa/ufs.c
--- a/sys/lib/libsa/ufs.c Sat Apr 23 22:40:28 2022 +0000
+++ b/sys/lib/libsa/ufs.c Sun Apr 24 06:48:15 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs.c,v 1.81 2022/04/19 09:25:38 skrll Exp $ */
+/* $NetBSD: ufs.c,v 1.82 2022/04/24 06:48:15 mlelstv Exp $ */
/*-
* Copyright (c) 1993
@@ -594,13 +594,21 @@
struct file *fp = (struct file *)f->f_fsdata;
int rc;
size_t buf_size;
+ u_int secsize;
#ifdef LIBSA_FFSv2
static daddr_t sblock_try[] = SBLOCKSEARCH;
int i;
+#endif
+ secsize = 0;
+ rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, &secsize);
+ if (rc != 0 || secsize == 0)
+ secsize = DEV_BSIZE;
+
+#ifdef LIBSA_FFSv2
for (i = 0; sblock_try[i] != -1; i++) {
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
- sblock_try[i] / DEV_BSIZE, SBLOCKSIZE, fs, &buf_size);
+ sblock_try[i] / secsize, SBLOCKSIZE, fs, &buf_size);
if (rc)
return rc;
if (buf_size != SBLOCKSIZE)
@@ -615,7 +623,7 @@
return EINVAL;
#else /* LIBSA_FFSv2 */
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
- SBLOCKOFFSET / DEV_BSIZE, SBLOCKSIZE, fs, &buf_size);
+ SBLOCKOFFSET / secsize, SBLOCKSIZE, fs, &buf_size);
if (rc)
return rc;
if (buf_size != SBLOCKSIZE)
Home |
Main Index |
Thread Index |
Old Index