CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: ryoon Date: Fri Dec 11 18:49:38 UTC 2020 Modified Files: src/sbin/newfs_msdos: newfs_msdos.8 Log Message: Describe after example like other examples To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sbin/newfs_msdos/newfs_msdos.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/newfs_msdos.8 diff -u src/sbin/newfs_msdos/newfs_msdos.8:1.23 src/sbin/newfs_msdos/newfs_msdos.8:1.24 --- src/sbin/newfs_msdos/newfs_msdos.8:1.23 Fri Feb 17 09:29:35 2017 +++ src/sbin/newfs_msdos/newfs_msdos.8 Fri Dec 11 18:49:37 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: newfs_msdos.8,v 1.23 2017/02/17 09:29:35 wiz Exp $ +.\" $NetBSD: newfs_msdos.8,v 1.24 2020/12/11 18:49:37 ryoon Exp $ .\" .\" Copyright (c) 1998 Robert Nordier .\" All rights reserved. @@ -228,11 +228,12 @@ Create a standard 1.44M file system, wit .Ar foo , on .Pa /dev/rfd0a . -Create a 30MB image file, with the FAT partition starting -63 sectors within the image file: .Bd -literal -offset indent newfs_msdos -C 30M -@63s ./somefile .Ed +.Pp +Create a 30MB image file, with the FAT partition starting +63 sectors within the image file: .Sh DIAGNOSTICS Exit status is 0 on success and 1 on error. .Sh SEE ALSO
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: christos Date: Fri Apr 14 15:39:29 UTC 2017 Modified Files: src/sbin/newfs_msdos: mkfs_msdos.c Log Message: Use the create_size if given to compute the real size instead of stat'ing the file again, which might have been larger to start with. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sbin/newfs_msdos/mkfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/mkfs_msdos.c diff -u src/sbin/newfs_msdos/mkfs_msdos.c:1.12 src/sbin/newfs_msdos/mkfs_msdos.c:1.13 --- src/sbin/newfs_msdos/mkfs_msdos.c:1.12 Thu Feb 16 17:42:25 2017 +++ src/sbin/newfs_msdos/mkfs_msdos.c Fri Apr 14 11:39:29 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.c,v 1.12 2017/02/16 22:42:25 christos Exp $ */ +/* $NetBSD: mkfs_msdos.c,v 1.13 2017/04/14 15:39:29 christos Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -37,7 +37,7 @@ static const char rcsid[] = "$FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $"; #else -__RCSID("$NetBSD: mkfs_msdos.c,v 1.12 2017/02/16 22:42:25 christos Exp $"); +__RCSID("$NetBSD: mkfs_msdos.c,v 1.13 2017/04/14 15:39:29 christos Exp $"); #endif #endif /* not lint */ @@ -235,7 +235,7 @@ static int got_siginfo = 0; /* received static int check_mounted(const char *, mode_t); #endif static int getstdfmt(const char *, struct bpb *); -static int getbpbinfo(int, const char *, const char *, int, struct bpb *, int); +static int getbpbinfo(int, const char *, const char *, int, struct bpb *, off_t); static void print_bpb(struct bpb *); static int ckgeom(const char *, u_int, const char *); static int oklabel(const char *); @@ -331,7 +331,7 @@ mkfs_msdos(const char *fname, const char if (!(o.floppy || (o.drive_heads && o.sectors_per_track && o.bytes_per_sector && o.size && o.hidden_sectors_set))) { if (getbpbinfo(fd, fname, dtype, o.hidden_sectors_set, , - o.create_size != 0) == -1) + o.create_size) == -1) return -1; bpb.bsec -= (o.offset / bpb.bps); if (bpb.spc == 0) { /* set defaults */ @@ -817,7 +817,7 @@ getstdfmt(const char *fmt, struct bpb *b */ static int getbpbinfo(int fd, const char *fname, const char *dtype, int iflag, -struct bpb *bpb, int create) +struct bpb *bpb, off_t create_size) { const char *s1, *s2; int part; @@ -835,26 +835,31 @@ getbpbinfo(int fd, const char *fname, co #ifndef MAKEFS int maxpartitions = getmaxpartitions(); +struct disk_geom geo; +struct dkwedge_info dkw; // XXX: Does not work with wedges if (s2 && *s2 >= 'a' && *s2 <= 'a' + maxpartitions - 1) { part = *s2++ - 'a'; } #endif -if (((part != -1) && ((!iflag && part != -1) || !bpb->bsec)) || - !bpb->bps || !bpb->spt || !bpb->hds) { - u_int sector_size; - u_int nsectors; - u_int ntracks; - u_int size; -#ifndef MAKEFS - struct disk_geom geo; - struct dkwedge_info dkw; - if (!create && getdiskinfo(fname, fd, NULL, , ) != -1) { - sector_size = geo.dg_secsize = 512; - nsectors = geo.dg_nsectors = 63; - ntracks = geo.dg_ntracks = 255; +if (!(((part != -1) && ((!iflag && part != -1) || !bpb->bsec)) || + !bpb->bps || !bpb->spt || !bpb->hds)) { + return 0; +} + +u_int sector_size = 512; +u_int nsectors = 63; +u_int ntracks = 255; +u_int size; + +if (create_size == 0) { +#ifndef MAKEFS + if (getdiskinfo(fname, fd, NULL, , ) != -1) { + sector_size = geo.dg_secsize; + nsectors = geo.dg_nsectors; + ntracks = geo.dg_ntracks; size = dkw.dkw_size; } else #endif @@ -865,39 +870,39 @@ getbpbinfo(int fd, const char *fname, co warnx("Can't get disk size for `%s'", fname); return -1; } - /* create a fake geometry for a file image */ - sector_size = 512; - nsectors = 63; - ntracks = 255; size = st.st_size / sector_size; } - if (!bpb->bps) { - if (ckgeom(fname, sector_size, "bytes/sector") == -1) - return -1; - bpb->bps = sector_size; - } +} else { + size = create_size / sector_size; +} - if (nsectors > 63) { - /* - * The kernel doesn't accept BPB with spt > 63. - * (see sys/fs/msdosfs/msdosfs_vfsops.c:msdosfs_mountfs()) - * If values taken from disklabel don't match these - * restrictions, use popular BIOS default values instead. - */ - nsectors = 63; - } - if (!bpb->spt) { - if (ckgeom(fname, nsectors, "sectors/track") == -1) - return -1; - bpb->spt = nsectors; - } - if (!bpb->hds) - if (ckgeom(fname, ntracks, "drive heads") == -1) - return -1; - bpb->hds = ntracks; - if (!bpb->bsec) - bpb->bsec = size; +if (!bpb->bps) { + if (ckgeom(fname, sector_size, "bytes/sector") == -1) + return -1; + bpb->bps = sector_size; +} + +if (nsectors > 63) { + /* + * The kernel doesn't accept BPB with spt > 63. + * (see
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: wiz Date: Fri Feb 17 09:29:35 UTC 2017 Modified Files: src/sbin/newfs_msdos: mkfs_msdos.h newfs_msdos.8 Log Message: file system police. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sbin/newfs_msdos/mkfs_msdos.h cvs rdiff -u -r1.22 -r1.23 src/sbin/newfs_msdos/newfs_msdos.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/mkfs_msdos.h diff -u src/sbin/newfs_msdos/mkfs_msdos.h:1.5 src/sbin/newfs_msdos/mkfs_msdos.h:1.6 --- src/sbin/newfs_msdos/mkfs_msdos.h:1.5 Thu Feb 16 22:42:25 2017 +++ src/sbin/newfs_msdos/mkfs_msdos.h Fri Feb 17 09:29:35 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.h,v 1.5 2017/02/16 22:42:25 christos Exp $ */ +/* $NetBSD: mkfs_msdos.h,v 1.6 2017/02/17 09:29:35 wiz Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ AOPT('C', off_t, create_size, 0, "Create AOPT('F', uint8_t, fat_type, 12, "FAT type (12, 16, or 32)") \ AOPT('I', uint32_t, volume_id, 0, "Volume ID") \ AOPT('L', char *, volume_label, -1, "Volume Label") \ -AOPT('N', bool, no_create, -2, "Don't create filesystem, print params only") \ +AOPT('N', bool, no_create, -2, "Don't create file system, print params only") \ AOPT('O', char *, OEM_string, -1, "OEM string") \ AOPT('S', uint16_t, bytes_per_sector, 1, "Bytes per sector") \ AOPT('a', uint32_t, sectors_per_fat, 1, "Sectors per FAT") \ Index: src/sbin/newfs_msdos/newfs_msdos.8 diff -u src/sbin/newfs_msdos/newfs_msdos.8:1.22 src/sbin/newfs_msdos/newfs_msdos.8:1.23 --- src/sbin/newfs_msdos/newfs_msdos.8:1.22 Thu Feb 16 18:49:31 2017 +++ src/sbin/newfs_msdos/newfs_msdos.8 Fri Feb 17 09:29:35 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: newfs_msdos.8,v 1.22 2017/02/16 18:49:31 christos Exp $ +.\" $NetBSD: newfs_msdos.8,v 1.23 2017/02/17 09:29:35 wiz Exp $ .\" .\" Copyright (c) 1998 Robert Nordier .\" All rights reserved. @@ -149,7 +149,7 @@ Number of reserved sectors. .It Fl s Ar total File system size. .It Fl T At timestamp -Specify a timestamp to be used for filesystem creation so that +Specify a timestamp to be used for file system creation so that it can be consistent for reproducible builds. The timestamp can be a pathname, where the timestamps are derived from that file, a parseable date for parsedate(3) (this option is not
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: christos Date: Thu Feb 16 22:42:25 UTC 2017 Modified Files: src/sbin/newfs_msdos: mkfs_msdos.c mkfs_msdos.h newfs_msdos.c Log Message: Allow 0 timestamp To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sbin/newfs_msdos/mkfs_msdos.c cvs rdiff -u -r1.4 -r1.5 src/sbin/newfs_msdos/mkfs_msdos.h cvs rdiff -u -r1.44 -r1.45 src/sbin/newfs_msdos/newfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/mkfs_msdos.c diff -u src/sbin/newfs_msdos/mkfs_msdos.c:1.11 src/sbin/newfs_msdos/mkfs_msdos.c:1.12 --- src/sbin/newfs_msdos/mkfs_msdos.c:1.11 Thu Feb 16 13:49:31 2017 +++ src/sbin/newfs_msdos/mkfs_msdos.c Thu Feb 16 17:42:25 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.c,v 1.11 2017/02/16 18:49:31 christos Exp $ */ +/* $NetBSD: mkfs_msdos.c,v 1.12 2017/02/16 22:42:25 christos Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -37,7 +37,7 @@ static const char rcsid[] = "$FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $"; #else -__RCSID("$NetBSD: mkfs_msdos.c,v 1.11 2017/02/16 18:49:31 christos Exp $"); +__RCSID("$NetBSD: mkfs_msdos.c,v 1.12 2017/02/16 22:42:25 christos Exp $"); #endif #endif /* not lint */ @@ -621,7 +621,7 @@ mkfs_msdos(const char *fname, const char printf("MBR type: %d\n", ch); print_bpb(); if (!o.no_create) { - if (o.timestamp) { + if (o.timestamp_set) { tv.tv_sec = now = o.timestamp; tv.tv_usec = 0; tm = gmtime(); Index: src/sbin/newfs_msdos/mkfs_msdos.h diff -u src/sbin/newfs_msdos/mkfs_msdos.h:1.4 src/sbin/newfs_msdos/mkfs_msdos.h:1.5 --- src/sbin/newfs_msdos/mkfs_msdos.h:1.4 Thu Feb 16 13:49:31 2017 +++ src/sbin/newfs_msdos/mkfs_msdos.h Thu Feb 16 17:42:25 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.h,v 1.4 2017/02/16 18:49:31 christos Exp $ */ +/* $NetBSD: mkfs_msdos.h,v 1.5 2017/02/16 22:42:25 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -61,6 +61,7 @@ struct msdos_options { ALLOPTS #undef AOPT time_t timestamp; + uint32_t timestamp_set:1; uint32_t volume_id_set:1; uint32_t media_descriptor_set:1; uint32_t hidden_sectors_set:1; Index: src/sbin/newfs_msdos/newfs_msdos.c diff -u src/sbin/newfs_msdos/newfs_msdos.c:1.44 src/sbin/newfs_msdos/newfs_msdos.c:1.45 --- src/sbin/newfs_msdos/newfs_msdos.c:1.44 Thu Feb 16 13:49:31 2017 +++ src/sbin/newfs_msdos/newfs_msdos.c Thu Feb 16 17:42:25 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: newfs_msdos.c,v 1.44 2017/02/16 18:49:31 christos Exp $ */ +/* $NetBSD: newfs_msdos.c,v 1.45 2017/02/16 22:42:25 christos Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -33,7 +33,7 @@ static const char rcsid[] = "$FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $"; #else -__RCSID("$NetBSD: newfs_msdos.c,v 1.44 2017/02/16 18:49:31 christos Exp $"); +__RCSID("$NetBSD: newfs_msdos.c,v 1.45 2017/02/16 22:42:25 christos Exp $"); #endif #endif /* not lint */ @@ -170,6 +170,7 @@ main(int argc, char *argv[]) o.size = argto4(optarg, 1, "file system size"); break; case 'T': + o.timestamp_set = 1; o.timestamp = get_tstamp(optarg); break; case 'u':
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: christos Date: Thu Feb 16 18:49:31 UTC 2017 Modified Files: src/sbin/newfs_msdos: mkfs_msdos.c mkfs_msdos.h newfs_msdos.8 newfs_msdos.c Log Message: add -T for reproducible builds (used in makefs) To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sbin/newfs_msdos/mkfs_msdos.c cvs rdiff -u -r1.3 -r1.4 src/sbin/newfs_msdos/mkfs_msdos.h cvs rdiff -u -r1.21 -r1.22 src/sbin/newfs_msdos/newfs_msdos.8 cvs rdiff -u -r1.43 -r1.44 src/sbin/newfs_msdos/newfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/mkfs_msdos.c diff -u src/sbin/newfs_msdos/mkfs_msdos.c:1.10 src/sbin/newfs_msdos/mkfs_msdos.c:1.11 --- src/sbin/newfs_msdos/mkfs_msdos.c:1.10 Sun Apr 3 07:00:13 2016 +++ src/sbin/newfs_msdos/mkfs_msdos.c Thu Feb 16 13:49:31 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.c,v 1.10 2016/04/03 11:00:13 mlelstv Exp $ */ +/* $NetBSD: mkfs_msdos.c,v 1.11 2017/02/16 18:49:31 christos Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -37,7 +37,7 @@ static const char rcsid[] = "$FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $"; #else -__RCSID("$NetBSD: mkfs_msdos.c,v 1.10 2016/04/03 11:00:13 mlelstv Exp $"); +__RCSID("$NetBSD: mkfs_msdos.c,v 1.11 2017/02/16 18:49:31 christos Exp $"); #endif #endif /* not lint */ @@ -621,9 +621,15 @@ mkfs_msdos(const char *fname, const char printf("MBR type: %d\n", ch); print_bpb(); if (!o.no_create) { - gettimeofday(, NULL); - now = tv.tv_sec; - tm = localtime(); + if (o.timestamp) { + tv.tv_sec = now = o.timestamp; + tv.tv_usec = 0; + tm = gmtime(); + } else { + gettimeofday(, NULL); + now = tv.tv_sec; + tm = localtime(); + } if (!(img = malloc(bpb.bps))) err(1, NULL); dir = bpb.res + (bpb.spf ? bpb.spf : bpb.bspf) * bpb.nft; Index: src/sbin/newfs_msdos/mkfs_msdos.h diff -u src/sbin/newfs_msdos/mkfs_msdos.h:1.3 src/sbin/newfs_msdos/mkfs_msdos.h:1.4 --- src/sbin/newfs_msdos/mkfs_msdos.h:1.3 Fri Oct 16 13:38:17 2015 +++ src/sbin/newfs_msdos/mkfs_msdos.h Thu Feb 16 13:49:31 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.h,v 1.3 2015/10/16 17:38:17 christos Exp $ */ +/* $NetBSD: mkfs_msdos.h,v 1.4 2017/02/16 18:49:31 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -60,6 +60,7 @@ struct msdos_options { #define AOPT(_opt, _type, _name, _min, _desc) _type _name; ALLOPTS #undef AOPT + time_t timestamp; uint32_t volume_id_set:1; uint32_t media_descriptor_set:1; uint32_t hidden_sectors_set:1; Index: src/sbin/newfs_msdos/newfs_msdos.8 diff -u src/sbin/newfs_msdos/newfs_msdos.8:1.21 src/sbin/newfs_msdos/newfs_msdos.8:1.22 --- src/sbin/newfs_msdos/newfs_msdos.8:1.21 Mon Sep 12 01:09:39 2016 +++ src/sbin/newfs_msdos/newfs_msdos.8 Thu Feb 16 13:49:31 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: newfs_msdos.8,v 1.21 2016/09/12 05:09:39 sevan Exp $ +.\" $NetBSD: newfs_msdos.8,v 1.22 2017/02/16 18:49:31 christos Exp $ .\" .\" Copyright (c) 1998 Robert Nordier .\" All rights reserved. @@ -27,7 +27,7 @@ .\" .\" From: $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.8,v 1.13 2001/08/14 10:01:48 ru Exp $ .\" -.Dd September 12, 2016 +.Dd February 16, 2017 .Dt NEWFS_MSDOS 8 .Os .Sh NAME @@ -57,6 +57,7 @@ .Op Fl o Ar hidden .Op Fl r Ar reserved .Op Fl s Ar total +.Op Fl T Ar timestamp .Op Fl u Ar track-size .Ar special .Op Ar disktype @@ -147,6 +148,13 @@ Number of hidden sectors. Number of reserved sectors. .It Fl s Ar total File system size. +.It Fl T At timestamp +Specify a timestamp to be used for filesystem creation so that +it can be consistent for reproducible builds. +The timestamp can be a pathname, where the timestamps are derived from +that file, a parseable date for parsedate(3) (this option is not +yet available in the tools build), or an integer value interpreted +as the number of seconds from the Epoch. .It Fl u Ar track-size Number of sectors per track. .El Index: src/sbin/newfs_msdos/newfs_msdos.c diff -u src/sbin/newfs_msdos/newfs_msdos.c:1.43 src/sbin/newfs_msdos/newfs_msdos.c:1.44 --- src/sbin/newfs_msdos/newfs_msdos.c:1.43 Thu Apr 23 09:27:14 2015 +++ src/sbin/newfs_msdos/newfs_msdos.c Thu Feb 16 13:49:31 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: newfs_msdos.c,v 1.43 2015/04/23 13:27:14 abs Exp $ */ +/* $NetBSD: newfs_msdos.c,v 1.44 2017/02/16 18:49:31 christos Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -33,11 +33,12 @@ static const char rcsid[] = "$FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $"; #else -__RCSID("$NetBSD: newfs_msdos.c,v 1.43 2015/04/23 13:27:14 abs Exp $"); +__RCSID("$NetBSD: newfs_msdos.c,v 1.44 2017/02/16 18:49:31 christos Exp $"); #endif #endif /* not lint */ #include +#include #include #include #include @@ -45,6 +46,7 @@ __RCSID("$NetBSD: newfs_msdos.c,v 1.43 2 #include #include
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: sevan Date: Mon Sep 12 05:09:39 UTC 2016 Modified Files: src/sbin/newfs_msdos: newfs_msdos.8 Log Message: Note the origin of the newfs_msdos command from FreeBSD 3.0. Replace contraction. s/filesystem/file system/ Bump date. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sbin/newfs_msdos/newfs_msdos.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/newfs_msdos.8 diff -u src/sbin/newfs_msdos/newfs_msdos.8:1.20 src/sbin/newfs_msdos/newfs_msdos.8:1.21 --- src/sbin/newfs_msdos/newfs_msdos.8:1.20 Thu Apr 24 23:49:40 2014 +++ src/sbin/newfs_msdos/newfs_msdos.8 Mon Sep 12 05:09:39 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: newfs_msdos.8,v 1.20 2014/04/24 23:49:40 christos Exp $ +.\" $NetBSD: newfs_msdos.8,v 1.21 2016/09/12 05:09:39 sevan Exp $ .\" .\" Copyright (c) 1998 Robert Nordier .\" All rights reserved. @@ -27,7 +27,7 @@ .\" .\" From: $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.8,v 1.13 2001/08/14 10:01:48 ru Exp $ .\" -.Dd April 24, 2014 +.Dd September 12, 2016 .Dt NEWFS_MSDOS 8 .Os .Sh NAME @@ -74,9 +74,9 @@ to determine geometry, if required. The options are as follow: .Bl -tag -width indent .It Fl N -Don't create a file system: just print out parameters. +Do not create a file system: just print out parameters. .It Fl @ Ar offset -Build the filesystem at the specified offset in bytes in the device or file. +Build the file system at the specified offset in bytes in the device or file. A suffix s, k, m, g (lower or upper case) appended to the offset specifies that the number is in sectors, kilobytes, megabytes or gigabytes, respectively. @@ -120,7 +120,7 @@ Sectors per cluster. Acceptable values are powers of 2 in the range 1 through 128. If the block or cluster size are not specified, the code uses a cluster between 512 bytes and 32K depending on -the filesystem size. +the file system size. .It Fl e Ar dirents Number of root directory entries (FAT12 and FAT16 only). .It Fl f Ar format @@ -174,7 +174,7 @@ option. When the geometry is not available, it is assumed to be 63 sectors, 255 heads. The size is then rounded to become -a multiple of the track size and avoid complaints by some filesystem code. +a multiple of the track size and avoid complaints by some file system code. .Pp FAT file system parameters occupy a "Boot Sector BPB (BIOS Parameter Block)" in the first of the "reserved" sectors which precede the actual @@ -233,6 +233,10 @@ Exit status is 0 on success and 1 on err .Xr fdisk 8 , .Xr newfs 8 .Sh HISTORY +A +.Nm +utility appeared in +.Fx 3.0 . The .Nm command first appeared in
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: mlelstv Date: Sun Apr 3 11:00:13 UTC 2016 Modified Files: src/sbin/newfs_msdos: mkfs_msdos.c Log Message: Use the same defaults for cluster sizes as Windows. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sbin/newfs_msdos/mkfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/mkfs_msdos.c diff -u src/sbin/newfs_msdos/mkfs_msdos.c:1.9 src/sbin/newfs_msdos/mkfs_msdos.c:1.10 --- src/sbin/newfs_msdos/mkfs_msdos.c:1.9 Sun Jan 5 12:52:39 2014 +++ src/sbin/newfs_msdos/mkfs_msdos.c Sun Apr 3 11:00:13 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.c,v 1.9 2014/01/05 12:52:39 martin Exp $ */ +/* $NetBSD: mkfs_msdos.c,v 1.10 2016/04/03 11:00:13 mlelstv Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -37,7 +37,7 @@ static const char rcsid[] = "$FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $"; #else -__RCSID("$NetBSD: mkfs_msdos.c,v 1.9 2014/01/05 12:52:39 martin Exp $"); +__RCSID("$NetBSD: mkfs_msdos.c,v 1.10 2016/04/03 11:00:13 mlelstv Exp $"); #endif #endif /* not lint */ @@ -335,16 +335,26 @@ mkfs_msdos(const char *fname, const char return -1; bpb.bsec -= (o.offset / bpb.bps); if (bpb.spc == 0) { /* set defaults */ - if (bpb.bsec <= 6000) /* about 3MB -> 512 bytes */ - bpb.spc = 1; - else if (bpb.bsec <= (1<<17)) /* 64M -> 4k */ - bpb.spc = 8; - else if (bpb.bsec <= (1<<19)) /* 256M -> 8k */ - bpb.spc = 16; - else if (bpb.bsec <= (1<<21)) /* 1G -> 16k */ - bpb.spc = 32; - else - bpb.spc = 64; /* otherwise 32k */ + /* minimum cluster size */ + switch (o.fat_type) { + case 12: + bpb.spc = 1;/* use 512 bytes */ + x = 2; /* up to 2MB */ + break; + case 16: + bpb.spc = 1;/* use 512 bytes */ + x = 32; /* up to 32MB */ + break; + default: + bpb.spc = 8;/* use 4k */ + x = 8192; /* up to 8GB */ + break; + } + x1 = howmany(bpb.bsec, (1048576 / 512)); /* -> MB */ + while (bpb.spc < 128 && x < x1) { + x *= 2; + bpb.spc *= 2; + } } }
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: christos Date: Fri Oct 16 17:38:17 UTC 2015 Modified Files: src/sbin/newfs_msdos: mkfs_msdos.h Log Message: remove advertising clause. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sbin/newfs_msdos/mkfs_msdos.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/mkfs_msdos.h diff -u src/sbin/newfs_msdos/mkfs_msdos.h:1.2 src/sbin/newfs_msdos/mkfs_msdos.h:1.3 --- src/sbin/newfs_msdos/mkfs_msdos.h:1.2 Wed Jan 23 10:29:15 2013 +++ src/sbin/newfs_msdos/mkfs_msdos.h Fri Oct 16 13:38:17 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.h,v 1.2 2013/01/23 15:29:15 christos Exp $ */ +/* $NetBSD: mkfs_msdos.h,v 1.3 2015/10/16 17:38:17 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -15,9 +15,6 @@ * 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. - * 3. Neither the name of The NetBSD Foundation nor the names of its - *contributors may be used to endorse or promote products derived - *from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: abs Date: Thu Apr 23 13:27:14 UTC 2015 Modified Files: src/sbin/newfs_msdos: newfs_msdos.c Log Message: newfs_msdos allowed suffixes such as 'k', 'm' for some parameters, but amusingly this did not include Block size, or Sectors per cluster. Allow for all numeric parameters (If I want to specify the number of drive heads as '1K', then why not?) To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sbin/newfs_msdos/newfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/newfs_msdos.c diff -u src/sbin/newfs_msdos/newfs_msdos.c:1.42 src/sbin/newfs_msdos/newfs_msdos.c:1.43 --- src/sbin/newfs_msdos/newfs_msdos.c:1.42 Wed Jan 23 15:29:15 2013 +++ src/sbin/newfs_msdos/newfs_msdos.c Thu Apr 23 13:27:14 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: newfs_msdos.c,v 1.42 2013/01/23 15:29:15 christos Exp $ */ +/* $NetBSD: newfs_msdos.c,v 1.43 2015/04/23 13:27:14 abs Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -33,7 +33,7 @@ static const char rcsid[] = $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $; #else -__RCSID($NetBSD: newfs_msdos.c,v 1.42 2013/01/23 15:29:15 christos Exp $); +__RCSID($NetBSD: newfs_msdos.c,v 1.43 2015/04/23 13:27:14 abs Exp $); #endif #endif /* not lint */ @@ -168,14 +168,13 @@ main(int argc, char *argv[]) static u_int argtou(const char *arg, u_int lo, u_int hi, const char *msg) { -char *s; -u_long x; +off_t x; errno = 0; -x = strtoul(arg, s, 0); -if (errno || !*arg || *s || x lo || x hi) +x = argtooff(arg, msg); +if (x lo || x hi) errx(1, %s: bad %s, arg, msg); -return x; +return (u_int)x; } /*
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: martin Date: Sun Jan 5 12:52:39 UTC 2014 Modified Files: src/sbin/newfs_msdos: mkfs_msdos.c Log Message: PR bin/46743: mark the next free cluster value in the file system info block as unitialized. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sbin/newfs_msdos/mkfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/mkfs_msdos.c diff -u src/sbin/newfs_msdos/mkfs_msdos.c:1.8 src/sbin/newfs_msdos/mkfs_msdos.c:1.9 --- src/sbin/newfs_msdos/mkfs_msdos.c:1.8 Sat Oct 19 01:09:59 2013 +++ src/sbin/newfs_msdos/mkfs_msdos.c Sun Jan 5 12:52:39 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.c,v 1.8 2013/10/19 01:09:59 christos Exp $ */ +/* $NetBSD: mkfs_msdos.c,v 1.9 2014/01/05 12:52:39 martin Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -37,7 +37,7 @@ static const char rcsid[] = $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $; #else -__RCSID($NetBSD: mkfs_msdos.c,v 1.8 2013/10/19 01:09:59 christos Exp $); +__RCSID($NetBSD: mkfs_msdos.c,v 1.9 2014/01/05 12:52:39 martin Exp $); #endif #endif /* not lint */ @@ -709,7 +709,7 @@ mkfs_msdos(const char *fname, const char mk4(img, 0x41615252); mk4(img + MINBPS - 28, 0x61417272); mk4(img + MINBPS - 24, 0x); - mk4(img + MINBPS - 20, bpb.rdcl); + mk4(img + MINBPS - 20, 0x); mk2(img + MINBPS - 2, DOSMAGIC); } else if (lsn = bpb.res lsn dir !((lsn - bpb.res) %
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: christos Date: Sun Feb 3 03:21:42 UTC 2013 Modified Files: src/sbin/newfs_msdos: mkfs_msdos.c Log Message: don't truncate the file if an offset is given. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sbin/newfs_msdos/mkfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/mkfs_msdos.c diff -u src/sbin/newfs_msdos/mkfs_msdos.c:1.6 src/sbin/newfs_msdos/mkfs_msdos.c:1.7 --- src/sbin/newfs_msdos/mkfs_msdos.c:1.6 Sun Jan 27 16:56:26 2013 +++ src/sbin/newfs_msdos/mkfs_msdos.c Sat Feb 2 22:21:42 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.c,v 1.6 2013/01/27 21:56:26 christos Exp $ */ +/* $NetBSD: mkfs_msdos.c,v 1.7 2013/02/03 03:21:42 christos Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -37,7 +37,7 @@ static const char rcsid[] = $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $; #else -__RCSID($NetBSD: mkfs_msdos.c,v 1.6 2013/01/27 21:56:26 christos Exp $); +__RCSID($NetBSD: mkfs_msdos.c,v 1.7 2013/02/03 03:21:42 christos Exp $); #endif #endif /* not lint */ @@ -263,6 +263,7 @@ mkfs_msdos(const char *fname, const char u_int bss, rds, cls, dir, lsn, x, x1, x2; int ch, fd, fd1; struct msdos_options o = *op; +int oflags = O_RDWR | O_CREAT; if (o.block_size o.sectors_per_cluster) { warnx(Cannot specify both block size and sectors per cluster); @@ -278,7 +279,9 @@ mkfs_msdos(const char *fname, const char warnx(create (-C) is incompatible with -N); return -1; } - fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, 0644); + if (o.offset == 0) + oflags |= O_TRUNC; + fd = open(fname, oflags, 0644); if (fd == -1) { warnx(failed to create %s, fname); return -1;
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: christos Date: Sun Jan 27 21:56:27 UTC 2013 Modified Files: src/sbin/newfs_msdos: mkfs_msdos.c Log Message: nbtool_config.h undefines _NETBSD_SOURCE, and that makes sys/types.h not define cpuid_t, which makes sys/mount.h unincludable. Although this is a bug in the build system, it is simpler to fix it here. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sbin/newfs_msdos/mkfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/mkfs_msdos.c diff -u src/sbin/newfs_msdos/mkfs_msdos.c:1.5 src/sbin/newfs_msdos/mkfs_msdos.c:1.6 --- src/sbin/newfs_msdos/mkfs_msdos.c:1.5 Thu Jan 24 14:24:56 2013 +++ src/sbin/newfs_msdos/mkfs_msdos.c Sun Jan 27 16:56:26 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.c,v 1.5 2013/01/24 19:24:56 christos Exp $ */ +/* $NetBSD: mkfs_msdos.c,v 1.6 2013/01/27 21:56:26 christos Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -37,16 +37,16 @@ static const char rcsid[] = $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $; #else -__RCSID($NetBSD: mkfs_msdos.c,v 1.5 2013/01/24 19:24:56 christos Exp $); +__RCSID($NetBSD: mkfs_msdos.c,v 1.6 2013/01/27 21:56:26 christos Exp $); #endif #endif /* not lint */ #include sys/types.h #include sys/param.h -#include sys/mount.h #include sys/stat.h #include sys/time.h #ifndef MAKEFS +#include sys/mount.h #include sys/disk.h #endif
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: christos Date: Thu Jan 24 19:24:57 UTC 2013 Modified Files: src/sbin/newfs_msdos: mkfs_msdos.c Log Message: toolify To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sbin/newfs_msdos/mkfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/mkfs_msdos.c diff -u src/sbin/newfs_msdos/mkfs_msdos.c:1.4 src/sbin/newfs_msdos/mkfs_msdos.c:1.5 --- src/sbin/newfs_msdos/mkfs_msdos.c:1.4 Wed Jan 23 19:10:09 2013 +++ src/sbin/newfs_msdos/mkfs_msdos.c Thu Jan 24 14:24:56 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.c,v 1.4 2013/01/24 00:10:09 christos Exp $ */ +/* $NetBSD: mkfs_msdos.c,v 1.5 2013/01/24 19:24:56 christos Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -27,13 +27,17 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_NBTOOL_CONFIG_H +#include nbtool_config.h +#endif + #include sys/cdefs.h #ifndef lint #if 0 static const char rcsid[] = $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $; #else -__RCSID($NetBSD: mkfs_msdos.c,v 1.4 2013/01/24 00:10:09 christos Exp $); +__RCSID($NetBSD: mkfs_msdos.c,v 1.5 2013/01/24 19:24:56 christos Exp $); #endif #endif /* not lint */ @@ -42,7 +46,9 @@ __RCSID($NetBSD: mkfs_msdos.c,v 1.4 201 #include sys/mount.h #include sys/stat.h #include sys/time.h +#ifndef MAKEFS #include sys/disk.h +#endif #include ctype.h #include err.h @@ -59,7 +65,9 @@ __RCSID($NetBSD: mkfs_msdos.c,v 1.4 201 #include util.h #include disktab.h +#ifndef MAKEFS #include partutil.h +#endif #include mkfs_msdos.h #define MAXU16 0x /* maximum unsigned 16-bit quantity */ @@ -223,7 +231,9 @@ static u_int8_t bootcode[] = { static int got_siginfo = 0; /* received a SIGINFO */ +#ifndef MAKEFS static int check_mounted(const char *, mode_t); +#endif static int getstdfmt(const char *, struct bpb *); static int getbpbinfo(int, const char *, const char *, int, struct bpb *, int); static void print_bpb(struct bpb *); @@ -284,9 +294,11 @@ mkfs_msdos(const char *fname, const char warn(%s, fname); return -1; } +#ifndef MAKEFS if (!o.no_create) if (check_mounted(fname, sb.st_mode) == -1) return -1; +#endif if (!S_ISCHR(sb.st_mode) !o.create_size) { warnx(warning, %s is not a character device, fname); return -1; @@ -603,7 +615,9 @@ mkfs_msdos(const char *fname, const char if (!(img = malloc(bpb.bps))) err(1, NULL); dir = bpb.res + (bpb.spf ? bpb.spf : bpb.bspf) * bpb.nft; +#ifdef SIGINFO signal(SIGINFO, infohandler); +#endif for (lsn = 0; lsn dir + (o.fat_type == 32 ? bpb.spc : rds); lsn++) { if (got_siginfo) { fprintf(stderr,%s: writing sector %u of %u (%u%%)\n, @@ -727,6 +741,7 @@ mkfs_msdos(const char *fname, const char return 0; } +#ifndef MAKEFS /* * return -1 with error if file system is mounted. */ @@ -759,6 +774,7 @@ check_mounted(const char *fname, mode_t } return 0; } +#endif /* * Get a standard format. @@ -785,8 +801,6 @@ static int getbpbinfo(int fd, const char *fname, const char *dtype, int iflag, struct bpb *bpb, int create) { -struct disk_geom geo; -struct dkwedge_info dkw; const char *s1, *s2; int part; @@ -811,11 +825,22 @@ getbpbinfo(int fd, const char *fname, co #endif if (((part != -1) ((!iflag part != -1) || !bpb-bsec)) || !bpb-bps || !bpb-spt || !bpb-hds) { - if (create + u_int sector_size; + u_int nsectors; + u_int ntracks; + u_int size; #ifndef MAKEFS - || getdiskinfo(fname, fd, NULL, geo, dkw) == -1 + struct disk_geom geo; + struct dkwedge_info dkw; + + if (!create getdiskinfo(fname, fd, NULL, geo, dkw) != -1) { + sector_size = geo.dg_secsize = 512; + nsectors = geo.dg_nsectors = 63; + ntracks = geo.dg_ntracks = 255; + size = dkw.dkw_size; + } else #endif - ) { + { struct stat st; if (fstat(fd, st) == -1) { @@ -823,37 +848,37 @@ getbpbinfo(int fd, const char *fname, co return -1; } /* create a fake geometry for a file image */ - geo.dg_secsize = 512; - geo.dg_nsectors = 63; - geo.dg_ntracks = 255; - dkw.dkw_size = st.st_size / geo.dg_secsize; + sector_size = 512; + nsectors = 63; + ntracks = 255; + size = st.st_size / sector_size; } if (!bpb-bps) { - if (ckgeom(fname, geo.dg_secsize, bytes/sector) == -1) + if (ckgeom(fname, sector_size, bytes/sector) == -1) return -1; - bpb-bps = geo.dg_secsize; + bpb-bps = sector_size; } - if (geo.dg_nsectors 63) { + if (nsectors 63) { /* * The kernel doesn't accept BPB with spt 63. * (see sys/fs/msdosfs/msdosfs_vfsops.c:msdosfs_mountfs()) * If values taken from disklabel don't match these * restrictions, use popular BIOS default values instead. */ - geo.dg_nsectors = 63; + nsectors = 63; } if (!bpb-spt) { - if
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: christos Date: Wed Jan 23 15:29:15 UTC 2013 Modified Files: src/sbin/newfs_msdos: mkfs_msdos.c mkfs_msdos.h newfs_msdos.c Log Message: fix regressions after split. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sbin/newfs_msdos/mkfs_msdos.c \ src/sbin/newfs_msdos/mkfs_msdos.h cvs rdiff -u -r1.41 -r1.42 src/sbin/newfs_msdos/newfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/mkfs_msdos.c diff -u src/sbin/newfs_msdos/mkfs_msdos.c:1.1 src/sbin/newfs_msdos/mkfs_msdos.c:1.2 --- src/sbin/newfs_msdos/mkfs_msdos.c:1.1 Mon Jan 21 15:28:38 2013 +++ src/sbin/newfs_msdos/mkfs_msdos.c Wed Jan 23 10:29:15 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.c,v 1.1 2013/01/21 20:28:38 christos Exp $ */ +/* $NetBSD: mkfs_msdos.c,v 1.2 2013/01/23 15:29:15 christos Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -33,7 +33,7 @@ static const char rcsid[] = $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $; #else -__RCSID($NetBSD: mkfs_msdos.c,v 1.1 2013/01/21 20:28:38 christos Exp $); +__RCSID($NetBSD: mkfs_msdos.c,v 1.2 2013/01/23 15:29:15 christos Exp $); #endif #endif /* not lint */ @@ -258,7 +258,7 @@ mkfs_msdos(const char *fname, const char warnx(Cannot specify both block size and sectors per cluster); return -1; } -if (strlen(o.OEM_string) 8) { +if (o.OEM_string strlen(o.OEM_string) 8) { warnx(%s: bad OEM string, o.OEM_string); return -1; } @@ -280,9 +280,10 @@ mkfs_msdos(const char *fname, const char } pos = lseek(fd, 0, SEEK_SET); } else if ((fd = open(fname, o.no_create ? O_RDONLY : O_RDWR)) == -1 || - fstat(fd, sb)) + fstat(fd, sb)) { warn(%s, fname); return -1; +} if (!o.no_create) if (check_mounted(fname, sb.st_mode) == -1) return -1; @@ -333,7 +334,7 @@ mkfs_msdos(const char *fname, const char } } -if (!oklabel(o.volume_label)) { +if (o.volume_label !oklabel(o.volume_label)) { warnx(%s: bad volume label, o.volume_label); return -1; } @@ -385,12 +386,12 @@ mkfs_msdos(const char *fname, const char } if (o.block_size bpb.bps) { warnx(block size (%u) is too small; minimum is %u, - o.block_size, bpb.bps); + o.block_size, bpb.bps); return -1; } if (o.block_size bpb.bps * MAXSPC) { warnx(block size (%u) is too large; maximum is %u, - o.block_size, bpb.bps * MAXSPC); + o.block_size, bpb.bps * MAXSPC); return -1; } bpb.spc = o.block_size / bpb.bps; @@ -435,8 +436,10 @@ mkfs_msdos(const char *fname, const char bname = o.bootstrap; if (!strchr(bname, '/')) { snprintf(buf, sizeof(buf), /boot/%s, bname); - if (!(bname = strdup(buf))) - err(1, NULL); + if (!(bname = strdup(buf))) { + warn(NULL); + return -1; + } } if ((fd1 = open(bname, O_RDONLY)) == -1 || fstat(fd1, sb)) { warn(%s, bname); Index: src/sbin/newfs_msdos/mkfs_msdos.h diff -u src/sbin/newfs_msdos/mkfs_msdos.h:1.1 src/sbin/newfs_msdos/mkfs_msdos.h:1.2 --- src/sbin/newfs_msdos/mkfs_msdos.h:1.1 Mon Jan 21 15:28:38 2013 +++ src/sbin/newfs_msdos/mkfs_msdos.h Wed Jan 23 10:29:15 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.h,v 1.1 2013/01/21 20:28:38 christos Exp $ */ +/* $NetBSD: mkfs_msdos.h,v 1.2 2013/01/23 15:29:15 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -35,32 +35,32 @@ #include sys/types.h #include stdbool.h #define ALLOPTS \ -AOPT('@', off_t, offset, Offset in device) \ -AOPT('B', char *, bootstrap, Bootstrap file) \ -AOPT('C', off_t, create_size, Create file) \ -AOPT('F', uint8_t, fat_type, FAT type (12, 16, or 32)) \ -AOPT('I', uint32_t, volume_id, Volume ID) \ -AOPT('L', char *, volume_label, Volume Label) \ -AOPT('N', bool, no_create, Don't create filesystem, print params only) \ -AOPT('O', char *, OEM_string, OEM string) \ -AOPT('S', uint16_t, bytes_per_sector, Bytes per sector) \ -AOPT('a', uint32_t, sectors_per_fat, Sectors per FAT) \ -AOPT('b', uint32_t, block_size, Block size) \ -AOPT('c', uint8_t, sectors_per_cluster, Sectors per cluster) \ -AOPT('e', uint16_t, directory_entries, Directory entries) \ -AOPT('f', char *, floppy, Standard format floppies (160,180,320,360,640,720,1200,1232,1440,2880)) \ -AOPT('h', uint16_t, drive_heads, Drive heads) \ -AOPT('i', uint16_t, info_sector, Info sector) \ -AOPT('k', uint16_t, backup_sector, Backup sector) \ -AOPT('m', uint8_t, media_descriptor, Media descriptor) \ -AOPT('n', uint8_t, num_FAT, Number of FATs) \ -AOPT('o', uint32_t, hidden_sectors, Hidden sectors) \ -AOPT('r', uint16_t, reserved_sectors, Reserved sectors) \ -AOPT('s', uint32_t, size, File System size) \ -AOPT('u', uint16_t, sectors_per_track, Sectors per track) +AOPT('@', off_t, offset, 0, Offset in device) \ +AOPT('B', char *, bootstrap, -1, Bootstrap file) \ +AOPT('C', off_t, create_size, 0, Create
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: christos Date: Wed Jan 23 22:48:18 UTC 2013 Modified Files: src/sbin/newfs_msdos: mkfs_msdos.c Log Message: We don't need getdiskinfo() for makefs() since we always deal with an image. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sbin/newfs_msdos/mkfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/mkfs_msdos.c diff -u src/sbin/newfs_msdos/mkfs_msdos.c:1.2 src/sbin/newfs_msdos/mkfs_msdos.c:1.3 --- src/sbin/newfs_msdos/mkfs_msdos.c:1.2 Wed Jan 23 10:29:15 2013 +++ src/sbin/newfs_msdos/mkfs_msdos.c Wed Jan 23 17:48:18 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.c,v 1.2 2013/01/23 15:29:15 christos Exp $ */ +/* $NetBSD: mkfs_msdos.c,v 1.3 2013/01/23 22:48:18 christos Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -33,7 +33,7 @@ static const char rcsid[] = $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $; #else -__RCSID($NetBSD: mkfs_msdos.c,v 1.2 2013/01/23 15:29:15 christos Exp $); +__RCSID($NetBSD: mkfs_msdos.c,v 1.3 2013/01/23 22:48:18 christos Exp $); #endif #endif /* not lint */ @@ -804,12 +804,17 @@ getbpbinfo(int fd, const char *fname, co maxpartitions = getmaxpartitions(); +// XXX: Does not work with wedges if (s2 *s2 = 'a' *s2 = 'a' + maxpartitions - 1) { part = *s2++ - 'a'; } if (((part != -1) ((!iflag part != -1) || !bpb-bsec)) || !bpb-bps || !bpb-spt || !bpb-hds) { - if (create || getdiskinfo(fname, fd, NULL, geo, dkw) == -1) { + if (create +#ifndef MAKEFS + || getdiskinfo(fname, fd, NULL, geo, dkw) == -1 +#endif + ) { struct stat st; if (fstat(fd, st) == -1) {
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: christos Date: Thu Jan 24 00:10:09 UTC 2013 Modified Files: src/sbin/newfs_msdos: mkfs_msdos.c Log Message: don't do the partition dance for makefs; we have no real diskdon't do the partition dance for makefs; we have no real diskdon't do the partition dance for makefs; we have no real disk To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sbin/newfs_msdos/mkfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/mkfs_msdos.c diff -u src/sbin/newfs_msdos/mkfs_msdos.c:1.3 src/sbin/newfs_msdos/mkfs_msdos.c:1.4 --- src/sbin/newfs_msdos/mkfs_msdos.c:1.3 Wed Jan 23 17:48:18 2013 +++ src/sbin/newfs_msdos/mkfs_msdos.c Wed Jan 23 19:10:09 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs_msdos.c,v 1.3 2013/01/23 22:48:18 christos Exp $ */ +/* $NetBSD: mkfs_msdos.c,v 1.4 2013/01/24 00:10:09 christos Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -33,7 +33,7 @@ static const char rcsid[] = $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $; #else -__RCSID($NetBSD: mkfs_msdos.c,v 1.3 2013/01/23 22:48:18 christos Exp $); +__RCSID($NetBSD: mkfs_msdos.c,v 1.4 2013/01/24 00:10:09 christos Exp $); #endif #endif /* not lint */ @@ -789,7 +789,6 @@ getbpbinfo(int fd, const char *fname, co struct dkwedge_info dkw; const char *s1, *s2; int part; -int maxpartitions; part = -1; s1 = fname; @@ -802,12 +801,14 @@ getbpbinfo(int fd, const char *fname, co while (isdigit((unsigned char)*++s2)); s1 = s2; -maxpartitions = getmaxpartitions(); +#ifndef MAKEFS +int maxpartitions = getmaxpartitions(); // XXX: Does not work with wedges if (s2 *s2 = 'a' *s2 = 'a' + maxpartitions - 1) { part = *s2++ - 'a'; } +#endif if (((part != -1) ((!iflag part != -1) || !bpb-bsec)) || !bpb-bps || !bpb-spt || !bpb-hds) { if (create
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: jakllsch Date: Sat Dec 15 04:34:36 UTC 2012 Modified Files: src/sbin/newfs_msdos: newfs_msdos.c Log Message: There are two problems with insisting the FAT file system size be a multiple of track-size units: 2) the FAT metadata areas may not be a multiple of a track, 1) the partition may not be track-aligned to begin with, 0) what's a track? is it something a robot rover leaves on Mars? To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sbin/newfs_msdos/newfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/newfs_msdos.c diff -u src/sbin/newfs_msdos/newfs_msdos.c:1.39 src/sbin/newfs_msdos/newfs_msdos.c:1.40 --- src/sbin/newfs_msdos/newfs_msdos.c:1.39 Sun Nov 4 14:27:15 2012 +++ src/sbin/newfs_msdos/newfs_msdos.c Sat Dec 15 04:34:36 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: newfs_msdos.c,v 1.39 2012/11/04 14:27:15 jakllsch Exp $ */ +/* $NetBSD: newfs_msdos.c,v 1.40 2012/12/15 04:34:36 jakllsch Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -33,7 +33,7 @@ static const char rcsid[] = $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $; #else -__RCSID($NetBSD: newfs_msdos.c,v 1.39 2012/11/04 14:27:15 jakllsch Exp $); +__RCSID($NetBSD: newfs_msdos.c,v 1.40 2012/12/15 04:34:36 jakllsch Exp $); #endif #endif /* not lint */ @@ -409,15 +409,8 @@ main(int argc, char *argv[]) if (oflag) bpb.hid = opt_o; if (!(opt_f || (opt_h opt_u opt_S opt_s oflag))) { - off_t delta; getbpbinfo(fd, fname, dtype, oflag, bpb, opt_create != 0); bpb.bsec -= (opt_ofs / bpb.bps); - delta = bpb.bsec % bpb.spt; - if (delta != 0) { - warnx(trim %d sectors to adjust to a multiple of %d, - (int)delta, bpb.spt); - bpb.bsec -= delta; - } if (bpb.spc == 0) { /* set defaults */ if (bpb.bsec = 6000) /* about 3MB - 512 bytes */ bpb.spc = 1;
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: jakllsch Date: Sun Nov 4 14:27:16 UTC 2012 Modified Files: src/sbin/newfs_msdos: newfs_msdos.c Log Message: According to current file(1) magic definitions an unlabeled FAT is denoted with NO NAME rather than NO_NAME. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sbin/newfs_msdos/newfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/newfs_msdos.c diff -u src/sbin/newfs_msdos/newfs_msdos.c:1.38 src/sbin/newfs_msdos/newfs_msdos.c:1.39 --- src/sbin/newfs_msdos/newfs_msdos.c:1.38 Tue Jul 31 13:52:44 2012 +++ src/sbin/newfs_msdos/newfs_msdos.c Sun Nov 4 14:27:15 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: newfs_msdos.c,v 1.38 2012/07/31 13:52:44 jakllsch Exp $ */ +/* $NetBSD: newfs_msdos.c,v 1.39 2012/11/04 14:27:15 jakllsch Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -33,7 +33,7 @@ static const char rcsid[] = $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $; #else -__RCSID($NetBSD: newfs_msdos.c,v 1.38 2012/07/31 13:52:44 jakllsch Exp $); +__RCSID($NetBSD: newfs_msdos.c,v 1.39 2012/11/04 14:27:15 jakllsch Exp $); #endif #endif /* not lint */ @@ -699,7 +699,7 @@ main(int argc, char *argv[]) ((u_int)tm-tm_hour 8 | (u_int)tm-tm_min)); mk4(bsx-volid, x); - mklabel(bsx-label, opt_L ? opt_L : NO_NAME); + mklabel(bsx-label, opt_L ? opt_L : NO NAME); snprintf(buf, sizeof(buf), FAT%u, fat); setstr(bsx-type, buf, sizeof(bsx-type)); if (!opt_B) {
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: jakllsch Date: Tue Jul 31 13:52:45 UTC 2012 Modified Files: src/sbin/newfs_msdos: newfs_msdos.c Log Message: Use correct values for minimum and maximum cluster counts for the various FAT types. These values come from a publically-avaliable document of an infallible source that must not be named due to a violation of the document's license restrictions. This is justified by interoperability concerns. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sbin/newfs_msdos/newfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/newfs_msdos.c diff -u src/sbin/newfs_msdos/newfs_msdos.c:1.37 src/sbin/newfs_msdos/newfs_msdos.c:1.38 --- src/sbin/newfs_msdos/newfs_msdos.c:1.37 Wed Jul 4 18:35:58 2012 +++ src/sbin/newfs_msdos/newfs_msdos.c Tue Jul 31 13:52:44 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: newfs_msdos.c,v 1.37 2012/07/04 18:35:58 jakllsch Exp $ */ +/* $NetBSD: newfs_msdos.c,v 1.38 2012/07/31 13:52:44 jakllsch Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -33,7 +33,7 @@ static const char rcsid[] = $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $; #else -__RCSID($NetBSD: newfs_msdos.c,v 1.37 2012/07/04 18:35:58 jakllsch Exp $); +__RCSID($NetBSD: newfs_msdos.c,v 1.38 2012/07/31 13:52:44 jakllsch Exp $); #endif #endif /* not lint */ @@ -74,11 +74,11 @@ __RCSID($NetBSD: newfs_msdos.c,v 1.37 2 #define DEFRDE 512 /* default root directory entries */ #define RESFTE 2 /* reserved FAT entries */ #define MINCLS12 1 /* minimum FAT12 clusters */ -#define MINCLS16 0x1000 /* minimum FAT16 clusters */ -#define MINCLS32 2 /* minimum FAT32 clusters */ -#define MAXCLS12 0xfed /* maximum FAT12 clusters */ -#define MAXCLS16 0xfff5 /* maximum FAT16 clusters */ -#define MAXCLS32 0xff5 /* maximum FAT32 clusters */ +#define MINCLS16 0xff5 /* minimum FAT16 clusters */ +#define MINCLS32 0xfff5 /* minimum FAT32 clusters */ +#define MAXCLS12 0xff4 /* maximum FAT12 clusters */ +#define MAXCLS16 0xfff4 /* maximum FAT16 clusters */ +#define MAXCLS32 0xff4 /* maximum FAT32 clusters */ #define mincls(fat) ((fat) == 12 ? MINCLS12 : \ (fat) == 16 ? MINCLS16 : \
CVS commit: src/sbin/newfs_msdos
Module Name:src Committed By: lukem Date: Sat Apr 11 06:59:19 UTC 2009 Modified Files: src/sbin/newfs_msdos: newfs_msdos.c Log Message: fix sign-compare issues To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sbin/newfs_msdos/newfs_msdos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_msdos/newfs_msdos.c diff -u src/sbin/newfs_msdos/newfs_msdos.c:1.33 src/sbin/newfs_msdos/newfs_msdos.c:1.34 --- src/sbin/newfs_msdos/newfs_msdos.c:1.33 Sat Mar 28 21:34:33 2009 +++ src/sbin/newfs_msdos/newfs_msdos.c Sat Apr 11 06:59:18 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: newfs_msdos.c,v 1.33 2009/03/28 21:34:33 he Exp $ */ +/* $NetBSD: newfs_msdos.c,v 1.34 2009/04/11 06:59:18 lukem Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -33,7 +33,7 @@ static const char rcsid[] = $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $; #else -__RCSID($NetBSD: newfs_msdos.c,v 1.33 2009/03/28 21:34:33 he Exp $); +__RCSID($NetBSD: newfs_msdos.c,v 1.34 2009/04/11 06:59:18 lukem Exp $); #endif #endif /* not lint */ @@ -655,7 +655,7 @@ if (opt_B x bss) { if ((n = read(fd1, img, bpb.bps)) == -1) err(1, %s, bname); - if (n != bpb.bps) + if ((size_t)n != bpb.bps) errx(1, %s: can't read sector %u, bname, x); } else memset(img, 0, bpb.bps); @@ -743,7 +743,7 @@ } if ((n = write(fd, img, bpb.bps)) == -1) err(1, %s, fname); - if (n != bpb.bps) + if ((size_t)n != bpb.bps) errx(1, %s: can't write sector %u, fname, lsn); } }