History log of /freebsd-current/sbin/newfs_msdos/newfs_msdos.c
Revision Date Author Comments
# eba230af 25-Sep-2023 John Baldwin <jhb@FreeBSD.org>

Purge more stray embedded $FreeBSD$ strings

These do not use __FBSDID but instead use bare char arrays.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D41957


# 65f3be91 07-Jul-2023 Alfonso Gregory <gfunni234@gmail.com>

Mark usage function as __dead2 in programs where it does not return

In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# e54f2950 28-Jan-2020 Dimitry Andric <dim@FreeBSD.org>

Fix the following -Werror warning from clang 10.0.0 in newfs_msdos:

sbin/newfs_msdos/newfs_msdos.c:181:2: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
if (o.align) {
^
sbin/newfs_msdos/newfs_msdos.c:179:5: note: previous statement is here
if (argc < 1 || argc > 2)
^

MFC after: 3 days


# 2780a26b 07-Dec-2019 Xin LI <delphij@FreeBSD.org>

Fix a couple of minor issues with newfs_msdos:

- Do not unnecessarily strdup().
- Check return value of getdiskinfo(), if it failed, bail out.

Reviewed by: imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22729


# 7b9934a1 03-Dec-2019 Xin LI <delphij@FreeBSD.org>

Explicitly exit() instead of return in main().

MFC after: 2 weeks


# e453f016 03-Dec-2019 Xin LI <delphij@FreeBSD.org>

newfs_msdos: -A is incompatible with -r, not -o.

PR: 242314
Submitted by: Guy Yur <guyyur gmail com>
MFC after: 2 weeks


# 0531ab72 15-Jun-2018 Xin LI <delphij@FreeBSD.org>

Added option to cluster-align the start of the root directory.

Obtained from: Android
Obtained from: https://android.googlesource.com/platform/system/core/+/052f27562154d175267999106bd6bf18fc8c363e
Obtained from: https://android.googlesource.com/platform/system/core/+/8218b6aae9cd4a19fa074a8a8203fe9275b35447
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D15672


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# 28ef05f7 16-May-2017 Ed Maste <emaste@FreeBSD.org>

newfs_msdos: add -T (timestamp) option for reproducible builds

This includes some whitespace and minor bug fixes relative to NetBSD,
which will be submitted upstream at the conclusion of the makefs
msdos update.

NetBSD revs:
mkfs_msdos.c 1.11
mkfs_msdos.h 1.4
newfs_msdos.8 1.22
newfs_msdos.c 1.44

Submitted by: Siva Mahadevan <smahadevan@freebsdfoundation.org>
Reviewed by: emaste
Obtained from: NetBSD
Sponsored by: The FreeBSD Foundation


# 64953dd1 27-Nov-2015 Ed Maste <emaste@FreeBSD.org>

Use netbsd usage() implementation in newfs_msdos

In r289629 newfs_msdos option descriptions are available in
mkfs_msdos.h.

Obtained from: NetBSD


# 99f4158c 23-Nov-2015 Ed Maste <emaste@FreeBSD.org>

newfs_msdos: rework error handling for eventual use in makefs

Return -1 on errors from mkfs_msdos() instead of err()/errx(), to
allow different consumers to handle errors as appropriate.

Obtained from: NetBSD
Sponsored by: The FreeBSD Foundation


# 041b03da 15-Oct-2015 Ed Maste <emaste@FreeBSD.org>

newfs_msdos: move mkfs_msdos to separate file for later use in makefs

Sponsored by: The FreeBSD Foundation


# 4d45a673 15-Oct-2015 Ed Maste <emaste@FreeBSD.org>

newfs_msdos: rework option parsing to match NetBSD

NetBSD split newfs_msdos in two so that they can reuse the file system
creation part in makefs. This change is a step on the path of bringing
that support to FreeBSD.

Reviewed by: kib, pfg
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3905


# a91275f7 05-Jan-2015 Warner Losh <imp@FreeBSD.org>

Remove old ioctl use and support, once and for all.


# 69905bde 13-Aug-2014 Pedro F. Giffuni <pfg@FreeBSD.org>

Use "NO NAME" as the default unnamed label.

Microsoft recommends avoiding the use of spaces in the
string structures for FAT. Unfortunately they do just
that by default in the case of unlabeled filesystems.

Follow the default MS behavior to avoid confusion in
common tools like file(1). This was actually the
default behavior before r203868.

Obtained from: NetBSD (CVS rev. 1.39)
MFC after: 3 days


# b251c17a 30-Apr-2014 Pedro F. Giffuni <pfg@FreeBSD.org>

Small cleanup: mostly whitespace vs. tabs.


# 6bb4cf4f 24-Apr-2014 Ed Maste <emaste@FreeBSD.org>

Correct min/max cluster counts for FAT12/16/32

FAT12 1..4084
FAT16 4085..65524
FAT32 65525..

This is required for interoperability with other FAT implementations,
and in particular UEFI.

Obtained from: NetBSD
Sponsored by: The FreeBSD Foundation


# a0161728 06-Sep-2013 Pedro F. Giffuni <pfg@FreeBSD.org>

newfs_msdos: fix inaccurate comments.

The fields from deMTime and deMDate in the DOS directory entry
are actually the last-modified time/date.

According to some online documentation these are the only
timestamps available in FAT12/FAT16.

MFC after: 3 days


# f4f891a7 18-Jan-2013 Pedro F. Giffuni <pfg@FreeBSD.org>

newfs_msdos: cosmetical cleanups

- Simplify diagnostic messages.
- Adopt lowercase first letters to make the messages
more canonical.

PR: bin/175404
Submitted by: Christoph Mallon
Reviewed by: bde
MFC after: 3 days


# 1ac4aa74 20-Dec-2011 Pedro F. Giffuni <pfg@FreeBSD.org>

Many style fixes.
Remove C99 initializers: they don't help in this case.
Set errno to 0 before strtoll() (from NetBSD).

PR: 151850
Suggested by: bde
Approved by: jhb (Mentor)
MFC after: 2 weeks


# 658029e0 11-Nov-2011 Xin LI <delphij@FreeBSD.org>

Use __packed to prevent alignment from taking place, which otherwise may
change the on-disk format in an incompatible way. Without this change,
msdosfs created on FreeBSD/arm would not be mountable.

PR: bin/162486
Submitted by: Ian Lepore <freebsd damnhippie dyndns org>
Reported by: Mattia Rossi <mrossi at swin.edu.au>
MFC after: 3 days


# 20ddb079 12-Jul-2011 Andrey V. Elsukov <ae@FreeBSD.org>

Use NULL instead of 0 for third argument of sigaction(2).

Pointed by: kib
MFC after: 2 weeks


# 40be4bee 12-Jul-2011 Andrey V. Elsukov <ae@FreeBSD.org>

Add SIGINFO handler.

Reviewed by: kib
Obtained from: NetBSD (partly)
MFC after: 2 weeks


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 12ec42c8 02-May-2010 Konstantin Belousov <kib@FreeBSD.org>

MFC r203869:
Rename variables to match msdosfs headers.


# 89b93ff1 02-May-2010 Konstantin Belousov <kib@FreeBSD.org>

MFC r203868:
Some cleanups from NetBSD.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 2490c565 13-Feb-2010 Konstantin Belousov <kib@FreeBSD.org>

Rename variables to match msdosfs headers.

Submitted by: Pedro F. Giffuni <giffunip tutopia com>
Reviewed by: bde
MFC after: 2 weeks


# fb95e056 13-Feb-2010 Konstantin Belousov <kib@FreeBSD.org>

Some cleanups from NetBSD:
- C99 initializers.
- Change the default volume label from "NO NAME" to "NO_NAME".
- Set OEM String to "BSD4.4 " following the unnamed spacing convention
in that other OS that suggests "MSWIN4.1"
Also, David Naylor's changes for Clang, mostly changing the signess
of constants.

Submitted by: Pedro F. Giffuni <giffunip tutopia com>
Clang fixes by: David Naylor <naylor.b.david gmail com>
Reviewed by: bde (with some disagreement about Clang issues)
MFC after: 2 weeks


# 3c7bcffa 11-Apr-2009 Ed Schouten <ed@FreeBSD.org>

Do not prepend /dev/ when -C is used.

Submitted by: Christoph Mallon <christoph mallon gmx de>


# 36df607c 11-Apr-2009 Ed Schouten <ed@FreeBSD.org>

When using -C, do not warn when the file is not a character device, but warn when it is not a regular file.

Submitted by: Christoph Mallon <christoph mallon gmx de>


# f069c0af 11-Apr-2009 Ed Schouten <ed@FreeBSD.org>

Fix a bug in r185587.

fstat(fd, &sb) was not executed unconditionally anymore so sb was read
uninitialised when -C is used.

Submitted by: Christoph Mallon <christoph mallon gmx de>


# 18a06443 11-Apr-2009 Ed Schouten <ed@FreeBSD.org>

Use ftruncate() instead of lseek()+write()+lseek() to set the created
file (-C) to the requested size.

Submitted by: Christoph Mallon <christoph mallon gmx de>


# 20f96000 11-Apr-2009 Ed Schouten <ed@FreeBSD.org>

De-static local variables in main() (which is not recursive) and const-ify
others.

Submitted by: Christoph Mallon <christoph mallon gmx de>


# 101669c6 11-Apr-2009 Ed Schouten <ed@FreeBSD.org>

Show -@ and -C in usage, which were added in r185587.

Submitted by: Christoph Mallon <christoph mallon gmx de>


# b64e8d53 11-Apr-2009 Ed Schouten <ed@FreeBSD.org>

Clean up the usage() function to use a single fprintf().

Submitted by: Christoph Mallon <christoph mallon gmx de>


# d461b46d 27-Feb-2009 Andriy Gapon <avg@FreeBSD.org>

newfs_msdos: allow to work with media that doesn't have any CHS params

Either use parameters provided by user or make them up.
The code for faking CHS params is borrowed from disklabel code.
The logic for using user-provided and auto-guessed parameters is not
perfect, so to speak.

PR: bin/121182
Approved by: jhb (mentor)


# d3adc655 03-Dec-2008 Max Laier <mlaier@FreeBSD.org>

Fix build - cast off_t to (intmax_t) for printing.


# b87d1601 03-Dec-2008 Luigi Rizzo <luigi@FreeBSD.org>

Some useful operational extensions to newfs_msdos, especially
when preparing images for emulators or flash devices:

+ option '-C size' to create the underlying image file with given size.
Saves doing a 'dd' before, and especially it creates a sparse file

+ option '-@ offset' to build the FAT image at the specified offset
in the image file or device;

+ make the cluster size adaptive on the filesystem size.
Previously the default was 4k which is really unconvenient with
large media; now it goes from 512 bytes to 32k depending on
filesystem size (i still need to check whether it makes sense
to go further up, to 64k or above);

+ fix default geometry when not specified on the command line,
use 63 sectors/255 heads by default.
Also trim the size so it exactly a multiple of a track, to avoid
complaints in some filesystem code.

+ document all the above, plus some manual page clarifications.

MFC after: 4 weeks


# 045651ec 26-Nov-2008 Luigi Rizzo <luigi@FreeBSD.org>

Create a fake geometry (16 heads, 64 sectors) when dealing with
a plain file and a geometry is not explicitly supplied through
command line or disktab entry.

This way you can a FAT image on a file as simply as this:

newfs_msdos ./some/file

(right now you need a much longer command

newfs_msdos -h 32 -u 64 -S 512 -s $total_blocks -o 0 ./some/file

Will be merged after 7.1 and 6.4 are released.
See also the related PR which suggests a similar change.

PR: bin/121182
MFC after: 4 weeks


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 93c26a82 31-May-2007 Tom Rhodes <trhodes@FreeBSD.org>

The newfs_msdos utility does not store the boot signature in the
correct place on large sector disks. The boot signature should be at
offset 0x1fe in the BPB; newfs_msdos currently stores it 2 bytes from
the end of the sector.

Taken from: NetBSD


# d4b44279 17-Jan-2005 Xin LI <delphij@FreeBSD.org>

WARNS=6 cleanup:

- Initialize everything in the struct array, not only the mentioned
ones
- Unconditionally initialize hs to 0 to avoid repeatly doing so
- Cast to unsigned int when comparing to unsigned variables.


# 6abefb4f 16-Feb-2004 Tim J. Robbins <tjr@FreeBSD.org>

Remove unnecessary newlines from errx() arguments.


# d702a854 03-Nov-2002 Scott Long <scottl@FreeBSD.org>

Bring newfs_msdos into the GEOM world. Totally rewrite and simplify
getdiskinfo(). For the fixed-disk case, bpb->hid probably isn't
handled correctly, but I'm not sure if this is a serious problem since
the primary use of this program is to format floppy disks.

Reviewed by: phk


# a1c254d8 03-Oct-2002 Peter Wemm <peter@FreeBSD.org>

EFI GPT partitions use 'p' as a slice seperator. eg: da0p1 or da0p217.
(There is a theoretical limit of 16384 partitions)


# ce66ddb7 21-Aug-2002 Tom Rhodes <trhodes@FreeBSD.org>

s/filesystem/file system/g as discussed on -developers


# 3468b317 15-May-2002 Tom Rhodes <trhodes@FreeBSD.org>

more file system > filesystem


# eb2fc780 09-Oct-2000 Garrett Wollman <wollman@FreeBSD.org>

Don't depend on <sys/stat.h> bogusly including <sys/time.h> (and thereby
<time.h>).


# 5306a1ec 15-Aug-2000 Robert Nordier <rnordier@FreeBSD.org>

Remove redundant code left over on removal of /dev/rXXX handling
in r1.12.


# e3d24c1a 15-Aug-2000 Robert Nordier <rnordier@FreeBSD.org>

Partially revert r1.12, in which a warnx() if the device is not a
character device is changed to an errx(). This unnecessarily
compromises device independence.


# 7333848d 26-Jul-2000 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>

Fix the reporting of a raw device node.

Change a warnx to an errx since we should only attempt to use
this utility on a character device.

Approved by: green


# 71e93b39 14-Apr-2000 Warner Losh <imp@FreeBSD.org>

Better error message for a case that I hit.


# 4557555b 29-Mar-2000 KATO Takenori <kato@FreeBSD.org>

Added 640KB and 1232KB formats, which were standard MS-DOS formats of
2DD and 2HD disks in Japan.

Submitted by: Shigeharu TAKENO <shige@iee.niit.ac.jp>
Pointed out by: chi@bd.mbn.or.jp (Chiharu Shibata)


# 7f3dea24 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 9292be42 20-Jul-1999 Bill Fumerola <billf@FreeBSD.org>

Avoid ambigious if-else


# d26a815b 02-Jan-1999 Jordan K. Hubbard <jkh@FreeBSD.org>

Clean up some more residual /usr/mdec references. I left all the
extra rbootd/boot rom cruft pointing at /usr/mdec since it either
doesn't exist or doesn't work anyway, so who cares? :)


# 71d7142d 07-Dec-1998 Robert Nordier <rnordier@FreeBSD.org>

Use '#' flag in place of "0x" in format strings.


# b5bd7211 16-Oct-1998 Bruce Evans <bde@FreeBSD.org>

Don't assume that time_t is long.


# 5fc905fc 19-Jul-1998 Robert Nordier <rnordier@FreeBSD.org>

Minor consistency fixes.


# 4633bc16 15-Jul-1998 Robert Nordier <rnordier@FreeBSD.org>

Reverse charnier's changes to usage.


# f6f3d507 15-Jul-1998 Philippe Charnier <charnier@FreeBSD.org>

Correct use of .Nm. Remove unused #includes. Short usage() string, see man
page for details.


# dc9ef4d1 06-Jul-1998 Robert Nordier <rnordier@FreeBSD.org>

Add newfs_msdos: extensive newfs-style support for creating FAT12,
FAT16, and FAT32 file systems in all their various horriblenesses.

Approved-in-concept by: joerg