diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-08-08 23:49:54 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-08-08 23:49:54 +0000 |
commit | 39fbf175f3c3d2f6af075622e52b06c981b78656 (patch) | |
tree | 0793e726574a7b0c41ad408a213cf10b6409a203 /sbin | |
parent | 6c6bcec1e5b311470799378c970ce1cff6ade984 (diff) |
Admit b_blkno means block number; a block is DEV_BSIZE (a.k.a.
512) bytes; ffs is inextricably tied to using b_blkno and disklabel
always uses sectorsize units.
Thus use DEV_BSIZE units for all fields describing ffs filesystems
and convert to/from sectors where required. This enables the creation
and use of ffs filesystems on non-512 byte sectorsize devices.
This diff allows i386 and sgi (the two test platforms) to find
disklabels that are not on a sectorsize boundary. Same change to
further archs coming.
This is a no-op on 512-byte sectorsize devices.
This work triggered by jsing@'s need to create ffs filesystems on
sgi cdroms so we can create cdrom install media for sgi.
sgi testing by jsing@
ok jsing@ pedro@ "looks sane" beck@ weingart@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/newfs/mkfs.c | 26 | ||||
-rw-r--r-- | sbin/newfs/newfs.c | 5 |
2 files changed, 16 insertions, 15 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index 31979558c5f..6ae21a3f170 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkfs.c,v 1.71 2008/01/05 19:51:55 otto Exp $ */ +/* $OpenBSD: mkfs.c,v 1.72 2008/08/08 23:49:53 krw Exp $ */ /* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */ /* @@ -174,7 +174,7 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo, mode_t mfsmode, time(&utime); #endif if (mfs) { - quad_t sz = (quad_t)fssize * sectorsize; + quad_t sz = (quad_t)fssize * DEV_BSIZE; if (sz > SIZE_T_MAX) { errno = ENOMEM; err(12, "mmap"); @@ -197,7 +197,7 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo, mode_t mfsmode, errx(13, "preposterous size %lld, max is %lld", fssize, MAXDISKSIZE); - wtfs(fssize - 1, sectorsize, (char *)&sblock); + wtfs(fssize - (sectorsize / DEV_BSIZE), sectorsize, (char *)&sblock); sblock.fs_postblformat = FS_DYNAMICPOSTBLFMT; sblock.fs_avgfilesize = avgfilesize; @@ -248,9 +248,9 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo, mode_t mfsmode, sblock.fs_bsize / MAXFRAG); } sblock.fs_fragshift = ilog2(sblock.fs_frag); - sblock.fs_fsbtodb = ilog2(sblock.fs_fsize / sectorsize); + sblock.fs_fsbtodb = ilog2(sblock.fs_fsize / DEV_BSIZE); sblock.fs_size = dbtofsb(&sblock, fssize); - sblock.fs_nspf = sblock.fs_fsize / sectorsize; + sblock.fs_nspf = sblock.fs_fsize / DEV_BSIZE; sblock.fs_maxcontig = 1; sblock.fs_nrpos = 1; sblock.fs_cpg = 1; @@ -506,15 +506,15 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo, mode_t mfsmode, if (fsun1 == NULL) err(39, "calloc"); fs1 = &fsun1->fs; - rdfs(SBLOCK_UFS1 / sectorsize, SBSIZE, (char *)fs1); + rdfs(SBLOCK_UFS1 / DEV_BSIZE, SBSIZE, (char *)fs1); if (fs1->fs_magic == FS_UFS1_MAGIC) { fs1->fs_magic = FS_BAD_MAGIC; - wtfs(SBLOCK_UFS1 / sectorsize, SBSIZE, (char *)fs1); + wtfs(SBLOCK_UFS1 / DEV_BSIZE, SBSIZE, (char *)fs1); } free(fsun1); } - wtfs((int)sblock.fs_sblockloc / sectorsize, SBSIZE, (char *)&sblock); + wtfs((int)sblock.fs_sblockloc / DEV_BSIZE, SBSIZE, (char *)&sblock); sblock.fs_magic = (Oflag <= 1) ? FS_UFS1_MAGIC : FS_UFS2_MAGIC; /* @@ -583,7 +583,7 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo, mode_t mfsmode, errx(32, "fsinit2 failed"); } - wtfs((int)sblock.fs_sblockloc / sectorsize, SBSIZE, (char *)&sblock); + wtfs((int)sblock.fs_sblockloc / DEV_BSIZE, SBSIZE, (char *)&sblock); for (i = 0; i < sblock.fs_cssize; i += sblock.fs_bsize) wtfs(fsbtodb(&sblock, sblock.fs_csaddr + numfrags(&sblock, i)), @@ -1004,10 +1004,10 @@ rdfs(daddr64_t bno, int size, void *bf) int n; if (mfs) { - memcpy(bf, membase + bno * sectorsize, size); + memcpy(bf, membase + bno * DEV_BSIZE, size); return; } - n = pread(fsi, bf, size, (off_t)bno * sectorsize); + n = pread(fsi, bf, size, (off_t)bno * DEV_BSIZE); if (n != size) { err(34, "rdfs: read error on block %lld", bno); } @@ -1022,12 +1022,12 @@ wtfs(daddr64_t bno, int size, void *bf) int n; if (mfs) { - memcpy(membase + bno * sectorsize, bf, size); + memcpy(membase + bno * DEV_BSIZE, bf, size); return; } if (Nflag) return; - n = pwrite(fso, bf, size, (off_t)bno * sectorsize); + n = pwrite(fso, bf, size, (off_t)bno * DEV_BSIZE); if (n != size) { err(36, "wtfs: write error on block %lld", bno); } diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index 23c4d5aa406..8944333ac47 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newfs.c,v 1.80 2008/08/04 18:46:32 otto Exp $ */ +/* $OpenBSD: newfs.c,v 1.81 2008/08/08 23:49:53 krw Exp $ */ /* $NetBSD: newfs.c,v 1.20 1996/05/16 07:13:03 thorpej Exp $ */ /* @@ -433,6 +433,7 @@ havelabel: if (sectorsize <= 0) fatal("%s: no default sector size", argv[0]); } + fssize *= sectorsize / DEV_BSIZE; if (fsize == 0) { fsize = DISKLABELV1_FFS_FSIZE(pp->p_fragblock); if (fsize <= 0) @@ -480,7 +481,7 @@ havelabel: struct mfs_args args; memset(&args, 0, sizeof(args)); args.base = membase; - args.size = fssize * sectorsize; + args.size = fssize * DEV_BSIZE; args.export_info.ex_root = -2; if (mntflags & MNT_RDONLY) args.export_info.ex_flags = MNT_EXRDONLY; |