Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/lib/libsa push the FFSv1 superblock code into ffs_find_s...
details: https://anonhg.NetBSD.org/src/rev/477758e4a91f
branches: trunk
changeset: 983253:477758e4a91f
user: mrg <mrg%NetBSD.org@localhost>
date: Wed May 12 08:45:28 2021 +0000
description:
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.
diffstat:
sys/lib/libsa/ufs.c | 51 ++++++++++++++++++++-------------------------------
1 files changed, 20 insertions(+), 31 deletions(-)
diffs (101 lines):
diff -r 9f0c7a756fa5 -r 477758e4a91f sys/lib/libsa/ufs.c
--- a/sys/lib/libsa/ufs.c Wed May 12 06:39:28 2021 +0000
+++ b/sys/lib/libsa/ufs.c Wed May 12 08:45:28 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs.c,v 1.78 2020/12/19 08:51:03 rin Exp $ */
+/* $NetBSD: ufs.c,v 1.79 2021/05/12 08:45:28 mrg Exp $ */
/*-
* Copyright (c) 1993
@@ -201,9 +201,6 @@
#ifdef LIBSA_FFSv1
static void ffs_oldfscompat(FS *);
#endif
-#ifdef LIBSA_FFSv2
-static int ffs_find_superblock(struct open_file *, FS *);
-#endif
#ifdef LIBSA_LFS
@@ -513,15 +510,14 @@
return ENOENT;
}
-#ifdef LIBSA_FFSv2
-
-daddr_t sblock_try[] = SBLOCKSEARCH;
-
-static int
+static __inline__ int
ffs_find_superblock(struct open_file *f, FS *fs)
{
- int i, rc;
+ int rc;
size_t buf_size;
+#ifdef LIBSA_FFSv2
+ static daddr_t sblock_try[] = SBLOCKSEARCH;
+ int i;
for (i = 0; sblock_try[i] != -1; i++) {
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
@@ -536,10 +532,21 @@
}
}
return EINVAL;
+#else /* LIBSA_FFSv2 */
+ rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
+ SBLOCKOFFSET / DEV_BSIZE, SBLOCKSIZE, fs, &buf_size);
+ if (rc)
+ return rc;
+ if (buf_size != SBLOCKSIZE ||
+#ifdef LIBSA_LFS
+ fs->lfs_version != REQUIRED_LFS_VERSION ||
+#endif
+ fs->fs_magic != FS_MAGIC)
+ return EINVAL;
+ return 0;
+#endif /* !LIBSA_FFSv2 */
}
-#endif
-
/*
* Open a file.
*/
@@ -571,26 +578,10 @@
fp->f_fs = fs;
twiddle();
-#ifdef LIBSA_FFSv2
rc = ffs_find_superblock(f, fs);
if (rc)
goto out;
-#else
- {
- size_t buf_size;
- rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
- SBLOCKOFFSET / DEV_BSIZE, SBLOCKSIZE, fs, &buf_size);
- if (rc)
- goto out;
- if (buf_size != SBLOCKSIZE ||
-#ifdef LIBSA_LFS
- fs->lfs_version != REQUIRED_LFS_VERSION ||
-#endif
- fs->fs_magic != FS_MAGIC) {
- rc = EINVAL;
- goto out;
- }
- }
+
#if defined(LIBSA_LFS) && REQUIRED_LFS_VERSION == 2
/*
* XXX We should check the second superblock and use the eldest
@@ -604,8 +595,6 @@
fs->lfs_dobyteswap = 0;
fs->lfs_hasolddirfmt = (fs->fs_maxsymlinklen <= 0);
#endif
-#endif
-
#ifdef LIBSA_FFSv1
ffs_oldfscompat(fs);
#endif
Home |
Main Index |
Thread Index |
Old Index