Commit graph

272 commits

Author SHA1 Message Date
Ed Maste 0459337491 makefs: warn that ffs sectorsize other than 512 may not work
newfs always sets sectorsize to DEV_BSIZE (512) and derives some other
values based on the number of 512-byte sectors per real sector.  Similar
logic is required in makefs.  Until that happens, emit a warning that
the image may be incorrect.

PR:		276571
(cherry picked from commit 176b9e0d72)
(cherry picked from commit 8e40217819)
2024-03-22 15:03:48 -04:00
Stéphane Rochoy d8d0ecd973 makefs: Handle missing link keyword in mtree spec
PR:		241178
Reviewed by:	emaste
Pull Request:	https://github.com/freebsd/freebsd-src/pull/850

(cherry picked from commit d26c1a0f8b)
(cherry picked from commit be31bd5989)
2024-01-22 09:28:57 -05:00
Ed Maste fcd0bbbd4a makefs: clean up some leftovers after $FreeBSD$ tag removal
Fixes: 2a63c3be15
(cherry picked from commit 90aad5d3e4)
2023-08-23 11:43:34 -06:00
Warner Losh b144e70a33 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/

Similar commit in main:
(cherry picked from commit fa9896e082)
2023-08-23 11:43:31 -06:00
Warner Losh 023fc80ee3 Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/

Similar commit in main:
(cherry picked from commit d0b2dbfa0e)
2023-08-23 11:43:30 -06:00
Warner Losh 3d497e17eb Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/

Similar commit in main:
(cherry picked from commit 1d386b48a5)
2023-08-23 11:43:26 -06:00
Warner Losh 8ad303d68c Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/

Similar commit in main:
(cherry picked from commit 2a63c3be15)
2023-08-23 11:43:23 -06:00
Warner Losh 34041aac83 Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/

Similar commit in main:
(cherry picked from commit 42b388439b)
2023-08-23 11:43:22 -06:00
Warner Losh 17da660ad5 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/

Similar commit in main:
(cherry picked from commit b3e7694832)
2023-08-23 11:43:21 -06:00
Warner Losh f73b4bf27c spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD
The SPDX folks have obsoleted the BSD-2-Clause-NetBSD 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

(cherry picked from commit b61a573019)
2023-07-25 09:15:32 -06:00
Warner Losh caa41f6417 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

(cherry picked from commit 4d846d260e)
2023-07-25 09:13:49 -06:00
Chuck Silvers 89bd147dbf ffs: restore backward compatibility of newfs and makefs with older binaries
The previous change to CGSIZE had the unintended side-effect of allowing
newfs and makefs to create file systems that would fail validation when
examined by older commands and kernels, by allowing newfs/makefs to pack
slightly more blocks into a CG than those older binaries think is valid.
Fix this by having newfs/makefs artificially restrict the number of blocks
in a CG to the slightly smaller value that those older binaries will accept.
The validation code will continue to accept the slightly larger value
that the current newfs/makefs (before this change) could create.

Fixes:		0a6e34e950
Reviewed by:	mckusick
MFC after:	3 days
Sponsored by:	Netflix

(cherry picked from commit d464a7698d)
2023-06-04 04:00:22 -07:00
Kirk McKusick 4a3834e31f Fix size differences between architectures of the UFS/FFS CGSIZE macro value.
Reported-by:  Tijl Coosemans
Tested-by:    Tijl Coosemans and Peter Holm
Sponsored-by: The FreeBSD Foundation

(cherry picked from commit 0a6e34e950)
2023-05-26 14:25:50 -07:00
Ed Maste 0001406ae2 makefs: set cd9660 Rock Ridge timestamps for . and ..
DOT and DOTDOT entries have special handling, and previously only Rock
Ridge PX (POSIX attributes) entries were attached.  Add TF (timestamp)
entries as well.

PR:		203531
Reported by:	Thomas Schmitt <scdbackup@gmx.net>
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39662

(cherry picked from commit dd9059b3e9)
2023-04-27 12:45:37 -04:00
Ed Maste d74a8305b0 makefs: call brelse from bread
This matches NetBSD and rationalizes makefs with the kernel API.

This reverts commit 370e009188.

Reviewed by:	mckusick
Sponsored by:	The FreeBSD Foundation
Obtained from:	NetBSD 0a62dad69f62, 0c4125e1a19f, cb6a5a3575fd
Differential Revision:	https://reviews.freebsd.org/D39070

