Commit Graph

22 Commits

Author SHA1 Message Date
Mark Johnston
240afd8c1f makefs: Add ZFS support
This allows one to take a staged directory tree and create a file
consisting of a ZFS pool with one or more datasets that contain the
contents of the directory tree.  This is useful for creating virtual
machine images without using the kernel to create a pool; "zpool create"
requires root privileges and currently is not permitted in jails.
makefs -t zfs also provides reproducible images by using a fixed seed
for pseudo-random number generation, used for generating GUIDs and hash
salts.  makefs -t zfs requires relatively little by way of machine
resources.

The "zpool_reguid" rc.conf setting can be used to ask a FreeBSD guest to
generate a unique pool GUID upon first boot.

A small number of pool and dataset properties are supported.  The pool
is backed by a single disk vdev.  Data is always checksummed using
Fletcher-4, no redundant copies are made, and no compression is used.
The manual page documents supported pool and filesystem properties.

The implementation uses a few pieces of ZFS support from with the boot
loader, especially definitions for various on-disk structures, but is
otherwise standalone and in particular doesn't depend on OpenZFS.

This feature should be treated as experimental for now, i.e., important
data shouldn't be trusted to a makefs-created pool, and the command-line
interface is subject to change.

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35248
2022-08-05 13:42:29 -04:00
Mark Johnston
cc1a53bc1a 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.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2022-05-10 17:38:23 -04:00
Alex Richardson
6424881cc8 Fix makefs bootstrap on macOS after D25563
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
2020-08-25 13:30:24 +00:00
Ed Maste
98dc8da58c makefs: add msdosfs (FAT) support
Add FAT support to makefs by copying some files from sys/fs/msdosfs/ and
updating others with changes from NetBSD.

The six files copied from sys/fs/msdosfs at r348251 and modified are:
denode.h direntry.h fat.h msdosfs_fat.c msdosfs_lookup.c msdosfsmount.h

I would prefer to avoid the duplication, but reluctance to doing so was
expressed in a previous review (D11197); for now copy the files and
revisit in the future.

Submitted by:	Siva Mahadevan
Discussed with:	cem, imp
MFC after:	1 month
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D16438
2019-08-20 18:20:45 +00:00
Ed Maste
daddfa7cc7 makefs: tidy up reach-over source
- cd9660 relies on an #include "iso.h" but does not build any .c files
  out of source, so remove reach-over .PATH
- ffs does not rely on any sys/ headers, so remove -I from CFLAGS.
- ffs_tables from sys/ is used by ffs; move the SRCS entry from the top-
  level Makefile to ffs' Makefile.inc.

Sponsored by:	The FreeBSD Foundation
2018-04-20 22:23:38 +00:00
Enji Cooper
d511b20a69 Add HAS_TESTS to all Makefiles that are currently using the
`SUBDIR.${MK_TESTS}+= tests` idiom.

This is a follow up to r321912.
2017-08-02 08:50:42 +00:00
Enji Cooper
4b330699f8 Convert traditional ${MK_TESTS} conditional idiom for including test
directories to SUBDIR.${MK_TESTS} idiom

This is being done to pave the way for future work (and homogenity) in
^/projects/make-check-sandbox .

No functional change intended.

MFC after:	1 weeks
2017-08-02 08:35:51 +00:00
Ed Maste
7092a907e5 makefs: drop WARNS back to 2
GCC warns about additional signed comparision issues compared to Clang.
Drop WARNS for now until the underlying issue is fixed.
2017-05-18 17:55:33 +00:00
Ed Maste
3afe6a68e0 makefs: clean up signedness warnings and bump WARNS to 3
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D10650
2017-05-18 14:05:29 +00:00
Marcel Moolenaar
4ad8d73326 Assign a random number to di_gen (for FFS), instead of extracting it
from struct stat.  We don't necessarily have permissions to see the
generation number and the host OS may not have st_gen in struct stat
anyway.  Since the kernel assigns random numbers, there's nothing
meaningful about the generation that requires us to preserve it when
the file system image is created.  With this change, all generation
numbers come from random() and that makes it easier to add support
for reproducible builds at some time in the future (i.e. by adding
an argument to makefs that changes the behaviour of random() so that
it always returns 0 or some predictable sequence).

