diff options
author | jmallett <jmallett@FreeBSD.org> | 2003-01-27 07:24:32 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2003-01-27 07:24:32 +0000 |
commit | 273be50650cbddcef59f940fadc3ee725fb05a27 (patch) | |
tree | c6002c834785472f07ba74d94bc68dac0eaf6f99 /sbin/newfs/newfs.c | |
parent | 9527a0b0213657fdcc71dbc45effa68b47ffec2a (diff) | |
download | FreeBSD-src-273be50650cbddcef59f940fadc3ee725fb05a27.zip FreeBSD-src-273be50650cbddcef59f940fadc3ee725fb05a27.tar.gz |
Convert newfs to use libufs. I've tested this on md filesystems, as has
keramida, and all seems well.
Diffstat (limited to 'sbin/newfs/newfs.c')
-rw-r--r-- | sbin/newfs/newfs.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index 50034a2..2d7b0c2 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -135,7 +135,6 @@ int maxcontig = 0; /* max contiguous blocks to allocate */ int maxbpg; /* maximum blocks per file in a cyl group */ int avgfilesize = AVFILESIZ;/* expected average file size */ int avgfilesperdir = AFPDIR;/* expected number of files per directory */ -int fso; /* filedescriptor to device */ static char device[MAXPATHLEN]; static char *disktype; @@ -261,17 +260,20 @@ main(int argc, char *argv[]) special = device; } - fso = open(special, Nflag ? O_RDONLY : O_RDWR); - if (fso < 0) - err(1, "%s", special); - if (fstat(fso, &st) < 0) + if (ufs_disk_fillout_blank(&disk, special) == -1) { + if (disk.d_error != NULL) + errx(1, "%s: %s", special, disk.d_error); + else + err(1, "%s", special); + } + if (fstat(disk.d_fd, &st) < 0) err(1, "%s", special); if ((st.st_mode & S_IFMT) != S_IFCHR) errx(1, "%s: not a character-special device", special); if (sectorsize == 0) - ioctl(fso, DIOCGSECTORSIZE, §orsize); - if (sectorsize && !ioctl(fso, DIOCGMEDIASIZE, &mediasize)) { + ioctl(disk.d_fd, DIOCGSECTORSIZE, §orsize); + if (sectorsize && !ioctl(disk.d_fd, DIOCGMEDIASIZE, &mediasize)) { if (fssize == 0) fssize = mediasize / sectorsize; else if (fssize > mediasize / sectorsize) @@ -350,7 +352,7 @@ main(int argc, char *argv[]) if (!Nflag && bcmp(pp, &oldpartition, sizeof(oldpartition))) rewritelabel(special, lp); } - close(fso); + ufs_disk_close(&disk); exit(0); } @@ -360,7 +362,7 @@ getdisklabel(char *s) static struct disklabel lab; struct disklabel *lp; - if (!ioctl(fso, DIOCGDINFO, (char *)&lab)) + if (!ioctl(disk.d_fd, DIOCGDINFO, (char *)&lab)) return (&lab); unlabeled++; if (disktype) { @@ -378,12 +380,12 @@ rewritelabel(char *s, struct disklabel *lp) return; lp->d_checksum = 0; lp->d_checksum = dkcksum(lp); - if (ioctl(fso, DIOCWDINFO, (char *)lp) < 0) + if (ioctl(disk.d_fd, DIOCWDINFO, (char *)lp) < 0) warn("ioctl (WDINFO): %s: can't rewrite disk label", s); } static void -usage() +usage(void) { fprintf(stderr, "usage: %s [ -fsoptions ] special-device%s\n", |