(cherry picked from commit e5551216d8)
2023-04-27 12:45:37 -04:00
Ed Maste 775defbe0c makefs: use unsigned and %u for rock_ridge_move_count
For diff reduction against NetBSD's makefs.  Based on NetBSD git mirror
commit 00991aee8248.

With this change our makefs cd9660 support should be in sync up to
NetBSD commit bdae6c9dc792 ("makefs(8): Nix trailing whitespace.").

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 10854bf517)
2023-04-21 17:19:48 -04:00
Ed Maste 6dda38e5ca makefs: remove unused variable
Reported by:	Clang
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 79ead08497)
2023-04-21 17:19:48 -04:00
Ed Maste 5fbe15bc21 makefs: remove unused cd9660 options
Makefs defined "follow-symlinks" and "help" options, but they did
nothing.  Remove them.

Obtained from:	OpenBSD a8f1645688c2
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c753f49f70)
2023-04-21 17:18:24 -04:00
Ed Maste 72ef847c17 makefs: use %s and __func__ in printf messages
For diff reduction against NetBSD.

Obtained from:	NetBSD 0c4125e1a19f
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit af7624ed31)
2023-04-14 08:10:38 -04:00
Ed Maste 496478c1dc makefs: set the validation entry system type
Obtained from:	NetBSD c3cb4dcc9c43
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 22db5e5d03)
2023-04-14 08:10:38 -04:00
Ed Maste c821bafd9c makefs: use size_t or ssize_t where appropriate
Obtained from:	NetBSD af7bc97830ac

(cherry picked from commit 1d1ffa2efd)
2023-04-14 08:10:38 -04:00
Ed Maste 066d6824fc makefs: simplify filename conversion handling
Obtained from:	OpenBSD 4095a2e01d18
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c02e6ca7c2)
2023-04-14 08:10:38 -04:00
Ed Maste 511e83ab14 makefs: remove some unused cd9660 types and defines
Obtained from:	OpenBSD
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d73acb32d3)
2023-04-14 08:10:38 -04:00
Ed Maste 1a38a53924 makefs: avoid uninitialized memory in root directory date
Move date setting into cd9660_populate_iso_dir_record so there is no
path that leaves it unset.

PR:		203531
Reported by:	Thomas Schmitt <scdbackup@gmx.net>
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39258

(cherry picked from commit 7bc4ccf3ae)
2023-04-14 08:10:37 -04:00
Ed Maste 6787081641 makefs: remove CD9660MAXPATH #define
It was used only in constructing the host path that contains file
content, which is not related to anything CD9660-specific.  PATH_MAX is
the appropriate limit.  See OpenBSD commit 299d8950f319.

Obtained from:	OpenBSD
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2f11df6337)
2023-04-14 08:10:37 -04:00
Ed Maste ac8ec8c7cc makefs: improve some cd9660 error messages
Obtained from:	OpenBSD
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c6ed8694ac)
2023-04-14 08:10:37 -04:00
Ed Maste 4311c5b3db makefs: #define Apple Partition bits
NetBSD defines these in sys/bootblock.h, which we don't have.  Add local
defintions in cd9660_eltorito.c (as OpenBSD did) to reduce diffs between
the three makefs implementations.

Obtained from:	OpenBSD
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit f0bef3d20e)
2023-04-14 08:10:37 -04:00
Ed Maste 8c22a34e9a makefs: correct "filname" typo
Obtained from:	NetBSD cd9660.c r1.58

(cherry picked from commit efe6a1574e)
2023-04-14 08:10:37 -04:00
Ed Maste 3dff748720 makefs: Whitespace cleanup to sync with NetBSD
(cherry picked from commit 52c68e1625)
2023-04-14 08:10:37 -04:00
Ed Maste 57f6ba0e38 makefs: remove vestigial '?' cases from top-level getopt(3) loop
getopt(3) returns '?' when it encounters a flag not present in the in
the optstring or if a flag is missing its option argument.  We can
handle this case with the "default" failure case with no loss of
legibility.

Obtained from:	OpenBSD makefs.c 1.22

(cherry picked from commit cc4adc4c4e)
2023-04-14 08:10:36 -04:00
Ed Maste 5f31bbc5fa makefs: do not pass mode to open() call lacking O_CREAT
Obtained from:	OpenBSD ffs.c 1.35

