Add a (draft) 64-bit superblock. Make things build again.

Add pieces of support for using both superblock types where
convenient, and specifically to the superblock accessors, but don't
actually enable it anywhere.

First substantive step on PR 50000.
This commit is contained in:
dholland 2015-08-02 18:18:09 +00:00
parent 992b9a23af
commit 9e5184b86b
20 changed files with 398 additions and 111 deletions

View File

@ -16,7 +16,11 @@ struct clfs_seguse {
* The cleaner's view of the superblock data structure.
*/
struct clfs {
struct dlfs lfs_dlfs;
union {
struct dlfs u_32;
struct dlfs64 u_64;
} lfs_dlfs_u;
unsigned lfs_is64 : 1;
/* Ifile */
int clfs_ifilefd; /* Ifile file descriptor */

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_cleanerd.c,v 1.43 2015/08/02 18:14:16 dholland Exp $ */
/* $NetBSD: lfs_cleanerd.c,v 1.44 2015/08/02 18:18:09 dholland Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@ -94,6 +94,11 @@ extern u_int32_t lfs_sb_cksum(struct dlfs *);
extern u_int32_t lfs_cksum_part(void *, size_t, u_int32_t);
extern int ulfs_getlbns(struct lfs *, struct uvnode *, daddr_t, struct indir *, int *);
/* Ugh */
#define FSMNT_SIZE MAX(sizeof(((struct dlfs *)0)->dlfs_fsmnt), \
sizeof(((struct dlfs64 *)0)->dlfs_fsmnt))
/* Compat */
void pwarn(const char *unused, ...) { /* Does nothing */ };
@ -133,9 +138,9 @@ handle_error(struct clfs **cfsp, int n)
int
reinit_fs(struct clfs *fs)
{
char fsname[sizeof(fs->lfs_dlfs.dlfs_fsmnt)];
char fsname[FSMNT_SIZE];
memcpy(fsname, fs->lfs_dlfs.dlfs_fsmnt, sizeof(fsname));
memcpy(fsname, lfs_sb_getfsmnt(fs), sizeof(fsname));
fsname[sizeof(fsname) - 1] = '\0';
kops.ko_close(fs->clfs_ifilefd);
@ -202,7 +207,7 @@ init_unmounted_fs(struct clfs *fs, char *fsname)
int
init_fs(struct clfs *fs, char *fsname)
{
char mnttmp[sizeof(fs->lfs_dlfs.dlfs_fsmnt)];
char mnttmp[FSMNT_SIZE];
struct statvfs sf;
int rootfd;
int i;
@ -254,9 +259,17 @@ init_fs(struct clfs *fs, char *fsname)
return -1;
}
memcpy(&(fs->lfs_dlfs), sbuf, sizeof(struct dlfs));
__CTASSERT(sizeof(struct dlfs) == sizeof(struct dlfs64));
memcpy(&fs->lfs_dlfs_u, sbuf, sizeof(struct dlfs));
free(sbuf);
/* If it is not LFS, complain and exit! */
if (fs->lfs_dlfs_u.u_32.dlfs_magic != LFS_MAGIC) {
syslog(LOG_ERR, "%s: not LFS", fsname);
return -1;
}
fs->lfs_is64 = 0; /* XXX notyet */
/* If this is not a version 2 filesystem, complain and exit */
if (lfs_sb_getversion(fs) != 2) {
syslog(LOG_ERR, "%s: not a version 2 LFS", fsname);
@ -266,7 +279,7 @@ init_fs(struct clfs *fs, char *fsname)
/* Assume fsname is the mounted name */
strncpy(mnttmp, fsname, sizeof(mnttmp));
mnttmp[sizeof(mnttmp) - 1] = '\0';
memcpy(fs->lfs_dlfs.dlfs_fsmnt, mnttmp, sizeof(mnttmp));
lfs_sb_setfsmnt(fs, mnttmp);
/* Set up vnodes for Ifile and raw device */
fs->lfs_ivnode = fd_vget(fs->clfs_ifilefd, lfs_sb_getbsize(fs), 0, 0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_inode.c,v 1.22 2015/08/02 18:14:16 dholland Exp $ */
/* $NetBSD: lfs_inode.c,v 1.23 2015/08/02 18:18:09 dholland Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993, 1994\
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95";
#else
__RCSID("$NetBSD: lfs_inode.c,v 1.22 2015/08/02 18:14:16 dholland Exp $");
__RCSID("$NetBSD: lfs_inode.c,v 1.23 2015/08/02 18:18:09 dholland Exp $");
#endif
#endif /* not lint */
@ -86,7 +86,7 @@ fs_read_sblock(char *superblock)
sblock = (struct lfs *)superblock;
while(1) {
rawread(sboff, (char *) sblock, LFS_SBPAD);
if (sblock->lfs_magic != LFS_MAGIC) {
if (sblock->lfs_dlfs_u.u_32.dlfs_magic != LFS_MAGIC) {
#ifdef notyet
if (sblock->lfs_magic == bswap32(LFS_MAGIC)) {
lfs_sb_swap(sblock, sblock, 0);
@ -111,7 +111,7 @@ fs_read_sblock(char *superblock)
if (ns)
lfs_sb_swap(u.tbuf, u.tbuf, 0);
#endif
if (u.lfss.lfs_magic != LFS_MAGIC) {
if (u.lfss.lfs_dlfs_u.u_32.dlfs_magic != LFS_MAGIC) {
msg("Warning: secondary superblock at 0x%" PRIx64 " bad magic\n",
LFS_FSBTODB(sblock, (off_t)lfs_sb_getsboff(sblock, 1)));
} else {

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs.c,v 1.51 2015/08/02 18:14:16 dholland Exp $ */
/* $NetBSD: lfs.c,v 1.52 2015/08/02 18:18:09 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@ -95,7 +95,7 @@
#define panic call_panic
extern u_int32_t cksum(void *, size_t);
extern u_int32_t lfs_sb_cksum(struct dlfs *);
extern u_int32_t lfs_sb_cksum(struct lfs *);
extern void pwarn(const char *, ...);
extern struct uvnodelst vnodelist;
@ -427,15 +427,19 @@ static int
check_sb(struct lfs *fs)
{
u_int32_t checksum;
u_int32_t magic;
if (fs->lfs_magic != LFS_MAGIC) {
/* we can read the magic out of either the 32-bit or 64-bit dlfs */
magic = fs->lfs_dlfs_u.u_32.dlfs_magic;
if (magic != LFS_MAGIC) {
printf("Superblock magic number (0x%lx) does not match "
"expected 0x%lx\n", (unsigned long) fs->lfs_magic,
"expected 0x%lx\n", (unsigned long) magic,
(unsigned long) LFS_MAGIC);
return 1;
}
/* checksum */
checksum = lfs_sb_cksum(&(fs->lfs_dlfs));
checksum = lfs_sb_cksum(fs);
if (lfs_sb_getcksum(fs) != checksum) {
printf("Superblock checksum (%lx) does not match computed checksum (%lx)\n",
(unsigned long) lfs_sb_getcksum(fs), (unsigned long) checksum);
@ -482,7 +486,8 @@ lfs_init(int devfd, daddr_t sblkno, daddr_t idaddr, int dummy_read, int debug)
(void)bread(devvp, sblkno, LFS_SBPAD, 0, &bp);
fs = ecalloc(1, sizeof(*fs));
fs->lfs_dlfs = *((struct dlfs *) bp->b_data);
__CTASSERT(sizeof(struct dlfs) == sizeof(struct dlfs64));
memcpy(&fs->lfs_dlfs_u, bp->b_data, sizeof(struct dlfs));
fs->lfs_devvp = devvp;
bp->b_flags |= B_INVAL;
brelse(bp, 0);
@ -493,7 +498,8 @@ lfs_init(int devfd, daddr_t sblkno, daddr_t idaddr, int dummy_read, int debug)
(void)bread(devvp, LFS_FSBTODB(fs, lfs_sb_getsboff(fs, 1)),
LFS_SBPAD, 0, &bp);
altfs = ecalloc(1, sizeof(*altfs));
altfs->lfs_dlfs = *((struct dlfs *) bp->b_data);
memcpy(&altfs->lfs_dlfs_u, bp->b_data,
sizeof(struct dlfs));
altfs->lfs_devvp = devvp;
bp->b_flags |= B_INVAL;
brelse(bp, 0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: segwrite.c,v 1.35 2015/08/02 18:14:16 dholland Exp $ */
/* $NetBSD: segwrite.c,v 1.36 2015/08/02 18:18:09 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@ -103,7 +103,7 @@ int written_inodes = 0;
time_t write_time;
extern u_int32_t cksum(void *, size_t);
extern u_int32_t lfs_sb_cksum(struct dlfs *);
extern u_int32_t lfs_sb_cksum(struct lfs *);
extern int preen;
/*
@ -1003,13 +1003,15 @@ lfs_writesuper(struct lfs *fs, ulfs_daddr_t daddr)
lfs_sb_setotstamp(fs, write_time);
lfs_sb_settstamp(fs, write_time);
__CTASSERT(sizeof(struct dlfs) == sizeof(struct dlfs64));
/* Checksum the superblock and copy it into a buffer. */
lfs_sb_setcksum(fs, lfs_sb_cksum(&(fs->lfs_dlfs)));
lfs_sb_setcksum(fs, lfs_sb_cksum(fs));
assert(daddr > 0);
bp = getblk(fs->lfs_devvp, LFS_FSBTODB(fs, daddr), LFS_SBPAD);
memcpy(bp->b_data, &fs->lfs_dlfs_u, sizeof(struct dlfs));
memset(bp->b_data + sizeof(struct dlfs), 0,
LFS_SBPAD - sizeof(struct dlfs));
*(struct dlfs *) bp->b_data = fs->lfs_dlfs;
bwrite(bp);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.12 2008/02/16 17:58:43 matt Exp $ */
/* $NetBSD: extern.h,v 1.13 2015/08/02 18:18:09 dholland Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -31,9 +31,9 @@
* @(#)extern.h 8.2 (Berkeley) 5/24/95
*/
struct dlfs;
struct lfs;
uint32_t lfs_sb_cksum(struct dlfs *);
uint32_t lfs_sb_cksum(struct lfs *);
void fatal(const char *fmt, ...)
__attribute__((__format__(__printf__,1,2)));
u_int lfs_log2(u_int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: make_lfs.c,v 1.39 2015/08/02 18:14:16 dholland Exp $ */
/* $NetBSD: make_lfs.c,v 1.40 2015/08/02 18:18:09 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -62,7 +62,7 @@
#if 0
static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95";
#else
__RCSID("$NetBSD: make_lfs.c,v 1.39 2015/08/02 18:14:16 dholland Exp $");
__RCSID("$NetBSD: make_lfs.c,v 1.40 2015/08/02 18:18:09 dholland Exp $");
#endif
#endif /* not lint */
@ -109,8 +109,7 @@ ulfs_daddr_t ifibc; /* How many indirect blocks */
# define HIGHEST_USED_INO ULFS_ROOTINO
#endif
static struct lfs lfs_default = {
.lfs_dlfs = {
static const struct dlfs dlfs32_default = {
.dlfs_magic = LFS_MAGIC,
.dlfs_version = LFS_VERSION,
.dlfs_size = 0,
@ -174,9 +173,73 @@ static struct lfs lfs_default = {
.dlfs_pad = { 0 },
.dlfs_cksum = 0
},
};
static const struct dlfs64 dlfs64_default = {
.dlfs_magic = LFS64_MAGIC,
.dlfs_version = LFS_VERSION,
.dlfs_size = 0,
.dlfs_dsize = 0,
.dlfs_ssize = DFL_LFSSEG,
.dlfs_bsize = DFL_LFSBLOCK,
.dlfs_fsize = DFL_LFSFRAG,
.dlfs_frag = DFL_LFSBLOCK/DFL_LFSFRAG,
.dlfs_freehd = HIGHEST_USED_INO + 1,
.dlfs_nfiles = 0,
.dlfs_bfree = 0,
.dlfs_avail = 0,
.dlfs_idaddr = 0,
.dlfs_uinodes = 0,
.dlfs_ifile = LFS_IFILE_INUM,
.dlfs_lastseg = 0,
.dlfs_nextseg = 0,
.dlfs_curseg = 0,
.dlfs_offset = 0,
.dlfs_lastpseg = 0,
.dlfs_inopf = 0,
.dlfs_minfree = MINFREE,
.dlfs_maxfilesize = 0,
.dlfs_fsbpseg = 0,
.dlfs_inopb = DFL_LFSBLOCK/sizeof(struct ulfs1_dinode),
.dlfs_ifpb = DFL_LFSBLOCK/sizeof(IFILE),
.dlfs_sepb = DFL_LFSBLOCK/sizeof(SEGUSE),
.dlfs_nindir = DFL_LFSBLOCK/sizeof(int64_t),
.dlfs_nseg = 0,
.dlfs_nspf = 0,
.dlfs_cleansz = 0,
.dlfs_segtabsz = 0,
.dlfs_bshift = DFL_LFSBLOCK_SHIFT,
.dlfs_ffshift = DFL_LFS_FFSHIFT,
.dlfs_fbshift = DFL_LFS_FBSHIFT,
.dlfs_bmask = DFL_LFSBLOCK_MASK,
.dlfs_ffmask = DFL_LFS_FFMASK,
.dlfs_fbmask = DFL_LFS_FBMASK,
.dlfs_blktodb = 0,
.dlfs_sushift = 0,
.dlfs_sboffs = { 0 },
.dlfs_maxsymlinklen = ULFS1_MAXSYMLINKLEN,
.dlfs_nclean = 0,
.dlfs_fsmnt = { 0 },
.dlfs_pflags = LFS_PF_CLEAN,
.dlfs_dmeta = 0,
.dlfs_minfreeseg = 0,
.dlfs_sumsize = 0,
.dlfs_ibsize = DFL_LFSFRAG,
.dlfs_inodefmt = LFS_44INODEFMT,
.dlfs_serial = 0,
.dlfs_s0addr = 0,
.dlfs_tstamp = 0,
.dlfs_interleave = 0,
.dlfs_ident = 0,
.dlfs_fsbtodb = 0,
.dlfs_resvseg = 0,
.dlfs_pad = { 0 },
.dlfs_cksum = 0
};
static const struct lfs lfs_default;
#define UMASK 0755
struct lfs_direct lfs_root_dir[] = {
@ -325,6 +388,7 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
int dmeta, labelskew;
u_int64_t tsepb, tnseg;
time_t stamp;
bool is64 = false; /* XXX notyet */
/*
* Initialize buffer cache. Use a ballpark guess of the length of
@ -340,7 +404,13 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
fs = lfs_init(devfd, start, (ulfs_daddr_t)0, 1, 1/* XXX debug*/);
save_devvp = fs->lfs_devvp;
vp = fs->lfs_ivnode;
/* XXX this seems like a rubbish */
*fs = lfs_default;
if (is64) {
fs->lfs_dlfs_u.u_64 = dlfs64_default;
} else {
fs->lfs_dlfs_u.u_32 = dlfs32_default;
}
fs->lfs_ivnode = vp;
fs->lfs_devvp = save_devvp;
@ -423,10 +493,16 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
if (lfs_sb_getversion(fs) == 1) {
lfs_sb_setsumsize(fs, LFS_V1_SUMMARY_SIZE);
lfs_sb_setsegshift(fs, lfs_log2(ssize));
if (1 << lfs_sb_getsegshift(fs) != ssize)
fatal("%d: segment size not power of 2", ssize);
lfs_sb_setsegmask(fs, ssize - 1);
if (!is64) {
unsigned segshift;
segshift = lfs_log2(ssize);
if (1 << segshift != ssize)
fatal("%d: segment size not power of 2",
ssize);
fs->lfs_dlfs_u.u_32.dlfs_segshift = segshift;
fs->lfs_dlfs_u.u_32.dlfs_segmask = ssize - 1;
}
lfs_sb_setifpb(fs, lfs_sb_getbsize(fs) / sizeof(IFILE_V1));
lfs_sb_setibsize(fs, lfs_sb_getbsize(fs));
lfs_sb_setsepb(fs, bsize / sizeof(SEGUSE_V1));
@ -441,8 +517,11 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
goto tryagain;
}
lfs_sb_setsumsize(fs, fsize);
lfs_sb_setsegshift(fs, 0);
lfs_sb_setsegmask(fs, 0);
if (!is64) {
/* these do not exist in the 64-bit superblock */
fs->lfs_dlfs_u.u_32.dlfs_segshift = 0;
fs->lfs_dlfs_u.u_32.dlfs_segmask = 0;
}
lfs_sb_setsepb(fs, bsize / sizeof(SEGUSE));
lfs_sb_setssize(fs, ssize);
lfs_sb_setibsize(fs, ibsize);
@ -840,7 +919,7 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
/* Leave the time stamp on the alt sb, zero the rest */
if (i == 2) {
lfs_sb_settstamp(fs, 0);
lfs_sb_setcksum(fs, lfs_sb_cksum(&(fs->lfs_dlfs)));
lfs_sb_setcksum(fs, lfs_sb_cksum(fs));
}
if (!Nflag)
lfs_writesuper(fs, seg_addr);

View File

@ -1,4 +1,4 @@
/* $NetBSD: resize_lfs.c,v 1.13 2015/08/02 18:12:18 dholland Exp $ */
/* $NetBSD: resize_lfs.c,v 1.14 2015/08/02 18:18:09 dholland Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
* All rights reserved.
@ -125,7 +125,8 @@ main(int argc, char **argv)
fs = (struct lfs *)malloc(sizeof(*fs));
for (sboff = LFS_LABELPAD;;) {
pread(devfd, buf, sboff, LFS_SBPAD);
memcpy(&fs->lfs_dlfs, buf, sizeof(struct dlfs));
__CTASSERT(sizeof(struct dlfs) == sizeof(struct dlfs64));
memcpy(&fs->lfs_dlfs_u, buf, sizeof(struct dlfs));
if (sboff == LFS_LABELPAD && lfs_fsbtob(fs, 1) > LFS_LABELPAD)
sboff = lfs_fsbtob(fs, (off_t)lfs_sb_getsboff(fs, 0));
else

View File

@ -1,4 +1,4 @@
/* $NetBSD: scan_ffs.c,v 1.30 2015/08/02 18:14:16 dholland Exp $ */
/* $NetBSD: scan_ffs.c,v 1.31 2015/08/02 18:18:09 dholland Exp $ */
/*
* Copyright (c) 2005-2007 Juan Romero Pardines
@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: scan_ffs.c,v 1.30 2015/08/02 18:14:16 dholland Exp $");
__RCSID("$NetBSD: scan_ffs.c,v 1.31 2015/08/02 18:18:09 dholland Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -288,7 +288,7 @@ lfs_scan(struct sblockinfo *sbi, int n)
size_t namesize;
/* Check to see if the sb checksums correctly */
if (lfs_sb_cksum(&(sbi->lfs->lfs_dlfs)) != lfs_sb_getcksum(sbi->lfs)) {
if (lfs_sb_cksum(sbi->lfs) != lfs_sb_getcksum(sbi->lfs)) {
if (flags & VERBOSE)
printf("LFS bad superblock at %" PRIu64 "\n",
BLK_CNT);
@ -318,9 +318,10 @@ lfs_scan(struct sblockinfo *sbi, int n)
break;
case SECOND_SBLOCK_ADDRESS:
/* copy the path of last mount */
namesize = MIN(sizeof(sbi->lfs_path),
sizeof(sbi->lfs->lfs_dlfs.dlfs_fsmnt));
(void)memcpy(sbi->lfs_path, sbi->lfs->lfs_dlfs.dlfs_fsmnt,
namesize = MIN(sizeof(sbi->lfs_path), MIN(
sizeof(sbi->lfs->lfs_dlfs_u.u_32.dlfs_fsmnt),
sizeof(sbi->lfs->lfs_dlfs_u.u_64.dlfs_fsmnt)));
(void)memcpy(sbi->lfs_path, lfs_sb_getfsmnt(sbi->lfs),
namesize);
sbi->lfs_path[namesize - 1] = '\0';
/* print now that we have the info */
@ -381,7 +382,7 @@ scan_disk(int fd, daddr_t beg, daddr_t end, int fflags)
break;
case FSTYPE_NONE:
/* maybe LFS? */
if (sbinfo.lfs->lfs_magic == LFS_MAGIC)
if (sbinfo.lfs->lfs_dlfs_u.u_32.dlfs_magic == LFS_MAGIC)
lfs_scan(&sbinfo, n);
break;
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfsv1.c,v 1.11 2015/07/24 06:56:42 dholland Exp $ */
/* $NetBSD: lfsv1.c,v 1.12 2015/08/02 18:18:09 dholland Exp $ */
#define LIBSA_LFS
#define REQUIRED_LFS_VERSION 1
@ -15,7 +15,7 @@
#define ufs_dinode ulfs1_dinode
#define fs_bsize lfs_dlfs.dlfs_ibsize
#define fs_bsize lfs_dlfs_u.u_32.dlfs_ibsize
#define IFILE_Vx IFILE_V1
#define INOPBx(fs) LFS_INOPB(fs)

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfsv2.c,v 1.11 2015/07/24 06:56:42 dholland Exp $ */
/* $NetBSD: lfsv2.c,v 1.12 2015/08/02 18:18:09 dholland Exp $ */
#define LIBSA_LFS
#define REQUIRED_LFS_VERSION 2
@ -13,10 +13,9 @@
#define ufs_ls lfsv2_ls
#endif
/* XXX wrong! but for now it won't build with ulfs2_dinode */
#define ufs_dinode ulfs1_dinode
#define fs_bsize lfs_dlfs.dlfs_bsize
#define fs_bsize lfs_dlfs_u.u_32.dlfs_bsize
#define IFILE_Vx IFILE
#ifdef LFS_IFILE_FRAG_ADDRESSING /* XXX see sys/ufs/lfs/ -- not tested */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs.c,v 1.69 2015/07/28 05:13:14 dholland Exp $ */
/* $NetBSD: ufs.c,v 1.70 2015/08/02 18:18:09 dholland Exp $ */
/*-
* Copyright (c) 1993
@ -104,15 +104,19 @@
* In-core LFS superblock - just the on-disk one.
*/
struct salfs {
struct dlfs lfs_dlfs;
union {
struct dlfs u_32;
struct dlfs64 u_64;
} lfs_dlfs_u;
unsigned lfs_is64 : 1;
};
/* Get lfs accessors that use struct salfs. */
#define STRUCT_LFS struct salfs
#include <ufs/lfs/lfs_accessors.h>
typedef struct salfs FS;
#define fs_magic lfs_dlfs.dlfs_magic
#define fs_maxsymlinklen lfs_dlfs.dlfs_maxsymlinklen
#define fs_magic lfs_dlfs_u.u_32.dlfs_magic
#define fs_maxsymlinklen lfs_dlfs_u.u_32.dlfs_maxsymlinklen
#define FS_MAGIC LFS_MAGIC
#define SBLOCKSIZE LFS_SBPAD
@ -586,6 +590,9 @@ ufs_open(const char *path, struct open_file *f)
* This may need a LIBSA_LFS_SMALL check as well.
*/
#endif
#if defined(LIBSA_LFS)
fs->lfs_is64 = 0;
#endif
#endif
#ifdef LIBSA_FFSv1

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs.h,v 1.170 2015/08/02 18:12:59 dholland Exp $ */
/* $NetBSD: lfs.h,v 1.171 2015/08/02 18:18:10 dholland Exp $ */
/* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */
/* from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp */
@ -570,11 +570,43 @@ struct segsum {
/*
* On-disk super block.
*
* We have separate superblock structures for the 32-bit and 64-bit
* LFS, and accessor functions to hide the differences.
*
* For lfs64, the format version is always 2; version 1 lfs is old.
* For both, the inode format version is 0; for lfs32 this selects the
* same 32-bit inode as always, and for lfs64 this selects the larger
* 64-bit inode structure we got from ffsv2.
*
* In lfs64:
* - inode numbers are still 32 bit
* - segments may not be larger than 4G (counted in bytes)
* - there may not be more than 2^32 (or perhaps 2^31) segments
* - the total volume size is limited to 2^63 frags and/or 2^63
* disk blocks, and probably in practice 2^63 bytes.
*/
#define LFS_MAGIC 0x070162
#define LFS_MAGIC_SWAPPED 0x62010700
#define LFS64_MAGIC 0x19620701
#define LFS64_MAGIC_SWAPPED 0x01076219
#define LFS_VERSION 2
#define LFS_MIN_SBINTERVAL 5 /* min superblock segment spacing */
#define LFS_MAXNUMSB 10 /* max number of superblocks */
/* flags for dlfs_pflags */
#define LFS_PF_CLEAN 0x1
/* Inode format versions */
#define LFS_44INODEFMT 0
#define LFS_MAXINODEFMT 0
struct dlfs {
#define LFS_MAGIC 0x070162
u_int32_t dlfs_magic; /* 0: magic number */
#define LFS_VERSION 2
u_int32_t dlfs_version; /* 4: version number */
u_int32_t dlfs_size; /* 8: number of blocks in fs (v1) */
@ -627,13 +659,11 @@ struct dlfs {
u_int32_t dlfs_sushift; /* 180: fast mult/div for segusage table */
int32_t dlfs_maxsymlinklen; /* 184: max length of an internal symlink */
#define LFS_MIN_SBINTERVAL 5 /* minimum superblock segment spacing */
#define LFS_MAXNUMSB 10 /* 188: superblock disk offsets */
int32_t dlfs_sboffs[LFS_MAXNUMSB];
/* 188: superblock disk offsets */
int32_t dlfs_sboffs[LFS_MAXNUMSB];
u_int32_t dlfs_nclean; /* 228: Number of clean segments */
u_char dlfs_fsmnt[MNAMELEN]; /* 232: name mounted on */
#define LFS_PF_CLEAN 0x1
u_int16_t dlfs_pflags; /* 322: file system persistent flags */
int32_t dlfs_dmeta; /* 324: total number of dirty summaries */
u_int32_t dlfs_minfreeseg; /* 328: segments not counted in bfree */
@ -642,8 +672,6 @@ struct dlfs {
u_int32_t dlfs_ibsize; /* 344: size of inode blocks */
int32_t dlfs_s0addr; /* 348: start of segment 0 */
u_int64_t dlfs_tstamp; /* 352: time stamp */
#define LFS_44INODEFMT 0
#define LFS_MAXINODEFMT 0
u_int32_t dlfs_inodefmt; /* 360: inode format version */
u_int32_t dlfs_interleave; /* 364: segment interleave */
u_int32_t dlfs_ident; /* 368: per-fs identifier */
@ -654,6 +682,79 @@ struct dlfs {
u_int32_t dlfs_cksum; /* 508: checksum for superblock checking */
};
struct dlfs64 {
u_int32_t dlfs_magic; /* 0: magic number */
u_int32_t dlfs_version; /* 4: version number (2) */
u_int64_t dlfs_size; /* 8: number of frags in fs (v2) */
u_int64_t dlfs_dsize; /* 16: number of disk blocks in fs */
u_int32_t dlfs_ssize; /* 24: number of bytes per segment (v2) */
u_int32_t dlfs_bsize; /* 28: file system block size */
u_int32_t dlfs_fsize; /* 32: size of frag blocks in fs */
u_int32_t dlfs_frag; /* 36: number of frags in a block in fs */
/* Checkpoint region. */
u_int32_t dlfs_freehd; /* 40: start of the free inode list */
u_int32_t dlfs_nfiles; /* 44: number of allocated inodes */
int64_t dlfs_bfree; /* 48: number of free frags */
int64_t dlfs_avail; /* 56: blocks available for writing */
int64_t dlfs_idaddr; /* 64: inode file disk address */
int32_t dlfs_uinodes; /* 72: inodes in cache not yet on disk */
u_int32_t dlfs_ifile; /* 76: inode file inode number */
int64_t dlfs_lastseg; /* 80: address of last segment written */
int64_t dlfs_nextseg; /* 88: address of next segment to write */
int64_t dlfs_curseg; /* 96: current segment being written */
int64_t dlfs_offset; /* 104: offset in curseg for next partial */
int64_t dlfs_lastpseg; /* 112: address of last partial written */
u_int32_t dlfs_inopf; /* 120: inodes per frag */
/* These are configuration parameters. */
u_int32_t dlfs_minfree; /* 124: minimum percentage of free blocks */
/* These fields can be computed from the others. */
u_int64_t dlfs_maxfilesize; /* 128: maximum representable file size */
u_int32_t dlfs_fsbpseg; /* 136: frags (fsb) per segment */
u_int32_t dlfs_inopb; /* 140: inodes per block */
u_int32_t dlfs_ifpb; /* 144: IFILE entries per block */
u_int32_t dlfs_sepb; /* 148: SEGUSE entries per block */
u_int32_t dlfs_nindir; /* 152: indirect pointers per block */
u_int32_t dlfs_nseg; /* 156: number of segments */
u_int32_t dlfs_nspf; /* 160: number of sectors per fragment */
u_int32_t dlfs_cleansz; /* 164: cleaner info size in blocks */
u_int32_t dlfs_segtabsz; /* 168: segment table size in blocks */
u_int32_t dlfs_bshift; /* 172: calc block number from file offset */
u_int32_t dlfs_ffshift; /* 176: fast mult/div for frag from file */
u_int32_t dlfs_fbshift; /* 180: fast mult/div for frag from block */
u_int64_t dlfs_bmask; /* 184: calc block offset from file offset */
u_int64_t dlfs_ffmask; /* 192: calc frag offset from file offset */
u_int64_t dlfs_fbmask; /* 200: calc frag offset from block offset */
u_int32_t dlfs_blktodb; /* 208: blktodb and dbtoblk shift constant */
u_int32_t dlfs_sushift; /* 212: fast mult/div for segusage table */
/* 216: superblock disk offsets */
int64_t dlfs_sboffs[LFS_MAXNUMSB];
int32_t dlfs_maxsymlinklen; /* 296: max len of an internal symlink */
u_int32_t dlfs_nclean; /* 300: Number of clean segments */
u_char dlfs_fsmnt[MNAMELEN]; /* 304: name mounted on */
u_int16_t dlfs_pflags; /* 394: file system persistent flags */
int32_t dlfs_dmeta; /* 396: total number of dirty summaries */
u_int32_t dlfs_minfreeseg; /* 400: segments not counted in bfree */
u_int32_t dlfs_sumsize; /* 404: size of summary blocks */
u_int32_t dlfs_ibsize; /* 408: size of inode blocks */
u_int32_t dlfs_inodefmt; /* 412: inode format version */
u_int64_t dlfs_serial; /* 416: serial number */
int64_t dlfs_s0addr; /* 424: start of segment 0 */
u_int64_t dlfs_tstamp; /* 432: time stamp */
u_int32_t dlfs_interleave; /* 440: segment interleave */
u_int32_t dlfs_ident; /* 444: per-fs identifier */
u_int32_t dlfs_fsbtodb; /* 448: fsbtodb and dbtodsb shift constant */
u_int32_t dlfs_resvseg; /* 452: segments reserved for the cleaner */
int8_t dlfs_pad[52]; /* 456: round to 512 bytes */
/* Checksum -- last valid disk field. */
u_int32_t dlfs_cksum; /* 508: checksum for superblock checking */
};
/* Type used for the inode bitmap */
typedef u_int32_t lfs_bm_t;
@ -671,9 +772,14 @@ struct segdelta {
* In-memory super block.
*/
struct lfs {
struct dlfs lfs_dlfs; /* on-disk parameters */
union { /* on-disk parameters */
struct dlfs u_32;
struct dlfs64 u_64;
} lfs_dlfs_u;
/* These fields are set at mount time and are meaningless on disk. */
unsigned lfs_is64 : 1; /* are we lfs64 or lfs32? */
struct segment *lfs_sp; /* current segment being written */
struct vnode *lfs_ivnode; /* vnode for the ifile */
u_int32_t lfs_seglock; /* single-thread the segment writer */

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_accessors.h,v 1.6 2015/08/02 18:14:16 dholland Exp $ */
/* $NetBSD: lfs_accessors.h,v 1.7 2015/08/02 18:18:10 dholland Exp $ */
/* from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp */
/* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */
@ -392,28 +392,57 @@
static __unused inline type \
lfs_sb_get##field(STRUCT_LFS *fs) \
{ \
return fs->lfs_dlfs.dlfs_##field; \
if (fs->lfs_is64) { \
return fs->lfs_dlfs_u.u_64.dlfs_##field; \
} else { \
return fs->lfs_dlfs_u.u_32.dlfs_##field; \
} \
} \
static __unused inline void \
lfs_sb_set##field(STRUCT_LFS *fs, type val) \
{ \
fs->lfs_dlfs.dlfs_##field = val; \
if (fs->lfs_is64) { \
fs->lfs_dlfs_u.u_64.dlfs_##field = val; \
} else { \
fs->lfs_dlfs_u.u_32.dlfs_##field = val; \
} \
} \
static __unused inline void \
lfs_sb_add##field(STRUCT_LFS *fs, type val) \
{ \
type32 *p = &fs->lfs_dlfs.dlfs_##field; \
*p += val; \
if (fs->lfs_is64) { \
type *p64 = &fs->lfs_dlfs_u.u_64.dlfs_##field; \
*p64 += val; \
} else { \
type32 *p32 = &fs->lfs_dlfs_u.u_32.dlfs_##field; \
*p32 += val; \
} \
} \
static __unused inline void \
lfs_sb_sub##field(STRUCT_LFS *fs, type val) \
{ \
type32 *p = &fs->lfs_dlfs.dlfs_##field; \
*p -= val; \
if (fs->lfs_is64) { \
type *p64 = &fs->lfs_dlfs_u.u_64.dlfs_##field; \
*p64 -= val; \
} else { \
type32 *p32 = &fs->lfs_dlfs_u.u_32.dlfs_##field; \
*p32 -= val; \
} \
}
#define LFS_DEF_SB_ACCESSOR(t, f) LFS_DEF_SB_ACCESSOR_FULL(t, t, f)
#define LFS_DEF_SB_ACCESSOR_32ONLY(type, field, val64) \
static __unused inline type \
lfs_sb_get##field(STRUCT_LFS *fs) \
{ \
if (fs->lfs_is64) { \
return val64; \
} else { \
return fs->lfs_dlfs_u.u_32.dlfs_##field; \
} \
}
#define lfs_magic lfs_dlfs.dlfs_magic
LFS_DEF_SB_ACCESSOR(u_int32_t, version);
LFS_DEF_SB_ACCESSOR_FULL(u_int64_t, u_int32_t, size);
@ -446,8 +475,8 @@ LFS_DEF_SB_ACCESSOR(u_int32_t, nseg);
LFS_DEF_SB_ACCESSOR(u_int32_t, nspf);
LFS_DEF_SB_ACCESSOR(u_int32_t, cleansz);
LFS_DEF_SB_ACCESSOR(u_int32_t, segtabsz);
LFS_DEF_SB_ACCESSOR(u_int32_t, segmask);
LFS_DEF_SB_ACCESSOR(u_int32_t, segshift);
LFS_DEF_SB_ACCESSOR_32ONLY(u_int32_t, segmask, 0);
LFS_DEF_SB_ACCESSOR_32ONLY(u_int32_t, segshift, 0);
LFS_DEF_SB_ACCESSOR(u_int64_t, bmask);
LFS_DEF_SB_ACCESSOR(u_int32_t, bshift);
LFS_DEF_SB_ACCESSOR(u_int64_t, ffmask);
@ -490,7 +519,11 @@ lfs_sb_getsboff(STRUCT_LFS *fs, unsigned n)
#ifdef KASSERT /* ugh */
KASSERT(n < LFS_MAXNUMSB);
#endif
return fs->lfs_dlfs.dlfs_sboffs[n];
if (fs->lfs_is64) {
return fs->lfs_dlfs_u.u_64.dlfs_sboffs[n];
} else {
return fs->lfs_dlfs_u.u_32.dlfs_sboffs[n];
}
}
static __unused inline void
lfs_sb_setsboff(STRUCT_LFS *fs, unsigned n, int32_t val)
@ -498,7 +531,11 @@ lfs_sb_setsboff(STRUCT_LFS *fs, unsigned n, int32_t val)
#ifdef KASSERT /* ugh */
KASSERT(n < LFS_MAXNUMSB);
#endif
fs->lfs_dlfs.dlfs_sboffs[n] = val;
if (fs->lfs_is64) {
fs->lfs_dlfs_u.u_64.dlfs_sboffs[n] = val;
} else {
fs->lfs_dlfs_u.u_32.dlfs_sboffs[n] = val;
}
}
/*
@ -507,7 +544,23 @@ lfs_sb_setsboff(STRUCT_LFS *fs, unsigned n, int32_t val)
static __unused inline const char *
lfs_sb_getfsmnt(STRUCT_LFS *fs)
{
return fs->lfs_dlfs.dlfs_fsmnt;
if (fs->lfs_is64) {
return fs->lfs_dlfs_u.u_64.dlfs_fsmnt;
} else {
return fs->lfs_dlfs_u.u_32.dlfs_fsmnt;
}
}
static __unused inline void
lfs_sb_setfsmnt(STRUCT_LFS *fs, const char *str)
{
if (fs->lfs_is64) {
(void)strncpy(fs->lfs_dlfs_u.u_64.dlfs_fsmnt, str,
sizeof(fs->lfs_dlfs_u.u_64.dlfs_fsmnt));
} else {
(void)strncpy(fs->lfs_dlfs_u.u_32.dlfs_fsmnt, str,
sizeof(fs->lfs_dlfs_u.u_32.dlfs_fsmnt));
}
}
/* LFS_NINDIR is the number of indirects in a file system block. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_cksum.c,v 1.29 2013/06/06 00:54:49 dholland Exp $ */
/* $NetBSD: lfs_cksum.c,v 1.30 2015/08/02 18:18:10 dholland Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_cksum.c,v 1.29 2013/06/06 00:54:49 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_cksum.c,v 1.30 2015/08/02 18:18:10 dholland Exp $");
#include <sys/param.h>
#ifdef _KERNEL
@ -100,10 +100,18 @@ cksum(void *str, size_t len)
}
u_int32_t
lfs_sb_cksum(struct dlfs *fs)
lfs_sb_cksum(struct lfs *fs)
{
void *ptr;
size_t size;
size = (size_t)offsetof(struct dlfs, dlfs_cksum);
return cksum(fs, size);
if (fs->lfs_is64) {
ptr = &fs->lfs_dlfs_u.u_64;
size = (size_t)offsetof(struct dlfs64, dlfs_cksum);
} else {
ptr = &fs->lfs_dlfs_u.u_32;
size = (size_t)offsetof(struct dlfs64, dlfs_cksum);
}
return cksum(ptr, size);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_debug.c,v 1.49 2015/08/02 18:14:16 dholland Exp $ */
/* $NetBSD: lfs_debug.c,v 1.50 2015/08/02 18:18:10 dholland Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_debug.c,v 1.49 2015/08/02 18:14:16 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_debug.c,v 1.50 2015/08/02 18:18:10 dholland Exp $");
#ifdef DEBUG
@ -128,7 +128,9 @@ lfs_dump_super(struct lfs *lfsp)
int i;
printf("%s%x\t%s%x\t%s%ju\t%s%d\n",
"magic ", lfsp->lfs_magic,
"magic ", lfsp->lfs_is64 ?
lfsp->lfs_dlfs_u.u_64.dlfs_magic :
lfsp->lfs_dlfs_u.u_32.dlfs_magic,
"version ", lfs_sb_getversion(lfsp),
"size ", (uintmax_t)lfs_sb_getsize(lfsp),
"ssize ", lfs_sb_getssize(lfsp));

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_extern.h,v 1.106 2015/08/02 18:10:08 dholland Exp $ */
/* $NetBSD: lfs_extern.h,v 1.107 2015/08/02 18:18:10 dholland Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -272,7 +272,7 @@ extern const struct genfs_ops lfs_genfsops;
u_int32_t cksum(void *, size_t);
u_int32_t lfs_cksum_part(void *, size_t, u_int32_t);
#define lfs_cksum_fold(sum) (sum)
u_int32_t lfs_sb_cksum(struct dlfs *);
u_int32_t lfs_sb_cksum(struct lfs *);
__END_DECLS

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_segment.c,v 1.249 2015/08/02 18:14:16 dholland Exp $ */
/* $NetBSD: lfs_segment.c,v 1.250 2015/08/02 18:18:10 dholland Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.249 2015/08/02 18:14:16 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.250 2015/08/02 18:18:10 dholland Exp $");
#define _VFS_VNODE_PRIVATE /* XXX: check for VI_MARKER, this has to go */
@ -2366,7 +2366,11 @@ lfs_writesuper(struct lfs *fs, daddr_t daddr)
ASSERT_MAYBE_SEGLOCK(fs);
#ifdef DIAGNOSTIC
KASSERT(fs->lfs_magic == LFS_MAGIC);
if (fs->lfs_is64) {
KASSERT(fs->lfs_dlfs_u.u_64.dlfs_magic == LFS64_MAGIC);
} else {
KASSERT(fs->lfs_dlfs_u.u_32.dlfs_magic == LFS_MAGIC);
}
#endif
/*
* If we can write one superblock while another is in
@ -2388,13 +2392,16 @@ lfs_writesuper(struct lfs *fs, daddr_t daddr)
lfs_sb_setotstamp(fs, time_second);
lfs_sb_settstamp(fs, time_second);
/* The next chunk of code relies on this assumption */
CTASSERT(sizeof(struct dlfs) == sizeof(struct dlfs64));
/* Checksum the superblock and copy it into a buffer. */
lfs_sb_setcksum(fs, lfs_sb_cksum(&(fs->lfs_dlfs)));
lfs_sb_setcksum(fs, lfs_sb_cksum(fs));
bp = lfs_newbuf(fs, devvp,
LFS_FSBTODB(fs, daddr), LFS_SBPAD, LFS_NB_SBLOCK);
memcpy(bp->b_data, &fs->lfs_dlfs_u, sizeof(struct dlfs));
memset((char *)bp->b_data + sizeof(struct dlfs), 0,
LFS_SBPAD - sizeof(struct dlfs));
*(struct dlfs *)bp->b_data = fs->lfs_dlfs;
bp->b_cflags |= BC_BUSY;
bp->b_flags = (bp->b_flags & ~B_READ) | B_ASYNC;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_vfsops.c,v 1.332 2015/08/02 18:14:16 dholland Exp $ */
/* $NetBSD: lfs_vfsops.c,v 1.333 2015/08/02 18:18:10 dholland Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.332 2015/08/02 18:14:16 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.333 2015/08/02 18:18:10 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@ -606,8 +606,7 @@ lfs_mountroot(void)
mountlist_append(mp);
ump = VFSTOULFS(mp);
fs = ump->um_lfs;
memset(fs->lfs_dlfs.dlfs_fsmnt, 0, sizeof(fs->lfs_dlfs.dlfs_fsmnt));
(void)copystr(mp->mnt_stat.f_mntonname, fs->lfs_dlfs.dlfs_fsmnt, sizeof(fs->lfs_dlfs.dlfs_fsmnt), 0);
lfs_sb_setfsmnt(fs, mp->mnt_stat.f_mntonname);
(void)lfs_statvfs(mp, &mp->mnt_stat);
vfs_unbusy(mp, false, NULL);
setrootfstime((time_t)lfs_sb_gettstamp(VFSTOULFS(mp)->um_lfs));
@ -809,9 +808,7 @@ lfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
error = set_statvfs_info(path, UIO_USERSPACE, args->fspec,
UIO_USERSPACE, mp->mnt_op->vfs_name, mp, l);
if (error == 0)
(void)strncpy(fs->lfs_dlfs.dlfs_fsmnt,
mp->mnt_stat.f_mntonname,
sizeof(fs->lfs_dlfs.dlfs_fsmnt));
lfs_sb_setfsmnt(fs, mp->mnt_stat.f_mntonname);
return error;
fail:
@ -950,7 +947,8 @@ lfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l)
/* Allocate the mount structure, copy the superblock into it. */
fs = kmem_zalloc(sizeof(struct lfs), KM_SLEEP);
memcpy(&fs->lfs_dlfs, tdfs, sizeof(struct dlfs));
memcpy(&fs->lfs_dlfs_u.u_32, tdfs, sizeof(struct dlfs));
fs->lfs_is64 = false;
/* Compatibility */
if (lfs_sb_getversion(fs) < 2) {
@ -1362,8 +1360,6 @@ lfs_statvfs(struct mount *mp, struct statvfs *sbp)
ump = VFSTOULFS(mp);
fs = ump->um_lfs;
if (fs->lfs_magic != LFS_MAGIC)
panic("lfs_statvfs: magic");
sbp->f_bsize = lfs_sb_getbsize(fs);
sbp->f_frsize = lfs_sb_getfsize(fs);

View File

@ -1,4 +1,4 @@
/* $NetBSD: dumplfs.c,v 1.48 2015/08/02 18:14:16 dholland Exp $ */
/* $NetBSD: dumplfs.c,v 1.49 2015/08/02 18:18:10 dholland Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\
#if 0
static char sccsid[] = "@(#)dumplfs.c 8.5 (Berkeley) 5/24/95";
#else
__RCSID("$NetBSD: dumplfs.c,v 1.48 2015/08/02 18:14:16 dholland Exp $");
__RCSID("$NetBSD: dumplfs.c,v 1.49 2015/08/02 18:18:10 dholland Exp $");
#endif
#endif /* not lint */
@ -185,14 +185,15 @@ main(int argc, char **argv)
if (sbdaddr == 0x0) {
/* Read the proto-superblock */
__CTASSERT(sizeof(struct dlfs) == sizeof(struct dlfs64));
get(fd, LFS_LABELPAD, sbuf, LFS_SBPAD);
memcpy(&(lfs_sb1.lfs_dlfs), sbuf, sizeof(struct dlfs));
memcpy(&lfs_sb1.lfs_dlfs_u, sbuf, sizeof(struct dlfs));
/* If that wasn't the real first sb, get the real first sb */
if (lfs_sb_getversion(&lfs_sb1) > 1 &&
lfs_sb_getsboff(&lfs_sb1, 0) > lfs_btofsb(&lfs_sb1, LFS_LABELPAD))
get(fd, lfs_fsbtob(&lfs_sb1, lfs_sb_getsboff(&lfs_sb1, 0)),
&(lfs_sb1.lfs_dlfs), sizeof(struct dlfs));
&lfs_sb1.lfs_dlfs_u, sizeof(struct dlfs));
/*
* Read the second superblock and figure out which check point is
@ -201,7 +202,7 @@ main(int argc, char **argv)
get(fd,
fsbtobyte(&lfs_sb1, lfs_sb_getsboff(&lfs_sb1, 1)),
sbuf, LFS_SBPAD);
memcpy(&(lfs_sb2.lfs_dlfs), sbuf, sizeof(struct dlfs));
memcpy(&lfs_sb2.lfs_dlfs_u, sbuf, sizeof(struct dlfs));
lfs_master = &lfs_sb1;
if (lfs_sb_getversion(&lfs_sb1) > 1) {
@ -220,7 +221,7 @@ main(int argc, char **argv)
} else {
/* Read the first superblock */
get(fd, dbtob((off_t)sbdaddr), sbuf, LFS_SBPAD);
memcpy(&(lfs_sb1.lfs_dlfs), sbuf, sizeof(struct dlfs));
memcpy(&lfs_sb1.lfs_dlfs_u, sbuf, sizeof(struct dlfs));
lfs_master = &lfs_sb1;
}
@ -682,11 +683,13 @@ dump_segment(int fd, int segnum, daddr_t addr, struct lfs *lfsp, int dump_sb)
sump->ss_sumsum != cksum (&sump->ss_datasum,
lfs_sb_getsumsize(lfsp) - sizeof(sump->ss_sumsum))) {
sbp = (struct lfs *)sump;
if ((sb = (sbp->lfs_magic == LFS_MAGIC))) {
if ((sb = (sbp->lfs_dlfs_u.u_32.dlfs_magic == LFS_MAGIC))) {
printf("Superblock at 0x%x\n",
(unsigned)lfs_btofsb(lfsp, sum_offset));
if (dump_sb) {
get(fd, sum_offset, &(lfs_sb.lfs_dlfs),
__CTASSERT(sizeof(struct dlfs) ==
sizeof(struct dlfs64));
get(fd, sum_offset, &(lfs_sb.lfs_dlfs_u),
sizeof(struct dlfs));
dump_super(&lfs_sb);
}
@ -727,7 +730,7 @@ dump_super(struct lfs *lfsp)
int i;
(void)printf(" %s0x%-8x %s0x%-8x %s%-10ju\n",
"magic ", lfsp->lfs_magic,
"magic ", lfsp->lfs_dlfs_u.u_32.dlfs_magic,
"version ", lfs_sb_getversion(lfsp),
"size ", (uintmax_t)lfs_sb_getsize(lfsp));
(void)printf(" %s%-10d %s%-10ju %s%-10d\n",