aboutsummaryrefslogtreecommitdiff
path: root/sbin/newfs_msdos
Commit message (Collapse)AuthorAgeFilesLines
* newfs_msdos: Improve error messagesEd Maste2025-11-101-3/+3
| | | | | | | | | | | - Report overly long OEM string as too long, not just "bad". - Use warn instead of warnx for open or ftruncate failure to report the error string. Reviewed by: se Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D53649
* Revert "sbin/newfs_msdos: add support for exFAT file systems"Stefan Eßer2025-08-065-1305/+64
| | | | This reverts commit 024f676b399fc8acee7288c543d32c581328833c.
* sbin/newfs_msdos: add support for exFAT file systemsStefan Eßer2025-08-055-64/+1305
| | | | | | | | | | | Add support for the creation of exFAT file systems, if invoked as newfs_exfat. Reviewed by: olce Approved by: olce, mckusick MFC after: 4 weeks Relnotes: yes Differential Revision: https://reviews.freebsd.org/D48727
* msdosfs manuals: Improve visibility and linkingAlexander Ziaee2025-04-171-0/+1
| | | | | | | | | | | | + add `(FAT)` to all descriptions to enable `apropos fat` + xref all msdosfs(4) utilities in base to msdosfs(4) + xref msdosfs(4) to all msdosfs(4) utilities + remove unrelated fsck_ffs(8) from fsck_msdos(8) MFC after: 3 days Reviewed by: mhorne Approved by: mhorne (mentor) Pull Request: https://github.com/freebsd/freebsd-src/pull/1557
* src: Use gnu17 as the default C standard for userland instead of gnu99Minsoo Choo2025-02-111-1/+0
| | | | | | | | | | | | | | | | | | | | | | Tracking newer versions of C (and C++) permits assuming newer language features in the base system. Some C11 extensions are already used in the base system but implemented on top of GNU C extensions such as _Alignas and _Static_assert. In some cases the fallback versions in cdefs.h are more limited than the native C11 extensions. Even though C11 is the next major version of C, C17 is chosen instead since C17 does not add new features to C but merely fixes defects in C11. It is also well supported by a wide range of clang (7.0.0+) and GCC (8.1+) versions. Along with changing the default, this change also removes explicit requests for c11 via the CSTD variable in various Makefiles. Libraries and binaries for ZFS continue to use c99. PR: 284039 (exp-run) Reviewed by: imp, arichardson, emaste Differential Revision: https://reviews.freebsd.org/D43237
* Remove residual blank line at start of MakefileWarner Losh2024-07-151-1/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* newfs_msdos: align to multiple of cluster size by defaultStefan Eßer2024-06-062-20/+9
| | | | | | | | | | | | | | | | | | | | | A previous commit aligned the start of the data area to a multiple of the VM page size, in order to prevent extra buffers to be allocated (which failed for 64 KB cluster size without this alignment). Since a dependency on PAGE_SIZE caused compatibility issues, the alignment was made conditional on this macro being defined, in the previous commit. This lead to different behavior of this program when built on FreeBSD vs. Linux (which does not define PAGE_SIZE). This commit removes any use of PAGE_SIZE and instead always aligns the start of the data area to a multiple of the cluster size. The -A option is now implied, unless overridden by a specific number of reserved sectors with the -r option. Approved by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D45436
* newfs_msdos: fix build on non-FreeBSD systemsStefan Eßer2024-06-041-0/+4
| | | | | | | | Disable data area alignment if the build environment does not define PAGE_SIZE (e.g., when building on Linux or macOS). Reported by: jrtc27 MFC after: 1 week
* newfs_msdos: align data area to VM page boundary by defaultStefan Eßer2024-06-022-10/+32
| | | | | | | | | | | | | | | | | | | | | | | | Without alignment, the data area will not be aligned with the buffer cache, leading to overhead, higher write multiplication on SSD devices and issues with very large cluster sizes (see PR 277414). The -A option used to align the start of the root directory to a multiple of the cluster size, which happens to align the start of the data area with a buffer page boundary in case of large clusters and the default number of directory entries (512 entries requiring 16 KB for FAT12 or FAT16, FAT32 puts the root directory into the data area). This commit aligns the start of the data area with the page size, if neither -A nor -r is used. It changes -A to align the start of the data area (end of the root directory) to a multiple of the cluster size, since this is the alignment that prevents write multiplication due to clusters crossing erase block boundaries of a SSD device. The -r option is unchanged and will prevent any automatic alignment from occuring. Approved by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D45436
* newfs_msdos.8: example for specific cluster sizeAlexander Ziaee2024-01-221-2/+8
| | | | | | | | | | The usual use case in 2024 for newfs_msdosfs is creating filesystems on SD cards for older hardware. In most tutorials, they call the cluster size "allocation size". Therefore, add a small note next to cluster size that it is also called allocation size, and add an example for how to do this. Reviewed by: jhb Pull Request: https://github.com/freebsd/freebsd-src/pull/1045
* Purge more stray embedded $FreeBSD$ stringsJohn Baldwin2023-09-252-10/+0
| | | | | | | These do not use __FBSDID but instead use bare char arrays. Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D41957
* Remove $FreeBSD$: two-line nroff patternWarner Losh2023-08-161-2/+0
| | | | Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-162-2/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c comment patternWarner Losh2023-08-161-1/+0
| | | | Remove /^/[*/]\s*\$FreeBSD\$.*\n/
* Mark usage function as __dead2 in programs where it does not returnAlfonso Gregory2023-07-071-1/+1
| | | | | | | | 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
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | 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
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-191-1/+0
|
* newfs_msdos: Fix warnings that arise when compiled for makefsMark Johnston2022-05-101-2/+5
| | | | | MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* newfs_msdos: connect the ATF test from NetBSDEric van Gyzen2022-02-162-0/+11
| | | | | | | | | | | NetBSD has an ATF test for newfs_msdos. Connect it to the build. Adapt it for FreeBSD. This would have caught the bug fixed by my previous commit. Reviewed by: delphij, emaste MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D34116
* newfs_msdos: fix type of kern.maxphysEric van Gyzen2022-02-161-3/+3
| | | | | | | | | | The type of the kern.maxphys sysctl OID is now ulong. Change the local variable type to match. Reviewed by: delphij, emaste MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D34116
* Fix makefs bootstrap on macOS after D25563Alex Richardson2020-08-251-0/+1
| | | | | | | | | | | The macOS assert.h header does not define static_assert when compiling in C99 mode. To fix this compile with -std=c11. Reviewed By: emaste Differential Revision: https://reviews.freebsd.org/D25928 Notes: svn path=/head/; revision=364765
* Use KERN_MAXPHYS.Xin LI2020-07-051-19/+46
| | | | | | | | | | Suggested by: imp Reviewed by: imp, cem (earlier version), emaste MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D25563 Notes: svn path=/head/; revision=362937
* Gather writes to larger chunks (MAXPHYS) instead of issuing them inXin LI2020-07-041-18/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | sectors. On my SanDisk Cruzer Blade 16GB USB stick this made formatting much faster: x before + after +--------------------------------------------------------------------------+ |+ | |+ x | |+ x x| |A MA|| +--------------------------------------------------------------------------+ N Min Max Median Avg Stddev x 3 15.89 16.38 16 16.09 0.2570992 + 3 0.32 0.37 0.35 0.34666667 0.025166115 Difference at 95.0% confidence -15.7433 +/- 0.414029 -97.8455% +/- 0.25668% (Student's t, pooled s = 0.182665) Reviewed by: emaste MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D24508 Notes: svn path=/head/; revision=362936
* Fix the following -Werror warning from clang 10.0.0 in newfs_msdos:Dimitry Andric2020-01-281-4/+4
| | | | | | | | | | | | | | 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 Notes: svn path=/projects/clang1000-import/; revision=357225
* Allow bootstrapping makefs on older FreeBSD hosts and Linux/macOSAlex Richardson2020-01-271-11/+44
| | | | | | | | | | | | | | | | | | | | | | In order to do so we need to install the msdosfs headers to the bootstrap sysroot and avoid includes of kernel headers that may not exist on every host (e.g. sys/lockmgr.h). This change should allow bootstrapping of makefs on FreeBSD 11+ as well as Linux and macOS. We also have to avoid using the IO_SYNC macro since that may not be available. In makefs it is only used to switch between calling bwrite() and bdwrite() which both call the same function. Therefore we can simply always call bwrite(). For our CheriBSD builds we always bootstrap makefs by setting LOCAL_XTOOL_DIRS='lib/libnetbsd usr.sbin/makefs' and use the makefs binary from the build tree to create a bootable disk image. Reviewed By: brooks Differential Revision: https://reviews.freebsd.org/D23201 Notes: svn path=/head/; revision=357169
* Fix a couple of minor issues with newfs_msdos:Xin LI2019-12-082-7/+4
| | | | | | | | | | | | - 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 Notes: svn path=/head/; revision=355513
* Explicitly exit() instead of return in main().Xin LI2019-12-031-1/+1
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=355318
* newfs_msdos: -A is incompatible with -r, not -o.Xin LI2019-12-031-1/+1
| | | | | | | | | PR: 242314 Submitted by: Guy Yur <guyyur gmail com> MFC after: 2 weeks Notes: svn path=/head/; revision=355317
* makefs: avoid warning when creating FAT filesystem on existing fileEd Maste2019-11-081-0/+2
| | | | | | | | | | | | | | Previously the mkfs_msdos function (from newfs_msdos) emitted warnings in the case that an image size is specified and the target is not a file, or no size is specified and the target is not a character device. The latter warning (not a character device) doesn't make sense when this code is used in makefs, regardless of whether an image size is specified or not. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=354537
* When creating a new FAT32 filesystem, use "unknown" (0xFFFFFFFF) forXin LI2019-08-221-1/+1
| | | | | | | | | | | | FSI_Nxt_Free instead of providing a wrong value. With this change, fsck_msdosfs would no longer complain about invalid FSInfo information. MFC after: 2 weeks Notes: svn path=/head/; revision=351382
* Added option to cluster-align the start of the root directory.Xin LI2018-06-154-47/+93
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=335189
* Only call close if fd and fd1 are not -1.Warner Losh2018-01-051-2/+4
| | | | | | | CID: 1384018, 1384017 Notes: svn path=/head/; revision=327570
* Close fd and fd1 before returning now that we're done with them.Warner Losh2017-12-281-0/+3
| | | | | | | CID: 978234, 978236 Notes: svn path=/head/; revision=327275
* various: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-1/+3
| | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326276
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* newfs_msdos: clarify description of -T (timestamp) optionEd Maste2017-05-161-9/+11
| | | | | | | | | | Submitted by: Siva Mahadevan <smahadevan@freebsdfoundation.org> Reported by: Daniel Shahaf <danielsh apache org> Reviewed by: emaste Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=318366
* newfs_msdos: add -T (timestamp) option for reproducible buildsEd Maste2017-05-164-6/+44
| | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=318355
* The code only converts from bpbHugeSectors to bpbSectors if the sum ofWarner Losh2016-08-301-1/+1
| | | | | | | | | | | | | | | the hidden and huge sectors is less than or equal MAXU16. When formatting in Windows bpbSectors is still used for 63488 sectors and 2048 hidden (sum > MAXU16). The hidden sectors count is the number of sectors before the FAT16 Boot Record so it shouldn't affect the sector count. Attached patch (huge_sec_conversion.patch) to only check for bpb.bpbHugeSectors <= MAXU16 when converting to bpbSectors. Submitted by: Guy Yur PR: 183234 Notes: svn path=/head/; revision=305075
* Remove CHS alignment. It's not needed and causes problems for the BBBWarner Losh2016-08-301-7/+0
| | | | | | | | | | boot partition. NetBSD removed it in 1.10 in their repo some time ago. Submitted by: Guy Yur PR: 183234 Notes: svn path=/head/; revision=305074
* Use nitems() from sys/param.h.Marcelo Araujo2016-04-191-1/+1
| | | | | | | MFC after: 2 weeks. Notes: svn path=/head/; revision=298250
* Explicitly add more files to the 'runtime' package.Glen Barber2016-02-091-0/+1
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=295450
* Fix leak in mkfs_msdos(..) by initializing img to NULL and free'ing at the endEnji Cooper2015-12-061-40/+47
| | | | | | | | | | | | | | of the function Differential Revision: https://reviews.freebsd.org/D4405 MFC after: 1 week PR: 204943 Reviewed by: emaste, jilles Reported by: David Binderman <dcb314@hotmail.com> Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=291908
* Use netbsd usage() implementation in newfs_msdosEd Maste2015-11-271-27/+14
| | | | | | | | | | In r289629 newfs_msdos option descriptions are available in mkfs_msdos.h. Obtained from: NetBSD Notes: svn path=/head/; revision=291385
* mkfs_msdos: sync with NetBSDEd Maste2015-11-271-3/+8
| | | | | | | | | Add a sanity test and clean up whitespace. Obtained from: NetBSD Notes: svn path=/head/; revision=291382
* newfs_msdos: rework error handling for eventual use in makefsEd Maste2015-11-232-98/+191
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=291219
* Update $NetBSD$ IDEd Maste2015-11-231-1/+1
| | | | | | | | | NetBSD mkfs_msdos.h rev 1.3 removed the no-endorsement clause from the license block, which had already been done in the source I imported in r289629. Notes: svn path=/head/; revision=291218
* newfs_msdos: use NetBSD's mkfs_msdos.h verbatim for makefs compatibilityEd Maste2015-10-201-42/+50
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=289629
* newfs_msdos: prefer snprintf to sprintfEd Maste2015-10-161-1/+1
| | | | | | | | Obtained from: NetBSD Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=289424
* newfs_msdos: move mkfs_msdos to separate file for later use in makefsEd Maste2015-10-154-835/+918
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=289376
* newfs_msdos: rework option parsing to match NetBSDEd Maste2015-10-151-125/+162
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=289369