Commit graph

342 commits

Author SHA1 Message Date
Minsoo Choo
ca4eddea97 src: Use gnu17 as the default C standard for userland instead of gnu99
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
2025-02-11 09:16:25 -05:00
Kirk McKusick
aa90fbed15 Standardize the definition of a UFS dinode.
Each program that operates on UFS on-disk inodes defines its own
version of a dinode. They all (of necessity) define the same
layout but use different names. This change adds a definition of
a dinode (a union of a UFS1 on-disk inode and a UFS2 on-disk inode)
as well as a dinodep (a union of a pointer to a UFS1 on-disk inode
and a pointer to a UFS2 on-disk inode) in sys/ufs/ufs/dinode.h.
It then deletes the definitions of dinode and dinodep in all the
programs that operate on them and instead uses these standard
definitions.

No functional change intended.

MFC-after: 1 week
2025-01-27 17:39:45 -08:00
Mark Johnston
ce87828431 makefs: Handle special file types when creating a zpool
Previously, anything other than a regular file, directory or symlink
would cause makefs to exit with an assertion failure.  Make it a bit
more resilient to user error: print a warning and skip the file.  Add a
regression test wherein we create an image from a devfs mount.

PR:		283583
MFC after:	2 weeks
2025-01-07 14:32:20 +00:00
Mark Johnston
2be86b6cc1 makefs: Remove dead code in inode_type()
No functional change intended.

MFC after:	1 week
2025-01-07 14:32:20 +00:00
Ed Maste
1f31d43742 makefs: Fix cd9660 duplicate directory names
Previously we could create cd9660 images with duplicate short (level 2)
names.

cd9660_level2_convert_filename used a 30-character limit (for files and
directories), not including the '.' separator.  cd9660_rename_filename
used a 31-character limit, including the '.'.  Directory names 31
characters or longer (without '.') were shortened to 30 characters, and
if a collision occurred cd9660_rename_filename uniquified them starting
with the 31st character.  Unfortunately the directory record's name_len
was already set, so the unique part of the name was stripped off.

Directories are up to 31 d-characters (i.e., A-Z 0-9 and _); there is no
provision for a '.' in a directory name.  Increase the name length limit
to 31 for directories, and exclude '.'s.

This name mapping and deduplication code is still fragile and convoluted
and would beenfit from a more holistic effort.

PR:		283238, 283112
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48251
2024-12-30 14:48:44 -05:00
Ed Maste
788e1eb7c1 makefs: Remove impossible if condition
This test is inside the else block for `if (*oldname == '.')`, so
*oldname cannot be '.' here.

Reviewed by:	kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48243
2024-12-29 15:28:32 -05:00
Ed Maste
2e09cef8dc makefs: Fix cd9660 filename buffer maximum length
The maximum length is 30 characters for name and extension, two
separators (. and ;) and 5 characters for file version from 1 to 32767,
which is 37 characters.  Add one for the null term as we treat these
buffers as C strings.

This is not an issue in practice, as the file version is always 1 in
makefs.

While here, drop `_WITH_PADDING` from the macro name and update the
previously-unused ISO_FILENAME_MAXLENGTH for the corrected length.
A 0x00 padding byte is used by ISO9660 when needed for alignment, which
can be the null byte at the end of the string.

Use sizeof where appropriate.

Reviewed by:	kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48193
2024-12-26 11:44:36 -05:00
Ed Maste
b45f84cc62 makefs: Exit with error if writing cd image fails
Obtained from:	OpenBSD c8f48d9b1ea9
Sponsored by:	The FreeBSD Foundation
2024-12-23 11:03:36 -05:00
Ed Maste
2069f6ecb1 makefs: Crudely fix a sprintf warning
Reviewed by:	kevans
Obtained from:	OpenBSD d95291fdb2dc
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48178
2024-12-23 10:30:03 -05:00
Mark Johnston
a20249443b makefs.8: Clarify that makefs-generated zpools always have the same GUID
PR:		282832
MFC after:	1 week
2024-11-19 21:18:38 +00:00
Mark Johnston
e19c607ff9 makefs.8: Remove a warning about makefs -t zfs being experimental
This should have been done with commit d9fe718287 but was missed.

Fixes:	d9fe718287 ("makefs: Remove the warning printed when makefs -t zfs is used")
MFC after:	3 days
2024-11-19 21:18:38 +00:00
Zhenlei Huang
56b17de1e8 makefs: Remove a stray semicolon
MFC after:	1 week
2024-10-24 23:04:48 +08:00
Mark Johnston
4e15366c6a makefs: Record a larger TXG number in the uberblock
By default, OpenZFS will perform metadata verification of the most
recent TXGs, but this can be very slow since all data in a pool
generated by makefs was logically written in a single transaction.