Differential Revision:	https://reviews.freebsd.org/D8418
2016-11-05 16:23:33 +00:00
Marcel Moolenaar
46783b12e3 Allow building makefs(8) from another Makefile (such as one in
a seperate directory hierarchy used to build tools). This boils
down to replacing the use of ${.CURDIR} with either ${SRCDIR}
or ${SRCTOP}. SRCDIR is defined as the directory in which the
Makefile lives that bmake(1) is currently reading. Use SRCTOP
when reaching outside of makefs's directory.
2016-10-25 16:21:38 +00:00
Enji Cooper
7bdfc3b75e Correctly reintroduce the rudimentary smoke tests I botched up
in r289684

MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
2015-10-22 05:32:45 +00:00
Enji Cooper
6cf8c0fe51 Revert r289694
I committed some other undesirable local changes by accident
2015-10-21 13:15:04 +00:00
Enji Cooper
b4c3ec123e Add some rudimentary [smoke] testcases for makefs
MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
2015-10-21 13:13:38 +00:00
Baptiste Daroussin
2df4d9628a Convert makefs to LIBADD
Add definition of libnetbsd in src.libnames.mk
2014-11-24 22:15:30 +00:00
Bryan Drewery
5608fd23c2 Revert r267233 for now. PIE support needs to be reworked.
1. 50+% of NO_PIE use is fixed by adding -fPIC to INTERNALLIB and other
   build-only utility libraries.
2. Another 40% is fixed by generating _pic.a variants of various libraries.
3. Some of the NO_PIE use is a bit absurd as it is disabling PIE (and ASLR)
   where it never would work anyhow, such as csu or loader. This suggests
   there may be better ways of adding support to the tree. Many of these
   cases can be fixed such that -fPIE will work but there is really no
   reason to have it in those cases.
4. Some of the uses are working around hacks done to some Makefiles that are
   really building libraries but have been using bsd.prog.mk because the code
   is cleaner. Had they been using bsd.lib.mk then NO_PIE would not have
   been needed.

We likely do want to enable PIE by default (opt-out) for non-tree consumers
(such as ports). For in-tree though we probably want to only enable PIE
(opt-in) for common attack targets such as remote service daemons and setuid
utilities. This is also a great performance compromise since ASLR is expected
to reduce performance. As such it does not make sense to enable it in all
utilities such as ls(1) that have little benefit to having it enabled.

Reported by:	kib
2014-08-19 15:04:32 +00:00
Bryan Drewery
864c53ead8 In preparation for ASLR [1] support add WITH_PIE to support building with -fPIE.
This is currently an opt-in build flag. Once ASLR support is ready and stable
it should changed to opt-out and be enabled by default along with ASLR.

Each application Makefile uses opt-out to ensure that ASLR will be enabled by
default in new directories when the system is compiled with PIE/ASLR. [2]

Mark known build failures as NO_PIE for now.

The only known runtime failure was rtld.

[1] http://www.bsdcan.org/2014/schedule/events/452.en.html
Submitted by:		Shawn Webb <lattera@gmail.com>
Discussed between:	des@ and Shawn Webb [2]
2014-06-08 17:29:31 +00:00
Brooks Davis
43e8dbd316 Remove duplicated copies of various NetBSD compatibility shims used by
makefs and use libnetbsd, contrib/mtree, and contrib/mknod instead.

Sponsored by:	DARPA, AFRLo
MFC after:	1 month
2013-05-09 14:43:36 +00:00
Marcel Moolenaar
484b5c257d Add support for using mtree(5) manifest files to define the image
to be created. The support is based on mtree version 2.0, as used
in libarchive, but adds new features on top of it.

The current implementation is fully functional, but is envisioned
to grow at least the following additional features over time:
o   Add support for the /include special command so that manifest
    files can be constructed using includable fragments.
o   Add support specifying a search path to locate content files.
o   Content file filters: commands that provide file contents on
    stdout.

The manifest file eliminates the need to first construct a tree
as root in order to create an image and allows images (releases)
to be created directly from object trees and/or source trees.

Reviewed by:	deo
Sponsored by:	Juniper Networks, Inc
2011-06-19 18:34:49 +00:00
Olivier Houchard
01a0f8531a Sync with the latest version from NetBSD. It notably addds ISO9660 support.
Submitted by:	bapt
2010-11-07 16:05:04 +00:00
Sam Leffler
6ba525d6e0 fix pathnames to work w/ buildworld 2008-12-19 22:59:05 +00:00
Sam Leffler
d347a0da97 import netbsd makefs tool 2008-12-19 18:47:46 +00:00