(cherry picked from commit 45e405603b)
2023-04-14 08:10:36 -04:00
Ed Maste a025a94c50 makefs: spelling
Obtained from:	OpenBSD msdosfs_fat.c 1.7

(cherry picked from commit 1fb7d2cf99)
2023-04-14 08:10:36 -04:00
Christos Margiolis 18eb15bd8a makefs(8): do not print comma after the last super-block
Reviewed by:	markj, emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39430

(cherry picked from commit f21faa67ab)
2023-04-12 10:18:37 -04:00
Ed Maste 3a52cc4445 makefs: emit NM records for all directory entries
We previously attempted to emit Rock Ridge NM records only when the name
represented by the Rock Ridge extensions would actually differ. We would
omit the record for an all-upper-case directory name, however Linux (and
perhaps other operating systems) map names with no NM record to
lowercase.

This affected only directories, as file names have an implicit ";1"
version number appended and thus always differ.  To solve, just emit NM
records for all entries other than DOT and DOTDOT .

We could continue to omit the NM record for directories that would avoid
mapping (for example, one named 1234.567) but this does not seem worth
the complexity.

PR:		203531
Reported by:	Thomas Schmitt <scdbackup@gmx.net
Reviewed by:	kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39258

(cherry picked from commit 978013a094)
2023-04-10 09:37:40 -04:00
Ed Maste b957461353 makefs: correct El Torito bood record
The boot catalog pointer is a DWord, but we previously populated it via
cd9660_bothendian_dword which overwrote four unused bytes following it.
See El Torito 1.0 (1995) Figure 7 for details.

PR:		203531, 203646
Reported by:	Coverity Scan
Reported by:	Thomas Schmitt <scdbackup@gmx.net>
Reviewed by:	kevans
CID:		977470
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39231

(cherry picked from commit 9f2a525360)
2023-04-10 09:37:40 -04:00
Ed Maste 62f8e14192 makefs: correct iso9660 Rock Ridge NM values
These are not actually used by makefs (yet), but ought to match the
spec.

See RRIP 4.1.4 Description of the "NM" System Use Entry for details.

PR:		203531
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c3ec19359e)
2023-04-10 09:37:40 -04:00
Ed Maste a79601b07a makefs: correct iso9660 Rock Ridge TF timestamps
The bit definitions for the TF_* timestamp bits (TF_MODIFY, etc.) were
incorrect, and timestamps were written in the wrong order.

See RRIP 4.1.6 Description of the "TF" System Use Entry for details.

PR:		203531
Reported by:	Thomas Schmitt <scdbackup@gmx.net>
Reviewed by:	jrtc27, kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39221

(cherry picked from commit c65c969bd5)
2023-04-10 09:37:40 -04:00
John Baldwin f31f677c1d makefs: Ignore some sign comparison warnings from GCC.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D37470