Avoid triggering this verification by default, but add an option to
restore the previous behaviour and enable it in regression test cases.

Reported by:	cperciva
Tested by:	cperciva (previous version)
MFC after:	2 weeks
2024-10-14 13:14:37 +00:00
Mark Johnston
d9fe718287 makefs: Remove the warning printed when makefs -t zfs is used
We haven't seen bug reports relating to this feature for a while, so
stop printing a warning.

Reviewed by:	cperciva
MFC after:	2 weeks
2024-10-04 15:56:34 +00:00
Greg Lehey
b7b7800043 Explain the relationship between -p and -Z. 2024-09-26 12:07:02 +10:00
Warner Losh
e9ac41698b Remove residual blank line at start of Makefile
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
2024-07-15 16:43:39 -06:00
Mark Johnston
be2f92a96b makefs/zfs: Add a helper function for adding ZAP entries
Some ZAPs are used to represent sets, in which keys and values are the
same.  Add a helper function for this case.  No functional change
intended.

MFC after:	1 week
2024-06-01 11:16:18 -04:00
Ed Maste
176b9e0d72 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
2024-01-26 17:27:57 -05:00
Mark Johnston
e0deb85065 makefs: Make it possible to silence warnings about duplicate paths
When generating a VM image from an installworld mtree manifest, makefs
spits out several thousand warnings about duplicate paths in the
manifest.  These are harmless and have been around for a long time (see
the phabricator revision for some more details), so let's at least have
a way to make makefs quieter.

Reviewed by:	brooks, imp, emaste
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D43513
2024-01-19 19:50:56 -05:00
Jose Luis Duran
518a1fd7d3 makefs: Fix ZFS cross-reference sections
MFC after:	1 week
Fixes:		240afd8c1f ("makefs: Add ZFS support")
Pull Request:	https://github.com/freebsd/freebsd-src/pull/979
2024-01-02 09:20:26 -05:00
Warner Losh
4d65a7c695 usr.sbin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:01 -07:00
Warner Losh
8a7b612037 usr.sbin: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:56 -07:00
John Baldwin
5fc8ed9313 makefs: Quiet a -Wdangling-pointer warning in cd9660_generate_path_table
This function temporarily stores a pointer to an on-stack variable (a
TAILQ_HEAD of a temporary list) into a global variable (*n).

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42581
2023-11-14 18:35:44 -08:00
John Baldwin
c06962057b makefs cd9660: Unexpand a few TAILQ macros
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D42580
2023-11-14 18:35:27 -08:00
Mark Johnston
7e5002e3d6 makefs/zfs: Add a regression test which checks file access permissions
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2023-11-08 07:18:58 -05:00
Mark Johnston
50565cf514 makefs/zfs: Don't set ZFS_NO_EXECS_DENIED in file flags
This flag was leftover from testing and should have been removed.

PR:		274938
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2023-11-08 07:04:12 -05:00
Mark Johnston
ef067b5799 makefs/zfs: Update dd_used_breakdown after writing the MOS
Fixes:	96092bf910 ("makefs/zfs: Fill out dd_used_breakdown fields in DSL directories")
Sponsored by:	The FreeBSD Foundation
2023-10-23 12:29:20 -04:00
Mark Johnston
9f9d18d61e makefs/zfs: Add a regression test which checks the 'used*' properties
PR:		274613
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-10-23 11:15:00 -04:00
Mark Johnston
96092bf910 makefs/zfs: Fill out dd_used_breakdown fields in DSL directories
This is required for the "used", "usedds" and "usedchild" dataset
properties to be displayed.

