Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/lib/libsa Add support for LFSv2 filesystems. From a lib...
details: https://anonhg.NetBSD.org/src/rev/8bb4608a5b57
branches: trunk
changeset: 543367:8bb4608a5b57
user: simonb <simonb%NetBSD.org@localhost>
date: Sun Feb 23 23:17:42 2003 +0000
description:
Add support for LFSv2 filesystems. From a libsa standpoint, LFSv1 and
LFSv2 are treated as separate filesystem types for size considerations.
diffstat:
sys/lib/libsa/Makefile | 4 +-
sys/lib/libsa/lfs.c | 72 ++++++++++++++++++++++++++++++++++---------------
sys/lib/libsa/lfs.h | 23 +++++++++------
sys/lib/libsa/lfsv1.c | 4 ++
sys/lib/libsa/lfsv2.c | 4 ++
5 files changed, 74 insertions(+), 33 deletions(-)
diffs (216 lines):
diff -r 244debf78113 -r 8bb4608a5b57 sys/lib/libsa/Makefile
--- a/sys/lib/libsa/Makefile Sun Feb 23 23:08:21 2003 +0000
+++ b/sys/lib/libsa/Makefile Sun Feb 23 23:17:42 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.51 2002/03/15 13:23:34 simonb Exp $
+# $NetBSD: Makefile,v 1.52 2003/02/23 23:17:42 simonb Exp $
LIB= sa
NOPIC= # defined
@@ -44,7 +44,7 @@
# boot filesystems
SRCS+= nfs.c tftp.c
.endif
-SRCS+= lfs.c ufs.c ufs_ls.c cd9660.c ustarfs.c dosfs.c
+SRCS+= lfsv1.c lfsv2.c ufs.c ufs_ls.c cd9660.c ustarfs.c dosfs.c
# only needed during build
libinstall::
diff -r 244debf78113 -r 8bb4608a5b57 sys/lib/libsa/lfs.c
--- a/sys/lib/libsa/lfs.c Sun Feb 23 23:08:21 2003 +0000
+++ b/sys/lib/libsa/lfs.c Sun Feb 23 23:17:42 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.c,v 1.9 2003/02/23 22:47:44 simonb Exp $ */
+/* $NetBSD: lfs.c,v 1.10 2003/02/23 23:17:42 simonb Exp $ */
/*-
* Copyright (c) 1993
@@ -90,7 +90,6 @@
#define LIBSA_NO_FS_SYMLINK
#endif
-
/*
* In-core LFS superblock. This exists only to placate the macros in lfs.h,
* and to diff easily against the UFS code.
@@ -99,13 +98,50 @@
struct dlfs lfs_dlfs;
};
#define fs_magic lfs_magic
-#define fs_bsize lfs_bsize
#define fs_maxsymlinklen lfs_maxsymlinklen
#define FS_MAGIC LFS_MAGIC
#define SBSIZE LFS_SBPAD
#define SBLOCK (LFS_LABELPAD / DEV_BSIZE)
+
+#if defined(LIBSA_LFSv1) /* XXX not tested */
+
+#undef fsbtodb
+#define fsbtodb(fs, daddr) (daddr) /* LFSv1 uses sectors for addresses */
+#define lfs_open lfsv1_open
+#define lfs_close lfsv1_close
+#define lfs_read lfsv1_read
+#define lfs_write lfsv1_write
+#define lfs_seek lfsv1_seek
+#define lfs_stat lfsv1_stat
+
+#define REQUIRED_LFS_VERSION 1
+#define fs_bsize lfs_ibsize
+#define IFILE IFILE_V1
+
+#elif defined(LIBSA_LFSv2)
+
+#define lfs_open lfsv2_open
+#define lfs_close lfsv2_close
+#define lfs_read lfsv2_read
+#define lfs_write lfsv2_write
+#define lfs_seek lfsv2_seek
+#define lfs_stat lfsv2_stat
+
+#define REQUIRED_LFS_VERSION 2
+#define fs_bsize lfs_bsize
+
+#ifdef LFS_IFILE_FRAG_ADDRESSING /* XXX see sys/ufs/lfs/ -- not tested */
+#undef INOPB
+#define INOPB INOPF
+#endif
+
+#else
+#error Must define one of LIBSA_LFSv1, LIBSA_LFSv2
+#endif
+
+
/*
* In-core open file.
*/
@@ -161,12 +197,7 @@
if (buf_after_ent < sizeof (IFILE))
return (EINVAL);
-#if 0 /* LFS daddr_t's are in sectors, fsbtodb() shouldn't be used on them */
*isp = fsbtodb(fs, ((IFILE *)ent_in_buf)->if_daddr);
-#else
- *isp = ((IFILE *)ent_in_buf)->if_daddr;
-#endif
-
if (*isp == LFS_UNUSED_DADDR) /* again, something badly wrong */
return (EINVAL);
return (0);
@@ -189,7 +220,7 @@
int rc, cnt;
if (inumber == fs->lfs_ifile)
- inode_sector = fs->lfs_idaddr;
+ inode_sector = fsbtodb(fs, fs->lfs_idaddr);
else if ((rc = find_inode_sector(inumber, f, &inode_sector)) != 0)
return (rc);
@@ -320,11 +351,7 @@
twiddle();
#endif
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
-#if 0 /* LFS daddr_t's are in sectors, fsbtodb() shouldn't be used on them */
fsbtodb(fp->f_fs, ind_block_num),
-#else
- ind_block_num,
-#endif
fs->fs_bsize,
fp->f_blk[level],
&fp->f_blksize[level]);
@@ -390,11 +417,7 @@
twiddle();
#endif
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
-#if 0 /* LFS daddr_t's are in sectors, fsbtodb() shouldn't be used on them */
fsbtodb(fs, disk_block),
-#else
- disk_block,
-#endif
block_size, fp->f_buf, &fp->f_buf_size);
if (rc)
return (rc);
@@ -512,10 +535,19 @@
goto out;
if (buf_size != SBSIZE || fs->fs_magic != FS_MAGIC ||
- fs->fs_bsize > MAXBSIZE || fs->fs_bsize < sizeof(struct fs)) {
+ fs->fs_bsize > MAXBSIZE || fs->fs_bsize < sizeof(struct fs) ||
+ fs->lfs_version != REQUIRED_LFS_VERSION) {
rc = EINVAL;
goto out;
}
+#ifdef LIBSA_LFSv2
+ /*
+ * XXX We should check the second superblock and use the eldest
+ * of the two. See comments near the top of lfs_mountfs()
+ * in sys/ufs/lfs/lfs_vfsops.c.
+ * This may need a LIBSA_LFS_SMALL check as well.
+ */
+#endif
/*
* Calculate indirect block levels.
*/
@@ -627,11 +659,7 @@
twiddle();
#endif
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata,
-#if 0 /* LFS daddr_t's are in sectors, fsbtodb() shouldn't be used on them */
F_READ, fsbtodb(fs, disk_block),
-#else
- F_READ, disk_block,
-#endif
fs->fs_bsize, buf, &buf_size);
if (rc)
goto out;
diff -r 244debf78113 -r 8bb4608a5b57 sys/lib/libsa/lfs.h
--- a/sys/lib/libsa/lfs.h Sun Feb 23 23:08:21 2003 +0000
+++ b/sys/lib/libsa/lfs.h Sun Feb 23 23:17:42 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.h,v 1.1 1999/08/18 20:04:40 cgd Exp $ */
+/* $NetBSD: lfs.h,v 1.2 2003/02/23 23:17:42 simonb Exp $ */
/*-
* Copyright (c) 1993
@@ -35,11 +35,16 @@
* @(#)ufs.h 8.1 (Berkeley) 6/11/93
*/
-int lfs_open __P((char *path, struct open_file *f));
-int lfs_close __P((struct open_file *f));
-int lfs_read __P((struct open_file *f, void *buf,
- size_t size, size_t *resid));
-int lfs_write __P((struct open_file *f, void *buf,
- size_t size, size_t *resid));
-off_t lfs_seek __P((struct open_file *f, off_t offset, int where));
-int lfs_stat __P((struct open_file *f, struct stat *sb));
+int lfsv1_open(char *path, struct open_file *f);
+int lfsv1_close(struct open_file *f);
+int lfsv1_read(struct open_file *f, void *buf, size_t size, size_t *resid);
+int lfsv1_write(struct open_file *f, void *buf, size_t size, size_t *resid);
+off_t lfsv1_seek(struct open_file *f, off_t offset, int where);
+int lfsv1_stat(struct open_file *f, struct stat *sb);
+
+int lfsv2_open(char *path, struct open_file *f);
+int lfsv2_close(struct open_file *f);
+int lfsv2_read(struct open_file *f, void *buf, size_t size, size_t *resid);
+int lfsv2_write(struct open_file *f, void *buf, size_t size, size_t *resid);
+off_t lfsv2_seek(struct open_file *f, off_t offset, int where);
+int lfsv2_stat(struct open_file *f, struct stat *sb);
diff -r 244debf78113 -r 8bb4608a5b57 sys/lib/libsa/lfsv1.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/lib/libsa/lfsv1.c Sun Feb 23 23:17:42 2003 +0000
@@ -0,0 +1,4 @@
+/* $NetBSD: lfsv1.c,v 1.1 2003/02/23 23:17:42 simonb Exp $ */
+
+#define LIBSA_LFSv1
+#include "lib/libsa/lfs.c"
diff -r 244debf78113 -r 8bb4608a5b57 sys/lib/libsa/lfsv2.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/lib/libsa/lfsv2.c Sun Feb 23 23:17:42 2003 +0000
@@ -0,0 +1,4 @@
+/* $NetBSD: lfsv2.c,v 1.1 2003/02/23 23:17:42 simonb Exp $ */
+
+#define LIBSA_LFSv2
+#include "lib/libsa/lfs.c"
Home |
Main Index |
Thread Index |
Old Index