-/* $OpenBSD: setup.c,v 1.51 2013/11/22 04:38:02 guenther Exp $ */
+/* $OpenBSD: setup.c,v 1.52 2014/05/09 13:19:34 krw Exp $ */
/* $NetBSD: setup.c,v 1.27 1996/09/27 22:45:19 christos Exp $ */
/*
if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
errexit("cannot allocate space for superblock\n");
if ((lp = getdisklabel(NULL, fsreadfd)) != NULL)
- dev_bsize = secsize = lp->d_secsize;
+ secsize = lp->d_secsize;
else
- dev_bsize = secsize = DEV_BSIZE;
+ secsize = DEV_BSIZE;
/*
* Read in the superblock, looking for alternates if necessary
*/
}
} else {
for (i = 0; sbtry[i] != -1; i++) {
- super = sbtry[i] / dev_bsize;
+ super = sbtry[i] / DEV_BSIZE;
if (bread(fsreadfd, (char *)&sblock, super,
(long)SBSIZE) != 0)
return (0);
}
-
- /*
- * Compute block size that the filesystem is based on,
- * according to fsbtodb, and adjust superblock block number
- * so we can tell if this is an alternate later.
- */
- super *= dev_bsize;
- dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1);
- sblk.b_bno = super / dev_bsize;
if (bflag)
goto out;
getblk(&asblk, cgsblock(&sblock, sblock.fs_ncg - 1), sblock.fs_sbsize);
fs->fs_spc >>= 1;
goto again;
}
- dev_bsize = lp->d_secsize;
return (1);
}
-/* $OpenBSD: utilities.c,v 1.42 2013/11/01 17:36:18 krw Exp $ */
+/* $OpenBSD: utilities.c,v 1.43 2014/05/09 13:19:34 krw Exp $ */
/* $NetBSD: utilities.c,v 1.18 1996/09/27 22:45:20 christos Exp $ */
/*
return;
if (bp->b_errs != 0)
pfatal("WRITING %sZERO'ED BLOCK %lld TO DISK\n",
- (bp->b_errs == bp->b_size / dev_bsize) ? "" : "PARTIALLY ",
+ (bp->b_errs == bp->b_size / DEV_BSIZE) ? "" : "PARTIALLY ",
(long long)bp->b_bno);
bp->b_dirty = 0;
bp->b_errs = 0;
} else
sblockloc = SBLOCK_UFS2;
flush(fswritefd, &sblk);
- if (havesb && sblk.b_bno != sblockloc / dev_bsize && !preen &&
+ if (havesb && sblk.b_bno != sblockloc / DEV_BSIZE && !preen &&
reply("UPDATE STANDARD SUPERBLOCK")) {
- sblk.b_bno = sblockloc / dev_bsize;
+ sblk.b_bno = sblockloc / DEV_BSIZE;
sbdirty();
flush(fswritefd, &sblk);
}
off_t offset;
offset = blk;
- offset *= dev_bsize;
+ offset *= DEV_BSIZE;
if (lseek(fd, offset, SEEK_SET) < 0)
rwerror("SEEK", blk);
else if (read(fd, buf, (int)size) == size)
for (cp = buf, i = 0; i < size; i += secsize, cp += secsize) {
if (read(fd, cp, (int)secsize) != secsize) {
(void)lseek(fd, offset + i + secsize, SEEK_SET);
- if (secsize != dev_bsize && dev_bsize != 1)
+ if (secsize != DEV_BSIZE)
printf(" %lld (%lld),",
- (long long)((blk * dev_bsize + i) /
+ (long long)((blk * DEV_BSIZE + i) /
secsize),
- (long long)(blk + i / dev_bsize));
+ (long long)(blk + i / DEV_BSIZE));
else
printf(" %lld,",
- (long long)(blk + i / dev_bsize));
+ (long long)(blk + i / DEV_BSIZE));
errs++;
}
}
if (fd < 0)
return;
offset = blk;
- offset *= dev_bsize;
+ offset *= DEV_BSIZE;
if (lseek(fd, offset, SEEK_SET) < 0)
rwerror("SEEK", blk);
else if (write(fd, buf, (int)size) == size) {
if (lseek(fd, offset, SEEK_SET) < 0)
rwerror("SEEK", blk);
printf("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:");
- for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize)
- if (write(fd, cp, (int)dev_bsize) != dev_bsize) {
- (void)lseek(fd, offset + i + dev_bsize, SEEK_SET);
- printf(" %lld,", (long long)(blk + i / dev_bsize));
+ for (cp = buf, i = 0; i < size; i += secsize, cp += secsize)
+ if (write(fd, cp, (int)secsize) != secsize) {
+ (void)lseek(fd, offset + i + secsize, SEEK_SET);
+ if (secsize != DEV_BSIZE)
+ printf(" %lld (%lld),",
+ (long long)((blk * DEV_BSIZE + i) /
+ secsize),
+ (long long)(blk + i / DEV_BSIZE));
+ else
+ printf(" %lld,",
+ (long long)(blk + i / DEV_BSIZE));
}
printf("\n");
return;