PR:		274613
Reported by:	Mike Tancsa <mike@sentex.net>
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-10-23 11:12:14 -04:00
Dimitry Andric
8a77bc5e1b makefs/zfs: fix build with gcc 12 after b5a2bf512d
Due to integer promotion rules, dn_nlevels (uint8_t) gets promoted to a
plain int, resulting in -Werror warnings with gcc 12:

  In file included from /workspace/src/usr.sbin/makefs/zfs.c:35:
  /workspace/src/usr.sbin/makefs/zfs.c: In function '_dnode_cursor_flush':
  /workspace/src/usr.sbin/makefs/zfs.c:684:23: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
    684 |         assert(levels <= c->dnode->dn_nlevels - 1);
        |                       ^~
  /workspace/src/usr.sbin/makefs/zfs.c:691:27: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
    691 |                 if (level == c->dnode->dn_nlevels - 1) {
        |                           ^~
  /workspace/src/usr.sbin/makefs/zfs.c: In function 'dnode_cursor_next':
  /workspace/src/usr.sbin/makefs/zfs.c:739:41: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
    739 |                 for (levels = 0; levels < c->dnode->dn_nlevels - 1; levels++) {
        |                                         ^

Fix it by subtracting 1U instead of 1.

Fixes:		b5a2bf512d
MFC after:	3 days
2023-09-30 20:27:20 +02:00
Mark Johnston
b6da7f2fd1 makefs/zfs tests: Add a test case which appends to a file after import
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-09-28 16:36:12 -04:00
Mark Johnston
ef20cd33d3 makefs/zfs: Ensure that the last block of a file has the right size
When copying a file's contents into the pool, a loop copies blocks of
the maximum size (128KB), allocating space from the vdev for each block.
The space allocator rounds up to the nearest block size, but for files
larger than the maximum size, this can result in the last block having a
smaller logical size than the rest of the blocks belonging to that
dnode.  This violates some ZFS invariants when appending to that file.

Modify fs_populate_file() to use the same block size for the final
block.

Reported by:	cperciva
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-09-28 16:16:17 -04:00
Mark Johnston
60c95af88f makefs/zfs: Remove a nonsensical comment
When populating files, makefs needs to copy their contents into
userspace in order to compute a checksum, so copy_file_range(2) is out
of the question.  Though, it could possibly be used when building other
types of filesystems.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-09-27 19:03:26 -04:00
Mark Johnston
87534f95dd makefs/zfs tests: Run zdb prior to importing makefs-created pools
zdb contains quite a few assertions that can help catch bugs.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-09-27 12:00:00 -04:00
Mark Johnston
46402fd216 makefs/zfs: Set the objset block pointer fill field correctly
It is supposed to contain the number of objects allocated from the set,
excluding the meta dnode.

Reported by:	mav
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-09-27 12:00:00 -04:00
Mark Johnston
b5a2bf512d makefs/zfs: Use unsigned integers for indirect block level counts
No functional change intended.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-09-27 12:00:00 -04:00
Greg Lehey
915af88322 Explain the -d option. 2023-09-26 15:05:16 +10:00
Stéphane Rochoy
d26c1a0f8b makefs: Handle missing link keyword in mtree spec
PR:		241178
Reviewed by:	emaste
MFC after:	3 days
Pull Request:	https://github.com/freebsd/freebsd-src/pull/850
2023-09-21 12:49:11 -04:00
Ed Maste
84696cf10c makefs: remove ISO9660 Archimedes extension support
We have no need to create ISO images with RISC OS specific metadata.

Reviewed by:	imp
Relnotes:	yes
Obtained from:	OpenBSD a435da44c07f
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39344
2023-09-20 07:37:19 -04:00
Ed Maste
90aad5d3e4 makefs: clean up some leftovers after $FreeBSD$ tag removal
Fixes: 2a63c3be15
2023-08-16 16:24:37 -04:00
Warner Losh
fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh
d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh
1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh
2a63c3be15 Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:29 -06:00
Warner Losh
42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Warner Losh
b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Elyes Haouas
b152ff4c1e makefs: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/653
2023-06-01 20:33:41 -06:00
Chuck Silvers
d464a7698d 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
2023-05-29 19:26:28 -07:00
Mark Johnston
14c5cf3a16 makefs/zfs: Avoid generating a GUID of zero 2023-05-26 15:38:08 -04:00
Kirk McKusick
0a6e34e950 Fix size differences between architectures of the UFS/FFS CGSIZE macro value.
The cylinder group header structure ended with `u_int8_t cg_space[1]'
representing the beginning of the inode bitmap array. Some architectures
like the i386 rounded this up to a 4-byte boundry while other
architectures like the amd64 rounded it up to an 8-byte boundry.
Thus sizeof(struct cg) was four bytes bigger on an amd64 machine
than on an i386 machine. If a filesystem created on an i386 machine
was moved to an amd64 machine, the size of the cylinder group
calculated by the CGSIZE macro would appear to grow by four bytes.
Filesystems whose cylinder groups were exactly equal to the block
size on an i386 machine would appear to have a cylinder group that
was four bytes too big when moved to an amd64 machine. Note that
although the structure appears to be too big, it in fact is fine.
It is just the calaculation of its size that is in error.

The fix is to remove the cg_space element from the cylinder-group
structure so that the calculated size of the structure is the same
size on all architectures.

Reported by:  Tijl Coosemans
Tested by:    Tijl Coosemans and Peter Holm
MFC after:    1 week
Sponsored by: The FreeBSD Foundation
2023-05-15 12:57:15 -07:00