diff options
Diffstat (limited to 'sys/contrib/openzfs')
1161 files changed, 12060 insertions, 15479 deletions
diff --git a/sys/contrib/openzfs/.github/workflows/checkstyle.yaml b/sys/contrib/openzfs/.github/workflows/checkstyle.yaml index abc0ff11916a..8dafdcf07fed 100644 --- a/sys/contrib/openzfs/.github/workflows/checkstyle.yaml +++ b/sys/contrib/openzfs/.github/workflows/checkstyle.yaml @@ -40,11 +40,11 @@ jobs: - name: CheckABI id: CheckABI run: | - docker run -v $(pwd):/source ghcr.io/openzfs/libabigail make -j$(nproc) --no-print-directory --silent checkabi + docker run -v $PWD:/source ghcr.io/openzfs/libabigail make -j$(nproc) --no-print-directory --silent checkabi - name: StoreABI if: failure() && steps.CheckABI.outcome == 'failure' run: | - docker run -v $(pwd):/source ghcr.io/openzfs/libabigail make -j$(nproc) --no-print-directory --silent storeabi + docker run -v $PWD:/source ghcr.io/openzfs/libabigail make -j$(nproc) --no-print-directory --silent storeabi - name: Prepare artifacts if: failure() && steps.CheckABI.outcome == 'failure' run: | diff --git a/sys/contrib/openzfs/.github/workflows/zloop.yml b/sys/contrib/openzfs/.github/workflows/zloop.yml index 8eb2a1d9bb0f..d49eeae1653c 100644 --- a/sys/contrib/openzfs/.github/workflows/zloop.yml +++ b/sys/contrib/openzfs/.github/workflows/zloop.yml @@ -38,8 +38,9 @@ jobs: - name: Tests run: | sudo mkdir -p $TEST_DIR - # run for 20 minutes to have a total runner time of 30 minutes - sudo /usr/share/zfs/zloop.sh -t 1200 -l -m1 -- -T 120 -P 60 + # run for 10 minutes or at most 2 iterations for a maximum runner + # time of 20 minutes. + sudo /usr/share/zfs/zloop.sh -t 600 -I 2 -l -m1 -- -T 120 -P 60 - name: Prepare artifacts if: failure() run: | diff --git a/sys/contrib/openzfs/.gitignore b/sys/contrib/openzfs/.gitignore index 056bbb8f08c9..8d91dd9466c5 100644 --- a/sys/contrib/openzfs/.gitignore +++ b/sys/contrib/openzfs/.gitignore @@ -1,6 +1,7 @@ # -# N.B. -# This is the toplevel .gitignore file. +# This is the top-level .gitignore file: +# ignore everything except a list of allowed files. +# # This is not the place for entries that are specific to # a subdirectory. Instead add those files to the # .gitignore file in that subdirectory. @@ -10,6 +11,56 @@ # command after changing this file, to see if there are # any tracked files which get ignored after the change. +* + +!.github +!cmd +!config +!contrib +!etc +!include +!lib +!man +!module +!rpm +!scripts +!tests +!udev + +!.github/** +!cmd/** +!config/** +!contrib/** +!etc/** +!include/** +!lib/** +!man/** +!module/** +!rpm/** +!scripts/** +!tests/** +!udev/** + +!.editorconfig +!.gitignore +!.gitmodules +!AUTHORS +!autogen.sh +!CODE_OF_CONDUCT.md +!configure.ac +!copy-builtin +!COPYRIGHT +!LICENSE +!Makefile.am +!META +!NEWS +!NOTICE +!README.md +!RELEASES.md +!TEST +!zfs.release.in + + # # Normal rules # @@ -31,40 +82,7 @@ modules.order Makefile Makefile.in - -# -# Top level generated files specific to this top level dir -# -/bin -/build -/configure -/config.log -/config.status -/libtool -/zfs_config.h -/zfs_config.h.in -/zfs.release -/stamp-h1 -/aclocal.m4 -/autom4te.cache - -# -# Top level generic files -# -!.gitignore -tags -TAGS -current -cscope.* -*.rpm -*.deb -*.tar.gz *.patch *.orig -*.log *.tmp -venv - -*.so -*.so.debug -*.so.full +*.log diff --git a/sys/contrib/openzfs/Makefile.am b/sys/contrib/openzfs/Makefile.am index 098357902916..ebb385fabc06 100644 --- a/sys/contrib/openzfs/Makefile.am +++ b/sys/contrib/openzfs/Makefile.am @@ -1,33 +1,43 @@ +CLEANFILES = +EXTRA_DIST = +INSTALL_DATA_HOOKS = +ALL_LOCAL = +CLEAN_LOCAL = +CHECKS = shellcheck checkbashisms + +include $(top_srcdir)/config/Rules.am +include $(top_srcdir)/config/CppCheck.am include $(top_srcdir)/config/Shellcheck.am +include $(top_srcdir)/config/Substfiles.am ACLOCAL_AMFLAGS = -I config SUBDIRS = include if BUILD_LINUX -SUBDIRS += rpm +include $(srcdir)/%D%/rpm/Makefile.am endif if CONFIG_USER -SUBDIRS += man scripts lib tests cmd etc contrib +include $(srcdir)/%D%/cmd/Makefile.am +include $(srcdir)/%D%/contrib/Makefile.am +include $(srcdir)/%D%/etc/Makefile.am +include $(srcdir)/%D%/lib/Makefile.am +include $(srcdir)/%D%/man/Makefile.am +include $(srcdir)/%D%/scripts/Makefile.am +include $(srcdir)/%D%/tests/Makefile.am if BUILD_LINUX -SUBDIRS += udev +include $(srcdir)/%D%/udev/Makefile.am endif endif +CPPCHECKDIRS += module if CONFIG_KERNEL SUBDIRS += module extradir = $(prefix)/src/zfs-$(VERSION) extra_HEADERS = zfs.release.in zfs_config.h.in - -if BUILD_LINUX -kerneldir = $(prefix)/src/zfs-$(VERSION)/$(LINUX_VERSION) -nodist_kernel_HEADERS = zfs.release zfs_config.h module/$(LINUX_SYMBOLS) -endif endif -AUTOMAKE_OPTIONS = foreign -EXTRA_DIST = autogen.sh copy-builtin -EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am +EXTRA_DIST += autogen.sh copy-builtin EXTRA_DIST += AUTHORS CODE_OF_CONDUCT.md COPYRIGHT LICENSE META NEWS NOTICE EXTRA_DIST += README.md RELEASES.md EXTRA_DIST += module/lua/README.zfs module/os/linux/spl/README.md @@ -51,18 +61,22 @@ EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash.descrip @CODE_COVERAGE_RULES@ GITREV = include/zfs_gitrev.h - -PHONY = gitrev +CLEANFILES += $(GITREV) +PHONY += gitrev gitrev: $(AM_V_GEN)$(top_srcdir)/scripts/make_gitrev.sh $(GITREV) all: gitrev -# Double-colon rules are allowed; there are multiple independent definitions. -maintainer-clean-local:: +PHONY += install-data-hook $(INSTALL_DATA_HOOKS) +install-data-hook: $(INSTALL_DATA_HOOKS) + +PHONY += maintainer-clean-local +maintainer-clean-local: -$(RM) $(GITREV) -distclean-local:: +PHONY += distclean-local +distclean-local: -$(RM) -R autom4te*.cache build -find . \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \ -o -name .pc -o -name .hg -o -name .git \) -prune -o \ @@ -74,43 +88,27 @@ distclean-local:: -o -name '*.gcno' \) \ -type f -delete -all-local: - -[ -x ${top_builddir}/scripts/zfs-tests.sh ] && \ - ${top_builddir}/scripts/zfs-tests.sh -c +PHONY += $(CLEAN_LOCAL) +clean-local: $(CLEAN_LOCAL) + +PHONY += $(ALL_LOCAL) +all-local: $(ALL_LOCAL) dist-hook: - $(AM_V_GEN)$(top_srcdir)/scripts/make_gitrev.sh -D $(distdir) $(GITREV) - $(SED) ${ac_inplace} -e 's/Release:[[:print:]]*/Release: $(RELEASE)/' \ - $(distdir)/META + $(top_srcdir)/scripts/make_gitrev.sh -D $(distdir) $(GITREV) + $(SED) $(ac_inplace) 's/\(Release:[[:space:]]*\).*/\1$(RELEASE)/' $(distdir)/META -if BUILD_LINUX -# For compatibility, create a matching spl-x.y.z directly which contains -# symlinks to the updated header and object file locations. These -# compatibility links will be removed in the next major release. -if CONFIG_KERNEL -install-data-hook: - rm -rf $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ - mkdir $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ - cd $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ - ln -s ../zfs-$(VERSION)/include/spl include && \ - ln -s ../zfs-$(VERSION)/$(LINUX_VERSION) $(LINUX_VERSION) && \ - ln -s ../zfs-$(VERSION)/zfs_config.h.in spl_config.h.in && \ - ln -s ../zfs-$(VERSION)/zfs.release.in spl.release.in && \ - cd $(DESTDIR)$(prefix)/src/zfs-$(VERSION)/$(LINUX_VERSION) && \ - ln -fs zfs_config.h spl_config.h && \ - ln -fs zfs.release spl.release -endif -endif +PHONY += codecheck $(CHECKS) +codecheck: $(CHECKS) -PHONY += codecheck -codecheck: cstyle shellcheck checkbashisms flake8 mancheck testscheck vcscheck zstdcheck +SHELLCHECKSCRIPTS += autogen.sh PHONY += checkstyle checkstyle: codecheck commitcheck PHONY += commitcheck commitcheck: - @if git rev-parse --git-dir > /dev/null 2>&1; then \ + $(AM_V_at)if git rev-parse --git-dir > /dev/null 2>&1; then \ ${top_srcdir}/scripts/commitcheck.sh; \ fi @@ -119,9 +117,9 @@ cstyle_line = -print0 | parallel -X0 ${top_srcdir}/scripts/cstyle.pl -cpP {} else cstyle_line = -exec ${top_srcdir}/scripts/cstyle.pl -cpP {} + endif -PHONY += cstyle +CHECKS += cstyle cstyle: - @find ${top_srcdir} -name build -prune \ + $(AM_V_at)find $(top_srcdir) -name build -prune \ -o -type f -name '*.[hc]' \ ! -name 'zfs_config.*' ! -name '*.mod.c' \ ! -name 'opt_global.h' ! -name '*_if*.h' \ @@ -133,68 +131,41 @@ cstyle: $(cstyle_line) filter_executable = -exec test -x '{}' \; -print - -SHELLCHECKDIRS = cmd contrib etc scripts tests -SHELLCHECKSCRIPTS = autogen.sh - -PHONY += checkabi storeabi - -checkabi: lib - $(MAKE) -C lib checkabi - -storeabi: lib - $(MAKE) -C lib storeabi - -PHONY += mancheck -mancheck: - ${top_srcdir}/scripts/mancheck.sh ${top_srcdir}/man ${top_srcdir}/tests/test-runner/man - -PHONY += testscheck +CHECKS += testscheck testscheck: - @[ $$(find ${top_srcdir}/tests/zfs-tests -type f \ - \( -name '*.ksh' -not ${filter_executable} \) -o \ - \( -name '*.kshlib' ${filter_executable} \) -o \ - \( -name '*.shlib' ${filter_executable} \) -o \ - \( -name '*.cfg' ${filter_executable} \) | \ + $(AM_V_at)[ $$(find $(top_srcdir)/tests/zfs-tests -type f \ + \( -name '*.ksh' -not $(filter_executable) \) -o \ + \( -name '*.kshlib' $(filter_executable) \) -o \ + \( -name '*.shlib' $(filter_executable) \) -o \ + \( -name '*.cfg' $(filter_executable) \) | \ tee /dev/stderr | wc -l) -eq 0 ] -PHONY += vcscheck +CHECKS += vcscheck vcscheck: - @if git rev-parse --git-dir > /dev/null 2>&1; then \ + $(AM_V_at)if git rev-parse --git-dir > /dev/null 2>&1; then \ git ls-files . --exclude-standard --others | \ awk '{c++; print} END {if(c>0) exit 1}' ; \ fi -PHONY += zstdcheck +CHECKS += zstdcheck zstdcheck: - @$(MAKE) -C module/zstd checksymbols + @$(MAKE) -C module check-zstd-symbols PHONY += lint lint: cppcheck paxcheck -CPPCHECKDIRS = cmd lib module -PHONY += cppcheck -cppcheck: $(CPPCHECKDIRS) - @if test -n "$(CPPCHECK)"; then \ - set -e ; for dir in $(CPPCHECKDIRS) ; do \ - $(MAKE) -C $$dir cppcheck ; \ - done \ - else \ - echo "skipping cppcheck because cppcheck is not installed"; \ - fi - PHONY += paxcheck paxcheck: - @if type scanelf > /dev/null 2>&1; then \ - ${top_srcdir}/scripts/paxcheck.sh ${top_builddir}; \ + $(AM_V_at)if type scanelf > /dev/null 2>&1; then \ + $(top_srcdir)/scripts/paxcheck.sh $(top_builddir); \ else \ echo "skipping paxcheck because scanelf is not installed"; \ fi -PHONY += flake8 +CHECKS += flake8 flake8: - @if type flake8 > /dev/null 2>&1; then \ - flake8 ${top_srcdir}; \ + $(AM_V_at)if type flake8 > /dev/null 2>&1; then \ + flake8 $(top_srcdir); \ else \ echo "skipping flake8 because flake8 is not installed"; \ fi diff --git a/sys/contrib/openzfs/autogen.sh b/sys/contrib/openzfs/autogen.sh index 488e913b2bf4..c817090183f1 100755 --- a/sys/contrib/openzfs/autogen.sh +++ b/sys/contrib/openzfs/autogen.sh @@ -1,4 +1,62 @@ #!/bin/sh +[ "${0%/*}" = "$0" ] || cd "${0%/*}" || exit -autoreconf -fiv || exit 1 -rm -Rf autom4te.cache +# %reldir%/%canon_reldir% (%D%/%C%) only appeared in automake 1.14, but RHEL/CentOS 7 has 1.13.4 +# This is an (overly) simplistic preprocessor that papers around this for the duration of the generation step, +# and can be removed once support for CentOS 7 is dropped +automake --version | awk '{print $NF; exit}' | ( + IFS=. read -r AM_MAJ AM_MIN _ + [ "$AM_MAJ" -gt 1 ] || [ "$AM_MIN" -ge 14 ] +) || { + process_root() { + root="$1"; shift + + grep -q '%[CD]%' "$root/Makefile.am" || return + find "$root" -name Makefile.am "$@" | while read -r dir; do + dir="${dir%/Makefile.am}" + grep -q '%[CD]%' "$dir/Makefile.am" || continue + + reldir="${dir#$root}" + reldir="${reldir#/}" + + canon_reldir="$(printf '%s' "$reldir" | tr -C 'a-zA-Z0-9@_' '_')" + + reldir_slash="$reldir/" + canon_reldir_slash="${canon_reldir}_" + [ -z "$reldir" ] && reldir_slash= + [ -z "$reldir" ] && canon_reldir_slash= + + echo "$dir/Makefile.am" >&3 + sed -i~ -e "s:%D%/:$reldir_slash:g" -e "s:%D%:$reldir:g" \ + -e "s:%C%_:$canon_reldir_slash:g" -e "s:%C%:$canon_reldir:g" "$dir/Makefile.am" + done 3>>"$substituted_files" + } + + rollback() { + while read -r f; do + mv "$f~" "$f" + done < "$substituted_files" + rm -f "$substituted_files" + } + + + echo "Automake <1.14; papering over missing %reldir%/%canon_reldir% support" >&2 + + substituted_files="$(mktemp)" + trap rollback EXIT + + roots="$(sed '/Makefile$/!d;/module/d;s:^\s*:./:;s:/Makefile::;/^\.$/d' configure.ac)" + + IFS=" +" + for root in $roots; do + root="${root#./}" + process_root "$root" + done + + set -f + # shellcheck disable=SC2086,SC2046 + process_root . $(printf '!\n-path\n%s/*\n' $roots) +} + +autoreconf -fiv && rm -rf autom4te.cache diff --git a/sys/contrib/openzfs/cmd/Makefile.am b/sys/contrib/openzfs/cmd/Makefile.am index 68f1e892d3f4..9959760b523e 100644 --- a/sys/contrib/openzfs/cmd/Makefile.am +++ b/sys/contrib/openzfs/cmd/Makefile.am @@ -1,27 +1,115 @@ -include $(top_srcdir)/config/Shellcheck.am +bin_SCRIPTS = +bin_PROGRAMS = +sbin_SCRIPTS = +sbin_PROGRAMS = +dist_bin_SCRIPTS = +zfsexec_PROGRAMS = +mounthelper_PROGRAMS = -SUBDIRS = zfs zpool zdb zhack zinject zstream ztest -SUBDIRS += fsck_zfs vdev_id raidz_test zfs_ids_to_path -SUBDIRS += zpool_influxdb -CPPCHECKDIRS = zfs zpool zdb zhack zinject zstream ztest -CPPCHECKDIRS += raidz_test zfs_ids_to_path zpool_influxdb +sbin_SCRIPTS += fsck.zfs +SHELLCHECKSCRIPTS += fsck.zfs +CLEANFILES += fsck.zfs +EXTRA_DIST += %D%/fsck.zfs.in +$(call SUBST,fsck.zfs,%D%/) -# TODO: #12084: SHELLCHECKDIRS += vdev_id -SHELLCHECKDIRS = fsck_zfs zed zpool zvol_wait -if USING_PYTHON -SUBDIRS += arcstat arc_summary dbufstat -endif +sbin_PROGRAMS += zfs_ids_to_path +CPPCHECKTARGETS += zfs_ids_to_path + +zfs_ids_to_path_SOURCES = \ + %D%/zfs_ids_to_path.c + +zfs_ids_to_path_LDADD = \ + libzfs.la + + +zhack_CPPFLAGS = $(AM_CPPFLAGS) $(FORCEDEBUG_CPPFLAGS) + +sbin_PROGRAMS += zhack +CPPCHECKTARGETS += zhack + +zhack_SOURCES = \ + %D%/zhack.c + +zhack_LDADD = \ + libzpool.la \ + libzfs_core.la \ + libnvpair.la + + +ztest_CFLAGS = $(AM_CFLAGS) $(KERNEL_CFLAGS) +# Get rid of compiler warning for unchecked truncating snprintfs on gcc 7.1.1 +ztest_CFLAGS += $(NO_FORMAT_TRUNCATION) +ztest_CPPFLAGS = $(AM_CPPFLAGS) $(FORCEDEBUG_CPPFLAGS) + +sbin_PROGRAMS += ztest +CPPCHECKTARGETS += ztest + +ztest_SOURCES = \ + %D%/ztest.c + +ztest_LDADD = \ + libzpool.la \ + libzfs_core.la \ + libnvpair.la + +ztest_LDADD += -lm +ztest_LDFLAGS = -pthread + + +include $(srcdir)/%D%/raidz_test/Makefile.am +include $(srcdir)/%D%/zdb/Makefile.am +include $(srcdir)/%D%/zfs/Makefile.am +include $(srcdir)/%D%/zinject/Makefile.am +include $(srcdir)/%D%/zpool/Makefile.am +include $(srcdir)/%D%/zpool_influxdb/Makefile.am +include $(srcdir)/%D%/zstream/Makefile.am + if BUILD_LINUX -SUBDIRS += mount_zfs zed zgenhostid zvol_id zvol_wait -CPPCHECKDIRS += mount_zfs zed zgenhostid zvol_id -SHELLCHECKDIRS += zed +mounthelper_PROGRAMS += mount.zfs +CPPCHECKTARGETS += mount.zfs + +mount_zfs_SOURCES = \ + %D%/mount_zfs.c + +mount_zfs_LDADD = \ + libzfs.la \ + libzfs_core.la \ + libnvpair.la + +mount_zfs_LDADD += $(LTLIBINTL) + +CPPCHECKTARGETS += raidz_test + + +sbin_PROGRAMS += zgenhostid +CPPCHECKTARGETS += zgenhostid + +zgenhostid_SOURCES = \ + %D%/zgenhostid.c + + +dist_bin_SCRIPTS += %D%/zvol_wait +SHELLCHECKSCRIPTS += %D%/zvol_wait + + +include $(srcdir)/%D%/zed/Makefile.am +endif + + +if USING_PYTHON +bin_SCRIPTS += arc_summary arcstat dbufstat +CLEANFILES += arc_summary arcstat dbufstat +EXTRA_DIST += %D%/arc_summary %D%/arcstat.in %D%/dbufstat.in + +$(call SUBST,arcstat,%D%/) +$(call SUBST,dbufstat,%D%/) +arc_summary: %D%/arc_summary + $(AM_V_at)cp $< $@ endif -PHONY = cppcheck -cppcheck: $(CPPCHECKDIRS) - set -e ; for dir in $(CPPCHECKDIRS) ; do \ - $(MAKE) -C $$dir cppcheck ; \ - done + +PHONY += cmd +cmd: $(bin_SCRIPTS) $(bin_PROGRAMS) $(sbin_SCRIPTS) $(sbin_PROGRAMS) $(dist_bin_SCRIPTS) $(zfsexec_PROGRAMS) $(mounthelper_PROGRAMS) diff --git a/sys/contrib/openzfs/cmd/arc_summary/arc_summary3 b/sys/contrib/openzfs/cmd/arc_summary index 4f275813d973..4f275813d973 100755 --- a/sys/contrib/openzfs/cmd/arc_summary/arc_summary3 +++ b/sys/contrib/openzfs/cmd/arc_summary diff --git a/sys/contrib/openzfs/cmd/arc_summary/.gitignore b/sys/contrib/openzfs/cmd/arc_summary/.gitignore deleted file mode 100644 index 50ba15f034e2..000000000000 --- a/sys/contrib/openzfs/cmd/arc_summary/.gitignore +++ /dev/null @@ -1 +0,0 @@ -arc_summary diff --git a/sys/contrib/openzfs/cmd/arc_summary/Makefile.am b/sys/contrib/openzfs/cmd/arc_summary/Makefile.am deleted file mode 100644 index f419f07e0eda..000000000000 --- a/sys/contrib/openzfs/cmd/arc_summary/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -bin_SCRIPTS = arc_summary - -CLEANFILES = arc_summary -EXTRA_DIST = arc_summary3 -SCRIPT = arc_summary3 - -arc_summary: $(SCRIPT) - cp $< $@ diff --git a/sys/contrib/openzfs/cmd/arcstat/arcstat.in b/sys/contrib/openzfs/cmd/arcstat.in index 9327f644f544..9327f644f544 100755 --- a/sys/contrib/openzfs/cmd/arcstat/arcstat.in +++ b/sys/contrib/openzfs/cmd/arcstat.in diff --git a/sys/contrib/openzfs/cmd/arcstat/.gitignore b/sys/contrib/openzfs/cmd/arcstat/.gitignore deleted file mode 100644 index 6d6cd1ab75fc..000000000000 --- a/sys/contrib/openzfs/cmd/arcstat/.gitignore +++ /dev/null @@ -1 +0,0 @@ -arcstat diff --git a/sys/contrib/openzfs/cmd/arcstat/Makefile.am b/sys/contrib/openzfs/cmd/arcstat/Makefile.am deleted file mode 100644 index d1ba989a0cd8..000000000000 --- a/sys/contrib/openzfs/cmd/arcstat/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am - -bin_SCRIPTS = arcstat - -SUBSTFILES += $(bin_SCRIPTS) diff --git a/sys/contrib/openzfs/cmd/dbufstat/dbufstat.in b/sys/contrib/openzfs/cmd/dbufstat.in index b716a0c9749b..b716a0c9749b 100755 --- a/sys/contrib/openzfs/cmd/dbufstat/dbufstat.in +++ b/sys/contrib/openzfs/cmd/dbufstat.in diff --git a/sys/contrib/openzfs/cmd/dbufstat/.gitignore b/sys/contrib/openzfs/cmd/dbufstat/.gitignore deleted file mode 100644 index 2c2e913cef70..000000000000 --- a/sys/contrib/openzfs/cmd/dbufstat/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dbufstat diff --git a/sys/contrib/openzfs/cmd/dbufstat/Makefile.am b/sys/contrib/openzfs/cmd/dbufstat/Makefile.am deleted file mode 100644 index e672a01a4227..000000000000 --- a/sys/contrib/openzfs/cmd/dbufstat/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am - -bin_SCRIPTS = dbufstat - -SUBSTFILES += $(bin_SCRIPTS) diff --git a/sys/contrib/openzfs/cmd/fsck_zfs/fsck.zfs.in b/sys/contrib/openzfs/cmd/fsck.zfs.in index 37096902cb94..f0d4d2ec38ca 100755 --- a/sys/contrib/openzfs/cmd/fsck_zfs/fsck.zfs.in +++ b/sys/contrib/openzfs/cmd/fsck.zfs.in @@ -7,13 +7,13 @@ # see fsck.zfs(8) # -if [ "$#" = "0" ]; then +if [ $# -eq 0 ]; then echo "Usage: $0 [options] dataset…" >&2 exit 16 fi ret=0 -for dataset in "$@"; do +for dataset; do case "$dataset" in -*) continue diff --git a/sys/contrib/openzfs/cmd/fsck_zfs/.gitignore b/sys/contrib/openzfs/cmd/fsck_zfs/.gitignore deleted file mode 100644 index 0edf0309e94a..000000000000 --- a/sys/contrib/openzfs/cmd/fsck_zfs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/fsck.zfs diff --git a/sys/contrib/openzfs/cmd/fsck_zfs/Makefile.am b/sys/contrib/openzfs/cmd/fsck_zfs/Makefile.am deleted file mode 100644 index ec955c7c7ff9..000000000000 --- a/sys/contrib/openzfs/cmd/fsck_zfs/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -dist_sbin_SCRIPTS = fsck.zfs - -SUBSTFILES += $(dist_sbin_SCRIPTS) - diff --git a/sys/contrib/openzfs/cmd/mount_zfs/mount_zfs.c b/sys/contrib/openzfs/cmd/mount_zfs.c index 669ed88f91c4..669ed88f91c4 100644 --- a/sys/contrib/openzfs/cmd/mount_zfs/mount_zfs.c +++ b/sys/contrib/openzfs/cmd/mount_zfs.c diff --git a/sys/contrib/openzfs/cmd/mount_zfs/.gitignore b/sys/contrib/openzfs/cmd/mount_zfs/.gitignore deleted file mode 100644 index cd9254bde3da..000000000000 --- a/sys/contrib/openzfs/cmd/mount_zfs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -mount.zfs diff --git a/sys/contrib/openzfs/cmd/mount_zfs/Makefile.am b/sys/contrib/openzfs/cmd/mount_zfs/Makefile.am deleted file mode 100644 index 3957602d27ad..000000000000 --- a/sys/contrib/openzfs/cmd/mount_zfs/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -# -# Ignore the prefix for the mount helper. It must be installed in /sbin/ -# because this path is hardcoded in the mount(8) for security reasons. -# However, if needed, the configure option --with-mounthelperdir= can be used -# to override the default install location. -# -sbindir=$(mounthelperdir) -sbin_PROGRAMS = mount.zfs - -mount_zfs_SOURCES = \ - mount_zfs.c - -mount_zfs_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la - -mount_zfs_LDADD += $(LTLIBINTL) - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/raidz_test/.gitignore b/sys/contrib/openzfs/cmd/raidz_test/.gitignore deleted file mode 100644 index f8b83d9cce03..000000000000 --- a/sys/contrib/openzfs/cmd/raidz_test/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/raidz_test diff --git a/sys/contrib/openzfs/cmd/raidz_test/Makefile.am b/sys/contrib/openzfs/cmd/raidz_test/Makefile.am index 983ff25dc92a..3b8b60568323 100644 --- a/sys/contrib/openzfs/cmd/raidz_test/Makefile.am +++ b/sys/contrib/openzfs/cmd/raidz_test/Makefile.am @@ -1,22 +1,16 @@ -include $(top_srcdir)/config/Rules.am +raidz_test_CFLAGS = $(AM_CFLAGS) $(KERNEL_CFLAGS) +raidz_test_CPPFLAGS = $(AM_CPPFLAGS) $(FORCEDEBUG_CPPFLAGS) -# Includes kernel code, generate warnings for large stack frames -AM_CFLAGS += $(FRAME_LARGER_THAN) - -# Unconditionally enable ASSERTs -AM_CPPFLAGS += -DDEBUG -UNDEBUG -DZFS_DEBUG - -bin_PROGRAMS = raidz_test +bin_PROGRAMS += raidz_test +CPPCHECKTARGETS += raidz_test raidz_test_SOURCES = \ - raidz_test.h \ - raidz_test.c \ - raidz_bench.c + %D%/raidz_bench.c \ + %D%/raidz_test.c \ + %D%/raidz_test.h raidz_test_LDADD = \ - $(abs_top_builddir)/lib/libzpool/libzpool.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la + libzpool.la \ + libzfs_core.la raidz_test_LDADD += -lm - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/vdev_id/Makefile.am b/sys/contrib/openzfs/cmd/vdev_id/Makefile.am deleted file mode 100644 index 4071c6d5ed6b..000000000000 --- a/sys/contrib/openzfs/cmd/vdev_id/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -include $(top_srcdir)/config/Shellcheck.am - -dist_udev_SCRIPTS = vdev_id diff --git a/sys/contrib/openzfs/cmd/zdb/.gitignore b/sys/contrib/openzfs/cmd/zdb/.gitignore deleted file mode 100644 index f64a3fc5a160..000000000000 --- a/sys/contrib/openzfs/cmd/zdb/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zdb diff --git a/sys/contrib/openzfs/cmd/zdb/Makefile.am b/sys/contrib/openzfs/cmd/zdb/Makefile.am index c5858c298053..b80f38b3fd57 100644 --- a/sys/contrib/openzfs/cmd/zdb/Makefile.am +++ b/sys/contrib/openzfs/cmd/zdb/Makefile.am @@ -1,18 +1,14 @@ -include $(top_srcdir)/config/Rules.am +zdb_CPPFLAGS = $(AM_CPPFLAGS) $(FORCEDEBUG_CPPFLAGS) -# Unconditionally enable debugging for zdb -AM_CPPFLAGS += -DDEBUG -UNDEBUG -DZFS_DEBUG - -sbin_PROGRAMS = zdb +sbin_PROGRAMS += zdb +CPPCHECKTARGETS += zdb zdb_SOURCES = \ - zdb.c \ - zdb_il.c \ - zdb.h + %D%/zdb.c \ + %D%/zdb.h \ + %D%/zdb_il.c zdb_LDADD = \ - $(abs_top_builddir)/lib/libzpool/libzpool.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la - -include $(top_srcdir)/config/CppCheck.am + libzpool.la \ + libzfs_core.la \ + libnvpair.la diff --git a/sys/contrib/openzfs/cmd/zdb/zdb.c b/sys/contrib/openzfs/cmd/zdb/zdb.c index f18c9fd6b930..3d4d956e5698 100644 --- a/sys/contrib/openzfs/cmd/zdb/zdb.c +++ b/sys/contrib/openzfs/cmd/zdb/zdb.c @@ -3926,7 +3926,7 @@ dump_uberblock(uberblock_t *ub, const char *header, const char *footer) (void) printf("\ttxg = %llu\n", (u_longlong_t)ub->ub_txg); (void) printf("\tguid_sum = %llu\n", (u_longlong_t)ub->ub_guid_sum); (void) printf("\ttimestamp = %llu UTC = %s", - (u_longlong_t)ub->ub_timestamp, asctime(localtime(×tamp))); + (u_longlong_t)ub->ub_timestamp, ctime(×tamp)); (void) printf("\tmmp_magic = %016llx\n", (u_longlong_t)ub->ub_mmp_magic); @@ -8405,7 +8405,6 @@ int main(int argc, char **argv) { int c; - struct rlimit rl = { 1024, 1024 }; spa_t *spa = NULL; objset_t *os = NULL; int dump_all = 1; @@ -8424,9 +8423,6 @@ main(int argc, char **argv) boolean_t target_is_spa = B_TRUE, dataset_lookup = B_FALSE; nvlist_t *cfg = NULL; - (void) setrlimit(RLIMIT_NOFILE, &rl); - (void) enable_extended_FILE_stdio(-1, -1); - dprintf_setup(&argc, argv); /* diff --git a/sys/contrib/openzfs/cmd/zed/Makefile.am b/sys/contrib/openzfs/cmd/zed/Makefile.am index 7b662994d1c6..6eea1a135f56 100644 --- a/sys/contrib/openzfs/cmd/zed/Makefile.am +++ b/sys/contrib/openzfs/cmd/zed/Makefile.am @@ -1,53 +1,46 @@ -include $(top_srcdir)/config/Rules.am -include $(top_srcdir)/config/Shellcheck.am - -AM_CFLAGS += $(LIBUDEV_CFLAGS) $(LIBUUID_CFLAGS) - -SUBDIRS = zed.d -SHELLCHECKDIRS = $(SUBDIRS) - -sbin_PROGRAMS = zed - -ZED_SRC = \ - zed.c \ - zed.h \ - zed_conf.c \ - zed_conf.h \ - zed_disk_event.c \ - zed_disk_event.h \ - zed_event.c \ - zed_event.h \ - zed_exec.c \ - zed_exec.h \ - zed_file.c \ - zed_file.h \ - zed_log.c \ - zed_log.h \ - zed_strings.c \ - zed_strings.h - -FMA_SRC = \ - agents/zfs_agents.c \ - agents/zfs_agents.h \ - agents/zfs_diagnosis.c \ - agents/zfs_mod.c \ - agents/zfs_retire.c \ - agents/fmd_api.c \ - agents/fmd_api.h \ - agents/fmd_serd.c \ - agents/fmd_serd.h - -zed_SOURCES = $(ZED_SRC) $(FMA_SRC) +include $(srcdir)/%D%/zed.d/Makefile.am + +zed_CFLAGS = $(AM_CFLAGS) +zed_CFLAGS += $(LIBUDEV_CFLAGS) $(LIBUUID_CFLAGS) + +sbin_PROGRAMS += zed +CPPCHECKTARGETS += zed + +zed_SOURCES = \ + %D%/zed.c \ + %D%/zed.h \ + %D%/zed_conf.c \ + %D%/zed_conf.h \ + %D%/zed_disk_event.c \ + %D%/zed_disk_event.h \ + %D%/zed_event.c \ + %D%/zed_event.h \ + %D%/zed_exec.c \ + %D%/zed_exec.h \ + %D%/zed_file.c \ + %D%/zed_file.h \ + %D%/zed_log.c \ + %D%/zed_log.h \ + %D%/zed_strings.c \ + %D%/zed_strings.h \ + \ + %D%/agents/fmd_api.c \ + %D%/agents/fmd_api.h \ + %D%/agents/fmd_serd.c \ + %D%/agents/fmd_serd.h \ + %D%/agents/zfs_agents.c \ + %D%/agents/zfs_agents.h \ + %D%/agents/zfs_diagnosis.c \ + %D%/agents/zfs_mod.c \ + %D%/agents/zfs_retire.c zed_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la \ - $(abs_top_builddir)/lib/libuutil/libuutil.la + libzfs.la \ + libzfs_core.la \ + libnvpair.la \ + libuutil.la zed_LDADD += -lrt $(LIBATOMIC_LIBS) $(LIBUDEV_LIBS) $(LIBUUID_LIBS) zed_LDFLAGS = -pthread -EXTRA_DIST = agents/README.md - -include $(top_srcdir)/config/CppCheck.am +EXTRA_DIST += $(addprefix %D%/,agents/README.md) diff --git a/sys/contrib/openzfs/cmd/zed/zed.d/Makefile.am b/sys/contrib/openzfs/cmd/zed/zed.d/Makefile.am index 3c0f5c3dd1b2..122d2c0c51bc 100644 --- a/sys/contrib/openzfs/cmd/zed/zed.d/Makefile.am +++ b/sys/contrib/openzfs/cmd/zed/zed.d/Makefile.am @@ -1,36 +1,27 @@ -include $(top_srcdir)/config/Rules.am -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -EXTRA_DIST += README - zedconfdir = $(sysconfdir)/zfs/zed.d - dist_zedconf_DATA = \ - zed-functions.sh \ - zed.rc - -SHELLCHECKSCRIPTS = zed-functions.sh zed.rc -SHELLCHECK_SHELL = sh + %D%/zed-functions.sh \ + %D%/zed.rc zedexecdir = $(zfsexecdir)/zed.d dist_zedexec_SCRIPTS = \ - all-debug.sh \ - all-syslog.sh \ - data-notify.sh \ - generic-notify.sh \ - resilver_finish-notify.sh \ - scrub_finish-notify.sh \ - statechange-led.sh \ - statechange-notify.sh \ - vdev_clear-led.sh \ - vdev_attach-led.sh \ - pool_import-led.sh \ - resilver_finish-start-scrub.sh \ - trim_finish-notify.sh - -nodist_zedexec_SCRIPTS = history_event-zfs-list-cacher.sh + %D%/all-debug.sh \ + %D%/all-syslog.sh \ + %D%/data-notify.sh \ + %D%/generic-notify.sh \ + %D%/pool_import-led.sh \ + %D%/resilver_finish-notify.sh \ + %D%/resilver_finish-start-scrub.sh \ + %D%/scrub_finish-notify.sh \ + %D%/statechange-led.sh \ + %D%/statechange-notify.sh \ + %D%/trim_finish-notify.sh \ + %D%/vdev_attach-led.sh \ + %D%/vdev_clear-led.sh + +nodist_zedexec_SCRIPTS = \ + %D%/history_event-zfs-list-cacher.sh SUBSTFILES += $(nodist_zedexec_SCRIPTS) @@ -38,23 +29,27 @@ zedconfdefaults = \ all-syslog.sh \ data-notify.sh \ history_event-zfs-list-cacher.sh \ + pool_import-led.sh \ resilver_finish-notify.sh \ + resilver_finish-start-scrub.sh \ scrub_finish-notify.sh \ statechange-led.sh \ statechange-notify.sh \ - vdev_clear-led.sh \ vdev_attach-led.sh \ - pool_import-led.sh \ - resilver_finish-start-scrub.sh + vdev_clear-led.sh + +EXTRA_DIST += $(addprefix %D%/,README) -install-data-hook: +INSTALL_DATA_HOOKS += zed-install-data-hook +zed-install-data-hook: $(MKDIR_P) "$(DESTDIR)$(zedconfdir)" - for f in $(zedconfdefaults); do \ - test -f "$(DESTDIR)$(zedconfdir)/$${f}" -o \ - -L "$(DESTDIR)$(zedconfdir)/$${f}" || \ - ln -s "$(zedexecdir)/$${f}" "$(DESTDIR)$(zedconfdir)"; \ + set -x; for f in $(zedconfdefaults); do \ + [ -f "$(DESTDIR)$(zedconfdir)/$${f}" ] ||\ + [ -L "$(DESTDIR)$(zedconfdir)/$${f}" ] || \ + $(LN_S) "$(zedexecdir)/$${f}" "$(DESTDIR)$(zedconfdir)"; \ done - chmod 0600 "$(DESTDIR)$(zedconfdir)/zed.rc" +SHELLCHECKSCRIPTS += $(dist_zedconf_DATA) $(dist_zedexec_SCRIPTS) $(nodist_zedexec_SCRIPTS) +$(call SHELLCHECK_OPTS,$(dist_zedconf_DATA) $(dist_zedexec_SCRIPTS) $(nodist_zedexec_SCRIPTS)): SHELLCHECK_SHELL = sh # False positive: 1>&"${ZED_FLOCK_FD}" looks suspiciously similar to a >&filename bash extension -CHECKBASHISMS_IGNORE = -e 'should be >word 2>&1' -e '&"$${ZED_FLOCK_FD}"' +$(call SHELLCHECK_OPTS,$(dist_zedconf_DATA) $(dist_zedexec_SCRIPTS) $(nodist_zedexec_SCRIPTS)): CHECKBASHISMS_IGNORE = -e 'should be >word 2>&1' -e '&"$${ZED_FLOCK_FD}"' diff --git a/sys/contrib/openzfs/cmd/zed/zed.d/all-debug.sh b/sys/contrib/openzfs/cmd/zed/zed.d/all-debug.sh index ba19b96b082f..9794cf26ce76 100755 --- a/sys/contrib/openzfs/cmd/zed/zed.d/all-debug.sh +++ b/sys/contrib/openzfs/cmd/zed/zed.d/all-debug.sh @@ -15,7 +15,7 @@ zed_exit_if_ignoring_this_event zed_lock "${ZED_DEBUG_LOG}" { - printenv | sort + env | sort echo } 1>&"${ZED_FLOCK_FD}" zed_unlock "${ZED_DEBUG_LOG}" diff --git a/sys/contrib/openzfs/cmd/zed/zed.d/zed-functions.sh b/sys/contrib/openzfs/cmd/zed/zed.d/zed-functions.sh index e6d3ce9ecc49..70a7113c6580 100644 --- a/sys/contrib/openzfs/cmd/zed/zed.d/zed-functions.sh +++ b/sys/contrib/openzfs/cmd/zed/zed.d/zed-functions.sh @@ -76,8 +76,7 @@ zed_log_msg() # zed_log_err() { - logger -p "${ZED_SYSLOG_PRIORITY}" -t "${ZED_SYSLOG_TAG}" -- "error:" \ - "${0##*/}:""${ZEVENT_EID:+" eid=${ZEVENT_EID}:"}" "$@" + zed_log_msg "error: ${0##*/}:""${ZEVENT_EID:+" eid=${ZEVENT_EID}:"}" "$@" } diff --git a/sys/contrib/openzfs/cmd/zed/zed.d/zed.rc b/sys/contrib/openzfs/cmd/zed/zed.d/zed.rc index a8fdc86c3431..3c58a2c281f5 100644 --- a/sys/contrib/openzfs/cmd/zed/zed.d/zed.rc +++ b/sys/contrib/openzfs/cmd/zed/zed.d/zed.rc @@ -1,7 +1,5 @@ ## -# zed.rc -# -# This file should be owned by root and permissioned 0600. +# zed.rc – ZEDLET configuration. ## # shellcheck disable=SC2034 diff --git a/sys/contrib/openzfs/cmd/zed/zed_event.c b/sys/contrib/openzfs/cmd/zed/zed_event.c index 9eaad0e92fbb..d5cafdaff061 100644 --- a/sys/contrib/openzfs/cmd/zed/zed_event.c +++ b/sys/contrib/openzfs/cmd/zed/zed_event.c @@ -884,21 +884,21 @@ _zed_event_get_subclass(const char *class) static void _zed_event_add_time_strings(uint64_t eid, zed_strings_t *zsp, int64_t etime[]) { - struct tm *stp; + struct tm stp; char buf[32]; assert(zsp != NULL); assert(etime != NULL); _zed_event_add_var(eid, zsp, ZEVENT_VAR_PREFIX, "TIME_SECS", - "%lld", (long long int) etime[0]); + "%" PRId64, etime[0]); _zed_event_add_var(eid, zsp, ZEVENT_VAR_PREFIX, "TIME_NSECS", - "%lld", (long long int) etime[1]); + "%" PRId64, etime[1]); - if (!(stp = localtime((const time_t *) &etime[0]))) { + if (!localtime_r((const time_t *) &etime[0], &stp)) { zed_log_msg(LOG_WARNING, "Failed to add %s%s for eid=%llu: %s", ZEVENT_VAR_PREFIX, "TIME_STRING", eid, "localtime error"); - } else if (!strftime(buf, sizeof (buf), "%Y-%m-%d %H:%M:%S%z", stp)) { + } else if (!strftime(buf, sizeof (buf), "%Y-%m-%d %H:%M:%S%z", &stp)) { zed_log_msg(LOG_WARNING, "Failed to add %s%s for eid=%llu: %s", ZEVENT_VAR_PREFIX, "TIME_STRING", eid, "strftime error"); } else { diff --git a/sys/contrib/openzfs/cmd/zfs/.gitignore b/sys/contrib/openzfs/cmd/zfs/.gitignore deleted file mode 100644 index 0fd9cc63af2a..000000000000 --- a/sys/contrib/openzfs/cmd/zfs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zfs diff --git a/sys/contrib/openzfs/cmd/zfs/Makefile.am b/sys/contrib/openzfs/cmd/zfs/Makefile.am index 1ead457f0f29..8a3c13a1fcfe 100644 --- a/sys/contrib/openzfs/cmd/zfs/Makefile.am +++ b/sys/contrib/openzfs/cmd/zfs/Makefile.am @@ -1,25 +1,22 @@ -include $(top_srcdir)/config/Rules.am - -sbin_PROGRAMS = zfs +sbin_PROGRAMS += zfs +CPPCHECKTARGETS += zfs zfs_SOURCES = \ - zfs_iter.c \ - zfs_iter.h \ - zfs_main.c \ - zfs_util.h \ - zfs_project.c \ - zfs_projectutil.h + %D%/zfs_iter.c \ + %D%/zfs_iter.h \ + %D%/zfs_main.c \ + %D%/zfs_project.c \ + %D%/zfs_projectutil.h \ + %D%/zfs_util.h zfs_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la \ - $(abs_top_builddir)/lib/libuutil/libuutil.la + libzfs.la \ + libzfs_core.la \ + libnvpair.la \ + libuutil.la zfs_LDADD += $(LTLIBINTL) if BUILD_FREEBSD zfs_LDADD += -lgeom -ljail endif - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/zfs/zfs_main.c b/sys/contrib/openzfs/cmd/zfs/zfs_main.c index b153d217df1a..69f5bdf4d494 100644 --- a/sys/contrib/openzfs/cmd/zfs/zfs_main.c +++ b/sys/contrib/openzfs/cmd/zfs/zfs_main.c @@ -315,9 +315,9 @@ get_usage(zfs_help_t idx) case HELP_ROLLBACK: return (gettext("\trollback [-rRf] <snapshot>\n")); case HELP_SEND: - return (gettext("\tsend [-DnPpRvLecwhb] " - "[-X dataset[,dataset]...] " - "[-[i|I] snapshot] <snapshot>\n" + return (gettext("\tsend [-DLPbcehnpsvw] " + "[-i|-I snapshot]\n" + "\t [-R [-X dataset[,dataset]...]] <snapshot>\n" "\tsend [-DnvPLecw] [-i snapshot|bookmark] " "<filesystem|volume|snapshot>\n" "\tsend [-DnPpvLec] [-i bookmark|snapshot] " @@ -486,10 +486,7 @@ usage_prop_cb(int prop, void *cb) else (void) fprintf(fp, " NO "); - if (zfs_prop_values(prop) == NULL) - (void) fprintf(fp, "-\n"); - else - (void) fprintf(fp, "%s\n", zfs_prop_values(prop)); + (void) fprintf(fp, "%s\n", zfs_prop_values(prop) ?: "-"); return (ZPROP_CONT); } @@ -767,12 +764,12 @@ zfs_mount_and_share(libzfs_handle_t *hdl, const char *dataset, zfs_type_t type) (void) fprintf(stderr, gettext("filesystem " "successfully created, but not mounted\n")); ret = 1; - } else if (zfs_share(zhp) != 0) { + } else if (zfs_share(zhp, NULL) != 0) { (void) fprintf(stderr, gettext("filesystem " "successfully created, but not shared\n")); ret = 1; } - zfs_commit_all_shares(); + zfs_commit_shares(NULL); } zfs_close(zhp); @@ -4318,73 +4315,27 @@ usage: return (-1); } +/* + * Array of prefixes to exclude – + * a linear search, even if executed for each dataset, + * is plenty good enough. + */ typedef struct zfs_send_exclude_arg { size_t count; - char **list; + const char **list; } zfs_send_exclude_arg_t; -/* - * This function creates the zfs_send_exclude_arg_t - * object described above; it can be called multiple - * times, and the input can be comma-separated. - * This is NOT the most efficient data layout; however, - * I couldn't think of a non-pathological case where - * it should have more than a couple dozen instances - * of excludes. If that turns out to be used in - * practice, we might want to instead use a tree. - */ -static void -add_dataset_excludes(char *exclude, zfs_send_exclude_arg_t *context) -{ - char *tok; - while ((tok = strsep(&exclude, ",")) != NULL) { - if (!zfs_name_valid(tok, ZFS_TYPE_DATASET) || - strchr(tok, '/') == NULL) { - (void) fprintf(stderr, gettext("-X %s: " - "not a valid non-root dataset name.\n"), tok); - usage(B_FALSE); - } - context->list = safe_realloc(context->list, - (sizeof (char *)) * (context->count + 1)); - context->list[context->count++] = tok; - } -} - -static void -free_dataset_excludes(zfs_send_exclude_arg_t *exclude_list) -{ - free(exclude_list->list); -} - -/* - * This is the call back used by zfs_send to - * determine if a dataset should be skipped. - * As stated above, this is not the most efficient - * data structure to use, but as long as the - * number of excluded datasets is relatively - * small (a couple of dozen or so), it won't - * have a big impact on performance on modern - * processors. Since it's excluding hierarchies, - * we'd probably want to move to a more complex - * tree structure in that case. - */ static boolean_t zfs_do_send_exclude(zfs_handle_t *zhp, void *context) { - zfs_send_exclude_arg_t *exclude = context; + zfs_send_exclude_arg_t *excludes = context; const char *name = zfs_get_name(zhp); - for (size_t indx = 0; indx < exclude->count; indx++) { - char *exclude_name = exclude->list[indx]; - size_t len = strlen(exclude_name); - /* If it's shorter, it can't possibly match */ - if (strlen(name) < len) - continue; - if (strncmp(name, exclude_name, len) == 0 && - (name[len] == '/' || name[len] == '\0' || - name[len] == '@')) { + for (size_t i = 0; i < excludes->count; ++i) { + size_t len = strlen(excludes->list[i]); + if (strncmp(name, excludes->list[i], len) == 0 && + memchr("/@", name[len], sizeof ("/@"))) return (B_FALSE); - } } return (B_TRUE); @@ -4405,11 +4356,11 @@ zfs_do_send(int argc, char **argv) int c, err; nvlist_t *dbgnv = NULL; char *redactbook = NULL; - zfs_send_exclude_arg_t exclude_context = { 0 }; + zfs_send_exclude_arg_t excludes = { 0 }; struct option long_options[] = { {"replicate", no_argument, NULL, 'R'}, - {"skip-missing", no_argument, NULL, 's'}, + {"skip-missing", no_argument, NULL, 's'}, {"redact", required_argument, NULL, 'd'}, {"props", no_argument, NULL, 'p'}, {"parsable", no_argument, NULL, 'P'}, @@ -4433,7 +4384,18 @@ zfs_do_send(int argc, char **argv) long_options, NULL)) != -1) { switch (c) { case 'X': - add_dataset_excludes(optarg, &exclude_context); + for (char *ds; (ds = strsep(&optarg, ",")) != NULL; ) { + if (!zfs_name_valid(ds, ZFS_TYPE_DATASET) || + strchr(ds, '/') == NULL) { + (void) fprintf(stderr, gettext("-X %s: " + "not a valid non-root dataset name" + ".\n"), ds); + usage(B_FALSE); + } + excludes.list = safe_realloc(excludes.list, + sizeof (char *) * (excludes.count + 1)); + excludes.list[excludes.count++] = ds; + } break; case 'i': if (fromname) @@ -4544,7 +4506,7 @@ zfs_do_send(int argc, char **argv) if (flags.parsable && flags.verbosity == 0) flags.verbosity = 1; - if (exclude_context.count > 0 && !flags.replicate) { + if (excludes.count > 0 && !flags.replicate) { (void) fprintf(stderr, gettext("Cannot specify " "dataset exclusion (-X) on a non-recursive " "send.\n")); @@ -4733,10 +4695,8 @@ zfs_do_send(int argc, char **argv) flags.doall = B_TRUE; err = zfs_send(zhp, fromname, toname, &flags, STDOUT_FILENO, - exclude_context.count > 0 ? zfs_do_send_exclude : NULL, - &exclude_context, flags.verbosity >= 3 ? &dbgnv : NULL); - - free_dataset_excludes(&exclude_context); + excludes.count > 0 ? zfs_do_send_exclude : NULL, + &excludes, flags.verbosity >= 3 ? &dbgnv : NULL); if (flags.verbosity >= 3 && dbgnv != NULL) { /* @@ -4748,8 +4708,9 @@ zfs_do_send(int argc, char **argv) dump_nvlist(dbgnv, 0); nvlist_free(dbgnv); } - zfs_close(zhp); + zfs_close(zhp); + free(excludes.list); return (err != 0); } @@ -5473,8 +5434,6 @@ parse_fs_perm_set(fs_perm_set_t *fspset, nvlist_t *nvl) data_type_t type = nvpair_type(nvp); fs_perm_t *fsperm = NULL; fs_perm_node_t *node = safe_malloc(sizeof (fs_perm_node_t)); - if (node == NULL) - nomem(); fsperm = &node->fspn_fsperm; @@ -6536,13 +6495,10 @@ holds_callback(zfs_handle_t *zhp, void *data) static int zfs_do_holds(int argc, char **argv) { - int errors = 0; int c; - int i; + boolean_t errors = B_FALSE; boolean_t scripted = B_FALSE; boolean_t recursive = B_FALSE; - const char *opts = "rH"; - nvlist_t *nvl; int types = ZFS_TYPE_SNAPSHOT; holds_cbdata_t cb = { 0 }; @@ -6552,7 +6508,7 @@ zfs_do_holds(int argc, char **argv) int flags = 0; /* check options */ - while ((c = getopt(argc, argv, opts)) != -1) { + while ((c = getopt(argc, argv, "rH")) != -1) { switch (c) { case 'r': recursive = B_TRUE; @@ -6579,10 +6535,9 @@ zfs_do_holds(int argc, char **argv) if (argc < 1) usage(B_FALSE); - if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0) - nomem(); + nvlist_t *nvl = fnvlist_alloc(); - for (i = 0; i < argc; ++i) { + for (int i = 0; i < argc; ++i) { char *snapshot = argv[i]; const char *delim; const char *snapname; @@ -6591,7 +6546,7 @@ zfs_do_holds(int argc, char **argv) if (delim == NULL) { (void) fprintf(stderr, gettext("'%s' is not a snapshot\n"), snapshot); - ++errors; + errors = B_TRUE; continue; } snapname = delim + 1; @@ -6605,10 +6560,10 @@ zfs_do_holds(int argc, char **argv) /* * 1. collect holds data, set format options */ - ret = zfs_for_each(argc, argv, flags, types, NULL, NULL, limit, + ret = zfs_for_each(1, argv + i, flags, types, NULL, NULL, limit, holds_callback, &cb); if (ret != 0) - ++errors; + errors = B_TRUE; } /* @@ -6621,7 +6576,7 @@ zfs_do_holds(int argc, char **argv) nvlist_free(nvl); - return (0 != errors); + return (errors); } #define CHECK_SPINNER 30 @@ -6703,7 +6658,7 @@ typedef struct share_mount_state { boolean_t sm_verbose; int sm_flags; char *sm_options; - char *sm_proto; /* only valid for OP_SHARE */ + enum sa_protocol sm_proto; /* only valid for OP_SHARE */ pthread_mutex_t sm_lock; /* protects the remaining fields */ uint_t sm_total; /* number of filesystems to process */ uint_t sm_done; /* number of filesystems processed */ @@ -6714,7 +6669,7 @@ typedef struct share_mount_state { * Share or mount a dataset. */ static int -share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol, +share_mount_one(zfs_handle_t *zhp, int op, int flags, enum sa_protocol protocol, boolean_t explicit, const char *options) { char mountpoint[ZFS_MAXPROPLEN]; @@ -6832,7 +6787,7 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol, return (0); if (op == OP_SHARE && !zfs_is_mounted(zhp, NULL)) { /* also purge it from existing exports */ - zfs_unshareall_bypath(zhp, mountpoint); + zfs_unshare(zhp, mountpoint, NULL); return (0); } } @@ -6890,10 +6845,11 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol, * filesystem. */ switch (op) { - case OP_SHARE: - - shared_nfs = zfs_is_shared_nfs(zhp, NULL); - shared_smb = zfs_is_shared_smb(zhp, NULL); + case OP_SHARE: { + enum sa_protocol prot[] = {SA_PROTOCOL_NFS, SA_NO_PROTOCOL}; + shared_nfs = zfs_is_shared(zhp, NULL, prot); + *prot = SA_PROTOCOL_SMB; + shared_smb = zfs_is_shared(zhp, NULL, prot); if ((shared_nfs && shared_smb) || (shared_nfs && strcmp(shareopts, "on") == 0 && @@ -6913,23 +6869,11 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol, zfs_mount(zhp, NULL, flags) != 0) return (1); - if (protocol == NULL) { - if (zfs_shareall(zhp) != 0) - return (1); - } else if (strcmp(protocol, "nfs") == 0) { - if (zfs_share_nfs(zhp)) - return (1); - } else if (strcmp(protocol, "smb") == 0) { - if (zfs_share_smb(zhp)) - return (1); - } else { - (void) fprintf(stderr, gettext("cannot share " - "'%s': invalid share type '%s' " - "specified\n"), - zfs_get_name(zhp), protocol); + *prot = protocol; + if (zfs_share(zhp, protocol == SA_NO_PROTOCOL ? NULL : prot)) return (1); - } + } break; case OP_MOUNT: @@ -7027,6 +6971,22 @@ append_options(char *mntopts, char *newopts) (void) strcpy(&mntopts[len], newopts); } +static enum sa_protocol +sa_protocol_decode(const char *protocol) +{ + for (enum sa_protocol i = 0; i < ARRAY_SIZE(sa_protocol_names); ++i) + if (strcmp(protocol, sa_protocol_names[i]) == 0) + return (i); + + (void) fputs(gettext("share type must be one of: "), stderr); + for (enum sa_protocol i = 0; + i < ARRAY_SIZE(sa_protocol_names); ++i) + (void) fprintf(stderr, "%s%s", + i != 0 ? ", " : "", sa_protocol_names[i]); + (void) fputc('\n', stderr); + usage(B_FALSE); +} + static int share_mount(int op, int argc, char **argv) { @@ -7085,16 +7045,10 @@ share_mount(int op, int argc, char **argv) /* check number of arguments */ if (do_all) { - char *protocol = NULL; + enum sa_protocol protocol = SA_NO_PROTOCOL; if (op == OP_SHARE && argc > 0) { - if (strcmp(argv[0], "nfs") != 0 && - strcmp(argv[0], "smb") != 0) { - (void) fprintf(stderr, gettext("share type " - "must be 'nfs' or 'smb'\n")); - usage(B_FALSE); - } - protocol = argv[0]; + protocol = sa_protocol_decode(argv[0]); argc--; argv++; } @@ -7131,7 +7085,7 @@ share_mount(int op, int argc, char **argv) zfs_foreach_mountpoint(g_zfs, cb.cb_handles, cb.cb_used, share_mount_one_cb, &share_mount_state, op == OP_MOUNT && !(flags & MS_CRYPT)); - zfs_commit_all_shares(); + zfs_commit_shares(NULL); ret = share_mount_state.sm_status; @@ -7183,9 +7137,9 @@ share_mount(int op, int argc, char **argv) ZFS_TYPE_FILESYSTEM)) == NULL) { ret = 1; } else { - ret = share_mount_one(zhp, op, flags, NULL, B_TRUE, - options); - zfs_commit_all_shares(); + ret = share_mount_one(zhp, op, flags, SA_NO_PROTOCOL, + B_TRUE, options); + zfs_commit_shares(NULL); zfs_close(zhp); } } @@ -7195,7 +7149,7 @@ share_mount(int op, int argc, char **argv) } /* - * zfs mount -a [nfs] + * zfs mount -a * zfs mount filesystem * * Mount all filesystems, or mount the given filesystem. @@ -7304,12 +7258,12 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual) "'%s': legacy share\n"), path); (void) fprintf(stderr, gettext("use exportfs(8) " "or smbcontrol(1) to unshare this filesystem\n")); - } else if (!zfs_is_shared(zhp)) { + } else if (!zfs_is_shared(zhp, NULL, NULL)) { (void) fprintf(stderr, gettext("cannot unshare '%s': " "not currently shared\n"), path); } else { - ret = zfs_unshareall_bypath(zhp, path); - zfs_commit_all_shares(); + ret = zfs_unshare(zhp, path, NULL); + zfs_commit_shares(NULL); } } else { char mtpt_prop[ZFS_MAXPROPLEN]; @@ -7399,16 +7353,12 @@ unshare_unmount(int op, int argc, char **argv) unshare_unmount_node_t *node; uu_avl_index_t idx; uu_avl_walk_t *walk; - char *protocol = NULL; + enum sa_protocol *protocol = NULL, + single_protocol[] = {SA_NO_PROTOCOL, SA_NO_PROTOCOL}; if (op == OP_SHARE && argc > 0) { - if (strcmp(argv[0], "nfs") != 0 && - strcmp(argv[0], "smb") != 0) { - (void) fprintf(stderr, gettext("share type " - "must be 'nfs' or 'smb'\n")); - usage(B_FALSE); - } - protocol = argv[0]; + *single_protocol = sa_protocol_decode(argv[0]); + protocol = single_protocol; argc--; argv++; } @@ -7515,7 +7465,7 @@ unshare_unmount(int op, int argc, char **argv) uu_avl_remove(tree, node); switch (op) { case OP_SHARE: - if (zfs_unshareall_bytype(node->un_zhp, + if (zfs_unshare(node->un_zhp, node->un_mountp, protocol) != 0) ret = 1; break; @@ -7588,12 +7538,12 @@ unshare_unmount(int op, int argc, char **argv) "exports(5) or smb.conf(5) to unshare " "this filesystem\n")); ret = 1; - } else if (!zfs_is_shared(zhp)) { + } else if (!zfs_is_shared(zhp, NULL, NULL)) { (void) fprintf(stderr, gettext("cannot " "unshare '%s': not currently " "shared\n"), zfs_get_name(zhp)); ret = 1; - } else if (zfs_unshareall(zhp) != 0) { + } else if (zfs_unshareall(zhp, NULL) != 0) { ret = 1; } break; @@ -8702,7 +8652,7 @@ main(int argc, char **argv) * Many commands modify input strings for string parsing reasons. * We create a copy to protect the original argv. */ - newargv = malloc((argc + 1) * sizeof (newargv[0])); + newargv = safe_malloc((argc + 1) * sizeof (newargv[0])); for (i = 0; i < argc; i++) newargv[i] = strdup(argv[i]); newargv[argc] = NULL; diff --git a/sys/contrib/openzfs/cmd/zfs/zfs_util.h b/sys/contrib/openzfs/cmd/zfs/zfs_util.h index a56af59adb15..cd0dc3ed04cc 100644 --- a/sys/contrib/openzfs/cmd/zfs/zfs_util.h +++ b/sys/contrib/openzfs/cmd/zfs/zfs_util.h @@ -31,7 +31,7 @@ extern "C" { #endif -void * safe_malloc(size_t size); +void *safe_malloc(size_t size); void nomem(void); extern libzfs_handle_t *g_zfs; diff --git a/sys/contrib/openzfs/cmd/zfs_ids_to_path/zfs_ids_to_path.c b/sys/contrib/openzfs/cmd/zfs_ids_to_path.c index 1d3bb6b29ee1..1d3bb6b29ee1 100644 --- a/sys/contrib/openzfs/cmd/zfs_ids_to_path/zfs_ids_to_path.c +++ b/sys/contrib/openzfs/cmd/zfs_ids_to_path.c diff --git a/sys/contrib/openzfs/cmd/zfs_ids_to_path/.gitignore b/sys/contrib/openzfs/cmd/zfs_ids_to_path/.gitignore deleted file mode 100644 index f95f853e48c2..000000000000 --- a/sys/contrib/openzfs/cmd/zfs_ids_to_path/.gitignore +++ /dev/null @@ -1 +0,0 @@ -zfs_ids_to_path diff --git a/sys/contrib/openzfs/cmd/zfs_ids_to_path/Makefile.am b/sys/contrib/openzfs/cmd/zfs_ids_to_path/Makefile.am deleted file mode 100644 index 549426764026..000000000000 --- a/sys/contrib/openzfs/cmd/zfs_ids_to_path/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -sbin_PROGRAMS = zfs_ids_to_path - -zfs_ids_to_path_SOURCES = \ - zfs_ids_to_path.c - -zfs_ids_to_path_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/zgenhostid/zgenhostid.c b/sys/contrib/openzfs/cmd/zgenhostid.c index 853931c6ad6e..853931c6ad6e 100644 --- a/sys/contrib/openzfs/cmd/zgenhostid/zgenhostid.c +++ b/sys/contrib/openzfs/cmd/zgenhostid.c diff --git a/sys/contrib/openzfs/cmd/zgenhostid/.gitignore b/sys/contrib/openzfs/cmd/zgenhostid/.gitignore deleted file mode 100644 index 072246c735ba..000000000000 --- a/sys/contrib/openzfs/cmd/zgenhostid/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zgenhostid diff --git a/sys/contrib/openzfs/cmd/zgenhostid/Makefile.am b/sys/contrib/openzfs/cmd/zgenhostid/Makefile.am deleted file mode 100644 index 4526a90a1d51..000000000000 --- a/sys/contrib/openzfs/cmd/zgenhostid/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -sbin_PROGRAMS = zgenhostid - -zgenhostid_SOURCES = zgenhostid.c - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/zhack/zhack.c b/sys/contrib/openzfs/cmd/zhack.c index 71a2c5ae6c3d..71a2c5ae6c3d 100644 --- a/sys/contrib/openzfs/cmd/zhack/zhack.c +++ b/sys/contrib/openzfs/cmd/zhack.c diff --git a/sys/contrib/openzfs/cmd/zhack/.gitignore b/sys/contrib/openzfs/cmd/zhack/.gitignore deleted file mode 100644 index 763a18898b88..000000000000 --- a/sys/contrib/openzfs/cmd/zhack/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zhack diff --git a/sys/contrib/openzfs/cmd/zhack/Makefile.am b/sys/contrib/openzfs/cmd/zhack/Makefile.am deleted file mode 100644 index 23f03ffd8243..000000000000 --- a/sys/contrib/openzfs/cmd/zhack/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -# Unconditionally enable debugging for zhack -AM_CPPFLAGS += -DDEBUG -UNDEBUG -DZFS_DEBUG - -sbin_PROGRAMS = zhack - -zhack_SOURCES = \ - zhack.c - -zhack_LDADD = \ - $(abs_top_builddir)/lib/libzpool/libzpool.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/zinject/.gitignore b/sys/contrib/openzfs/cmd/zinject/.gitignore deleted file mode 100644 index bded8400996c..000000000000 --- a/sys/contrib/openzfs/cmd/zinject/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zinject diff --git a/sys/contrib/openzfs/cmd/zinject/Makefile.am b/sys/contrib/openzfs/cmd/zinject/Makefile.am index 40f382c66191..c90f73fc0165 100644 --- a/sys/contrib/openzfs/cmd/zinject/Makefile.am +++ b/sys/contrib/openzfs/cmd/zinject/Makefile.am @@ -1,15 +1,12 @@ -include $(top_srcdir)/config/Rules.am - -sbin_PROGRAMS = zinject +sbin_PROGRAMS += zinject +CPPCHECKTARGETS += zinject zinject_SOURCES = \ - translate.c \ - zinject.c \ - zinject.h + %D%/translate.c \ + %D%/zinject.c \ + %D%/zinject.h zinject_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la - -include $(top_srcdir)/config/CppCheck.am + libzfs.la \ + libzfs_core.la \ + libnvpair.la diff --git a/sys/contrib/openzfs/cmd/zpool/.gitignore b/sys/contrib/openzfs/cmd/zpool/.gitignore deleted file mode 100644 index 8ea518af78e5..000000000000 --- a/sys/contrib/openzfs/cmd/zpool/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zpool diff --git a/sys/contrib/openzfs/cmd/zpool/Makefile.am b/sys/contrib/openzfs/cmd/zpool/Makefile.am index 7ea7c5fc3f3e..9ba72eadf3a7 100644 --- a/sys/contrib/openzfs/cmd/zpool/Makefile.am +++ b/sys/contrib/openzfs/cmd/zpool/Makefile.am @@ -1,34 +1,35 @@ -include $(top_srcdir)/config/Rules.am -include $(top_srcdir)/config/Shellcheck.am +zpool_CFLAGS = $(AM_CFLAGS) +zpool_CFLAGS += $(LIBBLKID_CFLAGS) $(LIBUUID_CFLAGS) -AM_CFLAGS += $(LIBBLKID_CFLAGS) $(LIBUUID_CFLAGS) +zpool_CPPFLAGS = $(AM_CPPFLAGS) +zpool_CPPFLAGS += -I$(srcdir)/%D% -DEFAULT_INCLUDES += -I$(srcdir) - - -sbin_PROGRAMS = zpool +sbin_PROGRAMS += zpool +CPPCHECKTARGETS += zpool zpool_SOURCES = \ - zpool_iter.c \ - zpool_main.c \ - zpool_util.c \ - zpool_util.h \ - zpool_vdev.c + %D%/zpool_iter.c \ + %D%/zpool_main.c \ + %D%/zpool_util.c \ + %D%/zpool_util.h \ + %D%/zpool_vdev.c if BUILD_FREEBSD -zpool_SOURCES += os/freebsd/zpool_vdev_os.c +zpool_SOURCES += \ + %D%/os/freebsd/zpool_vdev_os.c endif if BUILD_LINUX -zpool_SOURCES += os/linux/zpool_vdev_os.c +zpool_SOURCES += \ + %D%/os/linux/zpool_vdev_os.c endif zpool_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la \ - $(abs_top_builddir)/lib/libuutil/libuutil.la \ - $(abs_top_builddir)/lib/libzutil/libzutil.la + libzfs.la \ + libzfs_core.la \ + libnvpair.la \ + libuutil.la \ + libzutil.la zpool_LDADD += $(LTLIBINTL) @@ -37,56 +38,53 @@ zpool_LDADD += -lgeom endif zpool_LDADD += -lm $(LIBBLKID_LIBS) $(LIBUUID_LIBS) -include $(top_srcdir)/config/CppCheck.am +EXTRA_DIST += $(addprefix %D%/,zpool.d/README compatibility.d) -zpoolconfdir = $(sysconfdir)/zfs/zpool.d +SHELLCHECKSCRIPTS += $(dist_zpoolexec_SCRIPTS) zpoolexecdir = $(zfsexecdir)/zpool.d - -EXTRA_DIST = zpool.d/README compatibility.d - dist_zpoolexec_SCRIPTS = \ - zpool.d/dm-deps \ - zpool.d/enc \ - zpool.d/encdev \ - zpool.d/fault_led \ - zpool.d/iostat \ - zpool.d/iostat-1s \ - zpool.d/iostat-10s \ - zpool.d/label \ - zpool.d/locate_led \ - zpool.d/lsblk \ - zpool.d/media \ - zpool.d/model \ - zpool.d/serial \ - zpool.d/ses \ - zpool.d/size \ - zpool.d/slot \ - zpool.d/smart \ - zpool.d/smartx \ - zpool.d/temp \ - zpool.d/health \ - zpool.d/r_proc \ - zpool.d/w_proc \ - zpool.d/r_ucor \ - zpool.d/w_ucor \ - zpool.d/nonmed \ - zpool.d/defect \ - zpool.d/hours_on \ - zpool.d/realloc \ - zpool.d/rep_ucor \ - zpool.d/cmd_to \ - zpool.d/pend_sec \ - zpool.d/off_ucor \ - zpool.d/ata_err \ - zpool.d/nvme_err \ - zpool.d/pwr_cyc \ - zpool.d/upath \ - zpool.d/vendor \ - zpool.d/smart_test \ - zpool.d/test_type \ - zpool.d/test_status \ - zpool.d/test_progress \ - zpool.d/test_ended + %D%/zpool.d/ata_err \ + %D%/zpool.d/cmd_to \ + %D%/zpool.d/defect \ + %D%/zpool.d/dm-deps \ + %D%/zpool.d/enc \ + %D%/zpool.d/encdev \ + %D%/zpool.d/fault_led \ + %D%/zpool.d/health \ + %D%/zpool.d/hours_on \ + %D%/zpool.d/iostat \ + %D%/zpool.d/iostat-10s \ + %D%/zpool.d/iostat-1s \ + %D%/zpool.d/label \ + %D%/zpool.d/locate_led \ + %D%/zpool.d/lsblk \ + %D%/zpool.d/media \ + %D%/zpool.d/model \ + %D%/zpool.d/nonmed \ + %D%/zpool.d/nvme_err \ + %D%/zpool.d/off_ucor \ + %D%/zpool.d/pend_sec \ + %D%/zpool.d/pwr_cyc \ + %D%/zpool.d/r_proc \ + %D%/zpool.d/r_ucor \ + %D%/zpool.d/realloc \ + %D%/zpool.d/rep_ucor \ + %D%/zpool.d/serial \ + %D%/zpool.d/ses \ + %D%/zpool.d/size \ + %D%/zpool.d/slot \ + %D%/zpool.d/smart \ + %D%/zpool.d/smart_test \ + %D%/zpool.d/smartx \ + %D%/zpool.d/temp \ + %D%/zpool.d/test_ended \ + %D%/zpool.d/test_progress \ + %D%/zpool.d/test_status \ + %D%/zpool.d/test_type \ + %D%/zpool.d/upath \ + %D%/zpool.d/vendor \ + %D%/zpool.d/w_proc \ + %D%/zpool.d/w_ucor zpoolconfdefaults = \ dm-deps \ @@ -133,29 +131,28 @@ zpoolconfdefaults = \ test_ended zpoolcompatdir = $(pkgdatadir)/compatibility.d - dist_zpoolcompat_DATA = \ - compatibility.d/compat-2018 \ - compatibility.d/compat-2019 \ - compatibility.d/compat-2020 \ - compatibility.d/compat-2021 \ - compatibility.d/freebsd-11.0 \ - compatibility.d/freebsd-11.2 \ - compatibility.d/freebsd-11.3 \ - compatibility.d/freenas-9.10.2 \ - compatibility.d/grub2 \ - compatibility.d/openzfsonosx-1.7.0 \ - compatibility.d/openzfsonosx-1.8.1 \ - compatibility.d/openzfsonosx-1.9.3 \ - compatibility.d/openzfs-2.0-freebsd \ - compatibility.d/openzfs-2.0-linux \ - compatibility.d/openzfs-2.1-freebsd \ - compatibility.d/openzfs-2.1-linux \ - compatibility.d/zol-0.6.1 \ - compatibility.d/zol-0.6.4 \ - compatibility.d/zol-0.6.5 \ - compatibility.d/zol-0.7 \ - compatibility.d/zol-0.8 + %D%/compatibility.d/compat-2018 \ + %D%/compatibility.d/compat-2019 \ + %D%/compatibility.d/compat-2020 \ + %D%/compatibility.d/compat-2021 \ + %D%/compatibility.d/freebsd-11.0 \ + %D%/compatibility.d/freebsd-11.2 \ + %D%/compatibility.d/freebsd-11.3 \ + %D%/compatibility.d/freenas-9.10.2 \ + %D%/compatibility.d/grub2 \ + %D%/compatibility.d/openzfs-2.0-freebsd \ + %D%/compatibility.d/openzfs-2.0-linux \ + %D%/compatibility.d/openzfs-2.1-freebsd \ + %D%/compatibility.d/openzfs-2.1-linux \ + %D%/compatibility.d/openzfsonosx-1.7.0 \ + %D%/compatibility.d/openzfsonosx-1.8.1 \ + %D%/compatibility.d/openzfsonosx-1.9.3 \ + %D%/compatibility.d/zol-0.6.1 \ + %D%/compatibility.d/zol-0.6.4 \ + %D%/compatibility.d/zol-0.6.5 \ + %D%/compatibility.d/zol-0.7 \ + %D%/compatibility.d/zol-0.8 # canonical <- alias symbolic link pairs # eg: "2018" is a link to "compat-2018" @@ -178,13 +175,16 @@ zpoolcompatlinks = \ "zol-0.7 ubuntu-18.04" \ "zol-0.8 ubuntu-20.04" -install-data-hook: +zpoolconfdir = $(sysconfdir)/zfs/zpool.d +INSTALL_DATA_HOOKS += zpool-install-data-hook +zpool-install-data-hook: $(MKDIR_P) "$(DESTDIR)$(zpoolconfdir)" - for f in $(zpoolconfdefaults); do \ - test -f "$(DESTDIR)$(zpoolconfdir)/$${f}" -o \ - -L "$(DESTDIR)$(zpoolconfdir)/$${f}" || \ - ln -s "$(zpoolexecdir)/$${f}" "$(DESTDIR)$(zpoolconfdir)"; \ + set -x; for f in $(zpoolconfdefaults); do \ + [ -f "$(DESTDIR)$(zpoolconfdir)/$${f}" ] || \ + [ -L "$(DESTDIR)$(zpoolconfdir)/$${f}" ] || \ + $(LN_S) "$(zpoolexecdir)/$${f}" "$(DESTDIR)$(zpoolconfdir)"; \ done - for l in $(zpoolcompatlinks); do \ - (cd "$(DESTDIR)$(zpoolcompatdir)"; ln -sf $${l} ); \ + set -x; printf '%s\n' $(zpoolcompatlinks) | \ + while read -r canon alias; do \ + $(LN_S) -f "$${canon}" "$(DESTDIR)$(zpoolcompatdir)/$${alias}"; \ done diff --git a/sys/contrib/openzfs/cmd/zpool/zpool.d/iostat b/sys/contrib/openzfs/cmd/zpool/zpool.d/iostat index 95c459a3f0bf..2f8d79af8926 100755 --- a/sys/contrib/openzfs/cmd/zpool/zpool.d/iostat +++ b/sys/contrib/openzfs/cmd/zpool/zpool.d/iostat @@ -15,6 +15,15 @@ if [ "$1" = "-h" ] ; then exit fi +# Sometimes, UPATH ends up /dev/(null). +# That should be corrected, but for now... +# shellcheck disable=SC2154 +if [ ! -b "$VDEV_UPATH" ]; then + somepath="${VDEV_PATH}" +else + somepath="${VDEV_UPATH}" +fi + if [ "$script" = "iostat-1s" ] ; then # Do a single one-second sample interval=1 @@ -27,8 +36,7 @@ elif [ "$script" = "iostat-10s" ] ; then brief="yes" fi -# shellcheck disable=SC2154 -if [ -f "$VDEV_UPATH" ] ; then +if [ -f "$somepath" ] ; then # We're a file-based vdev, iostat doesn't work on us. Do nothing. exit fi @@ -37,13 +45,13 @@ if [ "$(uname)" = "FreeBSD" ]; then out=$(iostat -dKx \ ${interval:+"-w $interval"} \ ${interval:+"-c 1"} \ - "$VDEV_UPATH" | tail -n 2) + "$somepath" | tail -n 2) else out=$(iostat -kx \ ${brief:+"-y"} \ ${interval:+"$interval"} \ ${interval:+"1"} \ - "$VDEV_UPATH" | grep -v '^$' | tail -n 2) + "$somepath" | grep -v '^$' | tail -n 2) fi diff --git a/sys/contrib/openzfs/cmd/zpool/zpool.d/lsblk b/sys/contrib/openzfs/cmd/zpool/zpool.d/lsblk index 1ed1464431aa..293effd48ac5 100755 --- a/sys/contrib/openzfs/cmd/zpool/zpool.d/lsblk +++ b/sys/contrib/openzfs/cmd/zpool/zpool.d/lsblk @@ -61,21 +61,29 @@ else list=$(echo "$script" | tr '[:upper:]' '[:lower:]') fi +# Sometimes, UPATH ends up /dev/(null). +# That should be corrected, but for now... +# shellcheck disable=SC2154 +if [ ! -b "$VDEV_UPATH" ]; then + somepath="${VDEV_PATH}" +else + somepath="${VDEV_UPATH}" +fi + # Older versions of lsblk don't support all these values (like SERIAL). for i in $list ; do # Special case: Looking up the size of a file-based vdev can't # be done with lsblk. - # shellcheck disable=SC2154 - if [ "$i" = "size" ] && [ -f "$VDEV_UPATH" ] ; then - size=$(du -h --apparent-size "$VDEV_UPATH" | cut -f 1) + if [ "$i" = "size" ] && [ -f "$somepath" ] ; then + size=$(du -h --apparent-size "$somepath" | cut -f 1) echo "size=$size" continue fi val="" - if val=$(eval "lsblk -dl -n -o $i $VDEV_UPATH 2>/dev/null") ; then + if val=$(eval "lsblk -dl -n -o $i $somepath 2>/dev/null") ; then # Remove leading/trailing whitespace from value val=$(echo "$val" | sed -e 's/^[[:space:]]*//' \ -e 's/[[:space:]]*$//') diff --git a/sys/contrib/openzfs/cmd/zpool/zpool.d/smart b/sys/contrib/openzfs/cmd/zpool/zpool.d/smart index 032491988c18..8ad3e107f091 100755 --- a/sys/contrib/openzfs/cmd/zpool/zpool.d/smart +++ b/sys/contrib/openzfs/cmd/zpool/zpool.d/smart @@ -69,8 +69,16 @@ if [ "$1" = "-h" ] ; then exit fi +# Sometimes, UPATH ends up /dev/(null). +# That should be corrected, but for now... # shellcheck disable=SC2154 -if [ -b "$VDEV_UPATH" ] && PATH="/usr/sbin:$PATH" command -v smartctl > /dev/null || [ -n "$samples" ] ; then +if [ ! -b "$VDEV_UPATH" ]; then + somepath="${VDEV_PATH}" +else + somepath="${VDEV_UPATH}" +fi + +if [ -b "$somepath" ] && PATH="/usr/sbin:$PATH" command -v smartctl > /dev/null || [ -n "$samples" ] ; then if [ -n "$samples" ] ; then # cat a smartctl output text file instead of running smartctl # on a vdev (only used for developer testing). @@ -78,7 +86,7 @@ if [ -b "$VDEV_UPATH" ] && PATH="/usr/sbin:$PATH" command -v smartctl > /dev/nul echo "file=$file" raw_out=$(cat "$samples/$file") else - raw_out=$(sudo smartctl -a "$VDEV_UPATH") + raw_out=$(sudo smartctl -a "$somepath") fi # What kind of drive are we? Look for the right line in smartctl: diff --git a/sys/contrib/openzfs/cmd/zpool/zpool_main.c b/sys/contrib/openzfs/cmd/zpool/zpool_main.c index 5d1cae3e9552..ac4a0b23adad 100644 --- a/sys/contrib/openzfs/cmd/zpool/zpool_main.c +++ b/sys/contrib/openzfs/cmd/zpool/zpool_main.c @@ -1790,8 +1790,8 @@ zpool_do_create(int argc, char **argv) tname ? tname : poolname, ZFS_TYPE_FILESYSTEM); if (pool != NULL) { if (zfs_mount(pool, NULL, 0) == 0) { - ret = zfs_shareall(pool); - zfs_commit_all_shares(); + ret = zfs_share(pool, NULL); + zfs_commit_shares(NULL); } zfs_close(pool); } @@ -1987,40 +1987,21 @@ static int max_width(zpool_handle_t *zhp, nvlist_t *nv, int depth, int max, int name_flags) { - char *name; - nvlist_t **child; - uint_t c, children; - int ret; - - name = zpool_vdev_name(g_zfs, zhp, nv, name_flags); - if (strlen(name) + depth > max) - max = strlen(name) + depth; + static const char *const subtypes[] = + {ZPOOL_CONFIG_SPARES, ZPOOL_CONFIG_L2CACHE, ZPOOL_CONFIG_CHILDREN}; + char *name = zpool_vdev_name(g_zfs, zhp, nv, name_flags); + max = MAX(strlen(name) + depth, max); free(name); - if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_SPARES, - &child, &children) == 0) { - for (c = 0; c < children; c++) - if ((ret = max_width(zhp, child[c], depth + 2, - max, name_flags)) > max) - max = ret; - } - - if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_L2CACHE, - &child, &children) == 0) { - for (c = 0; c < children; c++) - if ((ret = max_width(zhp, child[c], depth + 2, - max, name_flags)) > max) - max = ret; - } - - if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN, - &child, &children) == 0) { - for (c = 0; c < children; c++) - if ((ret = max_width(zhp, child[c], depth + 2, - max, name_flags)) > max) - max = ret; - } + nvlist_t **child; + uint_t children; + for (size_t i = 0; i < ARRAY_SIZE(subtypes); ++i) + if (nvlist_lookup_nvlist_array(nv, subtypes[i], + &child, &children) == 0) + for (uint_t c = 0; c < children; ++c) + max = MAX(max_width(zhp, child[c], depth + 2, + max, name_flags), max); return (max); } @@ -2472,7 +2453,7 @@ print_status_config(zpool_handle_t *zhp, status_cbdata_t *cb, const char *name, if (vs->vs_scan_removing != 0) { (void) printf(gettext(" (removing)")); - } else if (vs->vs_noalloc != 0) { + } else if (VDEV_STAT_VALID(vs_noalloc, vsc) && vs->vs_noalloc != 0) { (void) printf(gettext(" (non-allocating)")); } @@ -6162,7 +6143,7 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv, * 'toplevel' boolean value is passed to the print_one_column() * to indicate that the value is valid. */ - if (vs->vs_pspace) + if (VDEV_STAT_VALID(vs_pspace, c) && vs->vs_pspace) print_one_column(ZPOOL_PROP_SIZE, vs->vs_pspace, NULL, scripted, B_TRUE, format); else @@ -10924,7 +10905,7 @@ main(int argc, char **argv) * Many commands modify input strings for string parsing reasons. * We create a copy to protect the original argv. */ - newargv = malloc((argc + 1) * sizeof (newargv[0])); + newargv = safe_malloc((argc + 1) * sizeof (newargv[0])); for (i = 0; i < argc; i++) newargv[i] = strdup(argv[i]); newargv[argc] = NULL; diff --git a/sys/contrib/openzfs/cmd/zpool_influxdb/.gitignore b/sys/contrib/openzfs/cmd/zpool_influxdb/.gitignore deleted file mode 100644 index bd765d188278..000000000000 --- a/sys/contrib/openzfs/cmd/zpool_influxdb/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zpool_influxdb diff --git a/sys/contrib/openzfs/cmd/zpool_influxdb/Makefile.am b/sys/contrib/openzfs/cmd/zpool_influxdb/Makefile.am index a59217570b9d..b237532ce24e 100644 --- a/sys/contrib/openzfs/cmd/zpool_influxdb/Makefile.am +++ b/sys/contrib/openzfs/cmd/zpool_influxdb/Makefile.am @@ -1,13 +1,10 @@ -include $(top_srcdir)/config/Rules.am - -zfsexec_PROGRAMS = zpool_influxdb +zfsexec_PROGRAMS += zpool_influxdb +CPPCHECKTARGETS += zpool_influxdb zpool_influxdb_SOURCES = \ - zpool_influxdb.c + %D%/zpool_influxdb.c zpool_influxdb_LDADD = \ - $(top_builddir)/lib/libspl/libspl.la \ - $(top_builddir)/lib/libnvpair/libnvpair.la \ - $(top_builddir)/lib/libzfs/libzfs.la - -include $(top_srcdir)/config/CppCheck.am + libspl.la \ + libnvpair.la \ + libzfs.la diff --git a/sys/contrib/openzfs/cmd/zstream/.gitignore b/sys/contrib/openzfs/cmd/zstream/.gitignore deleted file mode 100644 index fd1240d55c4b..000000000000 --- a/sys/contrib/openzfs/cmd/zstream/.gitignore +++ /dev/null @@ -1 +0,0 @@ -zstream diff --git a/sys/contrib/openzfs/cmd/zstream/Makefile.am b/sys/contrib/openzfs/cmd/zstream/Makefile.am index 8e813027fa3d..9b2716ae0391 100644 --- a/sys/contrib/openzfs/cmd/zstream/Makefile.am +++ b/sys/contrib/openzfs/cmd/zstream/Makefile.am @@ -1,20 +1,18 @@ -include $(top_srcdir)/config/Rules.am - -sbin_PROGRAMS = zstream +sbin_PROGRAMS += zstream +CPPCHECKTARGETS += zstream zstream_SOURCES = \ - zstream.c \ - zstream.h \ - zstream_dump.c \ - zstream_redup.c \ - zstream_token.c + %D%/zstream.c \ + %D%/zstream.h \ + %D%/zstream_dump.c \ + %D%/zstream_redup.c \ + %D%/zstream_token.c zstream_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la - -include $(top_srcdir)/config/CppCheck.am + libzfs.la \ + libzfs_core.la \ + libnvpair.la +PHONY += install-exec-hook install-exec-hook: cd $(DESTDIR)$(sbindir) && $(LN_S) -f zstream zstreamdump diff --git a/sys/contrib/openzfs/cmd/ztest/ztest.c b/sys/contrib/openzfs/cmd/ztest.c index d60422279ad7..ca05cf26511e 100644 --- a/sys/contrib/openzfs/cmd/ztest/ztest.c +++ b/sys/contrib/openzfs/cmd/ztest.c @@ -929,8 +929,7 @@ process_options(int argc, char **argv) int opt; uint64_t value; - char altdir[MAXNAMELEN] = { 0 }; - char raid_kind[8] = "random"; + const char *raid_kind = "random"; memcpy(zo, &ztest_opts_defaults, sizeof (*zo)); @@ -978,7 +977,7 @@ process_options(int argc, char **argv) zo->zo_raid_parity = MIN(MAX(value, 1), 3); break; case 'K': - (void) strlcpy(raid_kind, optarg, sizeof (raid_kind)); + raid_kind = optarg; break; case 'D': zo->zo_draid_data = MAX(1, value); @@ -1037,7 +1036,8 @@ process_options(int argc, char **argv) zo->zo_maxloops = MAX(1, value); break; case 'B': - (void) strlcpy(altdir, optarg, sizeof (altdir)); + (void) strlcpy(zo->zo_alt_ztest, optarg, + sizeof (zo->zo_alt_ztest)); break; case 'C': ztest_parse_name_value(optarg, zo); @@ -1076,8 +1076,7 @@ process_options(int argc, char **argv) /* When raid choice is 'random' add a draid pool 50% of the time */ if (strcmp(raid_kind, "random") == 0) { - (void) strlcpy(raid_kind, (ztest_random(2) == 0) ? - "draid" : "raidz", sizeof (raid_kind)); + raid_kind = (ztest_random(2) == 0) ? "draid" : "raidz"; if (ztest_opts.zo_verbose >= 3) (void) printf("choosing RAID type '%s'\n", raid_kind); @@ -1127,51 +1126,28 @@ process_options(int argc, char **argv) (zo->zo_vdevs > 0 ? zo->zo_time * NANOSEC / zo->zo_vdevs : UINT64_MAX >> 2); - if (strlen(altdir) > 0) { - char *cmd; - char *realaltdir; - char *bin; - char *ztest; - char *isa; - int isalen; - - cmd = umem_alloc(MAXPATHLEN, UMEM_NOFAIL); - realaltdir = umem_alloc(MAXPATHLEN, UMEM_NOFAIL); - - VERIFY3P(NULL, !=, realpath(getexecname(), cmd)); - if (0 != access(altdir, F_OK)) { - ztest_dump_core = B_FALSE; - fatal(B_TRUE, "invalid alternate ztest path: %s", - altdir); - } - VERIFY3P(NULL, !=, realpath(altdir, realaltdir)); - - /* - * 'cmd' should be of the form "<anything>/usr/bin/<isa>/ztest". - * We want to extract <isa> to determine if we should use - * 32 or 64 bit binaries. - */ - bin = strstr(cmd, "/usr/bin/"); - ztest = strstr(bin, "/ztest"); - isa = bin + 9; - isalen = ztest - isa; - (void) snprintf(zo->zo_alt_ztest, sizeof (zo->zo_alt_ztest), - "%s/usr/bin/%.*s/ztest", realaltdir, isalen, isa); - (void) snprintf(zo->zo_alt_libpath, sizeof (zo->zo_alt_libpath), - "%s/usr/lib/%.*s", realaltdir, isalen, isa); - - if (0 != access(zo->zo_alt_ztest, X_OK)) { - ztest_dump_core = B_FALSE; - fatal(B_TRUE, "invalid alternate ztest: %s", - zo->zo_alt_ztest); - } else if (0 != access(zo->zo_alt_libpath, X_OK)) { - ztest_dump_core = B_FALSE; - fatal(B_TRUE, "invalid alternate lib directory %s", - zo->zo_alt_libpath); - } + if (*zo->zo_alt_ztest) { + const char *invalid_what = "ztest"; + char *val = zo->zo_alt_ztest; + if (0 != access(val, X_OK) || + (strrchr(val, '/') == NULL && (errno = EINVAL))) + goto invalid; + + int dirlen = strrchr(val, '/') - val; + strncpy(zo->zo_alt_libpath, val, dirlen); + invalid_what = "library path", val = zo->zo_alt_libpath; + if (strrchr(val, '/') == NULL && (errno = EINVAL)) + goto invalid; + *strrchr(val, '/') = '\0'; + strlcat(val, "/lib", sizeof (zo->zo_alt_libpath)); + + if (0 != access(zo->zo_alt_libpath, X_OK)) + goto invalid; + return; - umem_free(cmd, MAXPATHLEN); - umem_free(realaltdir, MAXPATHLEN); +invalid: + ztest_dump_core = B_FALSE; + fatal(B_TRUE, "invalid alternate %s %s", invalid_what, val); } } @@ -1182,14 +1158,14 @@ ztest_kill(ztest_shared_t *zs) zs->zs_space = metaslab_class_get_space(spa_normal_class(ztest_spa)); /* - * Before we kill off ztest, make sure that the config is updated. + * Before we kill ourselves, make sure that the config is updated. * See comment above spa_write_cachefile(). */ mutex_enter(&spa_namespace_lock); spa_write_cachefile(ztest_spa, B_FALSE, B_FALSE); mutex_exit(&spa_namespace_lock); - (void) kill(getpid(), SIGKILL); + (void) raise(SIGKILL); } static void @@ -6626,22 +6602,22 @@ ztest_get_zdb_bin(char *bin, int len) { char *zdb_path; /* - * Try to use ZDB_PATH and in-tree zdb path. If not successful, just + * Try to use $ZDB and in-tree zdb path. If not successful, just * let popen to search through PATH. */ - if ((zdb_path = getenv("ZDB_PATH"))) { + if ((zdb_path = getenv("ZDB"))) { strlcpy(bin, zdb_path, len); /* In env */ if (!ztest_check_path(bin)) { ztest_dump_core = 0; - fatal(B_TRUE, "invalid ZDB_PATH '%s'", bin); + fatal(B_TRUE, "invalid ZDB '%s'", bin); } return; } VERIFY3P(realpath(getexecname(), bin), !=, NULL); - if (strstr(bin, "/ztest/")) { - strstr(bin, "/ztest/")[0] = '\0'; /* In-tree */ - strcat(bin, "/zdb/zdb"); + if (strstr(bin, ".libs/ztest")) { + strstr(bin, ".libs/ztest")[0] = '\0'; /* In-tree */ + strcat(bin, "zdb"); if (ztest_check_path(bin)) return; } @@ -6858,7 +6834,7 @@ ztest_run_zdb(char *pool) free(set_gvars_args_joined); if (ztest_opts.zo_verbose >= 5) - (void) printf("Executing %s\n", strstr(zdb, "zdb ")); + (void) printf("Executing %s\n", zdb); fp = popen(zdb, "r"); @@ -7888,21 +7864,24 @@ exec_child(char *cmd, char *libpath, boolean_t ignorekill, int *statusp) fatal(B_TRUE, "fork failed"); if (pid == 0) { /* child */ - char *emptyargv[2] = { cmd, NULL }; char fd_data_str[12]; - struct rlimit rl = { 1024, 1024 }; - (void) setrlimit(RLIMIT_NOFILE, &rl); - - (void) close(ztest_fd_rand); VERIFY3S(11, >=, snprintf(fd_data_str, 12, "%d", ztest_fd_data)); VERIFY0(setenv("ZTEST_FD_DATA", fd_data_str, 1)); - (void) enable_extended_FILE_stdio(-1, -1); - if (libpath != NULL) - VERIFY0(setenv("LD_LIBRARY_PATH", libpath, 1)); - (void) execv(cmd, emptyargv); + if (libpath != NULL) { + const char *curlp = getenv("LD_LIBRARY_PATH"); + if (curlp == NULL) + VERIFY0(setenv("LD_LIBRARY_PATH", libpath, 1)); + else { + char *newlp = NULL; + VERIFY3S(-1, !=, + asprintf(&newlp, "%s:%s", libpath, curlp)); + VERIFY0(setenv("LD_LIBRARY_PATH", newlp, 1)); + } + } + (void) execl(cmd, cmd, (char *)NULL); ztest_dump_core = B_FALSE; fatal(B_TRUE, "exec failed: %s", cmd); } @@ -8033,7 +8012,7 @@ main(int argc, char **argv) * ztest from needlessly depleting the system entropy pool. */ random_path = "/dev/urandom"; - ztest_fd_rand = open(random_path, O_RDONLY); + ztest_fd_rand = open(random_path, O_RDONLY | O_CLOEXEC); ASSERT3S(ztest_fd_rand, >=, 0); if (!fd_data_str) { diff --git a/sys/contrib/openzfs/cmd/ztest/.gitignore b/sys/contrib/openzfs/cmd/ztest/.gitignore deleted file mode 100644 index d3d498dae693..000000000000 --- a/sys/contrib/openzfs/cmd/ztest/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/ztest diff --git a/sys/contrib/openzfs/cmd/ztest/Makefile.am b/sys/contrib/openzfs/cmd/ztest/Makefile.am deleted file mode 100644 index d5e335e6d27e..000000000000 --- a/sys/contrib/openzfs/cmd/ztest/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -# Get rid of compiler warning for unchecked truncating snprintfs on gcc 7.1.1 -AM_CFLAGS += $(NO_FORMAT_TRUNCATION) - -# Includes kernel code, generate warnings for large stack frames -AM_CFLAGS += $(FRAME_LARGER_THAN) - -# Unconditionally enable ASSERTs -AM_CPPFLAGS += -DDEBUG -UNDEBUG -DZFS_DEBUG - -sbin_PROGRAMS = ztest - -ztest_SOURCES = \ - ztest.c - -ztest_LDADD = \ - $(abs_top_builddir)/lib/libzpool/libzpool.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la - -ztest_LDADD += -lm -ztest_LDFLAGS = -pthread - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/zvol_id/.gitignore b/sys/contrib/openzfs/cmd/zvol_id/.gitignore deleted file mode 100644 index 8b757a2d6781..000000000000 --- a/sys/contrib/openzfs/cmd/zvol_id/.gitignore +++ /dev/null @@ -1 +0,0 @@ -zvol_id diff --git a/sys/contrib/openzfs/cmd/zvol_id/Makefile.am b/sys/contrib/openzfs/cmd/zvol_id/Makefile.am deleted file mode 100644 index bb7e31a0590f..000000000000 --- a/sys/contrib/openzfs/cmd/zvol_id/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -# Disable GCC stack protection for zvol_id. This is a kludge and should be -# removed once https://github.com/openzfs/zfs/issues/569 is resolved. -AM_CFLAGS += -fno-stack-protector - -udev_PROGRAMS = zvol_id - -zvol_id_SOURCES = \ - zvol_id_main.c - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/zvol_id/zvol_id_main.c b/sys/contrib/openzfs/cmd/zvol_id/zvol_id_main.c deleted file mode 100644 index 929a1a6e794d..000000000000 --- a/sys/contrib/openzfs/cmd/zvol_id/zvol_id_main.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2011, Fajar A. Nugraha. All rights reserved. - * Use is subject to license terms. - */ - -#include <ctype.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <fcntl.h> -#include <unistd.h> -#include <linux/ioctl.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <sys/zfs_znode.h> -#include <sys/fs/zfs.h> - -#if defined(ZFS_ASAN_ENABLED) -/* - * zvol_id is invoked by udev with the help of ptrace() - * making sanitized binary with leak detection croak - * because of tracing mechanisms collision - */ -extern const char *__asan_default_options(void); - -const char *__asan_default_options(void) { - return ("abort_on_error=true:halt_on_error=true:" - "allocator_may_return_null=true:disable_coredump=false:" - "detect_stack_use_after_return=true:detect_leaks=false"); -} -#endif - -static int -ioctl_get_msg(char *var, int fd) -{ - int ret; - char msg[ZFS_MAX_DATASET_NAME_LEN]; - - ret = ioctl(fd, BLKZNAME, msg); - if (ret < 0) { - return (ret); - } - - snprintf(var, ZFS_MAX_DATASET_NAME_LEN, "%s", msg); - return (ret); -} - -int -main(int argc, char **argv) -{ - int fd = -1, ret = 0, status = EXIT_FAILURE; - char zvol_name[ZFS_MAX_DATASET_NAME_LEN]; - char *zvol_name_part = NULL; - char *dev_name; - struct stat64 statbuf; - int dev_minor, dev_part; - int i; - - if (argc < 2) { - fprintf(stderr, "Usage: %s /dev/zvol_device_node\n", argv[0]); - goto fail; - } - - dev_name = argv[1]; - ret = stat64(dev_name, &statbuf); - if (ret != 0) { - fprintf(stderr, "Unable to access device file: %s\n", dev_name); - goto fail; - } - - dev_minor = minor(statbuf.st_rdev); - dev_part = dev_minor % ZVOL_MINORS; - - fd = open(dev_name, O_RDONLY); - if (fd < 0) { - fprintf(stderr, "Unable to open device file: %s\n", dev_name); - goto fail; - } - - ret = ioctl_get_msg(zvol_name, fd); - if (ret < 0) { - fprintf(stderr, "ioctl_get_msg failed: %s\n", strerror(errno)); - goto fail; - } - if (dev_part > 0) - ret = asprintf(&zvol_name_part, "%s-part%d", zvol_name, - dev_part); - else - ret = asprintf(&zvol_name_part, "%s", zvol_name); - - if (ret == -1 || zvol_name_part == NULL) - goto fail; - - for (i = 0; i < strlen(zvol_name_part); i++) { - if (isblank(zvol_name_part[i])) - zvol_name_part[i] = '+'; - } - - printf("%s\n", zvol_name_part); - status = EXIT_SUCCESS; - -fail: - if (zvol_name_part) - free(zvol_name_part); - if (fd >= 0) - close(fd); - - return (status); -} diff --git a/sys/contrib/openzfs/cmd/zvol_wait/zvol_wait b/sys/contrib/openzfs/cmd/zvol_wait index 2aa929b0ca2b..f1fa42e27dc9 100755 --- a/sys/contrib/openzfs/cmd/zvol_wait/zvol_wait +++ b/sys/contrib/openzfs/cmd/zvol_wait @@ -28,15 +28,17 @@ filter_out_deleted_zvols() { list_zvols() { read -r default_volmode < /sys/module/zfs/parameters/zvol_volmode zfs list -t volume -H -o \ - name,volmode,receive_resume_token,redact_snaps | - while IFS=" " read -r name volmode token redacted; do # IFS=\t here! + name,volmode,receive_resume_token,redact_snaps,keystatus | + while IFS=" " read -r name volmode token redacted keystatus; do # IFS=\t here! - # /dev links are not created for zvols with volmode = "none" - # or for redacted zvols. + # /dev links are not created for zvols with volmode = "none", + # redacted zvols, or encrypted zvols for which the key has not + # been loaded. [ "$volmode" = "none" ] && continue [ "$volmode" = "default" ] && [ "$default_volmode" = "3" ] && continue [ "$redacted" = "-" ] || continue + [ "$keystatus" = "unavailable" ] && continue # We also ignore partially received zvols if it is # not an incremental receive, as those won't even have a block diff --git a/sys/contrib/openzfs/cmd/zvol_wait/Makefile.am b/sys/contrib/openzfs/cmd/zvol_wait/Makefile.am deleted file mode 100644 index e8b546a60659..000000000000 --- a/sys/contrib/openzfs/cmd/zvol_wait/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -include $(top_srcdir)/config/Shellcheck.am - -dist_bin_SCRIPTS = zvol_wait - diff --git a/sys/contrib/openzfs/config/Abigail.am b/sys/contrib/openzfs/config/Abigail.am deleted file mode 100644 index d1038f093373..000000000000 --- a/sys/contrib/openzfs/config/Abigail.am +++ /dev/null @@ -1,52 +0,0 @@ -# -# When performing an ABI check the following options are applied: -# -# --no-unreferenced-symbols: Exclude symbols which are not referenced by -# any debug information. Without this _init() and _fini() are incorrectly -# reported on CentOS7 for libuutil.so. -# -# --headers-dir1: Limit ABI checks to public OpenZFS headers, otherwise -# changes in public system headers are also reported. -# -# --suppressions: Honor a suppressions file for each library to provide -# a mechanism for suppressing harmless warnings. -# - -PHONY += checkabi storeabi check_libabi_version allow_libabi_only_for_x86_64 - -check_libabi_version: - libabiversion=`abidw -v | $(SED) 's/[^0-9]//g'`; \ - if test $$libabiversion -lt "200"; then \ - /bin/echo -e "\n" \ - "*** Please use libabigail 2.0.0 version or newer;\n" \ - "*** otherwise results are not consistent!\n" \ - "(or see https://github.com/openzfs/libabigail-docker )\n"; \ - exit 1; \ - fi; - -allow_libabi_only_for_x86_64: - echo '*** ABI definitions provided apply only to x86_64 architecture' - echo '*** Skipping `checkabi`/`storeabi` target and assuming success.' - -if TARGET_CPU_X86_64 -checkabi: check_libabi_version - for lib in $(lib_LTLIBRARIES) ; do \ - abidiff --no-unreferenced-symbols \ - --headers-dir1 ../../include \ - --suppressions $${lib%.la}.suppr \ - $${lib%.la}.abi .libs/$${lib%.la}.so ; \ - done - -storeabi: check_libabi_version - cd .libs ; \ - for lib in $(lib_LTLIBRARIES) ; do \ - abidw --no-show-locs \ - --no-corpus-path \ - --no-comp-dir-path \ - --type-id-style hash \ - $${lib%.la}.so > ../$${lib%.la}.abi ; \ - done -else -checkabi: allow_libabi_only_for_x86_64 -storeabi: allow_libabi_only_for_x86_64 -endif diff --git a/sys/contrib/openzfs/config/CppCheck.am b/sys/contrib/openzfs/config/CppCheck.am index e53013bd01cc..89a067d814ff 100644 --- a/sys/contrib/openzfs/config/CppCheck.am +++ b/sys/contrib/openzfs/config/CppCheck.am @@ -1,5 +1,5 @@ # -# Default rules for running cppcheck against the user space components. +# cppcheck for userspace – nodist_*_SOURCES are kernel code and cppcheck goes crazy on them. # PHONY += cppcheck @@ -7,5 +7,15 @@ PHONY += cppcheck CPPCHECKFLAGS = --std=c99 --quiet --max-configs=1 --error-exitcode=2 CPPCHECKFLAGS += --inline-suppr -U_KERNEL -cppcheck: - $(CPPCHECK) -j$(CPU_COUNT) $(CPPCHECKFLAGS) $(DEFAULT_INCLUDES) $(SOURCES) +CPPCHECKDIRS = +CPPCHECKTARGETS = + +cppcheck-recursive-%: + $(MAKE) -C $(subst cppcheck-recursive-,,$@) cppcheck + +_CTGT = $(subst cppcheck-for-,,$@) +cppcheck-for-%: + @[ -n "$($(_CTGT)_SOURCES)$(dist_$(_CTGT)_SOURCES)" ] + $(CPPCHECK) -j$(CPU_COUNT) $(CPPCHECKFLAGS) $(patsubst -U%,,$(patsubst -D%,,$(filter-out $(AM_CPPFLAGS_NOCHECK),$(or $($(_CTGT)_CPPFLAGS),$(AM_CPPFLAGS))))) $($(_CTGT)_SOURCES) $(dist_$(_CTGT)_SOURCES) + +cppcheck: $(addprefix cppcheck-for-,$(subst -,_,$(subst .,_,$(subst /,_,$(CPPCHECKTARGETS))))) $(addprefix cppcheck-recursive-,$(CPPCHECKDIRS)) diff --git a/sys/contrib/openzfs/config/Rules.am b/sys/contrib/openzfs/config/Rules.am index 1540738482ca..07e72d33fde7 100644 --- a/sys/contrib/openzfs/config/Rules.am +++ b/sys/contrib/openzfs/config/Rules.am @@ -4,22 +4,13 @@ # PHONY = -DEFAULT_INCLUDES = \ +AM_CPPFLAGS = \ -include $(top_builddir)/zfs_config.h \ -I$(top_builddir)/include \ -I$(top_srcdir)/include \ -I$(top_srcdir)/module/icp/include \ - -I$(top_srcdir)/lib/libspl/include - -if BUILD_LINUX -DEFAULT_INCLUDES += \ - -I$(top_srcdir)/lib/libspl/include/os/linux -endif - -if BUILD_FREEBSD -DEFAULT_INCLUDES += \ - -I$(top_srcdir)/lib/libspl/include/os/freebsd -endif + -I$(top_srcdir)/lib/libspl/include \ + -I$(top_srcdir)/lib/libspl/include/os/@ac_system_l@ AM_LIBTOOLFLAGS = --silent @@ -37,7 +28,7 @@ AM_CFLAGS += -include $(top_srcdir)/include/os/freebsd/spl/sys/ccompile.h AM_CFLAGS += -I/usr/include -I/usr/local/include endif -AM_CPPFLAGS = -D_GNU_SOURCE +AM_CPPFLAGS += -D_GNU_SOURCE AM_CPPFLAGS += -D_REENTRANT AM_CPPFLAGS += -D_FILE_OFFSET_BITS=64 AM_CPPFLAGS += -D_LARGEFILE64_SOURCE @@ -48,19 +39,20 @@ AM_CPPFLAGS += -DSYSCONFDIR=\"$(sysconfdir)\" AM_CPPFLAGS += -DPKGDATADIR=\"$(pkgdatadir)\" AM_CPPFLAGS += $(DEBUG_CPPFLAGS) AM_CPPFLAGS += $(CODE_COVERAGE_CPPFLAGS) -if BUILD_LINUX -AM_CPPFLAGS += -DTEXT_DOMAIN=\"zfs-linux-user\" -endif -if BUILD_FREEBSD -AM_CPPFLAGS += -DTEXT_DOMAIN=\"zfs-freebsd-user\" -endif -AM_CPPFLAGS += -D"strtok(...)=strtok(__VA_ARGS__) __attribute__((deprecated(\"Use strtok_r(3) instead!\")))" -AM_CPPFLAGS += -D"__xpg_basename(...)=__xpg_basename(__VA_ARGS__) __attribute__((deprecated(\"basename(3) is underspecified. Use zfs_basename() instead!\")))" -AM_CPPFLAGS += -D"basename(...)=basename(__VA_ARGS__) __attribute__((deprecated(\"basename(3) is underspecified. Use zfs_basename() instead!\")))" -AM_CPPFLAGS += -D"dirname(...)=dirname(__VA_ARGS__) __attribute__((deprecated(\"dirname(3) is underspecified. Use zfs_dirnamelen() instead!\")))" -AM_CPPFLAGS += -D"bcopy(...)=__attribute__((deprecated(\"bcopy(3) is deprecated. Use memcpy(3)/memmove(3) instead!\"))) bcopy(__VA_ARGS__)" -AM_CPPFLAGS += -D"bcmp(...)=__attribute__((deprecated(\"bcmp(3) is deprecated. Use memcmp(3) instead!\"))) bcmp(__VA_ARGS__)" -AM_CPPFLAGS += -D"bzero(...)=__attribute__((deprecated(\"bzero(3) is deprecated. Use memset(3) instead!\"))) bzero(__VA_ARGS__)" +AM_CPPFLAGS += -DTEXT_DOMAIN=\"zfs-@ac_system_l@-user\" + +AM_CPPFLAGS_NOCHECK = -D"strtok(...)=strtok(__VA_ARGS__) __attribute__((deprecated(\"Use strtok_r(3) instead!\")))" +AM_CPPFLAGS_NOCHECK += -D"__xpg_basename(...)=__xpg_basename(__VA_ARGS__) __attribute__((deprecated(\"basename(3) is underspecified. Use zfs_basename() instead!\")))" +AM_CPPFLAGS_NOCHECK += -D"basename(...)=basename(__VA_ARGS__) __attribute__((deprecated(\"basename(3) is underspecified. Use zfs_basename() instead!\")))" +AM_CPPFLAGS_NOCHECK += -D"dirname(...)=dirname(__VA_ARGS__) __attribute__((deprecated(\"dirname(3) is underspecified. Use zfs_dirnamelen() instead!\")))" +AM_CPPFLAGS_NOCHECK += -D"bcopy(...)=__attribute__((deprecated(\"bcopy(3) is deprecated. Use memcpy(3)/memmove(3) instead!\"))) bcopy(__VA_ARGS__)" +AM_CPPFLAGS_NOCHECK += -D"bcmp(...)=__attribute__((deprecated(\"bcmp(3) is deprecated. Use memcmp(3) instead!\"))) bcmp(__VA_ARGS__)" +AM_CPPFLAGS_NOCHECK += -D"bzero(...)=__attribute__((deprecated(\"bzero(3) is deprecated. Use memset(3) instead!\"))) bzero(__VA_ARGS__)" +AM_CPPFLAGS_NOCHECK += -D"asctime(...)=__attribute__((deprecated(\"Use strftime(3) instead!\"))) asctime(__VA_ARGS__)" +AM_CPPFLAGS_NOCHECK += -D"asctime_r(...)=__attribute__((deprecated(\"Use strftime(3) instead!\"))) asctime_r(__VA_ARGS__)" +AM_CPPFLAGS_NOCHECK += -D"gmtime(...)=__attribute__((deprecated(\"gmtime(3) isn't thread-safe. Use gmtime_r(3) instead!\"))) gmtime(__VA_ARGS__)" +AM_CPPFLAGS_NOCHECK += -D"localtime(...)=__attribute__((deprecated(\"localtime(3) isn't thread-safe. Use localtime_r(3) instead!\"))) localtime(__VA_ARGS__)" +AM_CPPFLAGS += $(AM_CPPFLAGS_NOCHECK) if ASAN_ENABLED AM_CPPFLAGS += -DZFS_ASAN_ENABLED @@ -79,3 +71,13 @@ AM_LDFLAGS += -fstack-protector-strong -shared AM_LDFLAGS += -Wl,-x -Wl,--fatal-warnings -Wl,--warn-shared-textrel AM_LDFLAGS += -lm endif + + +# If a target includes kernel code, generate warnings for large stack frames +KERNEL_CFLAGS = $(FRAME_LARGER_THAN) + +# See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54020 +LIBRARY_CFLAGS = -no-suppress + +# Forcibly enable asserts/debugging for libzpool &al. +FORCEDEBUG_CPPFLAGS = -DDEBUG -UNDEBUG -DZFS_DEBUG diff --git a/sys/contrib/openzfs/config/Shellcheck.am b/sys/contrib/openzfs/config/Shellcheck.am index fb0bdedd3be3..878919575321 100644 --- a/sys/contrib/openzfs/config/Shellcheck.am +++ b/sys/contrib/openzfs/config/Shellcheck.am @@ -1,30 +1,40 @@ -.PHONY: shellcheck -shellcheck: $(SCRIPTS) $(SHELLCHECKSCRIPTS) - -# ShellCheck exclusions +# Global ShellCheck exclusions: # # ShellCheck can't follow non-constant source. Use a directive to specify location. [SC1090] # Not following: a was not specified as input (see shellcheck -x). [SC1091] # Prefer putting braces around variable references even when not strictly required. [SC2250] # In POSIX sh, 'local' is undefined. [SC2039] # older ShellCheck versions # In POSIX sh, 'local' is undefined. [SC3043] # newer ShellCheck versions + +SHELLCHECKSCRIPTS = + +JUST_SHELLCHECK_OPTS = $(addprefix shellcheck-here-,$(subst /,^,$(1))) +JUST_CHECKBASHISMS_OPTS = $(addprefix checkbashisms-here-,$(subst /,^,$(1))) +SHELLCHECK_OPTS = $(call JUST_SHELLCHECK_OPTS,$(1)) $(call JUST_CHECKBASHISMS_OPTS,$(1)) + +PHONY += shellcheck + +_STGT = $(subst ^,/,$(subst shellcheck-here-,,$@)) +shellcheck-here-%: if HAVE_SHELLCHECK - [ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; shellcheck --format=gcc --enable=all --exclude=SC1090,SC1091,SC2039,SC2250,SC3043 $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") $(SHELLCHECK_OPTS) $(SCRIPTS) $(SHELLCHECKSCRIPTS) + shellcheck --format=gcc --enable=all --exclude=SC1090,SC1091,SC2039,SC2250,SC3043 $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") "$$([ -e "$(_STGT)" ] || echo "$(srcdir)/")$(_STGT)" else - @[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping shellcheck of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because shellcheck is not installed" + @echo "skipping shellcheck of" $(_STGT) "because shellcheck is not installed" endif - @set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir shellcheck; done + +shellcheck: $(SHELLCHECKSCRIPTS) $(call JUST_SHELLCHECK_OPTS,$(SHELLCHECKSCRIPTS)) +PHONY += checkbashisms + # command -v *is* specified by POSIX and every shell in existence supports it -.PHONY: checkbashisms -checkbashisms: $(SCRIPTS) $(SHELLCHECKSCRIPTS) +_BTGT = $(subst ^,/,$(subst checkbashisms-here-,,$@)) +checkbashisms-here-%: if HAVE_CHECKBASHISMS - [ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; ! if [ -z "$(SHELLCHECK_SHELL)" ]; then \ - checkbashisms -npx $(SCRIPTS) $(SHELLCHECKSCRIPTS); else \ - for f in $(SCRIPTS) $(SHELLCHECKSCRIPTS); do echo $$f >&3; { echo '#!/bin/$(SHELLCHECK_SHELL)'; cat $$f; } | checkbashisms -npx; done; \ - fi 3>&2 2>&1 | grep -vFe "'command' with option other than -p" -e 'command -v' $(CHECKBASHISMS_IGNORE) >&2 + ! { [ -n "$(SHELLCHECK_SHELL)" ] && echo '#!/bin/$(SHELLCHECK_SHELL)'; cat "$$([ -e "$(_BTGT)" ] || echo "$(srcdir)/")$(_BTGT)"; } | \ + checkbashisms -npx 2>&1 | grep -vFe "'command' with option other than -p" -e 'command -v' -e 'any possible bashisms' $(CHECKBASHISMS_IGNORE) >&2 else - @[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping checkbashisms of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because checkbashisms is not installed" + @echo "skipping checkbashisms of" $(_BTGT) "because checkbashisms is not installed" endif - @set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir checkbashisms; done + +checkbashisms: $(SHELLCHECKSCRIPTS) $(call JUST_CHECKBASHISMS_OPTS,$(SHELLCHECKSCRIPTS)) diff --git a/sys/contrib/openzfs/config/Substfiles.am b/sys/contrib/openzfs/config/Substfiles.am index b051438fb9e3..733073dd20ca 100644 --- a/sys/contrib/openzfs/config/Substfiles.am +++ b/sys/contrib/openzfs/config/Substfiles.am @@ -1,38 +1,46 @@ subst_sed_cmd = \ + -e 's|@abs_top_srcdir[@]|$(abs_top_srcdir)|g' \ -e 's|@bindir[@]|$(bindir)|g' \ - -e 's|@sbindir[@]|$(sbindir)|g' \ -e 's|@datadir[@]|$(datadir)|g' \ - -e 's|@sysconfdir[@]|$(sysconfdir)|g' \ - -e 's|@runstatedir[@]|$(runstatedir)|g' \ -e 's|@initconfdir[@]|$(initconfdir)|g' \ -e 's|@initdir[@]|$(initdir)|g' \ -e 's|@mounthelperdir[@]|$(mounthelperdir)|g' \ + -e 's|@pammoduledir[@]|$(pammoduledir)|g' \ + -e 's|@runstatedir[@]|$(runstatedir)|g' \ + -e 's|@sbindir[@]|$(sbindir)|g' \ + -e 's|@sysconfdir[@]|$(sysconfdir)|g' \ -e 's|@systemdgeneratordir[@]|$(systemdgeneratordir)|g' \ -e 's|@systemdunitdir[@]|$(systemdunitdir)|g' \ -e 's|@udevdir[@]|$(udevdir)|g' \ -e 's|@udevruledir[@]|$(udevruledir)|g' \ -e 's|@zfsexecdir[@]|$(zfsexecdir)|g' \ - -e 's|@PYTHON[@]|$(PYTHON)|g' \ - -e 's|@PYTHON_SHEBANG[@]|$(PYTHON_SHEBANG)|g' \ + \ + -e 's|@ASAN_ENABLED[@]|$(ASAN_ENABLED)|g' \ -e 's|@DEFAULT_INIT_NFS_SERVER[@]|$(DEFAULT_INIT_NFS_SERVER)|g' \ -e 's|@DEFAULT_INIT_SHELL[@]|$(DEFAULT_INIT_SHELL)|g' \ -e 's|@LIBFETCH_DYNAMIC[@]|$(LIBFETCH_DYNAMIC)|g' \ -e 's|@LIBFETCH_SONAME[@]|$(LIBFETCH_SONAME)|g' \ - -e 's|@ASAN_ENABLED[@]|$(ASAN_ENABLED)|g' \ - -e 's|@UBSAN_ENABLED[@]|$(UBSAN_ENABLED)|g' - -SUBSTFILES = -CLEANFILES = $(SUBSTFILES) -EXTRA_DIST = $(SUBSTFILES:=.in) + -e 's|@PYTHON[@]|$(PYTHON)|g' \ + -e 's|@PYTHON_SHEBANG[@]|$(PYTHON_SHEBANG)|g' \ + -e 's|@UBSAN_ENABLED[@]|$(UBSAN_ENABLED)|g' \ + -e 's|@VERSION[@]|$(VERSION)|g' -$(SUBSTFILES):%:%.in Makefile - $(AM_V_GEN)set -e; \ - $(MKDIR_P) $$(dirname $@); \ - $(RM) $@~; \ - $(SED) $(subst_sed_cmd) $< >$@~; \ - if grep -E '@[a-zA-Z0-9_]+@' $@~ >&2; then \ +define SUBST +$(1) : $(2)$(1).in Makefile; + $$(AM_V_GEN)set -e; \ + $$(MKDIR_P) $$(@D); \ + $$(RM) $$@~; \ + $$(SED) $$(subst_sed_cmd) $$< >$$@~; \ + if grep -E '@[a-zA-Z0-9_]+@' $$@~ >&2; then \ echo "Undefined substitution" >&2; \ exit 1; \ - else test $$? -eq 1; fi; \ - test -x $< && chmod +x $@~; \ - mv -f $@~ $@ + fi; \ + [ -x $$< ] && chmod +x $$@~; \ + mv -f $$@~ $$@ +endef + +SUBSTFILES = +CLEANFILES += $(SUBSTFILES) +EXTRA_DIST += $(SUBSTFILES:=.in) + +$(call SUBST,%,) diff --git a/sys/contrib/openzfs/config/always-cppcheck.m4 b/sys/contrib/openzfs/config/always-cppcheck.m4 index c7c134a3e8cd..fa5a3398d923 100644 --- a/sys/contrib/openzfs/config/always-cppcheck.m4 +++ b/sys/contrib/openzfs/config/always-cppcheck.m4 @@ -3,4 +3,7 @@ dnl # Check if cppcheck is available. dnl # AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CPPCHECK], [ AC_CHECK_PROG([CPPCHECK], [cppcheck], [cppcheck]) + if test -z "$CPPCHECK"; then + CPPCHECK='@printf "skipping cppcheck because cppcheck is not installed\n"' + fi ]) diff --git a/sys/contrib/openzfs/config/always-system.m4 b/sys/contrib/openzfs/config/always-system.m4 index 3225a52af8ae..3a3d4212f8b0 100644 --- a/sys/contrib/openzfs/config/always-system.m4 +++ b/sys/contrib/openzfs/config/always-system.m4 @@ -8,18 +8,22 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_SYSTEM], [ AC_DEFINE([SYSTEM_LINUX], [1], [True if ZFS is to be compiled for a Linux system]) ac_system="Linux" + ac_system_l="linux" ;; *freebsd*) AC_DEFINE([SYSTEM_FREEBSD], [1], [True if ZFS is to be compiled for a FreeBSD system]) ac_system="FreeBSD" + ac_system_l="freebsd" ;; *) ac_system="unknown" + ac_system_l="unknown" ;; esac AC_MSG_RESULT([$ac_system]) AC_SUBST([ac_system]) + AC_SUBST([ac_system_l]) AM_CONDITIONAL([BUILD_LINUX], [test "x$ac_system" = "xLinux"]) AM_CONDITIONAL([BUILD_FREEBSD], [test "x$ac_system" = "xFreeBSD"]) diff --git a/sys/contrib/openzfs/config/config.awk b/sys/contrib/openzfs/config/config.awk deleted file mode 100644 index cc4b7cc265cd..000000000000 --- a/sys/contrib/openzfs/config/config.awk +++ /dev/null @@ -1,15 +0,0 @@ -# Remove default preprocessor define's from config.h -# PACKAGE -# PACKAGE_BUGREPORT -# PACKAGE_NAME -# PACKAGE_STRING -# PACKAGE_TARNAME -# PACKAGE_VERSION -# STDC_HEADERS -# VERSION - -BEGIN { RS = "" ; FS = "\n" } \ - !/.#define PACKAGE./ && \ - !/.#define VERSION./ && \ - !/.#define STDC_HEADERS./ \ - { print $0"\n" } diff --git a/sys/contrib/openzfs/config/deb.am b/sys/contrib/openzfs/config/deb.am index 65aa70687ba5..0033dd7591ff 100644 --- a/sys/contrib/openzfs/config/deb.am +++ b/sys/contrib/openzfs/config/deb.am @@ -61,8 +61,8 @@ deb-utils: deb-local rpm-utils-initramfs pkg7=$${name}-test-$${version}.$${arch}.rpm; \ pkg8=$${name}-dracut-$${version}.noarch.rpm; \ pkg9=$${name}-initramfs-$${version}.$${arch}.rpm; \ - pkg10=`ls python*-pyzfs-$${version}* | tail -1`; \ - pkg11=pam_zfs_key-$${version}.$${arch}.rpm; \ + pkg10=`ls python3-pyzfs-$${version}.noarch.rpm 2>/dev/null`; \ + pkg11=`ls pam_zfs_key-$${version}.$${arch}.rpm 2>/dev/null`; \ ## Arguments need to be passed to dh_shlibdeps. Alien provides no mechanism ## to do this, so we install a shim onto the path which calls the real ## dh_shlibdeps with the required arguments. diff --git a/sys/contrib/openzfs/config/kernel-blk-queue.m4 b/sys/contrib/openzfs/config/kernel-blk-queue.m4 index 559ae9800e8f..2472c49dda4b 100644 --- a/sys/contrib/openzfs/config/kernel-blk-queue.m4 +++ b/sys/contrib/openzfs/config/kernel-blk-queue.m4 @@ -93,8 +93,10 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD], [ ZFS_LINUX_TEST_SRC([blk_queue_discard], [ #include <linux/blkdev.h> ],[ - struct request_queue *q __attribute__ ((unused)) = NULL; + struct request_queue r; + struct request_queue *q = &r; int value __attribute__ ((unused)); + memset(q, 0, sizeof(r)); value = blk_queue_discard(q); ]) ]) @@ -119,16 +121,20 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE], [ ZFS_LINUX_TEST_SRC([blk_queue_secure_erase], [ #include <linux/blkdev.h> ],[ - struct request_queue *q __attribute__ ((unused)) = NULL; + struct request_queue r; + struct request_queue *q = &r; int value __attribute__ ((unused)); + memset(q, 0, sizeof(r)); value = blk_queue_secure_erase(q); ]) ZFS_LINUX_TEST_SRC([blk_queue_secdiscard], [ #include <linux/blkdev.h> ],[ - struct request_queue *q __attribute__ ((unused)) = NULL; + struct request_queue r; + struct request_queue *q = &r; int value __attribute__ ((unused)); + memset(q, 0, sizeof(r)); value = blk_queue_secdiscard(q); ]) ]) diff --git a/sys/contrib/openzfs/config/kernel-config-defined.m4 b/sys/contrib/openzfs/config/kernel-config-defined.m4 index c7d18b49b14e..54837d728341 100644 --- a/sys/contrib/openzfs/config/kernel-config-defined.m4 +++ b/sys/contrib/openzfs/config/kernel-config-defined.m4 @@ -19,19 +19,48 @@ AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEFINED], [ ]) ]) + ZFS_AC_KERNEL_SRC_CONFIG_MODULES + ZFS_AC_KERNEL_SRC_CONFIG_BLOCK ZFS_AC_KERNEL_SRC_CONFIG_DEBUG_LOCK_ALLOC ZFS_AC_KERNEL_SRC_CONFIG_TRIM_UNUSED_KSYMS - ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_INFLATE ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_DEFLATE + ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_INFLATE AC_MSG_CHECKING([for kernel config option compatibility]) ZFS_LINUX_TEST_COMPILE_ALL([config]) AC_MSG_RESULT([done]) + ZFS_AC_KERNEL_CONFIG_MODULES + ZFS_AC_KERNEL_CONFIG_BLOCK ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC ZFS_AC_KERNEL_CONFIG_TRIM_UNUSED_KSYMS - ZFS_AC_KERNEL_CONFIG_ZLIB_INFLATE ZFS_AC_KERNEL_CONFIG_ZLIB_DEFLATE + ZFS_AC_KERNEL_CONFIG_ZLIB_INFLATE +]) + +dnl # +dnl # Check CONFIG_BLOCK +dnl # +dnl # Verify the kernel has CONFIG_BLOCK support enabled. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_BLOCK], [ + ZFS_LINUX_TEST_SRC([config_block], [ + #if !defined(CONFIG_BLOCK) + #error CONFIG_BLOCK not defined + #endif + ],[]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_CONFIG_BLOCK], [ + AC_MSG_CHECKING([whether CONFIG_BLOCK is defined]) + ZFS_LINUX_TEST_RESULT([config_block], [ + AC_MSG_RESULT([yes]) + ],[ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([ + *** This kernel does not include the required block device support. + *** Rebuild the kernel with CONFIG_BLOCK=y set.]) + ]) ]) dnl # @@ -73,6 +102,61 @@ AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC], [ ]) dnl # +dnl # Check CONFIG_MODULES +dnl # +dnl # Verify the kernel has CONFIG_MODULES support enabled. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_MODULES], [ + ZFS_LINUX_TEST_SRC([config_modules], [ + #if !defined(CONFIG_MODULES) + #error CONFIG_MODULES not defined + #endif + ],[]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_CONFIG_MODULES], [ + AC_MSG_CHECKING([whether CONFIG_MODULES is defined]) + AS_IF([test "x$enable_linux_builtin" != xyes], [ + ZFS_LINUX_TEST_RESULT([config_modules], [ + AC_MSG_RESULT([yes]) + ],[ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([ + *** This kernel does not include the required loadable module + *** support! + *** + *** To build OpenZFS as a loadable Linux kernel module + *** enable loadable module support by setting + *** `CONFIG_MODULES=y` in the kernel configuration and run + *** `make modules_prepare` in the Linux source tree. + *** + *** If you don't intend to enable loadable kernel module + *** support, please compile OpenZFS as a Linux kernel built-in. + *** + *** Prepare the Linux source tree by running `make prepare`, + *** use the OpenZFS `--enable-linux-builtin` configure option, + *** copy the OpenZFS sources into the Linux source tree using + *** `./copy-builtin <linux source directory>`, + *** set `CONFIG_ZFS=y` in the kernel configuration and compile + *** kernel as usual. + ]) + ]) + ], [ + ZFS_LINUX_TRY_COMPILE([], [], [ + AC_MSG_RESULT([not needed]) + ],[ + AC_MSG_RESULT([error]) + AC_MSG_ERROR([ + *** This kernel is unable to compile object files. + *** + *** Please make sure you prepared the Linux source tree + *** by running `make prepare` there. + ]) + ]) + ]) +]) + +dnl # dnl # Check CONFIG_TRIM_UNUSED_KSYMS dnl # dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS disabled. diff --git a/sys/contrib/openzfs/config/kernel-copy-from-user-inatomic.m4 b/sys/contrib/openzfs/config/kernel-copy-from-user-inatomic.m4 new file mode 100644 index 000000000000..fec354b2f38e --- /dev/null +++ b/sys/contrib/openzfs/config/kernel-copy-from-user-inatomic.m4 @@ -0,0 +1,29 @@ +dnl # +dnl # On certain architectures `__copy_from_user_inatomic` +dnl # is a GPL exported variable and cannot be used by OpenZFS. +dnl # + +dnl # +dnl # Checking if `__copy_from_user_inatomic` is available. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC___COPY_FROM_USER_INATOMIC], [ + ZFS_LINUX_TEST_SRC([__copy_from_user_inatomic], [ + #include <linux/uaccess.h> + ], [ + int result __attribute__ ((unused)) = __copy_from_user_inatomic(NULL, NULL, 0); + ], [], [ZFS_META_LICENSE]) +]) + +AC_DEFUN([ZFS_AC_KERNEL___COPY_FROM_USER_INATOMIC], [ + AC_MSG_CHECKING([whether __copy_from_user_inatomic is available]) + ZFS_LINUX_TEST_RESULT([__copy_from_user_inatomic_license], [ + AC_MSG_RESULT(yes) + ], [ + AC_MSG_RESULT(no) + AC_MSG_ERROR([ + *** The `__copy_from_user_inatomic()` Linux kernel function is + *** incompatible with the CDDL license and will prevent the module + *** linking stage from succeeding. OpenZFS cannot be compiled. + ]) + ]) +]) diff --git a/sys/contrib/openzfs/config/kernel-genhd-flags.m4 b/sys/contrib/openzfs/config/kernel-genhd-flags.m4 new file mode 100644 index 000000000000..af6a8a086bc9 --- /dev/null +++ b/sys/contrib/openzfs/config/kernel-genhd-flags.m4 @@ -0,0 +1,58 @@ +dnl # +dnl # 5.17 API change, +dnl # +dnl # GENHD_FL_EXT_DEVT flag removed +dnl # GENHD_FL_NO_PART_SCAN renamed GENHD_FL_NO_PART +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_GENHD_FLAGS], [ + + ZFS_LINUX_TEST_SRC([genhd_fl_ext_devt], [ + #include <linux/blkdev.h> + ], [ + int flags __attribute__ ((unused)) = GENHD_FL_EXT_DEVT; + ]) + + ZFS_LINUX_TEST_SRC([genhd_fl_no_part], [ + #include <linux/blkdev.h> + ], [ + int flags __attribute__ ((unused)) = GENHD_FL_NO_PART; + ]) + + ZFS_LINUX_TEST_SRC([genhd_fl_no_part_scan], [ + #include <linux/blkdev.h> + ], [ + int flags __attribute__ ((unused)) = GENHD_FL_NO_PART_SCAN; + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_GENHD_FLAGS], [ + + AC_MSG_CHECKING([whether GENHD_FL_EXT_DEVT flag is available]) + ZFS_LINUX_TEST_RESULT([genhd_fl_ext_devt], [ + AC_MSG_RESULT(yes) + AC_DEFINE(ZFS_GENHD_FL_EXT_DEVT, GENHD_FL_EXT_DEVT, + [GENHD_FL_EXT_DEVT flag is available]) + ], [ + AC_MSG_RESULT(no) + AC_DEFINE(ZFS_GENHD_FL_EXT_DEVT, 0, + [GENHD_FL_EXT_DEVT flag is not available]) + ]) + + AC_MSG_CHECKING([whether GENHD_FL_NO_PART flag is available]) + ZFS_LINUX_TEST_RESULT([genhd_fl_no_part], [ + AC_MSG_RESULT(yes) + AC_DEFINE(ZFS_GENHD_FL_NO_PART, GENHD_FL_NO_PART, + [GENHD_FL_NO_PART flag is available]) + ], [ + AC_MSG_RESULT(no) + + AC_MSG_CHECKING([whether GENHD_FL_NO_PART_SCAN flag is available]) + ZFS_LINUX_TEST_RESULT([genhd_fl_no_part_scan], [ + AC_MSG_RESULT(yes) + AC_DEFINE(ZFS_GENHD_FL_NO_PART, GENHD_FL_NO_PART_SCAN, + [GENHD_FL_NO_PART_SCAN flag is available]) + ], [ + ZFS_LINUX_TEST_ERROR([GENHD_FL_NO_PART|GENHD_FL_NO_PART_SCAN]) + ]) + ]) +]) diff --git a/sys/contrib/openzfs/config/kernel-global_page_state.m4 b/sys/contrib/openzfs/config/kernel-global_page_state.m4 index badb5e5d2e23..76f2bba202a1 100644 --- a/sys/contrib/openzfs/config/kernel-global_page_state.m4 +++ b/sys/contrib/openzfs/config/kernel-global_page_state.m4 @@ -55,7 +55,7 @@ dnl # AC_DEFUN([ZFS_AC_KERNEL_ENUM_MEMBER], [ AC_MSG_CHECKING([whether enum $2 contains $1]) AS_IF([AC_TRY_COMMAND( - "${srcdir}/scripts/enum-extract.pl" "$2" "$3" | egrep -qx $1)],[ + "${srcdir}/scripts/enum-extract.pl" "$2" "$3" | grep -Eqx $1)],[ AC_MSG_RESULT([yes]) AC_DEFINE(m4_join([_], [ZFS_ENUM], m4_toupper($2), $1), 1, [enum $2 contains $1]) diff --git a/sys/contrib/openzfs/config/kernel-group-info.m4 b/sys/contrib/openzfs/config/kernel-group-info.m4 index 0fee1d36d50d..6941d62da017 100644 --- a/sys/contrib/openzfs/config/kernel-group-info.m4 +++ b/sys/contrib/openzfs/config/kernel-group-info.m4 @@ -6,8 +6,8 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_GROUP_INFO_GID], [ ZFS_LINUX_TEST_SRC([group_info_gid], [ #include <linux/cred.h> ],[ - struct group_info *gi = groups_alloc(1); - gi->gid[0] = KGIDT_INIT(0); + struct group_info gi __attribute__ ((unused)) = {}; + gi.gid[0] = KGIDT_INIT(0); ]) ]) diff --git a/sys/contrib/openzfs/config/kernel-inode-permission.m4 b/sys/contrib/openzfs/config/kernel-inode-permission.m4 new file mode 100644 index 000000000000..ba9ff5d43d4d --- /dev/null +++ b/sys/contrib/openzfs/config/kernel-inode-permission.m4 @@ -0,0 +1,29 @@ +AC_DEFUN([ZFS_AC_KERNEL_SRC_PERMISSION], [ + dnl # + dnl # 5.12 API change that added the struct user_namespace* arg + dnl # to the front of this function type's arg list. + dnl # + ZFS_LINUX_TEST_SRC([permission_userns], [ + #include <linux/fs.h> + #include <linux/sched.h> + + int inode_permission(struct user_namespace *userns, + struct inode *inode, int mask) { return 0; } + + static const struct inode_operations + iops __attribute__ ((unused)) = { + .permission = inode_permission, + }; + ],[]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_PERMISSION], [ + AC_MSG_CHECKING([whether iops->permission() takes struct user_namespace*]) + ZFS_LINUX_TEST_RESULT([permission_userns], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_IOPS_PERMISSION_USERNS, 1, + [iops->permission() takes struct user_namespace*]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/sys/contrib/openzfs/config/kernel-mkdir.m4 b/sys/contrib/openzfs/config/kernel-mkdir.m4 index a162bcd880ff..6667ed04fa4c 100644 --- a/sys/contrib/openzfs/config/kernel-mkdir.m4 +++ b/sys/contrib/openzfs/config/kernel-mkdir.m4 @@ -53,6 +53,8 @@ AC_DEFUN([ZFS_AC_KERNEL_MKDIR], [ AC_DEFINE(HAVE_IOPS_MKDIR_USERNS, 1, [iops->mkdir() takes struct user_namespace*]) ],[ + AC_MSG_RESULT(no) + AC_MSG_CHECKING([whether iops->mkdir() takes umode_t]) ZFS_LINUX_TEST_RESULT([inode_operations_mkdir], [ AC_MSG_RESULT(yes) diff --git a/sys/contrib/openzfs/config/kernel-readpages.m4 b/sys/contrib/openzfs/config/kernel-readpages.m4 new file mode 100644 index 000000000000..0bf67ffd933d --- /dev/null +++ b/sys/contrib/openzfs/config/kernel-readpages.m4 @@ -0,0 +1,25 @@ +dnl # +dnl # Linux 5.18 removes address_space_operations ->readpages in favour of +dnl # ->readahead +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_READPAGES], [ + ZFS_LINUX_TEST_SRC([vfs_has_readpages], [ + #include <linux/fs.h> + + static const struct address_space_operations + aops __attribute__ ((unused)) = { + .readpages = NULL, + }; + ],[]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_VFS_READPAGES], [ + AC_MSG_CHECKING([address_space_operations->readpages exists]) + ZFS_LINUX_TEST_RESULT([vfs_has_readpages], [ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_VFS_READPAGES, 1, + [address_space_operations->readpages exists]) + ],[ + AC_MSG_RESULT([no]) + ]) +]) diff --git a/sys/contrib/openzfs/config/kernel-sysfs.m4 b/sys/contrib/openzfs/config/kernel-sysfs.m4 new file mode 100644 index 000000000000..668def5fe6bf --- /dev/null +++ b/sys/contrib/openzfs/config/kernel-sysfs.m4 @@ -0,0 +1,37 @@ +dnl # +dnl # Linux 5.2/5.18 API +dnl # +dnl # In cdb4f26a63c391317e335e6e683a614358e70aeb ("kobject: kobj_type: remove default_attrs") +dnl # struct kobj_type.default_attrs +dnl # was finally removed in favour of +dnl # struct kobj_type.default_groups +dnl # +dnl # This was added in aa30f47cf666111f6bbfd15f290a27e8a7b9d854 ("kobject: Add support for default attribute groups to kobj_type"), +dnl # if both are present (5.2-5.17), we prefer default_groups; they're otherwise equivalent +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_SYSFS_DEFAULT_GROUPS], [ + ZFS_LINUX_TEST_SRC([sysfs_default_groups], [ + #include <linux/kobject.h> + ],[ + struct kobj_type __attribute__ ((unused)) kt = { + .default_groups = (const struct attribute_group **)NULL }; + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_SYSFS_DEFAULT_GROUPS], [ + AC_MSG_CHECKING([for struct kobj_type.default_groups]) + ZFS_LINUX_TEST_RESULT([sysfs_default_groups],[ + AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_SYSFS_DEFAULT_GROUPS], 1, [struct kobj_type has default_groups]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_SRC_SYSFS], [ + ZFS_AC_KERNEL_SRC_SYSFS_DEFAULT_GROUPS +]) + +AC_DEFUN([ZFS_AC_KERNEL_SYSFS], [ + ZFS_AC_KERNEL_SYSFS_DEFAULT_GROUPS +]) diff --git a/sys/contrib/openzfs/config/kernel-vfs-filemap_dirty_folio.m4 b/sys/contrib/openzfs/config/kernel-vfs-filemap_dirty_folio.m4 new file mode 100644 index 000000000000..872879002928 --- /dev/null +++ b/sys/contrib/openzfs/config/kernel-vfs-filemap_dirty_folio.m4 @@ -0,0 +1,30 @@ +dnl # +dnl # Linux 5.18 uses filemap_dirty_folio in lieu of +dnl # ___set_page_dirty_nobuffers +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_FILEMAP_DIRTY_FOLIO], [ + ZFS_LINUX_TEST_SRC([vfs_has_filemap_dirty_folio], [ + #include <linux/pagemap.h> + #include <linux/writeback.h> + + static const struct address_space_operations + aops __attribute__ ((unused)) = { + .dirty_folio = filemap_dirty_folio, + }; + ],[]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_VFS_FILEMAP_DIRTY_FOLIO], [ + dnl # + dnl # Linux 5.18 uses filemap_dirty_folio in lieu of + dnl # ___set_page_dirty_nobuffers + dnl # + AC_MSG_CHECKING([filemap_dirty_folio exists]) + ZFS_LINUX_TEST_RESULT([vfs_has_filemap_dirty_folio], [ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_VFS_FILEMAP_DIRTY_FOLIO, 1, + [filemap_dirty_folio exists]) + ],[ + AC_MSG_RESULT([no]) + ]) +]) diff --git a/sys/contrib/openzfs/config/kernel.m4 b/sys/contrib/openzfs/config/kernel.m4 index d1d3dede175b..a70db91a8364 100644 --- a/sys/contrib/openzfs/config/kernel.m4 +++ b/sys/contrib/openzfs/config/kernel.m4 @@ -8,8 +8,8 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_QAT dnl # Sanity checks for module building and CONFIG_* defines - ZFS_AC_KERNEL_TEST_MODULE ZFS_AC_KERNEL_CONFIG_DEFINED + ZFS_AC_MODULE_SYMVERS dnl # Sequential ZFS_LINUX_TRY_COMPILE tests ZFS_AC_KERNEL_FPU_HEADER @@ -61,6 +61,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_BIO ZFS_AC_KERNEL_SRC_BLKDEV ZFS_AC_KERNEL_SRC_BLK_QUEUE + ZFS_AC_KERNEL_SRC_GENHD_FLAGS ZFS_AC_KERNEL_SRC_REVALIDATE_DISK ZFS_AC_KERNEL_SRC_GET_DISK_RO ZFS_AC_KERNEL_SRC_GENERIC_READLINK_GLOBAL @@ -82,6 +83,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_MKDIR ZFS_AC_KERNEL_SRC_LOOKUP_FLAGS ZFS_AC_KERNEL_SRC_CREATE + ZFS_AC_KERNEL_SRC_PERMISSION ZFS_AC_KERNEL_SRC_GET_LINK ZFS_AC_KERNEL_SRC_PUT_LINK ZFS_AC_KERNEL_SRC_TMPFILE @@ -99,6 +101,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_SET_NLINK ZFS_AC_KERNEL_SRC_SGET ZFS_AC_KERNEL_SRC_LSEEK_EXECUTE + ZFS_AC_KERNEL_SRC_VFS_FILEMAP_DIRTY_FOLIO ZFS_AC_KERNEL_SRC_VFS_GETATTR ZFS_AC_KERNEL_SRC_VFS_FSYNC_2ARGS ZFS_AC_KERNEL_SRC_VFS_ITERATE @@ -131,13 +134,16 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_BIO_MAX_SEGS ZFS_AC_KERNEL_SRC_SIGNAL_STOP ZFS_AC_KERNEL_SRC_SIGINFO + ZFS_AC_KERNEL_SRC_SYSFS ZFS_AC_KERNEL_SRC_SET_SPECIAL_STATE + ZFS_AC_KERNEL_SRC_VFS_READPAGES ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG ZFS_AC_KERNEL_SRC_PAGEMAP_FOLIO_WAIT_BIT ZFS_AC_KERNEL_SRC_ADD_DISK ZFS_AC_KERNEL_SRC_KTHREAD ZFS_AC_KERNEL_SRC_ZERO_PAGE + ZFS_AC_KERNEL_SRC___COPY_FROM_USER_INATOMIC AC_MSG_CHECKING([for available kernel interfaces]) ZFS_LINUX_TEST_COMPILE_ALL([kabi]) @@ -172,6 +178,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_BIO ZFS_AC_KERNEL_BLKDEV ZFS_AC_KERNEL_BLK_QUEUE + ZFS_AC_KERNEL_GENHD_FLAGS ZFS_AC_KERNEL_REVALIDATE_DISK ZFS_AC_KERNEL_GET_DISK_RO ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL @@ -193,6 +200,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_MKDIR ZFS_AC_KERNEL_LOOKUP_FLAGS ZFS_AC_KERNEL_CREATE + ZFS_AC_KERNEL_PERMISSION ZFS_AC_KERNEL_GET_LINK ZFS_AC_KERNEL_PUT_LINK ZFS_AC_KERNEL_TMPFILE @@ -210,6 +218,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_SET_NLINK ZFS_AC_KERNEL_SGET ZFS_AC_KERNEL_LSEEK_EXECUTE + ZFS_AC_KERNEL_VFS_FILEMAP_DIRTY_FOLIO ZFS_AC_KERNEL_VFS_GETATTR ZFS_AC_KERNEL_VFS_FSYNC_2ARGS ZFS_AC_KERNEL_VFS_ITERATE @@ -242,13 +251,16 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_BIO_MAX_SEGS ZFS_AC_KERNEL_SIGNAL_STOP ZFS_AC_KERNEL_SIGINFO + ZFS_AC_KERNEL_SYSFS ZFS_AC_KERNEL_SET_SPECIAL_STATE + ZFS_AC_KERNEL_VFS_READPAGES ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG ZFS_AC_KERNEL_PAGEMAP_FOLIO_WAIT_BIT ZFS_AC_KERNEL_ADD_DISK ZFS_AC_KERNEL_KTHREAD ZFS_AC_KERNEL_ZERO_PAGE + ZFS_AC_KERNEL___COPY_FROM_USER_INATOMIC ]) dnl # @@ -392,11 +404,11 @@ AC_DEFUN([ZFS_AC_KERNEL], [ utsrelease1=$kernelbuild/include/linux/version.h utsrelease2=$kernelbuild/include/linux/utsrelease.h utsrelease3=$kernelbuild/include/generated/utsrelease.h - AS_IF([test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1], [ + AS_IF([test -r $utsrelease1 && grep -qF UTS_RELEASE $utsrelease1], [ utsrelease=$utsrelease1 - ], [test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2], [ + ], [test -r $utsrelease2 && grep -qF UTS_RELEASE $utsrelease2], [ utsrelease=$utsrelease2 - ], [test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3], [ + ], [test -r $utsrelease3 && grep -qF UTS_RELEASE $utsrelease3], [ utsrelease=$utsrelease3 ]) @@ -437,8 +449,6 @@ AC_DEFUN([ZFS_AC_KERNEL], [ AC_SUBST(LINUX) AC_SUBST(LINUX_OBJ) AC_SUBST(LINUX_VERSION) - - ZFS_AC_MODULE_SYMVERS ]) dnl # @@ -534,27 +544,6 @@ AC_DEFUN([ZFS_AC_QAT], [ ]) dnl # -dnl # Basic toolchain sanity check. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_TEST_MODULE], [ - AC_MSG_CHECKING([whether modules can be built]) - ZFS_LINUX_TRY_COMPILE([], [], [ - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no]) - if test "x$enable_linux_builtin" != xyes; then - AC_MSG_ERROR([ - *** Unable to build an empty module. - ]) - else - AC_MSG_ERROR([ - *** Unable to build an empty module. - *** Please run 'make scripts' inside the kernel source tree.]) - fi - ]) -]) - -dnl # dnl # ZFS_LINUX_CONFTEST_H dnl # AC_DEFUN([ZFS_LINUX_CONFTEST_H], [ @@ -656,8 +645,10 @@ AC_DEFUN([ZFS_LINUX_COMPILE], [ build kernel modules with LLVM/CLANG toolchain]) AC_TRY_COMMAND([ KBUILD_MODPOST_NOFINAL="$5" KBUILD_MODPOST_WARN="$6" - make modules -k -j$TEST_JOBS ${KERNEL_CC:+CC=$KERNEL_CC} ${KERNEL_LD:+LD=$KERNEL_LD} ${KERNEL_LLVM:+LLVM=$KERNEL_LLVM} -C $LINUX_OBJ $ARCH_UM - M=$PWD/$1 >$1/build.log 2>&1]) + make modules -k -j$TEST_JOBS ${KERNEL_CC:+CC=$KERNEL_CC} + ${KERNEL_LD:+LD=$KERNEL_LD} ${KERNEL_LLVM:+LLVM=$KERNEL_LLVM} + CONFIG_MODULES=y CFLAGS_MODULE=-DCONFIG_MODULES + -C $LINUX_OBJ $ARCH_UM M=$PWD/$1 >$1/build.log 2>&1]) AS_IF([AC_TRY_COMMAND([$2])], [$3], [$4]) ]) diff --git a/sys/contrib/openzfs/config/user-systemd.m4 b/sys/contrib/openzfs/config/user-systemd.m4 index 63f02ad2a82b..e4fd0b57c2b7 100644 --- a/sys/contrib/openzfs/config/user-systemd.m4 +++ b/sys/contrib/openzfs/config/user-systemd.m4 @@ -35,16 +35,15 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_SYSTEMD], [ AC_MSG_RESULT([$enable_systemd]) AS_IF([test "x$enable_systemd" = xyes], [ - ZFS_INIT_SYSTEMD=systemd - ZFS_MODULE_LOAD=modules-load.d DEFINE_SYSTEMD='--with systemd --define "_unitdir $(systemdunitdir)" --define "_presetdir $(systemdpresetdir)" --define "_generatordir $(systemdgeneratordir)"' modulesloaddir=$systemdmodulesloaddir ],[ DEFINE_SYSTEMD='--without systemd' ]) - AC_SUBST(ZFS_INIT_SYSTEMD) - AC_SUBST(ZFS_MODULE_LOAD) + ZFS_INIT_SYSTEMD=$enable_systemd + ZFS_WANT_MODULES_LOAD_D=$enable_systemd + AC_SUBST(DEFINE_SYSTEMD) AC_SUBST(systemdunitdir) AC_SUBST(systemdpresetdir) diff --git a/sys/contrib/openzfs/config/user-sysvinit.m4 b/sys/contrib/openzfs/config/user-sysvinit.m4 index b6b63f1cfa36..cf3c8129f0d2 100644 --- a/sys/contrib/openzfs/config/user-sysvinit.m4 +++ b/sys/contrib/openzfs/config/user-sysvinit.m4 @@ -2,10 +2,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_SYSVINIT], [ AC_ARG_ENABLE(sysvinit, AS_HELP_STRING([--enable-sysvinit], [install SysV init scripts [default: yes]]), - [],enable_sysvinit=yes) + [], enable_sysvinit=yes) - AS_IF([test "x$enable_sysvinit" = xyes], - [ZFS_INIT_SYSV=init.d]) - - AC_SUBST(ZFS_INIT_SYSV) + ZFS_INIT_SYSV=$enable_sysvinit ]) diff --git a/sys/contrib/openzfs/config/user.m4 b/sys/contrib/openzfs/config/user.m4 index f450af47e04d..a7241f44f1fd 100644 --- a/sys/contrib/openzfs/config/user.m4 +++ b/sys/contrib/openzfs/config/user.m4 @@ -30,19 +30,8 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [ ZFS_AC_CONFIG_USER_MAKEDEV_IN_SYSMACROS ZFS_AC_CONFIG_USER_MAKEDEV_IN_MKDEV ZFS_AC_CONFIG_USER_ZFSEXEC - ZFS_AC_TEST_FRAMEWORK AC_CHECK_FUNCS([issetugid mlockall strlcat strlcpy]) -]) - -dnl # -dnl # Setup the environment for the ZFS Test Suite. Currently only -dnl # Linux style systems are supported but this infrastructure can -dnl # be extended to support other platforms if needed. -dnl # -AC_DEFUN([ZFS_AC_TEST_FRAMEWORK], [ - ZONENAME="echo global" - AC_SUBST(ZONENAME) AC_SUBST(RM) ]) diff --git a/sys/contrib/openzfs/config/zfs-build.m4 b/sys/contrib/openzfs/config/zfs-build.m4 index d516f3d2969f..59bca5579252 100644 --- a/sys/contrib/openzfs/config/zfs-build.m4 +++ b/sys/contrib/openzfs/config/zfs-build.m4 @@ -173,7 +173,7 @@ AC_DEFUN([ZFS_AC_DEBUG_KMEM_TRACKING], [ ]) AC_DEFUN([ZFS_AC_DEBUG_INVARIANTS_DETECT_FREEBSD], [ - AS_IF([sysctl -n kern.conftxt | fgrep -qx $'options\tINVARIANTS'], + AS_IF([sysctl -n kern.conftxt | grep -Fqx $'options\tINVARIANTS'], [enable_invariants="yes"], [enable_invariants="no"]) ]) @@ -259,6 +259,10 @@ AC_DEFUN([ZFS_AC_CONFIG], [ AC_SUBST(TEST_JOBS) ]) + ZFS_INIT_SYSV= + ZFS_INIT_SYSTEMD= + ZFS_WANT_MODULES_LOAD_D= + case "$ZFS_CONFIG" in kernel) ZFS_AC_CONFIG_KERNEL ;; user) ZFS_AC_CONFIG_USER ;; @@ -271,6 +275,10 @@ AC_DEFUN([ZFS_AC_CONFIG], [ user kernel|user|all|srpm]) ;; esac + AM_CONDITIONAL([INIT_SYSV], [test "x$ZFS_INIT_SYSV" = "xyes"]) + AM_CONDITIONAL([INIT_SYSTEMD], [test "x$ZFS_INIT_SYSTEMD" = "xyes"]) + AM_CONDITIONAL([WANT_MODULES_LOAD_D], [test "x$ZFS_WANT_MODULES_LOAD_D" = "xyes"]) + AM_CONDITIONAL([CONFIG_USER], [test "$ZFS_CONFIG" = user -o "$ZFS_CONFIG" = all]) AM_CONDITIONAL([CONFIG_KERNEL], diff --git a/sys/contrib/openzfs/configure.ac b/sys/contrib/openzfs/configure.ac index 990958bafa1e..7e356cbd20b2 100644 --- a/sys/contrib/openzfs/configure.ac +++ b/sys/contrib/openzfs/configure.ac @@ -1,5 +1,5 @@ /* - * This file is part of the ZFS Linux port. + * This file is part of OpenZFS. * * Copyright (c) 2009 Lawrence Livermore National Security, LLC. * Produced at Lawrence Livermore National Laboratory @@ -30,8 +30,8 @@ * CDDL HEADER END */ -AC_INIT(m4_esyscmd(grep ^Name: META | cut -d ':' -f 2 | tr -d ' \n'), - m4_esyscmd(grep ^Version: META | cut -d ':' -f 2 | tr -d ' \n')) +AC_INIT(m4_esyscmd(awk '/^Name:/ {printf $2}' META), + m4_esyscmd(awk '/^Version:/ {printf $2}' META)) AC_LANG(C) ZFS_AC_META AC_CONFIG_AUX_DIR([config]) @@ -39,11 +39,11 @@ AC_CONFIG_MACRO_DIR([config]) AC_CANONICAL_TARGET AM_MAINTAINER_MODE m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -AM_INIT_AUTOMAKE([subdir-objects]) +AM_INIT_AUTOMAKE([subdir-objects foreign]) +# Remove default macros from config.h: +# PACKAGE, PACKAGE_{BUGREPORT,NAME,STRING,TARNAME,VERSION}, STDC_HEADERS, VERSION AC_CONFIG_HEADERS([zfs_config.h], [ - (mv zfs_config.h zfs_config.h.tmp && - awk -f ${ac_srcdir}/config/config.awk zfs_config.h.tmp >zfs_config.h && - rm zfs_config.h.tmp) || exit 1]) + sed -nEi~ -e '/^$/be' -e 'N;N;/#define (PACKAGE|VERSION|STDC_HEADERS)/d' -e ':e' -e 'p' zfs_config.h && rm zfs_config.h~ || exit]) LT_INIT AC_PROG_INSTALL @@ -66,356 +66,19 @@ ZFS_AC_DEBUG_INVARIANTS AC_CONFIG_FILES([ Makefile - cmd/Makefile - cmd/arc_summary/Makefile - cmd/arcstat/Makefile - cmd/dbufstat/Makefile - cmd/fsck_zfs/Makefile - cmd/mount_zfs/Makefile - cmd/raidz_test/Makefile - cmd/vdev_id/Makefile - cmd/zdb/Makefile - cmd/zed/Makefile - cmd/zed/zed.d/Makefile - cmd/zfs/Makefile - cmd/zfs_ids_to_path/Makefile - cmd/zgenhostid/Makefile - cmd/zhack/Makefile - cmd/zinject/Makefile - cmd/zpool/Makefile - cmd/zstream/Makefile - cmd/ztest/Makefile - cmd/zvol_id/Makefile - cmd/zvol_wait/Makefile - cmd/zpool_influxdb/Makefile - contrib/Makefile - contrib/bash_completion.d/Makefile - contrib/bpftrace/Makefile - contrib/dracut/02zfsexpandknowledge/Makefile - contrib/dracut/90zfs/Makefile - contrib/dracut/Makefile - contrib/initramfs/Makefile - contrib/initramfs/conf.d/Makefile - contrib/initramfs/conf-hooks.d/Makefile - contrib/initramfs/hooks/Makefile - contrib/initramfs/scripts/Makefile - contrib/initramfs/scripts/local-top/Makefile - contrib/pam_zfs_key/Makefile - contrib/pyzfs/Makefile - contrib/pyzfs/setup.py - contrib/zcp/Makefile - etc/Makefile - etc/default/Makefile - etc/init.d/Makefile - etc/modules-load.d/Makefile - etc/sudoers.d/Makefile - etc/systemd/Makefile - etc/systemd/system-generators/Makefile - etc/systemd/system/Makefile - etc/zfs/Makefile include/Makefile - include/os/Makefile - include/os/freebsd/Makefile - include/os/freebsd/linux/Makefile - include/os/freebsd/spl/Makefile - include/os/freebsd/spl/acl/Makefile - include/os/freebsd/spl/rpc/Makefile - include/os/freebsd/spl/sys/Makefile - include/os/freebsd/zfs/Makefile - include/os/freebsd/zfs/sys/Makefile - include/os/linux/Makefile - include/os/linux/kernel/Makefile - include/os/linux/kernel/linux/Makefile - include/os/linux/spl/Makefile - include/os/linux/spl/rpc/Makefile - include/os/linux/spl/sys/Makefile - include/os/linux/zfs/Makefile - include/os/linux/zfs/sys/Makefile - include/sys/Makefile - include/sys/crypto/Makefile - include/sys/fm/Makefile - include/sys/fm/fs/Makefile - include/sys/fs/Makefile - include/sys/lua/Makefile - include/sys/sysevent/Makefile - include/sys/zstd/Makefile - lib/Makefile - lib/libavl/Makefile - lib/libefi/Makefile - lib/libicp/Makefile - lib/libnvpair/Makefile - lib/libshare/Makefile - lib/libspl/Makefile - lib/libspl/include/Makefile - lib/libspl/include/os/Makefile - lib/libspl/include/os/freebsd/Makefile - lib/libspl/include/os/freebsd/sys/Makefile - lib/libspl/include/os/linux/Makefile - lib/libspl/include/os/linux/sys/Makefile - lib/libspl/include/rpc/Makefile - lib/libspl/include/sys/Makefile - lib/libspl/include/sys/dktp/Makefile - lib/libspl/include/util/Makefile - lib/libtpool/Makefile - lib/libunicode/Makefile - lib/libuutil/Makefile - lib/libzfs/Makefile lib/libzfs/libzfs.pc - lib/libzfsbootenv/Makefile - lib/libzfsbootenv/libzfsbootenv.pc - lib/libzfs_core/Makefile lib/libzfs_core/libzfs_core.pc - lib/libzpool/Makefile - lib/libzstd/Makefile - lib/libzutil/Makefile - man/Makefile + lib/libzfsbootenv/libzfsbootenv.pc module/Kbuild module/Makefile - module/avl/Makefile - module/icp/Makefile - module/lua/Makefile - module/nvpair/Makefile - module/os/linux/spl/Makefile - module/os/linux/zfs/Makefile - module/spl/Makefile - module/unicode/Makefile - module/zcommon/Makefile - module/zfs/Makefile - module/zstd/Makefile - rpm/Makefile - rpm/generic/Makefile rpm/generic/zfs-dkms.spec rpm/generic/zfs-kmod.spec rpm/generic/zfs.spec - rpm/redhat/Makefile rpm/redhat/zfs-dkms.spec rpm/redhat/zfs-kmod.spec rpm/redhat/zfs.spec - scripts/Makefile - tests/Makefile - tests/runfiles/Makefile - tests/test-runner/Makefile - tests/test-runner/bin/Makefile - tests/test-runner/include/Makefile - tests/test-runner/man/Makefile - tests/zfs-tests/Makefile - tests/zfs-tests/callbacks/Makefile - tests/zfs-tests/cmd/Makefile - tests/zfs-tests/cmd/badsend/Makefile - tests/zfs-tests/cmd/btree_test/Makefile - tests/zfs-tests/cmd/chg_usr_exec/Makefile - tests/zfs-tests/cmd/devname2devid/Makefile - tests/zfs-tests/cmd/draid/Makefile - tests/zfs-tests/cmd/dir_rd_update/Makefile - tests/zfs-tests/cmd/file_check/Makefile - tests/zfs-tests/cmd/file_trunc/Makefile - tests/zfs-tests/cmd/file_write/Makefile - tests/zfs-tests/cmd/get_diff/Makefile - tests/zfs-tests/cmd/getversion/Makefile - tests/zfs-tests/cmd/largest_file/Makefile - tests/zfs-tests/cmd/libzfs_input_check/Makefile - tests/zfs-tests/cmd/mkbusy/Makefile - tests/zfs-tests/cmd/mkfile/Makefile - tests/zfs-tests/cmd/mkfiles/Makefile - tests/zfs-tests/cmd/mktree/Makefile - tests/zfs-tests/cmd/mmap_exec/Makefile - tests/zfs-tests/cmd/mmap_libaio/Makefile - tests/zfs-tests/cmd/mmap_seek/Makefile - tests/zfs-tests/cmd/mmapwrite/Makefile - tests/zfs-tests/cmd/nvlist_to_lua/Makefile - tests/zfs-tests/cmd/randfree_file/Makefile - tests/zfs-tests/cmd/randwritecomp/Makefile - tests/zfs-tests/cmd/readmmap/Makefile - tests/zfs-tests/cmd/read_dos_attributes/Makefile - tests/zfs-tests/cmd/rename_dir/Makefile - tests/zfs-tests/cmd/rm_lnkcnt_zero_file/Makefile - tests/zfs-tests/cmd/send_doall/Makefile - tests/zfs-tests/cmd/stride_dd/Makefile - tests/zfs-tests/cmd/threadsappend/Makefile - tests/zfs-tests/cmd/user_ns_exec/Makefile - tests/zfs-tests/cmd/write_dos_attributes/Makefile - tests/zfs-tests/cmd/xattrtest/Makefile - tests/zfs-tests/include/Makefile tests/zfs-tests/tests/Makefile - tests/zfs-tests/tests/functional/Makefile - tests/zfs-tests/tests/functional/acl/Makefile - tests/zfs-tests/tests/functional/acl/off/Makefile - tests/zfs-tests/tests/functional/acl/posix/Makefile - tests/zfs-tests/tests/functional/acl/posix-sa/Makefile - tests/zfs-tests/tests/functional/alloc_class/Makefile - tests/zfs-tests/tests/functional/arc/Makefile - tests/zfs-tests/tests/functional/atime/Makefile - tests/zfs-tests/tests/functional/bootfs/Makefile - tests/zfs-tests/tests/functional/btree/Makefile - tests/zfs-tests/tests/functional/cache/Makefile - tests/zfs-tests/tests/functional/cachefile/Makefile - tests/zfs-tests/tests/functional/casenorm/Makefile - tests/zfs-tests/tests/functional/channel_program/Makefile - tests/zfs-tests/tests/functional/channel_program/lua_core/Makefile - tests/zfs-tests/tests/functional/channel_program/synctask_core/Makefile - tests/zfs-tests/tests/functional/chattr/Makefile - tests/zfs-tests/tests/functional/checksum/Makefile - tests/zfs-tests/tests/functional/clean_mirror/Makefile - tests/zfs-tests/tests/functional/cli_root/Makefile - tests/zfs-tests/tests/functional/cli_root/zdb/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_change-key/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_clone/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_copies/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_create/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_destroy/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_diff/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_get/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_ids_to_path/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_inherit/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_jail/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_load-key/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_mount/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_program/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_promote/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_property/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_receive/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_rename/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_reservation/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_rollback/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_send/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_set/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_share/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_unmount/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_unshare/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_wait/Makefile - tests/zfs-tests/tests/functional/cli_root/zhack/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_attach/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_clear/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_destroy/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_detach/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_events/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_expand/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_export/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_get/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_history/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_import/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_import/blockfiles/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_initialize/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_offline/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_online/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_remove/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_reopen/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_replace/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_resilver/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_scrub/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_set/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_split/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_sync/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_trim/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/blockfiles/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_wait/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_wait/scan/Makefile - tests/zfs-tests/tests/functional/cli_user/Makefile - tests/zfs-tests/tests/functional/cli_user/misc/Makefile - tests/zfs-tests/tests/functional/cli_user/zfs_list/Makefile - tests/zfs-tests/tests/functional/cli_user/zpool_iostat/Makefile - tests/zfs-tests/tests/functional/cli_user/zpool_list/Makefile - tests/zfs-tests/tests/functional/cli_user/zpool_status/Makefile - tests/zfs-tests/tests/functional/compression/Makefile - tests/zfs-tests/tests/functional/cp_files/Makefile - tests/zfs-tests/tests/functional/crtime/Makefile - tests/zfs-tests/tests/functional/ctime/Makefile - tests/zfs-tests/tests/functional/deadman/Makefile - tests/zfs-tests/tests/functional/delegate/Makefile - tests/zfs-tests/tests/functional/devices/Makefile - tests/zfs-tests/tests/functional/dos_attributes/Makefile - tests/zfs-tests/tests/functional/events/Makefile - tests/zfs-tests/tests/functional/exec/Makefile - tests/zfs-tests/tests/functional/fallocate/Makefile - tests/zfs-tests/tests/functional/fault/Makefile - tests/zfs-tests/tests/functional/features/Makefile - tests/zfs-tests/tests/functional/features/async_destroy/Makefile - tests/zfs-tests/tests/functional/features/large_dnode/Makefile - tests/zfs-tests/tests/functional/grow/Makefile - tests/zfs-tests/tests/functional/history/Makefile - tests/zfs-tests/tests/functional/hkdf/Makefile - tests/zfs-tests/tests/functional/inheritance/Makefile - tests/zfs-tests/tests/functional/inuse/Makefile - tests/zfs-tests/tests/functional/io/Makefile - tests/zfs-tests/tests/functional/l2arc/Makefile - tests/zfs-tests/tests/functional/large_files/Makefile - tests/zfs-tests/tests/functional/largest_pool/Makefile - tests/zfs-tests/tests/functional/libzfs/Makefile - tests/zfs-tests/tests/functional/limits/Makefile - tests/zfs-tests/tests/functional/link_count/Makefile - tests/zfs-tests/tests/functional/log_spacemap/Makefile - tests/zfs-tests/tests/functional/migration/Makefile - tests/zfs-tests/tests/functional/mmap/Makefile - tests/zfs-tests/tests/functional/mmp/Makefile - tests/zfs-tests/tests/functional/mount/Makefile - tests/zfs-tests/tests/functional/mv_files/Makefile - tests/zfs-tests/tests/functional/nestedfs/Makefile - tests/zfs-tests/tests/functional/no_space/Makefile - tests/zfs-tests/tests/functional/nopwrite/Makefile - tests/zfs-tests/tests/functional/online_offline/Makefile - tests/zfs-tests/tests/functional/pam/Makefile - tests/zfs-tests/tests/functional/pool_checkpoint/Makefile - tests/zfs-tests/tests/functional/pool_names/Makefile - tests/zfs-tests/tests/functional/poolversion/Makefile - tests/zfs-tests/tests/functional/privilege/Makefile - tests/zfs-tests/tests/functional/procfs/Makefile - tests/zfs-tests/tests/functional/projectquota/Makefile - tests/zfs-tests/tests/functional/pyzfs/Makefile - tests/zfs-tests/tests/functional/quota/Makefile - tests/zfs-tests/tests/functional/raidz/Makefile - tests/zfs-tests/tests/functional/redacted_send/Makefile - tests/zfs-tests/tests/functional/redundancy/Makefile - tests/zfs-tests/tests/functional/refquota/Makefile - tests/zfs-tests/tests/functional/refreserv/Makefile - tests/zfs-tests/tests/functional/removal/Makefile - tests/zfs-tests/tests/functional/rename_dirs/Makefile - tests/zfs-tests/tests/functional/replacement/Makefile - tests/zfs-tests/tests/functional/reservation/Makefile - tests/zfs-tests/tests/functional/rootpool/Makefile - tests/zfs-tests/tests/functional/rsend/Makefile - tests/zfs-tests/tests/functional/scrub_mirror/Makefile - tests/zfs-tests/tests/functional/simd/Makefile - tests/zfs-tests/tests/functional/slog/Makefile - tests/zfs-tests/tests/functional/snapshot/Makefile - tests/zfs-tests/tests/functional/snapused/Makefile - tests/zfs-tests/tests/functional/sparse/Makefile - tests/zfs-tests/tests/functional/stat/Makefile - tests/zfs-tests/tests/functional/suid/Makefile - tests/zfs-tests/tests/functional/threadsappend/Makefile - tests/zfs-tests/tests/functional/tmpfile/Makefile - tests/zfs-tests/tests/functional/trim/Makefile - tests/zfs-tests/tests/functional/truncate/Makefile - tests/zfs-tests/tests/functional/upgrade/Makefile - tests/zfs-tests/tests/functional/user_namespace/Makefile - tests/zfs-tests/tests/functional/userquota/Makefile - tests/zfs-tests/tests/functional/vdev_zaps/Makefile - tests/zfs-tests/tests/functional/write_dirs/Makefile - tests/zfs-tests/tests/functional/xattr/Makefile - tests/zfs-tests/tests/functional/zpool_influxdb/Makefile - tests/zfs-tests/tests/functional/zvol/Makefile - tests/zfs-tests/tests/functional/zvol/zvol_ENOSPC/Makefile - tests/zfs-tests/tests/functional/zvol/zvol_cli/Makefile - tests/zfs-tests/tests/functional/zvol/zvol_misc/Makefile - tests/zfs-tests/tests/functional/zvol/zvol_swap/Makefile - tests/zfs-tests/tests/perf/Makefile - tests/zfs-tests/tests/perf/fio/Makefile - tests/zfs-tests/tests/perf/regression/Makefile - tests/zfs-tests/tests/perf/scripts/Makefile - tests/zfs-tests/tests/stress/Makefile - udev/Makefile - udev/rules.d/Makefile zfs.release ]) diff --git a/sys/contrib/openzfs/contrib/Makefile.am b/sys/contrib/openzfs/contrib/Makefile.am index 5ec13ece5327..fa51bd941d27 100644 --- a/sys/contrib/openzfs/contrib/Makefile.am +++ b/sys/contrib/openzfs/contrib/Makefile.am @@ -1,12 +1,13 @@ -include $(top_srcdir)/config/Shellcheck.am +include $(srcdir)/%D%/bash_completion.d/Makefile.am +include $(srcdir)/%D%/pyzfs/Makefile.am +include $(srcdir)/%D%/zcp/Makefile.am -SUBDIRS = bash_completion.d pyzfs zcp if BUILD_LINUX -SUBDIRS += bpftrace dracut initramfs +include $(srcdir)/%D%/bpftrace/Makefile.am +include $(srcdir)/%D%/dracut/Makefile.am +include $(srcdir)/%D%/initramfs/Makefile.am endif + if PAM_ZFS_ENABLED -SUBDIRS += pam_zfs_key +include $(srcdir)/%D%/pam_zfs_key/Makefile.am endif -DIST_SUBDIRS = bash_completion.d bpftrace dracut initramfs pam_zfs_key pyzfs zcp - -SHELLCHECKDIRS = bash_completion.d bpftrace dracut initramfs diff --git a/sys/contrib/openzfs/contrib/bash_completion.d/Makefile.am b/sys/contrib/openzfs/contrib/bash_completion.d/Makefile.am index eee617802bbe..dc4b610c42b8 100644 --- a/sys/contrib/openzfs/contrib/bash_completion.d/Makefile.am +++ b/sys/contrib/openzfs/contrib/bash_completion.d/Makefile.am @@ -1,12 +1,7 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - bashcompletiondir = $(sysconfdir)/bash_completion.d -noinst_DATA = zfs - -EXTRA_DIST += $(noinst_DATA) -SUBSTFILES += $(noinst_DATA) +nodist_bashcompletion_DATA = %D%/zfs +SUBSTFILES += $(nodist_bashcompletion_DATA) -SHELLCHECKSCRIPTS = $(noinst_DATA) -SHELLCHECK_SHELL = bash +SHELLCHECKSCRIPTS += $(nodist_bashcompletion_DATA) +$(call SHELLCHECK_OPTS,$(nodist_bashcompletion_DATA)): SHELLCHECK_SHELL = bash diff --git a/sys/contrib/openzfs/contrib/bpftrace/Makefile.am b/sys/contrib/openzfs/contrib/bpftrace/Makefile.am index 05e4f1c507ce..5382f1e1de42 100644 --- a/sys/contrib/openzfs/contrib/bpftrace/Makefile.am +++ b/sys/contrib/openzfs/contrib/bpftrace/Makefile.am @@ -1,7 +1,5 @@ -include $(top_srcdir)/config/Shellcheck.am - -EXTRA_DIST = \ +EXTRA_DIST += $(addprefix %D%/, \ taskqlatency.bt \ - zfs-trace.sh + zfs-trace.sh) -SHELLCHECKSCRIPTS = zfs-trace.sh +SHELLCHECKSCRIPTS += %D%/zfs-trace.sh diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/.gitignore b/sys/contrib/openzfs/contrib/dracut/.gitignore index cb84212f3a2a..cb84212f3a2a 100644 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/.gitignore +++ b/sys/contrib/openzfs/contrib/dracut/.gitignore diff --git a/sys/contrib/openzfs/contrib/dracut/02zfsexpandknowledge/.gitignore b/sys/contrib/openzfs/contrib/dracut/02zfsexpandknowledge/.gitignore deleted file mode 100644 index 7fb6b964f058..000000000000 --- a/sys/contrib/openzfs/contrib/dracut/02zfsexpandknowledge/.gitignore +++ /dev/null @@ -1 +0,0 @@ -module-setup.sh diff --git a/sys/contrib/openzfs/contrib/dracut/02zfsexpandknowledge/Makefile.am b/sys/contrib/openzfs/contrib/dracut/02zfsexpandknowledge/Makefile.am deleted file mode 100644 index b1bbb6bd3aac..000000000000 --- a/sys/contrib/openzfs/contrib/dracut/02zfsexpandknowledge/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -pkgdracutdir = $(dracutdir)/modules.d/02zfsexpandknowledge -pkgdracut_SCRIPTS = \ - module-setup.sh - -SUBSTFILES += $(pkgdracut_SCRIPTS) diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/Makefile.am b/sys/contrib/openzfs/contrib/dracut/90zfs/Makefile.am deleted file mode 100644 index 3f7050300994..000000000000 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -pkgdracutdir = $(dracutdir)/modules.d/90zfs -pkgdracut_SCRIPTS = \ - export-zfs.sh \ - module-setup.sh \ - mount-zfs.sh \ - parse-zfs.sh \ - zfs-generator.sh \ - zfs-load-key.sh \ - zfs-needshutdown.sh \ - zfs-lib.sh \ - import-opts-generator.sh - -pkgdracut_DATA = \ - zfs-env-bootfs.service \ - zfs-snapshot-bootfs.service \ - zfs-rollback-bootfs.service - -SUBSTFILES += $(pkgdracut_SCRIPTS) $(pkgdracut_DATA) - -# Provided by /bin/sleep, and, again, every implementation of that supports this -CHECKBASHISMS_IGNORE = -e 'sleep only takes one integer' -e 'sleep 0.' diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/module-setup.sh.in b/sys/contrib/openzfs/contrib/dracut/90zfs/module-setup.sh.in index c79323a3e613..f2145861d497 100755 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/module-setup.sh.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/module-setup.sh.in @@ -9,13 +9,10 @@ check() { for tool in "zgenhostid" "zpool" "zfs" "mount.zfs"; do command -v "${tool}" >/dev/null || return 1 done - - return 0 } depends() { echo udev-rules - return 0 } installkernel() { @@ -39,7 +36,6 @@ install() { { dfatal "Failed to install essential binaries"; exit 1; } # Adapted from https://github.com/zbm-dev/zfsbootmenu - if ! ldd "$(command -v zpool)" | grep -qF 'libgcc_s.so'; then # On systems with gcc-config (Gentoo, Funtoo, etc.), use it to find libgcc_s if command -v gcc-config >/dev/null; then @@ -79,7 +75,6 @@ install() { fi if dracut_module_included "systemd"; then - inst_simple "${systemdsystemunitdir}/zfs-import.target" systemctl -q --root "${initdir}" add-wants initrd.target zfs-import.target diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/mount-zfs.sh.in b/sys/contrib/openzfs/contrib/dracut/90zfs/mount-zfs.sh.in index 7e11c9afdaee..fa9f1bb767b8 100755 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/mount-zfs.sh.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/mount-zfs.sh.in @@ -3,46 +3,71 @@ . /lib/dracut-zfs-lib.sh -ZFS_DATASET="" -ZFS_POOL="" - -case "${root}" in - zfs:*) ;; - *) return ;; -esac +decode_root_args || return 0 GENERATOR_FILE=/run/systemd/generator/sysroot.mount GENERATOR_EXTENSION=/run/systemd/generator/sysroot.mount.d/zfs-enhancement.conf -if [ -e "$GENERATOR_FILE" ] && [ -e "$GENERATOR_EXTENSION" ] ; then - # If the ZFS sysroot.mount flag exists, the initial RAM disk configured - # it to mount ZFS on root. In that case, we bail early. This flag - # file gets created by the zfs-generator program upon successful run. - info "ZFS: There is a sysroot.mount and zfs-generator has extended it." - info "ZFS: Delegating root mount to sysroot.mount." - # Let us tell the initrd to run on shutdown. - # We have a shutdown hook to run - # because we imported the pool. +if [ -e "$GENERATOR_FILE" ] && [ -e "$GENERATOR_EXTENSION" ]; then + # We're under systemd and dracut-zfs-generator ran to completion. + info "ZFS: Delegating root mount to sysroot.mount at al." + # We now prevent Dracut from running this thing again. - for zfsmounthook in "$hookdir"/mount/*zfs* ; do - if [ -f "$zfsmounthook" ] ; then - rm -f "$zfsmounthook" - fi - done + rm -f "$hookdir"/mount/*zfs* return fi + info "ZFS: No sysroot.mount exists or zfs-generator did not extend it." info "ZFS: Mounting root with the traditional mount-zfs.sh instead." +# ask_for_password tries prompt cmd +# +# Wraps around plymouth ask-for-password and adds fallback to tty password ask +# if plymouth is not present. +ask_for_password() { + tries="$1" + prompt="$2" + cmd="$3" + + { + flock -s 9 + + # Prompt for password with plymouth, if installed and running. + if plymouth --ping 2>/dev/null; then + plymouth ask-for-password \ + --prompt "$prompt" --number-of-tries="$tries" | \ + eval "$cmd" + ret=$? + else + i=1 + while [ "$i" -le "$tries" ]; do + printf "%s [%i/%i]:" "$prompt" "$i" "$tries" >&2 + eval "$cmd" && ret=0 && break + ret=$? + i=$((i+1)) + printf '\n' >&2 + done + unset i + fi + } 9>/.console_lock + + [ "$ret" -ne 0 ] && echo "Wrong password" >&2 + return "$ret" +} + + # Delay until all required block devices are present. modprobe zfs 2>/dev/null udevadm settle +ZFS_DATASET= +ZFS_POOL= + if [ "${root}" = "zfs:AUTO" ] ; then - if ! ZFS_DATASET="$(find_bootfs)" ; then + if ! ZFS_DATASET="$(zpool get -Ho value bootfs | grep -m1 -vFx -)"; then # shellcheck disable=SC2086 zpool import -N -a ${ZPOOL_IMPORT_OPTS} - if ! ZFS_DATASET="$(find_bootfs)" ; then + if ! ZFS_DATASET="$(zpool get -Ho value bootfs | grep -m1 -vFx -)"; then warn "ZFS: No bootfs attribute found in importable pools." zpool export -aF @@ -53,34 +78,43 @@ if [ "${root}" = "zfs:AUTO" ] ; then info "ZFS: Using ${ZFS_DATASET} as root." fi -ZFS_DATASET="${ZFS_DATASET:-${root#zfs:}}" +ZFS_DATASET="${ZFS_DATASET:-${root}}" ZFS_POOL="${ZFS_DATASET%%/*}" -if import_pool "${ZFS_POOL}" ; then - # Load keys if we can or if we need to - if [ "$(zpool list -H -o feature@encryption "${ZFS_POOL}")" = 'active' ]; then - # if the root dataset has encryption enabled - ENCRYPTIONROOT="$(zfs get -H -o value encryptionroot "${ZFS_DATASET}")" - if ! [ "${ENCRYPTIONROOT}" = "-" ]; then - KEYSTATUS="$(zfs get -H -o value keystatus "${ENCRYPTIONROOT}")" - # if the key needs to be loaded - if [ "$KEYSTATUS" = "unavailable" ]; then - # decrypt them - ask_for_password \ - --tries 5 \ - --prompt "Encrypted ZFS password for ${ENCRYPTIONROOT}: " \ - --cmd "zfs load-key '${ENCRYPTIONROOT}'" - fi + +if ! zpool get -Ho name "${ZFS_POOL}" > /dev/null 2>&1; then + info "ZFS: Importing pool ${ZFS_POOL}..." + # shellcheck disable=SC2086 + if ! zpool import -N ${ZPOOL_IMPORT_OPTS} "${ZFS_POOL}"; then + warn "ZFS: Unable to import pool ${ZFS_POOL}" + rootok=0 + return 1 + fi +fi + +# Load keys if we can or if we need to +# TODO: for_relevant_root_children like in zfs-load-key.sh.in +if [ "$(zpool get -Ho value feature@encryption "${ZFS_POOL}")" = 'active' ]; then + # if the root dataset has encryption enabled + ENCRYPTIONROOT="$(zfs get -Ho value encryptionroot "${ZFS_DATASET}")" + if ! [ "${ENCRYPTIONROOT}" = "-" ]; then + KEYSTATUS="$(zfs get -Ho value keystatus "${ENCRYPTIONROOT}")" + # if the key needs to be loaded + if [ "$KEYSTATUS" = "unavailable" ]; then + # decrypt them + ask_for_password \ + 5 \ + "Encrypted ZFS password for ${ENCRYPTIONROOT}: " \ + "zfs load-key '${ENCRYPTIONROOT}'" fi fi - # Let us tell the initrd to run on shutdown. - # We have a shutdown hook to run - # because we imported the pool. - info "ZFS: Mounting dataset ${ZFS_DATASET}..." - if mount_dataset "${ZFS_DATASET}" ; then - ROOTFS_MOUNTED=yes - return 0 - fi fi -rootok=0 +# Let us tell the initrd to run on shutdown. +# We have a shutdown hook to run +# because we imported the pool. +info "ZFS: Mounting dataset ${ZFS_DATASET}..." +if ! mount_dataset "${ZFS_DATASET}"; then + rootok=0 + return 1 +fi diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/parse-zfs.sh.in b/sys/contrib/openzfs/contrib/dracut/90zfs/parse-zfs.sh.in index 724c5e2c6dff..f7d1f1c5da9f 100755 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/parse-zfs.sh.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/parse-zfs.sh.in @@ -1,7 +1,8 @@ #!/bin/sh # shellcheck disable=SC2034,SC2154 -. /lib/dracut-lib.sh +# shellcheck source=zfs-lib.sh.in +. /lib/dracut-zfs-lib.sh # Let the command line override our host id. spl_hostid=$(getarg spl_hostid=) @@ -15,52 +16,20 @@ else warn "ZFS: Pools may not import correctly." fi -wait_for_zfs=0 -case "${root}" in - ""|zfs|zfs:) - # We'll take root unset, root=zfs, or root=zfs: - # No root set, so we want to read the bootfs attribute. We - # can't do that until udev settles so we'll set dummy values - # and hope for the best later on. - root="zfs:AUTO" - rootok=1 - wait_for_zfs=1 - - info "ZFS: Enabling autodetection of bootfs after udev settles." - ;; - - ZFS=*|zfs:*|FILESYSTEM=*) - # root is explicit ZFS root. Parse it now. We can handle - # a root=... param in any of the following formats: - # root=ZFS=rpool/ROOT - # root=zfs:rpool/ROOT - # root=zfs:FILESYSTEM=rpool/ROOT - # root=FILESYSTEM=rpool/ROOT - # root=ZFS=pool+with+space/ROOT+WITH+SPACE (translates to root=ZFS=pool with space/ROOT WITH SPACE) - - # Strip down to just the pool/fs - root="${root#zfs:}" - root="${root#FILESYSTEM=}" - root="zfs:${root#ZFS=}" - # switch + with spaces because kernel cmdline does not allow us to quote parameters - root=$(echo "$root" | tr '+' ' ') - rootok=1 - wait_for_zfs=1 - - info "ZFS: Set ${root} as bootfs." - ;; - - *) - info "ZFS: no ZFS-on-root" -esac - -# Make sure Dracut is happy that we have a root and will wait for ZFS -# modules to settle before mounting. -if [ "${wait_for_zfs}" -eq 1 ]; then - ln -s /dev/null /dev/root 2>/dev/null - initqueuedir="${hookdir}/initqueue/finished" - test -d "${initqueuedir}" || { - initqueuedir="${hookdir}/initqueue-finished" - } - echo '[ -e /dev/zfs ]' > "${initqueuedir}/zfs.sh" +if decode_root_args; then + if [ "$root" = "zfs:AUTO" ]; then + info "ZFS: Boot dataset autodetected from bootfs=." + else + info "ZFS: Boot dataset is ${root}." + fi + + rootok=1 + # Make sure Dracut is happy that we have a root and will wait for ZFS + # modules to settle before mounting. + if [ -n "${wait_for_zfs}" ]; then + ln -s null /dev/root + echo '[ -e /dev/zfs ]' > "${hookdir}/initqueue/finished/zfs.sh" + fi +else + info "ZFS: no ZFS-on-root." fi diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-env-bootfs.service.in b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-env-bootfs.service.in index e143cb5ec1ed..34c88037cac2 100644 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-env-bootfs.service.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-env-bootfs.service.in @@ -8,7 +8,7 @@ Before=zfs-import.target [Service] Type=oneshot -ExecStart=/bin/sh -c "exec systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | grep -m1 -v '^-$')" +ExecStart=/bin/sh -c "exec systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | grep -m1 -vFx -)" [Install] WantedBy=zfs-import.target diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-generator.sh.in b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-generator.sh.in index e50b9530c4f0..56f7ca9785ba 100755 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-generator.sh.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-generator.sh.in @@ -1,5 +1,5 @@ #!/bin/sh -# shellcheck disable=SC2016,SC1004 +# shellcheck disable=SC2016,SC1004,SC2154 grep -wq debug /proc/cmdline && debug=1 [ -n "$debug" ] && echo "zfs-generator: starting" >> /dev/kmsg @@ -10,37 +10,17 @@ GENERATOR_DIR="$1" exit 1 } -[ -f /lib/dracut-lib.sh ] && dracutlib=/lib/dracut-lib.sh -[ -f /usr/lib/dracut/modules.d/99base/dracut-lib.sh ] && dracutlib=/usr/lib/dracut/modules.d/99base/dracut-lib.sh -command -v getarg >/dev/null 2>&1 || { - [ -n "$debug" ] && echo "zfs-generator: loading Dracut library from $dracutlib" >> /dev/kmsg - . "$dracutlib" -} - +# shellcheck source=zfs-lib.sh.in . /lib/dracut-zfs-lib.sh +decode_root_args || exit 0 -[ -z "$root" ] && root=$(getarg root=) -[ -z "$rootfstype" ] && rootfstype=$(getarg rootfstype=) -[ -z "$rootflags" ] && rootflags=$(getarg rootflags=) - -# If root is not ZFS= or zfs: or rootfstype is not zfs -# then we are not supposed to handle it. -[ "${root##zfs:}" = "${root}" ] && - [ "${root##ZFS=}" = "${root}" ] && - [ "$rootfstype" != "zfs" ] && - exit 0 - +[ -z "${rootflags}" ] && rootflags=$(getarg rootflags=) case ",${rootflags}," in *,zfsutil,*) ;; ,,) rootflags=zfsutil ;; *) rootflags="zfsutil,${rootflags}" ;; esac -if [ "${root}" != "zfs:AUTO" ]; then - root="${root##zfs:}" - root="${root##ZFS=}" -fi - [ -n "$debug" ] && echo "zfs-generator: writing extension for sysroot.mount to $GENERATOR_DIR/sysroot.mount.d/zfs-enhancement.conf" >> /dev/kmsg @@ -89,7 +69,7 @@ else _zfs_generator_cb() { dset="${1}" mpnt="${2}" - unit="sysroot$(echo "$mpnt" | tr '/' '-').mount" + unit="$(systemd-escape --suffix=mount -p "/sysroot${mpnt}")" { echo "[Unit]" diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-lib.sh.in b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-lib.sh.in index afd872d69d58..e44673c2d75b 100755 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-lib.sh.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-lib.sh.in @@ -1,74 +1,16 @@ #!/bin/sh +# shellcheck disable=SC2034 -command -v getarg >/dev/null || . /lib/dracut-lib.sh -command -v getargbool >/dev/null || { - # Compatibility with older Dracut versions. - # With apologies to the Dracut developers. - getargbool() { - _default="$1"; shift - ! _b=$(getarg "$@") && [ -z "$_b" ] && _b="$_default" - if [ -n "$_b" ]; then - [ "$_b" = "0" ] && return 1 - [ "$_b" = "no" ] && return 1 - [ "$_b" = "off" ] && return 1 - fi - return 0 - } -} +command -v getarg >/dev/null || . /lib/dracut-lib.sh || . /usr/lib/dracut/modules.d/99base/dracut-lib.sh -OLDIFS="${IFS}" -NEWLINE=" -" TAB=" " -ZPOOL_IMPORT_OPTS="" -if getargbool 0 zfs_force -y zfs.force -y zfsforce ; then +ZPOOL_IMPORT_OPTS= +if getargbool 0 zfs_force -y zfs.force -y zfsforce; then warn "ZFS: Will force-import pools if necessary." - ZPOOL_IMPORT_OPTS="${ZPOOL_IMPORT_OPTS} -f" + ZPOOL_IMPORT_OPTS=-f fi -# find_bootfs -# returns the first dataset with the bootfs attribute. -find_bootfs() { - IFS="${NEWLINE}" - for dataset in $(zpool list -H -o bootfs); do - case "${dataset}" in - "" | "-") - continue - ;; - "no pools available") - IFS="${OLDIFS}" - return 1 - ;; - *) - IFS="${OLDIFS}" - echo "${dataset}" - return 0 - ;; - esac - done - - IFS="${OLDIFS}" - return 1 -} - -# import_pool POOL -# imports the given zfs pool if it isn't imported already. -import_pool() { - pool="${1}" - - if ! zpool list -H "${pool}" > /dev/null 2>&1; then - info "ZFS: Importing pool ${pool}..." - # shellcheck disable=SC2086 - if ! zpool import -N ${ZPOOL_IMPORT_OPTS} "${pool}" ; then - warn "ZFS: Unable to import pool ${pool}" - return 1 - fi - fi - - return 0 -} - _mount_dataset_cb() { # shellcheck disable=SC2154 mount -o zfsutil -t zfs "${1}" "${NEWROOT}${2}" @@ -122,72 +64,57 @@ for_relevant_root_children() { ) } -# ask_for_password +# Parse root=, rootfstype=, return them decoded and normalised to zfs:AUTO for auto, plain dset for explicit +# +# True if ZFS-on-root, false if we shouldn't +# +# Supported values: +# root= +# root=zfs +# root=zfs: +# root=zfs:AUTO # -# Wraps around plymouth ask-for-password and adds fallback to tty password ask -# if plymouth is not present. +# root=ZFS=data/set +# root=zfs:data/set +# root=zfs:ZFS=data/set (as a side-effect; allowed but undocumented) # -# --cmd command -# Command to execute. Required. -# --prompt prompt -# Password prompt. Note that function already adds ':' at the end. -# Recommended. -# --tries n -# How many times repeat command on its failure. Default is 3. -# --ply-[cmd|prompt|tries] -# Command/prompt/tries specific for plymouth password ask only. -# --tty-[cmd|prompt|tries] -# Command/prompt/tries specific for tty password ask only. -# --tty-echo-off -# Turn off input echo before tty command is executed and turn on after. -# It's useful when password is read from stdin. -ask_for_password() { - ply_tries=3 - tty_tries=3 - while [ "$#" -gt 0 ]; do - case "$1" in - --cmd) ply_cmd="$2"; tty_cmd="$2"; shift;; - --ply-cmd) ply_cmd="$2"; shift;; - --tty-cmd) tty_cmd="$2"; shift;; - --prompt) ply_prompt="$2"; tty_prompt="$2"; shift;; - --ply-prompt) ply_prompt="$2"; shift;; - --tty-prompt) tty_prompt="$2"; shift;; - --tries) ply_tries="$2"; tty_tries="$2"; shift;; - --ply-tries) ply_tries="$2"; shift;; - --tty-tries) tty_tries="$2"; shift;; - --tty-echo-off) tty_echo_off=yes;; - *) echo "ask_for_password(): wrong opt '$1'" >&2;; +# rootfstype=zfs AND root=data/set <=> root=data/set +# rootfstype=zfs AND root= <=> root=zfs:AUTO +# +# '+'es in explicit dataset decoded to ' 's. +decode_root_args() { + if [ -n "$rootfstype" ]; then + [ "$rootfstype" = zfs ] + return + fi + + root=$(getarg root=) + rootfstype=$(getarg rootfstype=) + + # shellcheck disable=SC2249 + case "$root" in + ""|zfs|zfs:|zfs:AUTO) + root=zfs:AUTO + rootfstype=zfs + return 0 + ;; + + ZFS=*|zfs:*) + root="${root#zfs:}" + root="${root#ZFS=}" + root=$(echo "$root" | tr '+' ' ') + rootfstype=zfs + return 0 + ;; + esac + + if [ "$rootfstype" = "zfs" ]; then + case "$root" in + "") root=zfs:AUTO ;; + *) root=$(echo "$root" | tr '+' ' ') ;; esac - shift - done - - { flock -s 9; - # Prompt for password with plymouth, if installed and running. - if plymouth --ping 2>/dev/null; then - plymouth ask-for-password \ - --prompt "$ply_prompt" --number-of-tries="$ply_tries" | \ - eval "$ply_cmd" - ret=$? - else - if [ "$tty_echo_off" = yes ]; then - stty_orig="$(stty -g)" - stty -echo - fi - - i=1 - while [ "$i" -le "$tty_tries" ]; do - [ -n "$tty_prompt" ] && \ - printf "%s [%i/%i]:" "$tty_prompt" "$i" "$tty_tries" >&2 - eval "$tty_cmd" && ret=0 && break - ret=$? - i=$((i+1)) - [ -n "$tty_prompt" ] && printf '\n' >&2 - done - unset i - [ "$tty_echo_off" = yes ] && stty "$stty_orig" - fi - } 9>/.console_lock + return 0 + fi - [ "$ret" -ne 0 ] && echo "Wrong password" >&2 - return "$ret" + return 1 } diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-load-key.sh.in b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-load-key.sh.in index c974b3d9ec4c..d916f43b4e95 100755 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-load-key.sh.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-load-key.sh.in @@ -4,70 +4,61 @@ # only run this on systemd systems, we handle the decrypt in mount-zfs.sh in the mount hook otherwise [ -e /bin/systemctl ] || [ -e /usr/bin/systemctl ] || return 0 -# This script only gets executed on systemd systems, see mount-zfs.sh for non-systemd systems +# shellcheck source=zfs-lib.sh.in +. /lib/dracut-zfs-lib.sh -# import the libs now that we know the pool imported -[ -f /lib/dracut-lib.sh ] && dracutlib=/lib/dracut-lib.sh -[ -f /usr/lib/dracut/modules.d/99base/dracut-lib.sh ] && dracutlib=/usr/lib/dracut/modules.d/99base/dracut-lib.sh -# shellcheck source=./lib-zfs.sh.in -. "$dracutlib" - -# load the kernel command line vars -[ -z "$root" ] && root="$(getarg root=)" -# If root is not ZFS= or zfs: or rootfstype is not zfs then we are not supposed to handle it. -[ "${root##zfs:}" = "${root}" ] && [ "${root##ZFS=}" = "${root}" ] && [ "$rootfstype" != "zfs" ] && exit 0 +decode_root_args || return 0 # There is a race between the zpool import and the pre-mount hooks, so we wait for a pool to be imported -while [ "$(zpool list -H)" = "" ]; do - systemctl is-failed --quiet zfs-import-cache.service zfs-import-scan.service && exit 1 +while ! systemctl is-active --quiet zfs-import.target; do + systemctl is-failed --quiet zfs-import-cache.service zfs-import-scan.service && return 1 sleep 0.1s done -# run this after import as zfs-import-cache/scan service is confirmed good -# we do not overwrite the ${root} variable, but create a new one, BOOTFS, to hold the dataset -if [ "${root}" = "zfs:AUTO" ] ; then - BOOTFS="$(zpool list -H -o bootfs | awk '$1 != "-" {print; exit}')" -else - BOOTFS="${root##zfs:}" - BOOTFS="${BOOTFS##ZFS=}" +BOOTFS="$root" +if [ "$BOOTFS" = "zfs:AUTO" ]; then + BOOTFS="$(zpool get -Ho value bootfs | grep -m1 -vFx -)" fi -# if pool encryption is active and the zfs command understands '-o encryption' -if [ "$(zpool list -H -o feature@encryption "${BOOTFS%%/*}")" = 'active' ]; then - # if the root dataset has encryption enabled - ENCRYPTIONROOT="$(zfs get -H -o value encryptionroot "${BOOTFS}")" - if ! [ "${ENCRYPTIONROOT}" = "-" ]; then - KEYSTATUS="$(zfs get -H -o value keystatus "${ENCRYPTIONROOT}")" - # continue only if the key needs to be loaded - [ "$KEYSTATUS" = "unavailable" ] || exit 0 +[ "$(zpool get -Ho value feature@encryption "${BOOTFS%%/*}")" = 'active' ] || return 0 + +_load_key_cb() { + dataset="$1" + + ENCRYPTIONROOT="$(zfs get -Ho value encryptionroot "${dataset}")" + [ "${ENCRYPTIONROOT}" = "-" ] && return 0 - KEYLOCATION="$(zfs get -H -o value keylocation "${ENCRYPTIONROOT}")" - case "${KEYLOCATION%%://*}" in - prompt) - for _ in 1 2 3; do - systemd-ask-password --no-tty "Encrypted ZFS password for ${BOOTFS}" | zfs load-key "${ENCRYPTIONROOT}" && break + [ "$(zfs get -Ho value keystatus "${ENCRYPTIONROOT}")" = "unavailable" ] || return 0 + + KEYLOCATION="$(zfs get -Ho value keylocation "${ENCRYPTIONROOT}")" + case "${KEYLOCATION%%://*}" in + prompt) + for _ in 1 2 3; do + systemd-ask-password --no-tty "Encrypted ZFS password for ${dataset}" | zfs load-key "${ENCRYPTIONROOT}" && break + done + ;; + http*) + systemctl start network-online.target + zfs load-key "${ENCRYPTIONROOT}" + ;; + file) + KEYFILE="${KEYLOCATION#file://}" + [ -r "${KEYFILE}" ] || udevadm settle + [ -r "${KEYFILE}" ] || { + info "ZFS: Waiting for key ${KEYFILE} for ${ENCRYPTIONROOT}..." + for _ in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do + sleep 0.5s + [ -r "${KEYFILE}" ] && break done - ;; - http*) - systemctl start network-online.target - zfs load-key "${ENCRYPTIONROOT}" - ;; - file) - KEYFILE="${KEYLOCATION#file://}" - [ -r "${KEYFILE}" ] || udevadm settle - [ -r "${KEYFILE}" ] || { - info "Waiting for key ${KEYFILE} for ${ENCRYPTIONROOT}..." - for _ in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do - sleep 0.5s - [ -r "${KEYFILE}" ] && break - done - } - [ -r "${KEYFILE}" ] || warn "Key ${KEYFILE} for ${ENCRYPTIONROOT} hasn't appeared. Trying anyway." - zfs load-key "${ENCRYPTIONROOT}" - ;; - *) - zfs load-key "${ENCRYPTIONROOT}" - ;; - esac - fi -fi + } + [ -r "${KEYFILE}" ] || warn "ZFS: Key ${KEYFILE} for ${ENCRYPTIONROOT} hasn't appeared. Trying anyway." + zfs load-key "${ENCRYPTIONROOT}" + ;; + *) + zfs load-key "${ENCRYPTIONROOT}" + ;; + esac +} + +_load_key_cb "$BOOTFS" +for_relevant_root_children "$BOOTFS" _load_key_cb diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-needshutdown.sh.in b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-needshutdown.sh.in index dd6de30c2704..7fb825bc95a2 100755 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-needshutdown.sh.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-needshutdown.sh.in @@ -2,7 +2,7 @@ command -v getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh -if zpool list 2>&1 | grep -q 'no pools available' ; then +if [ -z "$(zpool get -Ho value name)" ]; then info "ZFS: No active pools, no need to export anything." else info "ZFS: There is an active pool, will export it." diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-rollback-bootfs.service.in b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-rollback-bootfs.service.in index 477b64f2b750..b4f5707516ce 100644 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-rollback-bootfs.service.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-rollback-bootfs.service.in @@ -1,14 +1,12 @@ [Unit] Description=Rollback bootfs just before it is mounted Requisite=zfs-import.target -After=zfs-import.target zfs-snapshot-bootfs.service +After=zfs-import.target dracut-pre-mount.service zfs-snapshot-bootfs.service Before=dracut-mount.service DefaultDependencies=no ConditionKernelCommandLine=bootfs.rollback [Service] -# ${BOOTFS} should have been set by zfs-env-bootfs.service Type=oneshot -ExecStartPre=/bin/test -n ${BOOTFS} -ExecStart=/bin/sh -c '. /lib/dracut-lib.sh; SNAPNAME="$(getarg bootfs.rollback)"; exec @sbindir@/zfs rollback -Rf "${BOOTFS}@${SNAPNAME:-%v}"' +ExecStart=/bin/sh -c '. /lib/dracut-zfs-lib.sh; decode_root_args || exit; [ "$root" = "zfs:AUTO" ] && root="$BOOTFS" SNAPNAME="$(getarg bootfs.rollback)"; exec @sbindir@/zfs rollback -Rf "$root@${SNAPNAME:-%v}"' RemainAfterExit=yes diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-snapshot-bootfs.service.in b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-snapshot-bootfs.service.in index 8eae04adfb99..afdba2c9d194 100644 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-snapshot-bootfs.service.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-snapshot-bootfs.service.in @@ -1,14 +1,12 @@ [Unit] Description=Snapshot bootfs just before it is mounted Requisite=zfs-import.target -After=zfs-import.target +After=zfs-import.target dracut-pre-mount.service Before=dracut-mount.service DefaultDependencies=no ConditionKernelCommandLine=bootfs.snapshot [Service] -# ${BOOTFS} should have been set by zfs-env-bootfs.service Type=oneshot -ExecStartPre=/bin/test -n ${BOOTFS} -ExecStart=-/bin/sh -c '. /lib/dracut-lib.sh; SNAPNAME="$(getarg bootfs.snapshot)"; exec @sbindir@/zfs snapshot "${BOOTFS}@${SNAPNAME:-%v}"' +ExecStart=/bin/sh -c '. /lib/dracut-zfs-lib.sh; decode_root_args || exit; [ "$root" = "zfs:AUTO" ] && root="$BOOTFS" SNAPNAME="$(getarg bootfs.snapshot)"; exec @sbindir@/zfs snapshot "$root@${SNAPNAME:-%v}"' RemainAfterExit=yes diff --git a/sys/contrib/openzfs/contrib/dracut/Makefile.am b/sys/contrib/openzfs/contrib/dracut/Makefile.am index 09805277ffb0..f0c103b0a4da 100644 --- a/sys/contrib/openzfs/contrib/dracut/Makefile.am +++ b/sys/contrib/openzfs/contrib/dracut/Makefile.am @@ -1,6 +1,27 @@ -include $(top_srcdir)/config/Shellcheck.am +pkgdracut_02dir = $(dracutdir)/modules.d/02zfsexpandknowledge +pkgdracut_02_SCRIPTS = \ + %D%/02zfsexpandknowledge/module-setup.sh -SUBDIRS = 02zfsexpandknowledge 90zfs -SHELLCHECKDIRS = $(SUBDIRS) +pkgdracut_90dir = $(dracutdir)/modules.d/90zfs +pkgdracut_90_SCRIPTS = \ + %D%/90zfs/export-zfs.sh \ + %D%/90zfs/import-opts-generator.sh \ + %D%/90zfs/module-setup.sh \ + %D%/90zfs/mount-zfs.sh \ + %D%/90zfs/parse-zfs.sh \ + %D%/90zfs/zfs-generator.sh \ + %D%/90zfs/zfs-lib.sh \ + %D%/90zfs/zfs-load-key.sh \ + %D%/90zfs/zfs-needshutdown.sh -EXTRA_DIST = README.md +pkgdracut_90_DATA = \ + %D%/90zfs/zfs-env-bootfs.service \ + %D%/90zfs/zfs-rollback-bootfs.service \ + %D%/90zfs/zfs-snapshot-bootfs.service + +SUBSTFILES += $(pkgdracut_02_SCRIPTS) $(pkgdracut_90_SCRIPTS) $(pkgdracut_90_DATA) +SHELLCHECKSCRIPTS += $(pkgdracut_02_SCRIPTS) $(pkgdracut_90_SCRIPTS) +# Provided by /bin/sleep, and, again, every implementation of that supports this +$(call SHELLCHECK_OPTS,$(pkgdracut_90_SCRIPTS)): CHECKBASHISMS_IGNORE = -e 'sleep only takes one integer' -e 'sleep 0.' + +EXTRA_DIST += $(addprefix %D%/,README.md) diff --git a/sys/contrib/openzfs/contrib/dracut/README.md b/sys/contrib/openzfs/contrib/dracut/README.md index fc3d504ef705..b7cd8c8125eb 100644 --- a/sys/contrib/openzfs/contrib/dracut/README.md +++ b/sys/contrib/openzfs/contrib/dracut/README.md @@ -15,19 +15,21 @@ Encrypted datasets have keys loaded automatically or prompted for. If the root dataset contains children with `mountpoint=`s of `/etc`, `/bin`, `/lib*`, or `/usr`, they're mounted too. +For complete documentation, see `dracut.zfs(7)`. + ## cmdline -1. `root=` | Root dataset is… | Pools imported | - -------------------|----------------------------------------------------------|----------------| - *(empty)* | the first `bootfs=` after `zpool import -aN` | all | - `zfs:AUTO` | *(as above, but overriding other autoselection methods)* | all | - `ZFS=pool/dataset` | `pool/dataset` | `pool` | - `zfs:pool/dataset` | *(as above)* | `pool` | +1. `root=` | Root dataset is… | + ---------------------------|----------------------------------------------------------| + *(empty)* | the first `bootfs=` after `zpool import -aN` | + `zfs:AUTO`, `zfs:`, `zfs` | *(as above, but overriding other autoselection methods)* | + `ZFS=pool/dataset` | `pool/dataset` | + `zfs:pool/dataset` | *(as above)* | All `+`es are replaced with spaces (i.e. to boot from `root pool/data set`, pass `root=zfs:root+pool/data+set`). The dataset can be at any depth, including being the pool's root dataset (i.e. `root=zfs:pool`). - `rootfstype=zfs` is mostly equivalent to `root=zfs:AUTO`. + `rootfstype=zfs` is equivalent to `root=zfs:AUTO`, `rootfstype=zfs root=pool/dataset` is equivalent to `root=zfs:pool/dataset`. 2. `spl_hostid`: passed to `zgenhostid -f`, useful to override the `/etc/hostid` file baked into the initrd. diff --git a/sys/contrib/openzfs/contrib/initramfs/Makefile.am b/sys/contrib/openzfs/contrib/initramfs/Makefile.am index 57e8f5c3a485..6917b517f330 100644 --- a/sys/contrib/openzfs/contrib/initramfs/Makefile.am +++ b/sys/contrib/openzfs/contrib/initramfs/Makefile.am @@ -1,11 +1,39 @@ -include $(top_srcdir)/config/Shellcheck.am +i_tdir = /usr/share/initramfs-tools +dist_i_t_SCRIPTS = \ + %D%/zfsunlock -initrddir = /usr/share/initramfs-tools -dist_initrd_SCRIPTS = \ - zfsunlock +i_t_confhooks_ddir = $(i_tdir)/conf-hooks.d +dist_i_t_confhooks_d_DATA = \ + %D%/conf-hooks.d/zfs -SUBDIRS = conf.d conf-hooks.d hooks scripts -SHELLCHECKDIRS = hooks scripts -EXTRA_DIST = README.md +i_t_conf_ddir = $(i_tdir)/conf.d +dist_i_t_conf_d_DATA = \ + %D%/conf.d/zfs + + +i_t_hooksdir = $(i_tdir)/hooks +i_t_hooks_SCRIPTS = \ + %D%/hooks/zfs \ + %D%/hooks/zfsunlock + +SUBSTFILES += $(i_t_hooks_SCRIPTS) + + +i_t_scriptsdir = $(i_tdir)/scripts +dist_i_t_scripts_SCRIPTS = \ + %D%/scripts/zfs + + +i_t_scripts_localtopdir = $(i_t_scriptsdir)/local-top +dist_i_t_scripts_localtop_SCRIPTS = \ + %D%/scripts/local-top/zfs + + +i_t_check_scripts = $(dist_i_t_SCRIPTS) $(i_t_hooks_SCRIPTS) $(dist_i_t_scripts_SCRIPTS) $(dist_i_t_scripts_localtop_SCRIPTS) +SHELLCHECKSCRIPTS += $(i_t_check_scripts) +$(call SHELLCHECK_OPTS,$(i_t_check_scripts)): SHELLCHECK_SHELL = sh + + +EXTRA_DIST += $(addprefix %D%/,README.md) diff --git a/sys/contrib/openzfs/contrib/initramfs/conf-hooks.d/Makefile.am b/sys/contrib/openzfs/contrib/initramfs/conf-hooks.d/Makefile.am deleted file mode 100644 index f84ba5cc7e37..000000000000 --- a/sys/contrib/openzfs/contrib/initramfs/conf-hooks.d/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -confhooksddir = /usr/share/initramfs-tools/conf-hooks.d - -dist_confhooksd_DATA = \ - zfs diff --git a/sys/contrib/openzfs/contrib/initramfs/conf.d/Makefile.am b/sys/contrib/openzfs/contrib/initramfs/conf.d/Makefile.am deleted file mode 100644 index 5ef27e0aa1ce..000000000000 --- a/sys/contrib/openzfs/contrib/initramfs/conf.d/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -confddir = /usr/share/initramfs-tools/conf.d - -dist_confd_DATA = \ - zfs diff --git a/sys/contrib/openzfs/contrib/initramfs/hooks/Makefile.am b/sys/contrib/openzfs/contrib/initramfs/hooks/Makefile.am deleted file mode 100644 index 0cd1aafcd359..000000000000 --- a/sys/contrib/openzfs/contrib/initramfs/hooks/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -hooksdir = /usr/share/initramfs-tools/hooks - -hooks_SCRIPTS = \ - zfs \ - zfsunlock - -SUBSTFILES += $(hooks_SCRIPTS) diff --git a/sys/contrib/openzfs/contrib/initramfs/scripts/Makefile.am b/sys/contrib/openzfs/contrib/initramfs/scripts/Makefile.am deleted file mode 100644 index 444a5f374bfe..000000000000 --- a/sys/contrib/openzfs/contrib/initramfs/scripts/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -include $(top_srcdir)/config/Shellcheck.am - -scriptsdir = /usr/share/initramfs-tools/scripts - -dist_scripts_SCRIPTS = \ - zfs - -SUBDIRS = local-top - -SHELLCHECKDIRS = $(SUBDIRS) -SHELLCHECK_SHELL = sh diff --git a/sys/contrib/openzfs/contrib/initramfs/scripts/local-top/Makefile.am b/sys/contrib/openzfs/contrib/initramfs/scripts/local-top/Makefile.am deleted file mode 100644 index f3dc23129f09..000000000000 --- a/sys/contrib/openzfs/contrib/initramfs/scripts/local-top/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Shellcheck.am - -localtopdir = /usr/share/initramfs-tools/scripts/local-top - -dist_localtop_SCRIPTS = \ - zfs - diff --git a/sys/contrib/openzfs/contrib/initramfs/scripts/zfs b/sys/contrib/openzfs/contrib/initramfs/scripts/zfs index 85b00f9da86d..1c8c496a7ff4 100644 --- a/sys/contrib/openzfs/contrib/initramfs/scripts/zfs +++ b/sys/contrib/openzfs/contrib/initramfs/scripts/zfs @@ -328,7 +328,7 @@ mount_fs() # Need the _original_ datasets mountpoint! mountpoint=$(get_fs_value "$fs" mountpoint) - ZFS_CMD="mount -o zfsutil -t zfs" + ZFS_CMD="mount.zfs -o zfsutil" if [ "$mountpoint" = "legacy" ] || [ "$mountpoint" = "none" ]; then # Can't use the mountpoint property. Might be one of our # clones. Check the 'org.zol:mountpoint' property set in @@ -351,7 +351,7 @@ mount_fs() # If it's not a legacy filesystem, it can only be a # native one... if [ "$mountpoint" = "legacy" ]; then - ZFS_CMD="mount -t zfs" + ZFS_CMD="mount.zfs" fi fi @@ -919,7 +919,7 @@ mountroot() echo " not specified on the kernel command line." echo "" echo "Manually mount the root filesystem on $rootmnt and then exit." - echo "Hint: Try: mount -o zfsutil -t zfs ${ZFS_RPOOL-rpool}/ROOT/system $rootmnt" + echo "Hint: Try: mount.zfs -o zfsutil ${ZFS_RPOOL-rpool}/ROOT/system $rootmnt" shell fi diff --git a/sys/contrib/openzfs/contrib/pam_zfs_key/Makefile.am b/sys/contrib/openzfs/contrib/pam_zfs_key/Makefile.am index f0f2550afccb..aaa608b7da2b 100644 --- a/sys/contrib/openzfs/contrib/pam_zfs_key/Makefile.am +++ b/sys/contrib/openzfs/contrib/pam_zfs_key/Makefile.am @@ -1,19 +1,18 @@ -include $(top_srcdir)/config/Rules.am +%C%_pam_zfs_key_la_CFLAGS = $(AM_CFLAGS) +%C%_pam_zfs_key_la_CFLAGS += $(LIBCRYPTO_CFLAGS) -AM_CFLAGS += $(LIBCRYPTO_CFLAGS) +pammodule_LTLIBRARIES = %D%/pam_zfs_key.la -pammodule_LTLIBRARIES=pam_zfs_key.la +%C%_pam_zfs_key_la_SOURCES = %D%/pam_zfs_key.c -pam_zfs_key_la_SOURCES = pam_zfs_key.c +%C%_pam_zfs_key_la_LIBADD = \ + libnvpair.la \ + libuutil.la \ + libzfs.la \ + libzfs_core.la -pam_zfs_key_la_LIBADD = \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la \ - $(abs_top_builddir)/lib/libuutil/libuutil.la \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la +%C%_pam_zfs_key_la_LIBADD += -lpam $(LIBCRYPTO_LIBS) -pam_zfs_key_la_LDFLAGS = -version-info 1:0:0 -avoid-version -module -shared +%C%_pam_zfs_key_la_LDFLAGS = -version-info 1:0:0 -avoid-version -module -shared -pam_zfs_key_la_LIBADD += -lpam $(LIBCRYPTO_LIBS) - -dist_pamconfigs_DATA = zfs_key +dist_pamconfigs_DATA = %D%/zfs_key diff --git a/sys/contrib/openzfs/contrib/pyzfs/Makefile.am b/sys/contrib/openzfs/contrib/pyzfs/Makefile.am index fa1bb32ce2eb..505cd3c8b355 100644 --- a/sys/contrib/openzfs/contrib/pyzfs/Makefile.am +++ b/sys/contrib/openzfs/contrib/pyzfs/Makefile.am @@ -1,10 +1,11 @@ -EXTRA_DIST = libzfs_core setup.py.in README LICENSE docs +EXTRA_DIST += $(addprefix %D%/,libzfs_core README LICENSE docs) +SUBSTFILES += %D%/setup.py if PYZFS_ENABLED -all: - -all-local: - $(PYTHON) setup.py build +ALL_LOCAL += pyzfs-all-local +pyzfs_V_1 = -v +pyzfs-all-local: %D%/setup.py + cd %D% && $(PYTHON) setup.py -q $(pyzfs_V_$(V)) egg_info -e . build # # On Debian (Ubuntu, and other downstream distros) the install location of @@ -24,17 +25,14 @@ all-local: # files are later created by manually loading the Python modules. # install-exec-local: - $(PYTHON) $(builddir)/setup.py install \ - --prefix $(prefix) \ - --root $(DESTDIR)/ \ - --install-lib $(pythonsitedir) \ - --single-version-externally-managed \ - --verbose - -clean: clean-local - rm -rf build/ pyzfs.egg-info/ - -clean-local: + cd %D% && $(PYTHON) setup.py egg_info -e . install \ + --prefix $(prefix) \ + --root $(DESTDIR)/ \ + --install-lib $(pythonsitedir) \ + --single-version-externally-managed \ + --verbose -check-local: all +CLEAN_LOCAL += pyzfs-clean-local +pyzfs-clean-local: + -$(RM) -r %D%/build/ %D%/pyzfs.egg-info/ endif diff --git a/sys/contrib/openzfs/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py b/sys/contrib/openzfs/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py index 2567f7ebf83d..9b1aea193f44 100644 --- a/sys/contrib/openzfs/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py +++ b/sys/contrib/openzfs/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py @@ -1903,6 +1903,8 @@ class ZFSTest(unittest.TestCase): with self.assertRaises(lzc_exc.StreamIOError) as ctx: lzc.lzc_send(snap, None, fd) os.close(fd) + os.unlink(output.name) + self.assertEqual(ctx.exception.errno, errno.EBADF) def test_recv_full(self): diff --git a/sys/contrib/openzfs/contrib/pyzfs/setup.py.in b/sys/contrib/openzfs/contrib/pyzfs/setup.py.in index 934b3189ebe1..43a1accfaf02 100644 --- a/sys/contrib/openzfs/contrib/pyzfs/setup.py.in +++ b/sys/contrib/openzfs/contrib/pyzfs/setup.py.in @@ -13,9 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from __future__ import absolute_import, division, print_function - from setuptools import setup, find_packages +import os.path + +srcdir = "@abs_top_srcdir@/contrib/pyzfs" setup( name="pyzfs", @@ -44,7 +45,8 @@ setup( "libzfs_core", ], - packages=find_packages(), + packages=find_packages(where=srcdir), + package_dir={"": os.path.relpath(srcdir)}, include_package_data=True, install_requires=[ "cffi", diff --git a/sys/contrib/openzfs/contrib/zcp/Makefile.am b/sys/contrib/openzfs/contrib/zcp/Makefile.am index e6a777ad7ba7..759a9d529dc8 100644 --- a/sys/contrib/openzfs/contrib/zcp/Makefile.am +++ b/sys/contrib/openzfs/contrib/zcp/Makefile.am @@ -1 +1 @@ -EXTRA_DIST = autosnap.lua +EXTRA_DIST += $(addprefix %D%/,autosnap.lua) diff --git a/sys/contrib/openzfs/copy-builtin b/sys/contrib/openzfs/copy-builtin index cd6f259092ed..18cc741b58e7 100755 --- a/sys/contrib/openzfs/copy-builtin +++ b/sys/contrib/openzfs/copy-builtin @@ -43,32 +43,8 @@ config ZFS If unsure, say N. EOF -add_after() -{ - FILE="$1" - MARKER="$2" - NEW="$3" - - while IFS='' read -r LINE - do - printf "%s\n" "$LINE" - - if [ -n "$MARKER" ] && [ "$LINE" = "$MARKER" ] - then - printf "%s\n" "$NEW" - MARKER='' - if IFS='' read -r LINE - then - [ "$LINE" != "$NEW" ] && printf "%s\n" "$LINE" - fi - fi - done < "$FILE" > "$FILE.new" - - mv "$FILE.new" "$FILE" -} - -add_after "$KERNEL_DIR/fs/Kconfig" 'if BLOCK' 'source "fs/zfs/Kconfig"' -add_after "$KERNEL_DIR/fs/Makefile" 'endif' 'obj-$(CONFIG_ZFS) += zfs/' +sed -i '/source "fs\/ext2\/Kconfig\"/i\source "fs/zfs/Kconfig"' "$KERNEL_DIR/fs/Kconfig" +echo 'obj-$(CONFIG_ZFS) += zfs/' >> "$KERNEL_DIR/fs/Makefile" echo "$0: done. now you can build the kernel with ZFS support." >&2 echo "$0: make sure you enable ZFS support (CONFIG_ZFS) before building." >&2 diff --git a/sys/contrib/openzfs/etc/Makefile.am b/sys/contrib/openzfs/etc/Makefile.am index 179c2400978c..ffe5fad2b4a9 100644 --- a/sys/contrib/openzfs/etc/Makefile.am +++ b/sys/contrib/openzfs/etc/Makefile.am @@ -1,9 +1,95 @@ -include $(top_srcdir)/config/Shellcheck.am +sudoersddir = $(sysconfdir)/sudoers.d +sudoersd_DATA = \ + %D%/sudoers.d/zfs + +EXTRA_DIST += $(sudoersd_DATA) + + +sysconf_zfsdir = $(sysconfdir)/zfs + +dist_sysconf_zfs_DATA = \ + %D%/zfs/vdev_id.conf.alias.example \ + %D%/zfs/vdev_id.conf.multipath.example \ + %D%/zfs/vdev_id.conf.sas_direct.example \ + %D%/zfs/vdev_id.conf.sas_switch.example \ + %D%/zfs/vdev_id.conf.scsi.example + +sysconf_zfs_SCRIPTS = \ + %D%/zfs/zfs-functions + +SUBSTFILES += $(sysconf_zfs_SCRIPTS) +SHELLCHECKSCRIPTS += $(sysconf_zfs_SCRIPTS) +$(call SHELLCHECK_OPTS,$(sysconf_zfs_SCRIPTS)): SHELLCHECK_SHELL = sh -SUBDIRS = zfs sudoers.d -SHELLCHECKDIRS = default $(ZFS_INIT_SYSV) zfs if BUILD_LINUX -SUBDIRS += default $(ZFS_INIT_SYSTEMD) $(ZFS_INIT_SYSV) $(ZFS_MODULE_LOAD) +initconf_SCRIPTS = \ + %D%/default/zfs + +SUBSTFILES += $(initconf_SCRIPTS) +SHELLCHECKSCRIPTS += $(initconf_SCRIPTS) +$(call SHELLCHECK_OPTS,$(initconf_SCRIPTS)): SHELLCHECK_SHELL = sh + + +if INIT_SYSV +EXTRA_DIST += $(addprefix %D%/,init.d/README.md) + +init_SCRIPTS = \ + %D%/init.d/zfs-import \ + %D%/init.d/zfs-load-key \ + %D%/init.d/zfs-mount \ + %D%/init.d/zfs-share \ + %D%/init.d/zfs-zed + +SUBSTFILES += $(init_SCRIPTS) +SHELLCHECKSCRIPTS += $(init_SCRIPTS) +$(call SHELLCHECK_OPTS,$(init_SCRIPTS)): SHELLCHECK_SHELL = sh +endif + + +if INIT_SYSTEMD +dist_systemdpreset_DATA = \ + %D%/systemd/system/50-zfs.preset + +systemdunit_DATA = \ + %D%/systemd/system/zfs-import-cache.service \ + %D%/systemd/system/zfs-import-scan.service \ + %D%/systemd/system/zfs-import.target \ + %D%/systemd/system/zfs-mount.service \ + %D%/systemd/system/zfs-scrub-monthly@.timer \ + %D%/systemd/system/zfs-scrub-weekly@.timer \ + %D%/systemd/system/zfs-scrub@.service \ + %D%/systemd/system/zfs-share.service \ + %D%/systemd/system/zfs-volume-wait.service \ + %D%/systemd/system/zfs-volumes.target \ + %D%/systemd/system/zfs-zed.service \ + %D%/systemd/system/zfs.target + +SUBSTFILES += $(systemdunit_DATA) + +INSTALL_DATA_HOOKS += systemd-install-data-hook +systemd-install-data-hook: + $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)" + ln -sf /dev/null "$(DESTDIR)$(systemdunitdir)/zfs-import.service" + + +systemdgenerator_PROGRAMS = \ + %D%/systemd/system-generators/zfs-mount-generator + +%C%_systemd_system_generators_zfs_mount_generator_SOURCES = \ + %D%/systemd/system-generators/zfs-mount-generator.c + +%C%_systemd_system_generators_zfs_mount_generator_LDADD = \ + libzfs.la + +%C%_systemd_system_generators_zfs_mount_generator_LDFLAGS = -pthread + +CPPCHECKTARGETS += $(systemdgenerator_PROGRAMS) +endif + + +if WANT_MODULES_LOAD_D +dist_modulesload_DATA = \ + %D%/modules-load.d/zfs.conf +endif endif -DIST_SUBDIRS = default init.d zfs systemd modules-load.d sudoers.d diff --git a/sys/contrib/openzfs/etc/default/Makefile.am b/sys/contrib/openzfs/etc/default/Makefile.am deleted file mode 100644 index 0f7c96698d45..000000000000 --- a/sys/contrib/openzfs/etc/default/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -initconf_SCRIPTS = zfs - -SUBSTFILES += $(initconf_SCRIPTS) - -SHELLCHECK_SHELL = sh diff --git a/sys/contrib/openzfs/etc/init.d/Makefile.am b/sys/contrib/openzfs/etc/init.d/Makefile.am deleted file mode 100644 index 625d0b91fd11..000000000000 --- a/sys/contrib/openzfs/etc/init.d/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -EXTRA_DIST += README.md - -init_SCRIPTS = zfs-import zfs-load-key zfs-mount zfs-share zfs-zed - -SUBSTFILES += $(init_SCRIPTS) - -SHELLCHECK_SHELL = sh diff --git a/sys/contrib/openzfs/etc/init.d/zfs-mount.in b/sys/contrib/openzfs/etc/init.d/zfs-mount.in index d196d1555a45..df28c6c951c5 100755 --- a/sys/contrib/openzfs/etc/init.d/zfs-mount.in +++ b/sys/contrib/openzfs/etc/init.d/zfs-mount.in @@ -63,7 +63,7 @@ do_depend() # Mount all datasets/filesystems do_mount() { - local verbose overlay i mntpt + local verbose overlay check_boolean "$VERBOSE_MOUNT" && verbose=v check_boolean "$DO_OVERLAY_MOUNTS" && overlay=O @@ -71,102 +71,18 @@ do_mount() zfs_action "Mounting ZFS filesystem(s)" \ "$ZFS" mount "-a$verbose$overlay" "$MOUNT_EXTRA_OPTIONS" - # Require each volume/filesystem to have 'noauto' and no fsck - # option. This shouldn't really be necessary, as long as one - # can get zfs-import to run sufficiently early on in the boot - # process - before local mounts. This is just here in case/if - # this isn't possible. - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_begin_msg "Mounting volumes and filesystems registered in fstab" - - read_mtab "^/dev/(zd|zvol)" - read_fstab "^/dev/(zd|zvol)" - i=0; var="FSTAB_0" - while [ -n "$(eval echo "\$$var")" ] - do - mntpt=$(eval echo "\$$var") - dev=$(eval echo "\$FSTAB_dev_$i") - if ! in_mtab "$mntpt" && ! is_mounted "$mntpt" && [ -e "$dev" ] - then - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_progress_msg "$mntpt " - fsck "$dev" && mount "$mntpt" - fi - - i=$((i + 1)) - var=$(eval echo "FSTAB_$i") - done - - read_mtab "[[:space:]]zfs[[:space:]]" - read_fstab "[[:space:]]zfs[[:space:]]" - i=0; var=$(eval echo "FSTAB_$i") - while [ -n "$(eval echo "\$$var")" ] - do - mntpt=$(eval echo "\$$var") - if ! in_mtab "$mntpt" && ! is_mounted "$mntpt" - then - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_progress_msg "$mntpt " - mount "$mntpt" - fi - - i=$((i + 1)) - var=$(eval echo "FSTAB_$i") - done - check_boolean "$VERBOSE_MOUNT" && zfs_log_end_msg 0 - return 0 } # Unmount all filesystems do_unmount() { - local i var mntpt - # This shouldn't really be necessary, as long as one can get # zfs-import to run sufficiently late in the shutdown/reboot process # - after unmounting local filesystems. This is just here in case/if # this isn't possible. zfs_action "Unmounting ZFS filesystems" "$ZFS" unmount -a - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_begin_msg "Unmounting volumes and filesystems registered in fstab" - - read_mtab "^/dev/(zd|zvol)" - read_fstab "^/dev/(zd|zvol)" - i=0; var="FSTAB_0" - while [ -n "$(eval echo "\$$var")" ] - do - mntpt=$(eval echo "\$$var") - dev=$(eval echo "\$FSTAB_dev_$i") - if in_mtab "$mntpt" - then - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_progress_msg "$mntpt " - umount "$mntpt" - fi - - i=$((i + 1)) - var=$(eval echo "FSTAB_$i") - done - - read_mtab "[[:space:]]zfs[[:space:]]" - read_fstab "[[:space:]]zfs[[:space:]]" - i=0; var="FSTAB_0" - while [ -n "$(eval echo "\$$var")" ] - do - mntpt=$(eval echo "\$$var") - if in_mtab "$mntpt"; then - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_progress_msg "$mntpt " - umount "$mntpt" - fi - - i=$((i + 1)) - var=$(eval echo "FSTAB_$i") - done - check_boolean "$VERBOSE_MOUNT" && zfs_log_end_msg 0 - return 0 } diff --git a/sys/contrib/openzfs/etc/init.d/zfs-zed.in b/sys/contrib/openzfs/etc/init.d/zfs-zed.in index 47f742259b27..e9cf8867403c 100755 --- a/sys/contrib/openzfs/etc/init.d/zfs-zed.in +++ b/sys/contrib/openzfs/etc/init.d/zfs-zed.in @@ -69,8 +69,7 @@ do_stop() then # No pools imported, it is/should be safe/possible to # unload modules. - zfs_action "Unloading modules" rmmod zfs zunicode \ - zavl zcommon znvpair zlua spl + zfs_action "Unloading modules" rmmod zfs spl return "$?" fi } diff --git a/sys/contrib/openzfs/etc/modules-load.d/.gitignore b/sys/contrib/openzfs/etc/modules-load.d/.gitignore deleted file mode 100644 index fee921708337..000000000000 --- a/sys/contrib/openzfs/etc/modules-load.d/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.conf diff --git a/sys/contrib/openzfs/etc/modules-load.d/Makefile.am b/sys/contrib/openzfs/etc/modules-load.d/Makefile.am deleted file mode 100644 index 8a2955767b1e..000000000000 --- a/sys/contrib/openzfs/etc/modules-load.d/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -dist_modulesload_DATA = \ - zfs.conf diff --git a/sys/contrib/openzfs/etc/sudoers.d/Makefile.am b/sys/contrib/openzfs/etc/sudoers.d/Makefile.am deleted file mode 100644 index 6f7ac8dbfd61..000000000000 --- a/sys/contrib/openzfs/etc/sudoers.d/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -sudoersddir = $(sysconfdir)/sudoers.d -sudoersd_DATA = zfs - -EXTRA_DIST = \ - zfs diff --git a/sys/contrib/openzfs/etc/systemd/Makefile.am b/sys/contrib/openzfs/etc/systemd/Makefile.am deleted file mode 100644 index 66232a5ff197..000000000000 --- a/sys/contrib/openzfs/etc/systemd/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -include $(top_srcdir)/config/Shellcheck.am - -SUBDIRS = system system-generators -SHELLCHECKDIRS = system-generators diff --git a/sys/contrib/openzfs/etc/systemd/system-generators/Makefile.am b/sys/contrib/openzfs/etc/systemd/system-generators/Makefile.am deleted file mode 100644 index e5920bf39203..000000000000 --- a/sys/contrib/openzfs/etc/systemd/system-generators/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -systemdgenerator_PROGRAMS = \ - zfs-mount-generator - -zfs_mount_generator_SOURCES = \ - zfs-mount-generator.c - -zfs_mount_generator_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la - -zfs_mount_generator_LDFLAGS = -pthread - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/etc/systemd/system/.gitignore b/sys/contrib/openzfs/etc/systemd/system/.gitignore index 4813c65a25a8..95d33fdd436d 100644 --- a/sys/contrib/openzfs/etc/systemd/system/.gitignore +++ b/sys/contrib/openzfs/etc/systemd/system/.gitignore @@ -1,4 +1,3 @@ *.service *.target -*.preset *.timer diff --git a/sys/contrib/openzfs/etc/systemd/system/50-zfs.preset.in b/sys/contrib/openzfs/etc/systemd/system/50-zfs.preset index e4056a92cd98..e4056a92cd98 100644 --- a/sys/contrib/openzfs/etc/systemd/system/50-zfs.preset.in +++ b/sys/contrib/openzfs/etc/systemd/system/50-zfs.preset diff --git a/sys/contrib/openzfs/etc/systemd/system/Makefile.am b/sys/contrib/openzfs/etc/systemd/system/Makefile.am deleted file mode 100644 index 5e65e1db420c..000000000000 --- a/sys/contrib/openzfs/etc/systemd/system/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am - -systemdpreset_DATA = \ - 50-zfs.preset - -systemdunit_DATA = \ - zfs-zed.service \ - zfs-import-cache.service \ - zfs-import-scan.service \ - zfs-mount.service \ - zfs-share.service \ - zfs-volume-wait.service \ - zfs-import.target \ - zfs-volumes.target \ - zfs.target \ - zfs-scrub-monthly@.timer \ - zfs-scrub-weekly@.timer \ - zfs-scrub@.service - -SUBSTFILES += $(systemdpreset_DATA) $(systemdunit_DATA) - -install-data-hook: - $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)" - ln -sf /dev/null "$(DESTDIR)$(systemdunitdir)/zfs-import.service" diff --git a/sys/contrib/openzfs/etc/zfs/Makefile.am b/sys/contrib/openzfs/etc/zfs/Makefile.am deleted file mode 100644 index 8a67d548bf7e..000000000000 --- a/sys/contrib/openzfs/etc/zfs/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -pkgsysconfdir = $(sysconfdir)/zfs - -dist_pkgsysconf_DATA = \ - vdev_id.conf.alias.example \ - vdev_id.conf.sas_direct.example \ - vdev_id.conf.sas_switch.example \ - vdev_id.conf.multipath.example \ - vdev_id.conf.scsi.example - -pkgsysconf_SCRIPTS = \ - zfs-functions - -SUBSTFILES += $(pkgsysconf_SCRIPTS) - -SHELLCHECK_SHELL = sh diff --git a/sys/contrib/openzfs/include/Makefile.am b/sys/contrib/openzfs/include/Makefile.am index 4da43afd850d..eee989d4a150 100644 --- a/sys/contrib/openzfs/include/Makefile.am +++ b/sys/contrib/openzfs/include/Makefile.am @@ -1,4 +1,10 @@ -SUBDIRS = sys os +if BUILD_LINUX +include $(srcdir)/%D%/os/linux/Makefile.am +endif +if BUILD_FREEBSD +include $(srcdir)/%D%/os/freebsd/Makefile.am +endif + COMMON_H = \ cityhash.h \ @@ -7,27 +13,187 @@ COMMON_H = \ zfs_deleg.h \ zfs_fletcher.h \ zfs_namecheck.h \ - zfs_prop.h + zfs_prop.h \ + \ + sys/abd.h \ + sys/abd_impl.h \ + sys/aggsum.h \ + sys/arc.h \ + sys/arc_impl.h \ + sys/avl.h \ + sys/avl_impl.h \ + sys/bitops.h \ + sys/blkptr.h \ + sys/bplist.h \ + sys/bpobj.h \ + sys/bptree.h \ + sys/bqueue.h \ + sys/btree.h \ + sys/dataset_kstats.h \ + sys/dbuf.h \ + sys/ddt.h \ + sys/dmu.h \ + sys/dmu_impl.h \ + sys/dmu_objset.h \ + sys/dmu_recv.h \ + sys/dmu_redact.h \ + sys/dmu_send.h \ + sys/dmu_traverse.h \ + sys/dmu_tx.h \ + sys/dmu_zfetch.h \ + sys/dnode.h \ + sys/dsl_bookmark.h \ + sys/dsl_crypt.h \ + sys/dsl_dataset.h \ + sys/dsl_deadlist.h \ + sys/dsl_deleg.h \ + sys/dsl_destroy.h \ + sys/dsl_dir.h \ + sys/dsl_pool.h \ + sys/dsl_prop.h \ + sys/dsl_scan.h \ + sys/dsl_synctask.h \ + sys/dsl_userhold.h \ + sys/edonr.h \ + sys/efi_partition.h \ + sys/frame.h \ + sys/hkdf.h \ + sys/metaslab.h \ + sys/metaslab_impl.h \ + sys/mmp.h \ + sys/mntent.h \ + sys/mod.h \ + sys/multilist.h \ + sys/nvpair.h \ + sys/nvpair_impl.h \ + sys/objlist.h \ + sys/pathname.h \ + sys/qat.h \ + sys/range_tree.h \ + sys/rrwlock.h \ + sys/sa.h \ + sys/sa_impl.h \ + sys/skein.h \ + sys/spa.h \ + sys/spa_boot.h \ + sys/spa_checkpoint.h \ + sys/spa_checksum.h \ + sys/spa_impl.h \ + sys/spa_log_spacemap.h \ + sys/space_map.h \ + sys/space_reftree.h \ + sys/sysevent.h \ + sys/txg.h \ + sys/txg_impl.h \ + sys/u8_textprep.h \ + sys/u8_textprep_data.h \ + sys/uberblock.h \ + sys/uberblock_impl.h \ + sys/uio_impl.h \ + sys/unique.h \ + sys/uuid.h \ + sys/vdev.h \ + sys/vdev_disk.h \ + sys/vdev_draid.h \ + sys/vdev_file.h \ + sys/vdev_impl.h \ + sys/vdev_indirect_births.h \ + sys/vdev_indirect_mapping.h \ + sys/vdev_initialize.h \ + sys/vdev_raidz.h \ + sys/vdev_raidz_impl.h \ + sys/vdev_rebuild.h \ + sys/vdev_removal.h \ + sys/vdev_trim.h \ + sys/xvattr.h \ + sys/zap.h \ + sys/zap_impl.h \ + sys/zap_leaf.h \ + sys/zcp.h \ + sys/zcp_global.h \ + sys/zcp_iter.h \ + sys/zcp_prop.h \ + sys/zcp_set.h \ + sys/zfeature.h \ + sys/zfs_acl.h \ + sys/zfs_bootenv.h \ + sys/zfs_context.h \ + sys/zfs_debug.h \ + sys/zfs_delay.h \ + sys/zfs_file.h \ + sys/zfs_fuid.h \ + sys/zfs_project.h \ + sys/zfs_quota.h \ + sys/zfs_racct.h \ + sys/zfs_ratelimit.h \ + sys/zfs_refcount.h \ + sys/zfs_rlock.h \ + sys/zfs_sa.h \ + sys/zfs_stat.h \ + sys/zfs_sysfs.h \ + sys/zfs_vfsops.h \ + sys/zfs_vnops.h \ + sys/zfs_znode.h \ + sys/zil.h \ + sys/zil_impl.h \ + sys/zio.h \ + sys/zio_checksum.h \ + sys/zio_compress.h \ + sys/zio_crypt.h \ + sys/zio_impl.h \ + sys/zio_priority.h \ + sys/zrlock.h \ + sys/zthr.h \ + \ + sys/crypto/api.h \ + sys/crypto/common.h \ + sys/crypto/icp.h \ + \ + sys/fm/protocol.h \ + sys/fm/util.h \ + sys/fm/fs/zfs.h \ + \ + sys/fs/zfs.h \ + \ + sys/lua/lauxlib.h \ + sys/lua/lua.h \ + sys/lua/luaconf.h \ + sys/lua/lualib.h \ + \ + sys/sysevent/dev.h \ + sys/sysevent/eventdefs.h \ + \ + sys/zstd/zstd.h + + +KERNEL_H = \ + sys/zfs_ioctl.h \ + sys/zfs_ioctl_impl.h \ + sys/zfs_onexit.h \ + sys/zvol.h \ + sys/zvol_impl.h + USER_H = \ libnvpair.h \ - libuutil_common.h \ libuutil.h \ + libuutil_common.h \ libuutil_impl.h \ libzfs.h \ - libzfsbootenv.h \ libzfs_core.h \ + libzfsbootenv.h \ libzutil.h \ thread_pool.h + if CONFIG_USER libzfsdir = $(includedir)/libzfs -libzfs_HEADERS = $(COMMON_H) $(USER_H) +nobase_libzfs_HEADERS = $(COMMON_H) $(USER_H) endif +kerneldir = $(prefix)/src/zfs-$(VERSION)/include if CONFIG_KERNEL if BUILD_LINUX -kerneldir = @prefix@/src/zfs-$(VERSION)/include -kernel_HEADERS = $(COMMON_H) +nobase_kernel_HEADERS = $(COMMON_H) $(KERNEL_H) endif endif diff --git a/sys/contrib/openzfs/include/libzfs.h b/sys/contrib/openzfs/include/libzfs.h index c0e53b88a636..04f464d12faf 100644 --- a/sys/contrib/openzfs/include/libzfs.h +++ b/sys/contrib/openzfs/include/libzfs.h @@ -35,6 +35,7 @@ #define _LIBZFS_H extern __attribute__((visibility("default"))) #include <assert.h> +#include <libshare.h> #include <libnvpair.h> #include <sys/mnttab.h> #include <sys/param.h> @@ -878,37 +879,25 @@ _LIBZFS_H void zfs_adjust_mount_options(zfs_handle_t *zhp, const char *mntpoint, /* * Share support functions. + * + * enum sa_protocol * lists are terminated with SA_NO_PROTOCOL, + * NULL means "all/any known to this libzfs". */ -_LIBZFS_H boolean_t zfs_is_shared(zfs_handle_t *); -_LIBZFS_H int zfs_share(zfs_handle_t *); -_LIBZFS_H int zfs_unshare(zfs_handle_t *); - -/* - * Protocol-specific share support functions. - */ -_LIBZFS_H boolean_t zfs_is_shared_nfs(zfs_handle_t *, char **); -_LIBZFS_H boolean_t zfs_is_shared_smb(zfs_handle_t *, char **); -_LIBZFS_H int zfs_share_nfs(zfs_handle_t *); -_LIBZFS_H int zfs_share_smb(zfs_handle_t *); -_LIBZFS_H int zfs_shareall(zfs_handle_t *); -_LIBZFS_H int zfs_unshare_nfs(zfs_handle_t *, const char *); -_LIBZFS_H int zfs_unshare_smb(zfs_handle_t *, const char *); -_LIBZFS_H int zfs_unshareall_nfs(zfs_handle_t *); -_LIBZFS_H int zfs_unshareall_smb(zfs_handle_t *); -_LIBZFS_H int zfs_unshareall_bypath(zfs_handle_t *, const char *); -_LIBZFS_H int zfs_unshareall_bytype(zfs_handle_t *, const char *, const char *); -_LIBZFS_H int zfs_unshareall(zfs_handle_t *); -_LIBZFS_H int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *, - void *, void *, int, zfs_share_op_t); -_LIBZFS_H void zfs_commit_nfs_shares(void); -_LIBZFS_H void zfs_commit_smb_shares(void); -_LIBZFS_H void zfs_commit_all_shares(void); -_LIBZFS_H void zfs_commit_shares(const char *); +#define SA_NO_PROTOCOL -1 + +_LIBZFS_H boolean_t zfs_is_shared(zfs_handle_t *zhp, char **where, + const enum sa_protocol *proto); +_LIBZFS_H int zfs_share(zfs_handle_t *zhp, const enum sa_protocol *proto); +_LIBZFS_H int zfs_unshare(zfs_handle_t *zhp, const char *mountpoint, + const enum sa_protocol *proto); +_LIBZFS_H int zfs_unshareall(zfs_handle_t *zhp, + const enum sa_protocol *proto); +_LIBZFS_H void zfs_commit_shares(const enum sa_protocol *proto); _LIBZFS_H int zfs_nicestrtonum(libzfs_handle_t *, const char *, uint64_t *); /* - * Utility functions to run an _LIBZFS_Hal process. + * Utility functions to run an external process. */ #define STDOUT_VERBOSE 0x01 #define STDERR_VERBOSE 0x02 diff --git a/sys/contrib/openzfs/include/libzutil.h b/sys/contrib/openzfs/include/libzutil.h index c0a660ea7067..d0d5632c027a 100644 --- a/sys/contrib/openzfs/include/libzutil.h +++ b/sys/contrib/openzfs/include/libzutil.h @@ -97,8 +97,8 @@ _LIBZUTIL_H int zfs_append_partition(char *path, size_t max_len); _LIBZUTIL_H int zfs_resolve_shortname(const char *name, char *path, size_t pathlen); -_LIBZUTIL_H char *zfs_strip_partition(char *); -_LIBZUTIL_H char *zfs_strip_path(char *); +_LIBZUTIL_H char *zfs_strip_partition(const char *); +_LIBZUTIL_H const char *zfs_strip_path(const char *); _LIBZUTIL_H int zfs_strcmp_pathname(const char *, const char *, int); diff --git a/sys/contrib/openzfs/include/os/Makefile.am b/sys/contrib/openzfs/include/os/Makefile.am deleted file mode 100644 index 7eab1abde984..000000000000 --- a/sys/contrib/openzfs/include/os/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -if BUILD_LINUX -SUBDIRS = linux -endif -if BUILD_FREEBSD -SUBDIRS = freebsd -endif diff --git a/sys/contrib/openzfs/include/os/freebsd/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/Makefile.am index 3c87d4a0e791..5ddb7cd710b8 100644 --- a/sys/contrib/openzfs/include/os/freebsd/Makefile.am +++ b/sys/contrib/openzfs/include/os/freebsd/Makefile.am @@ -1 +1,90 @@ -SUBDIRS = linux spl zfs +noinst_HEADERS = \ + %D%/linux/compiler.h \ + %D%/linux/types.h \ + \ + %D%/spl/acl/acl_common.h \ + \ + %D%/spl/rpc/xdr.h \ + \ + %D%/spl/sys/acl.h \ + %D%/spl/sys/acl_impl.h \ + %D%/spl/sys/atomic.h \ + %D%/spl/sys/byteorder.h \ + %D%/spl/sys/callb.h \ + %D%/spl/sys/ccompat.h \ + %D%/spl/sys/ccompile.h \ + %D%/spl/sys/cmn_err.h \ + %D%/spl/sys/condvar.h \ + %D%/spl/sys/cred.h \ + %D%/spl/sys/ctype.h \ + %D%/spl/sys/debug.h \ + %D%/spl/sys/dirent.h \ + %D%/spl/sys/disp.h \ + %D%/spl/sys/dkio.h \ + %D%/spl/sys/extdirent.h \ + %D%/spl/sys/fcntl.h \ + %D%/spl/sys/file.h \ + %D%/spl/sys/freebsd_rwlock.h \ + %D%/spl/sys/idmap.h \ + %D%/spl/sys/inttypes.h \ + %D%/spl/sys/isa_defs.h \ + %D%/spl/sys/kmem.h \ + %D%/spl/sys/kmem_cache.h \ + %D%/spl/sys/kstat.h \ + %D%/spl/sys/list.h \ + %D%/spl/sys/list_impl.h \ + %D%/spl/sys/lock.h \ + %D%/spl/sys/misc.h \ + %D%/spl/sys/mod_os.h \ + %D%/spl/sys/mode.h \ + %D%/spl/sys/mount.h \ + %D%/spl/sys/mutex.h \ + %D%/spl/sys/param.h \ + %D%/spl/sys/policy.h \ + %D%/spl/sys/proc.h \ + %D%/spl/sys/processor.h \ + %D%/spl/sys/procfs_list.h \ + %D%/spl/sys/random.h \ + %D%/spl/sys/rwlock.h \ + %D%/spl/sys/sdt.h \ + %D%/spl/sys/sid.h \ + %D%/spl/sys/sig.h \ + %D%/spl/sys/simd.h \ + %D%/spl/sys/simd_x86.h \ + %D%/spl/sys/spl_condvar.h \ + %D%/spl/sys/string.h \ + %D%/spl/sys/sunddi.h \ + %D%/spl/sys/sysmacros.h \ + %D%/spl/sys/systeminfo.h \ + %D%/spl/sys/systm.h \ + %D%/spl/sys/taskq.h \ + %D%/spl/sys/thread.h \ + %D%/spl/sys/time.h \ + %D%/spl/sys/timer.h \ + %D%/spl/sys/trace.h \ + %D%/spl/sys/trace_zfs.h \ + %D%/spl/sys/types.h \ + %D%/spl/sys/types32.h \ + %D%/spl/sys/uio.h \ + %D%/spl/sys/uuid.h \ + %D%/spl/sys/vfs.h \ + %D%/spl/sys/vm.h \ + %D%/spl/sys/vmsystm.h \ + %D%/spl/sys/vnode.h \ + %D%/spl/sys/vnode_impl.h \ + %D%/spl/sys/wmsum.h \ + %D%/spl/sys/zmod.h \ + %D%/spl/sys/zone.h \ + \ + %D%/zfs/sys/freebsd_crypto.h \ + %D%/zfs/sys/sha2.h \ + %D%/zfs/sys/vdev_os.h \ + %D%/zfs/sys/zfs_bootenv_os.h \ + %D%/zfs/sys/zfs_context_os.h \ + %D%/zfs/sys/zfs_ctldir.h \ + %D%/zfs/sys/zfs_dir.h \ + %D%/zfs/sys/zfs_ioctl_compat.h \ + %D%/zfs/sys/zfs_vfsops_os.h \ + %D%/zfs/sys/zfs_vnops_os.h \ + %D%/zfs/sys/zfs_znode_impl.h \ + %D%/zfs/sys/zpl.h diff --git a/sys/contrib/openzfs/include/os/freebsd/linux/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/linux/Makefile.am deleted file mode 100644 index 00cff7f5dc65..000000000000 --- a/sys/contrib/openzfs/include/os/freebsd/linux/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -KERNEL_H = \ - compiler.h \ - types.h - -noinst_HEADERS = $(KERNEL_H) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/spl/Makefile.am deleted file mode 100644 index b321825cb77e..000000000000 --- a/sys/contrib/openzfs/include/os/freebsd/spl/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = acl rpc sys diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/acl/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/spl/acl/Makefile.am deleted file mode 100644 index 5c0698d02ea6..000000000000 --- a/sys/contrib/openzfs/include/os/freebsd/spl/acl/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -KERNEL_H = \ - acl_common.h - -noinst_HEADERS = $(KERNEL_H) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/rpc/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/spl/rpc/Makefile.am deleted file mode 100644 index f6faf4b188be..000000000000 --- a/sys/contrib/openzfs/include/os/freebsd/spl/rpc/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -KERNEL_H = \ - xdr.h - -noinst_HEADERS = $(KERNEL_H) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/spl/sys/Makefile.am deleted file mode 100644 index 7d5081a4c25f..000000000000 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/Makefile.am +++ /dev/null @@ -1,73 +0,0 @@ -KERNEL_H = \ - acl_impl.h \ - acl.h \ - atomic.h \ - byteorder.h \ - callb.h \ - ccompat.h \ - ccompile.h \ - cmn_err.h \ - condvar.h \ - cred.h \ - ctype.h \ - debug.h \ - dirent.h \ - disp.h \ - dkio.h \ - extdirent.h \ - fcntl.h \ - file.h \ - freebsd_rwlock.h \ - idmap.h \ - inttypes.h \ - isa_defs.h \ - kmem_cache.h \ - kmem.h \ - kstat.h \ - list_impl.h \ - list.h \ - lock.h \ - Makefile.am \ - misc.h \ - mod_os.h \ - mode.h \ - mount.h \ - mutex.h \ - param.h \ - policy.h \ - proc.h \ - processor.h \ - procfs_list.h \ - random.h \ - rwlock.h \ - sdt.h \ - sid.h \ - sig.h \ - simd_x86.h \ - simd.h \ - spl_condvar.h \ - string.h \ - sunddi.h \ - sysmacros.h \ - systeminfo.h \ - systm.h \ - taskq.h \ - thread.h \ - time.h \ - timer.h \ - trace_zfs.h \ - trace.h \ - types.h \ - types32.h \ - uio.h \ - uuid.h \ - vfs.h \ - vm.h \ - vmsystm.h \ - vnode_impl.h \ - vnode.h \ - wmsum.h \ - zmod.h \ - zone.h - -noinst_HEADERS = $(KERNEL_H) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h index 23e637983475..a46a3a18be14 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h @@ -42,9 +42,6 @@ extern "C" { #endif #define EXPORT_SYMBOL(x) -#define MODULE_AUTHOR(s) -#define MODULE_DESCRIPTION(s) -#define MODULE_LICENSE(s) #define module_param(a, b, c) #define module_param_call(a, b, c, d, e) #define module_param_named(a, b, c, d) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h index 3481507d2c33..2e4efc60544a 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h @@ -52,8 +52,6 @@ struct opensolaris_utsname { char *machine; }; -extern char hw_serial[11]; - #define task_io_account_read(n) #define task_io_account_write(n) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h index 293bd7d2b983..3a9ebbfc3bc4 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h @@ -31,11 +31,6 @@ #include <sys/sysctl.h> -#define ZFS_MODULE_DESCRIPTION(s) -#define ZFS_MODULE_AUTHOR(s) -#define ZFS_MODULE_LICENSE(s) -#define ZFS_MODULE_VERSION(s) - #define EXPORT_SYMBOL(x) #define module_param(a, b, c) #define MODULE_PARM_DESC(a, b) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/sunddi.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/sunddi.h index bfbc3e10a1d2..28d40121d92e 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/sunddi.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/sunddi.h @@ -48,7 +48,6 @@ typedef int ddi_devid_t; #define ddi_prop_free(x) (void)0 #define ddi_root_node() (void)0 -extern int ddi_strtoul(const char *, char **, int, unsigned long *); extern int ddi_strtol(const char *, char **, int, long *); extern int ddi_strtoull(const char *, char **, int, unsigned long long *); extern int ddi_strtoll(const char *, char **, int, long long *); diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/vnode.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/vnode.h index d2c900854acb..e0f79a1116b2 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/vnode.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/vnode.h @@ -136,17 +136,7 @@ vn_flush_cached_data(vnode_t *vp, boolean_t sync) #define va_blksize va_blocksize #define MAXOFFSET_T OFF_MAX -#define EXCL 0 -#define FCREAT O_CREAT -#define FTRUNC O_TRUNC -#define FEXCL O_EXCL -#ifndef FDSYNC -#define FDSYNC FFSYNC -#endif -#define FRSYNC FFSYNC -#define FSYNC FFSYNC -#define FOFFMAX 0x00 #define FIGNORECASE 0x00 /* diff --git a/sys/contrib/openzfs/include/os/freebsd/zfs/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/zfs/Makefile.am deleted file mode 100644 index 081839c48c8f..000000000000 --- a/sys/contrib/openzfs/include/os/freebsd/zfs/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = sys diff --git a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am deleted file mode 100644 index 392bb4ae3477..000000000000 --- a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -KERNEL_H = \ - freebsd_crypto.h \ - sha2.h \ - vdev_os.h \ - zfs_bootenv_os.h \ - zfs_context_os.h \ - zfs_ctldir.h \ - zfs_dir.h \ - zfs_ioctl_compat.h \ - zfs_vfsops_os.h \ - zfs_vnops_os.h \ - zfs_znode_impl.h \ - zpl.h - -noinst_HEADERS = $(KERNEL_H) diff --git a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h index 096c9e16d347..5d64c3fccd3f 100644 --- a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h +++ b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h @@ -121,25 +121,29 @@ typedef struct zfs_soft_state { #define zn_rlimit_fsize(zp, uio) \ vn_rlimit_fsize(ZTOV(zp), GET_UIO_STRUCT(uio), zfs_uio_td(uio)) +#define ZFS_ENTER_ERROR(zfsvfs, error) do { \ + ZFS_TEARDOWN_ENTER_READ((zfsvfs), FTAG); \ + if (__predict_false((zfsvfs)->z_unmounted)) { \ + ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG); \ + return (error); \ + } \ +} while (0) + /* Called on entry to each ZFS vnode and vfs operation */ -#define ZFS_ENTER(zfsvfs) \ - { \ - ZFS_TEARDOWN_ENTER_READ((zfsvfs), FTAG); \ - if (__predict_false((zfsvfs)->z_unmounted)) { \ - ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG); \ - return (EIO); \ - } \ - } +#define ZFS_ENTER(zfsvfs) ZFS_ENTER_ERROR(zfsvfs, EIO) /* Must be called before exiting the vop */ -#define ZFS_EXIT(zfsvfs) ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG) +#define ZFS_EXIT(zfsvfs) ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG) + +#define ZFS_VERIFY_ZP_ERROR(zp, error) do { \ + if (__predict_false((zp)->z_sa_hdl == NULL)) { \ + ZFS_EXIT((zp)->z_zfsvfs); \ + return (error); \ + } \ +} while (0) /* Verifies the znode is valid */ -#define ZFS_VERIFY_ZP(zp) \ - if (__predict_false((zp)->z_sa_hdl == NULL)) { \ - ZFS_EXIT((zp)->z_zfsvfs); \ - return (EIO); \ - } \ +#define ZFS_VERIFY_ZP(zp) ZFS_VERIFY_ZP_ERROR(zp, EIO) /* * Macros for dealing with dmu_buf_hold diff --git a/sys/contrib/openzfs/include/os/linux/Makefile.am b/sys/contrib/openzfs/include/os/linux/Makefile.am index 605a1fcb7506..4d6901c694c8 100644 --- a/sys/contrib/openzfs/include/os/linux/Makefile.am +++ b/sys/contrib/openzfs/include/os/linux/Makefile.am @@ -1 +1,111 @@ -SUBDIRS = kernel spl zfs +if CONFIG_KERNEL +kernel_linuxdir = $(kerneldir)/linux +kernel_linux_HEADERS = \ + %D%/kernel/linux/blkdev_compat.h \ + %D%/kernel/linux/compiler_compat.h \ + %D%/kernel/linux/dcache_compat.h \ + %D%/kernel/linux/kmap_compat.h \ + %D%/kernel/linux/mod_compat.h \ + %D%/kernel/linux/page_compat.h \ + %D%/kernel/linux/percpu_compat.h \ + %D%/kernel/linux/simd.h \ + %D%/kernel/linux/simd_aarch64.h \ + %D%/kernel/linux/simd_powerpc.h \ + %D%/kernel/linux/simd_x86.h \ + %D%/kernel/linux/utsname_compat.h \ + %D%/kernel/linux/vfs_compat.h \ + %D%/kernel/linux/xattr_compat.h + +kernel_sysdir = $(kerneldir)/sys +kernel_sys_HEADERS = \ + %D%/zfs/sys/policy.h \ + %D%/zfs/sys/sha2.h \ + %D%/zfs/sys/trace_acl.h \ + %D%/zfs/sys/trace_arc.h \ + %D%/zfs/sys/trace_common.h \ + %D%/zfs/sys/trace_dbgmsg.h \ + %D%/zfs/sys/trace_dbuf.h \ + %D%/zfs/sys/trace_dmu.h \ + %D%/zfs/sys/trace_dnode.h \ + %D%/zfs/sys/trace_multilist.h \ + %D%/zfs/sys/trace_rrwlock.h \ + %D%/zfs/sys/trace_txg.h \ + %D%/zfs/sys/trace_vdev.h \ + %D%/zfs/sys/trace_zfs.h \ + %D%/zfs/sys/trace_zil.h \ + %D%/zfs/sys/trace_zio.h \ + %D%/zfs/sys/trace_zrlock.h \ + %D%/zfs/sys/zfs_bootenv_os.h \ + %D%/zfs/sys/zfs_context_os.h \ + %D%/zfs/sys/zfs_ctldir.h \ + %D%/zfs/sys/zfs_dir.h \ + %D%/zfs/sys/zfs_vfsops_os.h \ + %D%/zfs/sys/zfs_vnops_os.h \ + %D%/zfs/sys/zfs_znode_impl.h \ + %D%/zfs/sys/zpl.h + +kernel_spl_rpcdir = $(kerneldir)/spl/rpc +kernel_spl_rpc_HEADERS = \ + %D%/spl/rpc/xdr.h + +kernel_spl_sysdir = $(kerneldir)/spl/sys +kernel_spl_sys_HEADERS = \ + %D%/spl/sys/acl.h \ + %D%/spl/sys/atomic.h \ + %D%/spl/sys/byteorder.h \ + %D%/spl/sys/callb.h \ + %D%/spl/sys/callo.h \ + %D%/spl/sys/cmn_err.h \ + %D%/spl/sys/condvar.h \ + %D%/spl/sys/cred.h \ + %D%/spl/sys/ctype.h \ + %D%/spl/sys/debug.h \ + %D%/spl/sys/disp.h \ + %D%/spl/sys/dkio.h \ + %D%/spl/sys/errno.h \ + %D%/spl/sys/fcntl.h \ + %D%/spl/sys/file.h \ + %D%/spl/sys/inttypes.h \ + %D%/spl/sys/isa_defs.h \ + %D%/spl/sys/kmem.h \ + %D%/spl/sys/kmem_cache.h \ + %D%/spl/sys/kstat.h \ + %D%/spl/sys/list.h \ + %D%/spl/sys/mod_os.h \ + %D%/spl/sys/mutex.h \ + %D%/spl/sys/param.h \ + %D%/spl/sys/proc.h \ + %D%/spl/sys/processor.h \ + %D%/spl/sys/procfs_list.h \ + %D%/spl/sys/random.h \ + %D%/spl/sys/rwlock.h \ + %D%/spl/sys/shrinker.h \ + %D%/spl/sys/sid.h \ + %D%/spl/sys/signal.h \ + %D%/spl/sys/simd.h \ + %D%/spl/sys/stat.h \ + %D%/spl/sys/string.h \ + %D%/spl/sys/sunddi.h \ + %D%/spl/sys/sysmacros.h \ + %D%/spl/sys/systeminfo.h \ + %D%/spl/sys/taskq.h \ + %D%/spl/sys/thread.h \ + %D%/spl/sys/time.h \ + %D%/spl/sys/timer.h \ + %D%/spl/sys/trace.h \ + %D%/spl/sys/trace_spl.h \ + %D%/spl/sys/trace_taskq.h \ + %D%/spl/sys/tsd.h \ + %D%/spl/sys/types.h \ + %D%/spl/sys/types32.h \ + %D%/spl/sys/uio.h \ + %D%/spl/sys/user.h \ + %D%/spl/sys/vfs.h \ + %D%/spl/sys/vmem.h \ + %D%/spl/sys/vmsystm.h \ + %D%/spl/sys/vnode.h \ + %D%/spl/sys/wait.h \ + %D%/spl/sys/wmsum.h \ + %D%/spl/sys/zmod.h \ + %D%/spl/sys/zone.h +endif diff --git a/sys/contrib/openzfs/include/os/linux/kernel/Makefile.am b/sys/contrib/openzfs/include/os/linux/kernel/Makefile.am deleted file mode 100644 index 08b2f5fc5c99..000000000000 --- a/sys/contrib/openzfs/include/os/linux/kernel/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = linux diff --git a/sys/contrib/openzfs/include/os/linux/kernel/linux/Makefile.am b/sys/contrib/openzfs/include/os/linux/kernel/linux/Makefile.am deleted file mode 100644 index 6ff0df506d9c..000000000000 --- a/sys/contrib/openzfs/include/os/linux/kernel/linux/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -KERNEL_H = \ - dcache_compat.h \ - xattr_compat.h \ - vfs_compat.h \ - blkdev_compat.h \ - utsname_compat.h \ - kmap_compat.h \ - percpu_compat.h \ - simd.h \ - simd_x86.h \ - simd_aarch64.h \ - simd_powerpc.h \ - mod_compat.h \ - page_compat.h \ - compiler_compat.h - -if CONFIG_KERNEL -if BUILD_LINUX -kerneldir = @prefix@/src/zfs-$(VERSION)/include/linux -kernel_HEADERS = $(KERNEL_H) -endif -endif diff --git a/sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h b/sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h index a90bdf7cf2d2..78603e54f54c 100644 --- a/sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h +++ b/ |