(cherry picked from commit abb9a940bb)
2023-03-22 08:22:07 -07:00
Ed Maste a16159aa2e makefs: do not call brelse if bread returns an error
If bread returns an error there is no bp to brelse.  One of these
changes was taken from NetBSD commit 0a62dad69f62 ("This works well
enough to populate..."), the rest were found by looking for the same
pattern.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39069

(cherry picked from commit bc33c99234)
2023-03-21 11:58:40 -04:00
Warner Losh aa1e6a4f4c makefs: make msdos creation go fast
Add missing brelse(bp). Without it the cache grows and we have a n^2
lookup.  I'm not entirely sure why we read the block before we write it
back out, since the only side effect of that is to allocate memory,
clear the memory, read it in from disk, throw it away with the contents
of the file being written out. We likely should just do a getblk() here
instead, but even with all that, this takes the time it takes to create
a 150MB msdos fs image down from 5 minutes to 30 seconds.

Old: 317.663u 0.685s 5:18.34 100.0%	198+360k 0+19io 1009pf+0w
New: 7.330u 23.841s 0:31.17 100.0%	198+360k 0+250522io 4pf+0w

See code review for how we got this. tl;dr: netbsd move brelse
into bwrite and we picked up msdos code after that, but not the
move. That change should be picked up later.

Sponsored by:		Netflix
Reviewed by:		emaste
MFC After:		1 day (13.2 is coming fast)
Differential Revision:	https://reviews.freebsd.org/D39025

(cherry picked from commit 370e009188)
2023-03-14 09:47:46 -06:00
Jessica Clarke 3622fe1620 ufs: Rework shortlink handling to avoid subobject overflows
Shortlinks occupy the space of both di_db and di_ib when used. However,
everywhere that wants to read or write a shortlink takes a pointer do
di_db and promptly runs off the end of it into di_ib. This is fine on
most architectures, if a little dodgy. However, on CHERI, the compiler
can optionally restrict the bounds on pointers to subobjects to just
that subobject, in order to mitigate intra-object buffer overflows, and
this is enabled in CheriBSD's pure-capability kernels.

Instead, clean this up by inserting a union such that a new di_shortlink
can be added with the right size and element type, avoiding the need to
cast and allowing the use of the DIP macro to access the field. This
also mirrors how the ext2fs code implements extents support, with the
exact same structure other than having a uint32_t i_data[] instead of a
char di_shortlink[].

Reviewed by:	mckusick, jhb
Differential Revision:	https://reviews.freebsd.org/D33650

(cherry picked from commit 5b13fa7987)
2023-01-24 14:49:19 -07:00
Ed Maste e55ea61d07 makefs: whitespace cleanup (remove space before tab)
MFC after:	1 week

(cherry picked from commit 06a400d76b)
2022-10-01 20:37:18 -04:00
Gordon Bergling 4351e5a430 cd9660(5): Correct a typo in a source code comment
- s/byes/bytes/

(cherry picked from commit 5f285d5537)
2022-09-07 09:25:03 +02:00
Alan Somers 1a2920e96a makefs: fix calculation of file sizes
When a new FS image is created we need to calculate how much space each
file is going to consume.
Fix two bugs in that logic:

1) Count the space needed for indirect blocks for large files.
1) Normally the trailing data of a file is written to a block of frag
   size, 4 kB by default.

However for files that use indirect blocks a full block is allocated,
32kB by default.  Take that into account.

Adjust size calculations to match what is done in ffs_mkfs routine:

* Depending on the UFS version the superblock is stored at a different
  offset. Take that into account.
* Add the cylinder group block size.
* All of the above has to be aligned to the block size.

Finally, Remove "ncg" variable. It's always 1 and it was used to
multiply stuff.

PR:		229929
Reviewed by:	mckusick
Sponsored by:	Semihalf
Submitted by:	Kornel Dulęba <mindal@semihalf.com>
Differential Revision:	https://reviews.freebsd.org/D35131
Differential Revision:	https://reviews.freebsd.org/D35132

(cherry picked from commit ecdc04d006)
2022-06-18 08:17:23 -06:00
Ed Maste 6678474be7 makefs: sort cd9660 sysid entries in man page
"efi" was added at the end of the sysid list rather than in alpha
order.  Move it as a diff reduction against NetBSD.

(cherry picked from commit ec3c01ae72)
2022-06-16 08:49:43 -04:00
Mark Johnston e5b204542f makefs: Remove execute permission from in-tree test scripts
Let the build system set it as needed.  No functional change intended.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 21add93b58)
2022-05-26 09:42:39 -04:00
Mark Johnston bee87a7381 makefs: Fix warnings and reset WARNS to the default
Leave -Wcast-align disabled, at least for now, since there are numerous
instances of that warning in places where buffer pointers are cast to
pointers to various filesystem structures.  Fixing this properly would
be too much work for too little gain.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cc1a53bc1a)
2022-05-24 09:51:36 -04:00
Gordon Bergling 3222f9a524 makefs(8): Fix a few typos in source code comments
- s/concearned/concerned/
- s/quadradically/quadratically/

Obtained from:	NetBSD

(cherry picked from commit 164fa411b9)
2022-02-09 07:18:33 +01:00
Konstantin Belousov c1df4eef12 msdosfs: clusterfree() is used only in error handling cases
(cherry picked from commit 65990b68a2)
2022-01-14 20:11:02 +02:00
Nathaniel Filardo d2c77ce6f3 makefs: Cast daddr_t to off_t before multiplication
Apparently some large-file systems out there, such as my powerpc64le
Linux box, define daddr_t as a 32-bit type, which is sad and stymies
cross-building disk images.  Cast daddr_t to off_t before doing
arithmetic that overflows.

Reviewed by:	arichardson, jrtc27, imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D27458

(cherry picked from commit 7ef082733b)
2021-09-07 13:06:44 +01:00