diff options
| author | mlelstv <mlelstv@NetBSD.org> | 2022-04-24 06:48:15 +0000 |
|---|---|---|
| committer | mlelstv <mlelstv@NetBSD.org> | 2022-04-24 06:48:15 +0000 |
| commit | a17aed3befa70ff13d8e8d3ef4340fcecdcd445a (patch) | |
| tree | d6ce678d885587967b940269faa2d7ef9543ffac /sys/lib/libsa/ufs.c | |
| parent | 1640aad2b8e4339f34784a4bc14e52fb6a068cb4 (diff) | |
Ask driver about sector size to support reading superblocks from fixed
byte offsets.
Diffstat (limited to 'sys/lib/libsa/ufs.c')
| -rw-r--r-- | sys/lib/libsa/ufs.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/lib/libsa/ufs.c b/sys/lib/libsa/ufs.c index df0e5a7b475..8a8a328a96a 100644 --- a/sys/lib/libsa/ufs.c +++ b/sys/lib/libsa/ufs.c @@ -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 @@ ffs_find_superblock(struct open_file *f, FS *fs) 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 @@ ffs_find_superblock(struct open_file *f, FS *fs) 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) |
