diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-08 16:01:25 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-08 16:01:25 +0000 |
commit | 2466995ad992f390bf3478d82d1ead2773c7af82 (patch) | |
tree | eb302387d49252c0566ec0c67293de630faf97a8 | |
parent | 94066dc226175357dccd0a24663a177fa4058957 (diff) | |
parent | 6cbd5a634d77914c907cdc00b5bb9fdb1fbc438d (diff) | |
download | newfs_msdos-aml_tz2_303900102.tar.gz |
Snap for 8426163 from 6cbd5a634d77914c907cdc00b5bb9fdb1fbc438d to mainline-tzdata2-releaseandroid-mainline-12.0.0_r112aml_tz2_305400500aml_tz2_305400300aml_tz2_305400100aml_tz2_304500300aml_tz2_303900110aml_tz2_303900102aml_tz2_303800002aml_tz2_303800001aml_tz2_303200001android12-mainline-tzdata2-releaseaml_tz2_305400100
Change-Id: Ib491328118aea73b7e65f549ded6910559045982
-rwxr-xr-x | Android.bp | 22 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | NOTICE | 85 | ||||
-rw-r--r-- | freebsd-compat.h | 36 | ||||
-rw-r--r-- | mkfs_msdos.c | 197 | ||||
-rw-r--r-- | mkfs_msdos.h | 7 | ||||
-rw-r--r-- | newfs_msdos.c | 15 |
7 files changed, 157 insertions, 213 deletions
@@ -1,23 +1,5 @@ -package { - default_applicable_licenses: ["external_newfs_msdos_license"], -} - -// Added automatically by a large-scale-change -// See: http://go/android-license-faq -license { - name: "external_newfs_msdos_license", - visibility: [":__subpackages__"], - license_kinds: [ - "SPDX-license-identifier-BSD", - ], - license_text: [ - "LICENSE", - ], -} - cc_binary { name: "newfs_msdos", - c_std: "gnu11", cflags: [ "-Wall", "-Werror", @@ -25,7 +7,9 @@ cc_binary { "-Wno-unused-parameter", "-Wno-unused-variable", "-D_FILE_OFFSET_BITS=64", - "-include freebsd-compat.h" + "-D_GNU_SOURCE", + "-DSIGINFO=SIGUSR2", + "-Dnitems(x)=(sizeof((x))/sizeof((x)[0]))", ], srcs: [ "mkfs_msdos.c", @@ -5,13 +5,13 @@ description: third_party { url { type: HOMEPAGE - value: "https://github.com/freebsd/freebsd-src/tree/master/sbin/newfs_msdos" + value: "https://github.com/freebsd/freebsd/tree/master/sbin/newfs_msdos" } url { type: ARCHIVE - value: "https://github.git.corp.google.com/freebsd/freebsd-src/+archive/6424881cc82a65a833fc6fb79730474caedf6222/sbin/newfs_msdos.tar.gz" + value: "https://github.git.corp.google.com/freebsd/freebsd/+archive/b25a2bc/sbin/newfs_msdos.tar.gz" } - version: "6424881cc82a65a833fc6fb79730474caedf6222" - last_upgrade_date { year: 2021 month: 1 day: 20 } + version: "b25a2bc" + last_upgrade_date { year: 2018 month: 4 day: 26 } license_type: NOTICE } @@ -0,0 +1,85 @@ +Copyright (c) 1998 Robert Nordier +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------- + +Copyright (c) 2013 The NetBSD Foundation, Inc. +All rights reserved. + +This code is derived from software contributed to The NetBSD Foundation +by Christos Zoulas. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------- + +SPDX-License-Identifier: BSD-2-Clause-FreeBSD + +Copyright (c) 1998 Robert Nordier +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------- + diff --git a/freebsd-compat.h b/freebsd-compat.h deleted file mode 100644 index 1fdbafe..0000000 --- a/freebsd-compat.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#define _GNU_SOURCE - -#include <stdint.h> - -#include <sys/param.h> -// Ensure we use a BSD powerof2 that works in static_assert (unlike glibc's). -#undef powerof2 -#define powerof2(x) ((((x)-1)&(x))==0) -// This is in BSD's <sys/param.h>. -#define nitems(x) (sizeof((x))/sizeof((x)[0])) - -// This is used as the size of the write buffer of sectors. -#define MAXPHYS (1024 * 1024) - -// On glibc, these headers use `__unused` as an identifier, so drag them in -// first. -#include <sys/stat.h> -#if __has_include(<sys/sysctl.h>) -#include <sys/sysctl.h> -#endif -// Bionic, like the BSDs, has __unused. glibc doesn't. -#if defined(__GLIBC__) -#define __unused __attribute__((__unused__)) -#endif -// Neither macOS nor glibc has __packed. -#if defined(__APPLE__) || defined(__GLIBC__) -#define __packed __attribute__((__packed__)) -#endif - -// The BSDs (including Android and macOS) have getprogname(), but glibc doesn't. -#if defined(__GLIBC__) -#include <errno.h> -static inline char* getprogname() { return program_invocation_short_name; } -#endif diff --git a/mkfs_msdos.c b/mkfs_msdos.c index 946096f..04afc84 100644 --- a/mkfs_msdos.c +++ b/mkfs_msdos.c @@ -27,14 +27,11 @@ #ifndef lint static const char rcsid[] = - "$FreeBSD$"; + "$FreeBSD: head/sbin/newfs_msdos/mkfs_msdos.c 335189 2018-06-15 06:03:40Z delphij $"; #endif /* not lint */ #include <sys/param.h> -#ifdef MAKEFS -/* In the makefs case we only want struct disklabel */ -#include <sys/disk/bsd.h> -#elif defined(__linux__) +#if defined(__linux__) #include <linux/fs.h> #include <linux/hdreg.h> #include <sys/ioctl.h> @@ -47,12 +44,8 @@ static const char rcsid[] = #include <sys/mount.h> #endif #include <sys/stat.h> -#if __has_include(<sys/sysctl.h>) -#include <sys/sysctl.h> -#endif #include <sys/time.h> -#include <assert.h> #include <ctype.h> #include <err.h> #include <errno.h> @@ -68,13 +61,19 @@ static const char rcsid[] = #include "mkfs_msdos.h" +#if !defined(__packed) +#define __packed __attribute__((__packed__)) +#endif +#if !defined(__unused) +#define __unused __attribute__((__unused__)) +#endif + #define MAXU16 0xffff /* maximum unsigned 16-bit quantity */ #define BPN 4 /* bits per nibble */ #define NPB 2 /* nibbles per byte */ #define DOSMAGIC 0xaa55 /* DOS magic number */ #define MINBPS 512 /* minimum bytes per sector */ -#define MAXBPS 4096 /* maximum bytes per sector */ #define MAXSPC 128 /* maximum sectors per cluster */ #define MAXNFT 16 /* maximum number of FATs */ #define DEFBLK 4096 /* default block size */ @@ -231,7 +230,6 @@ static volatile sig_atomic_t got_siginfo; static void infohandler(int); static int check_mounted(const char *, mode_t); -static ssize_t getchunksize(void); static int getstdfmt(const char *, struct bpb *); static int getdiskinfo(int, const char *, const char *, int, struct bpb *); static void print_bpb(struct bpb *); @@ -255,7 +253,6 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) struct bsx *bsx; struct de *de; u_int8_t *img; - u_int8_t *physbuf, *physbuf_end; const char *bname; ssize_t n; time_t now; @@ -264,9 +261,8 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) bool set_res, set_spf, set_spc; int fd, fd1, rv; struct msdos_options o = *op; - ssize_t chunksize; - physbuf = NULL; + img = NULL; rv = -1; fd = fd1 = -1; @@ -304,18 +300,12 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) if (!S_ISREG(sb.st_mode)) warnx("warning, %s is not a regular file", fname); } else { -#ifdef MAKEFS - errx(1, "o.create_size must be set!"); -#else if (!S_ISCHR(sb.st_mode)) warnx("warning, %s is not a character device", fname); -#endif } -#ifndef MAKEFS if (!o.no_create) if (check_mounted(fname, sb.st_mode) == -1) goto done; -#endif if (o.offset && o.offset != lseek(fd, o.offset, SEEK_SET)) { warnx("cannot seek to %jd", (intmax_t)o.offset); goto done; @@ -341,8 +331,7 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) bpb.bpbHiddenSecs = o.hidden_sectors; if (!(o.floppy || (o.drive_heads && o.sectors_per_track && o.bytes_per_sector && o.size && o.hidden_sectors_set))) { - if (getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb) == -1) - goto done; + getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb); bpb.bpbHugeSectors -= (o.offset / bpb.bpbBytesPerSec); if (bpb.bpbSecPerClust == 0) { /* set defaults */ if (bpb.bpbHugeSectors <= 6000) /* about 3MB -> 512 bytes */ @@ -357,11 +346,13 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) bpb.bpbSecPerClust = 64; /* otherwise 32k */ } } - if (bpb.bpbBytesPerSec < MINBPS || - bpb.bpbBytesPerSec > MAXBPS || - !powerof2(bpb.bpbBytesPerSec)) { - warnx("Invalid bytes/sector (%u): must be 512, 1024, 2048 or 4096", - bpb.bpbBytesPerSec); + if (!powerof2(bpb.bpbBytesPerSec)) { + warnx("bytes/sector (%u) is not a power of 2", bpb.bpbBytesPerSec); + goto done; + } + if (bpb.bpbBytesPerSec < MINBPS) { + warnx("bytes/sector (%u) is too small; minimum is %u", + bpb.bpbBytesPerSec, MINBPS); goto done; } @@ -445,7 +436,10 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) bname = o.bootstrap; if (!strchr(bname, '/')) { snprintf(buf, sizeof(buf), "/boot/%s", bname); - bname = buf; + if (!(bname = strdup(buf))) { + warn(NULL); + goto done; + } } if ((fd1 = open(bname, O_RDONLY)) == -1 || fstat(fd1, &sb)) { warn("%s", bname); @@ -633,26 +627,19 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) tm = localtime(&now); } - chunksize = getchunksize(); - physbuf = malloc(chunksize); - if (physbuf == NULL) { + + if (!(img = malloc(bpb.bpbBytesPerSec))) { warn(NULL); goto done; } - physbuf_end = physbuf + chunksize; - img = physbuf; - dir = bpb.bpbResSectors + (bpb.bpbFATsecs ? bpb.bpbFATsecs : bpb.bpbBigFATsecs) * bpb.bpbFATs; memset(&si_sa, 0, sizeof(si_sa)); si_sa.sa_handler = infohandler; -#ifdef SIGINFO if (sigaction(SIGINFO, &si_sa, NULL) == -1) { warn("sigaction SIGINFO"); goto done; } -#endif - for (lsn = 0; lsn < dir + (fat == 32 ? bpb.bpbSecPerClust : rds); lsn++) { if (got_siginfo) { fprintf(stderr,"%s: writing sector %u of %u (%u%%)\n", @@ -745,7 +732,7 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) mk4(img, 0x41615252); mk4(img + MINBPS - 28, 0x61417272); mk4(img + MINBPS - 24, 0xffffffff); - mk4(img + MINBPS - 20, 0xffffffff); + mk4(img + MINBPS - 20, bpb.bpbRootClust); mk2(img + MINBPS - 2, DOSMAGIC); } else if (lsn >= bpb.bpbResSectors && lsn < dir && !((lsn - bpb.bpbResSectors) % @@ -767,37 +754,19 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) (u_int)tm->tm_mday; mk2(de->deMDate, x); } - /* - * Issue a write of chunksize once we have collected - * enough sectors. - */ - img += bpb.bpbBytesPerSec; - if (img >= physbuf_end) { - n = write(fd, physbuf, chunksize); - if (n != chunksize) { - warnx("%s: can't write sector %u", fname, lsn); - goto done; - } - img = physbuf; + if ((n = write(fd, img, bpb.bpbBytesPerSec)) == -1) { + warn("%s", fname); + goto done; + } + if ((unsigned)n != bpb.bpbBytesPerSec) { + warnx("%s: can't write sector %u", fname, lsn); + goto done; } - } - /* - * Write remaining sectors, if the last write didn't end - * up filling a whole chunk. - */ - if (img != physbuf) { - ssize_t tailsize = img - physbuf; - - n = write(fd, physbuf, tailsize); - if (n != tailsize) { - warnx("%s: can't write sector %u", fname, lsn); - goto done; - } } } rv = 0; done: - free(physbuf); + free(img); if (fd != -1) close(fd); if (fd1 != -1) @@ -812,11 +781,7 @@ done: static int check_mounted(const char *fname, mode_t mode) { -/* - * If getmntinfo() is not available (e.g. Linux) don't check. This should - * not be a problem since we will only be using makefs to create images. - */ -#if 0 && !defined(MAKEFS) +#if 0 struct statfs *mp; const char *s1, *s2; size_t len; @@ -846,47 +811,6 @@ check_mounted(const char *fname, mode_t mode) } /* - * Get optimal I/O size - */ -static ssize_t -getchunksize(void) -{ - static int chunksize; - - if (chunksize != 0) - return ((ssize_t)chunksize); - -#ifdef KERN_MAXPHYS - int mib[2]; - size_t len; - - mib[0] = CTL_KERN; - mib[1] = KERN_MAXPHYS; - len = sizeof(chunksize); - - if (sysctl(mib, 2, &chunksize, &len, NULL, 0) == -1) { - warn("sysctl: KERN_MAXPHYS, using %zu", (size_t)MAXPHYS); - chunksize = 0; - } -#endif - if (chunksize == 0) - chunksize = MAXPHYS; - - /* - * For better performance, we want to write larger chunks instead of - * individual sectors (the size can only be 512, 1024, 2048 or 4096 - * bytes). Assert that chunksize can always hold an integer number of - * sectors by asserting that both are power of two numbers and the - * chunksize is greater than MAXBPS. - */ - static_assert(powerof2(MAXBPS), "MAXBPS is not power of 2"); - assert(powerof2(chunksize)); - assert(chunksize > MAXBPS); - - return ((ssize_t)chunksize); -} - -/* * Get a standard format. */ static int @@ -904,25 +828,6 @@ getstdfmt(const char *fmt, struct bpb *bpb) return 0; } -#if 0 -static void -compute_geometry_from_file(int fd, const char *fname, struct disklabel *lp) -{ - struct stat st; - off_t ms; - - if (fstat(fd, &st)) - err(1, "cannot get disk size"); - if (!S_ISREG(st.st_mode)) - errx(1, "%s is not a regular file", fname); - ms = st.st_size; - lp->d_secsize = 512; - lp->d_nsectors = 63; - lp->d_ntracks = 255; - lp->d_secperunit = ms / lp->d_secsize; -} -#endif - /* * Get disk slice, partition, and geometry information. */ @@ -936,17 +841,16 @@ static int getdiskinfo(int fd, const char *fname, const char *dtype, if (ckgeom(fname, bpb->bpbBytesPerSec, "bytes/sector") == -1) return -1; - u_int64_t device_size; - if (ioctl(fd, BLKGETSIZE64, &device_size)) { - err(1, "ioctl(BLKGETSIZE64) failed"); + u_long block_size; + if (ioctl(fd, BLKGETSIZE, &block_size)) { + err(1, "ioctl(BLKGETSIZE) failed"); } - u_int64_t sectors = device_size/bpb->bpbBytesPerSec; - if (sectors > UINT_MAX) { - errx(1, "too many sectors: %"PRIu64" (%"PRIu64" byte device, %u bytes/sector)", - sectors, device_size, bpb->bpbBytesPerSec); + if (block_size > UINT32_MAX) { + errx(1, "block size too large: %lu", block_size); } - bpb->bpbHugeSectors = sectors; + + bpb->bpbHugeSectors = (u_int)block_size; bpb->bpbSecPerTrack = 63; if (ckgeom(fname, bpb->bpbSecPerTrack, "sectors/track") == -1) return -1; @@ -968,10 +872,8 @@ getdiskinfo(int fd, const char *fname, const char *dtype, __unused int oflag, struct bpb *bpb) { struct disklabel *lp, dlp; - off_t hs = 0; -#ifndef MAKEFS - off_t ms; struct fd_type type; + off_t ms, hs = 0; lp = NULL; @@ -983,8 +885,16 @@ getdiskinfo(int fd, const char *fname, const char *dtype, __unused int oflag, /* Maybe it's a floppy drive */ if (lp == NULL) { if (ioctl(fd, DIOCGMEDIASIZE, &ms) == -1) { + struct stat st; + + if (fstat(fd, &st)) + err(1, "cannot get disk size"); /* create a fake geometry for a file image */ - compute_geometry_from_file(fd, fname, &dlp); + ms = st.st_size; + dlp.d_secsize = 512; + dlp.d_nsectors = 63; + dlp.d_ntracks = 255; + dlp.d_secperunit = ms / dlp.d_secsize; lp = &dlp; } else if (ioctl(fd, FD_GTYPE, &type) != -1) { dlp.d_secsize = 128 << type.secsize; @@ -1024,11 +934,6 @@ getdiskinfo(int fd, const char *fname, const char *dtype, __unused int oflag, hs = (ms / dlp.d_secsize) - dlp.d_secperunit; lp = &dlp; } -#else - /* In the makefs case we only support image files: */ - compute_geometry_from_file(fd, fname, &dlp); - lp = &dlp; -#endif if (bpb->bpbBytesPerSec == 0) { if (ckgeom(fname, lp->d_secsize, "bytes/sector") == -1) diff --git a/mkfs_msdos.h b/mkfs_msdos.h index 7e0c662..b49a577 100644 --- a/mkfs_msdos.h +++ b/mkfs_msdos.h @@ -1,4 +1,4 @@ -/* $FreeBSD$ */ +/* $FreeBSD: head/sbin/newfs_msdos/mkfs_msdos.h 335189 2018-06-15 06:03:40Z delphij $ */ /* $NetBSD: mkfs_msdos.h,v 1.3 2015/10/16 17:38:17 christos Exp $ */ /*- @@ -32,6 +32,7 @@ #include <sys/types.h> #include <stdbool.h> +#include <stdint.h> #define ALLOPTS \ AOPT('@', off_t, offset, 0, "Offset in device") \ AOPT('A', bool, align, -2, "Attempt to cluster align root directory") \ @@ -70,3 +71,7 @@ ALLOPTS }; int mkfs_msdos(const char *, const char *, const struct msdos_options *); + +#if defined(__GLIBC__) +static inline char* getprogname() { return program_invocation_short_name; } +#endif diff --git a/newfs_msdos.c b/newfs_msdos.c index bac250e..cd03164 100644 --- a/newfs_msdos.c +++ b/newfs_msdos.c @@ -29,7 +29,7 @@ #ifndef lint static const char rcsid[] = - "$FreeBSD$"; + "$FreeBSD: head/sbin/newfs_msdos/newfs_msdos.c 335189 2018-06-15 06:03:40Z delphij $"; #endif /* not lint */ #include <sys/param.h> @@ -178,17 +178,18 @@ main(int argc, char *argv[]) argv += optind; if (argc < 1 || argc > 2) usage(); - if (o.align) { - if (o.reserved_sectors) - errx(1, "align (-A) is incompatible with -r"); - } + if (o.align) { + if (o.hidden_sectors_set) + errx(1, "align (-A) is incompatible with -r"); + } fname = *argv++; if (!o.create_size && !strchr(fname, '/')) { snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname); - fname = buf; + if (!(fname = strdup(buf))) + err(1, NULL); } dtype = *argv; - exit(!!mkfs_msdos(fname, dtype, &o)); + return !!mkfs_msdos(fname, dtype, &o); } /* |