diff options
Diffstat (limited to 'lib/libspl')
98 files changed, 0 insertions, 10795 deletions
diff --git a/lib/libspl/Makefile.am b/lib/libspl/Makefile.am deleted file mode 100644 index 0fd907d3011e..000000000000 --- a/lib/libspl/Makefile.am +++ /dev/null @@ -1,56 +0,0 @@ -include $(srcdir)/%D%/include/Makefile.am - -libspl_assert_la_CFLAGS = $(AM_CFLAGS) $(LIBRARY_CFLAGS) $(LIBUNWIND_CFLAGS) -libspl_la_CFLAGS = $(libspl_assert_la_CFLAGS) -if TARGET_CPU_I386 -libspl_la_CFLAGS += $(NO_ATOMIC_ALIGNMENT) -endif - -noinst_LTLIBRARIES += libspl_assert.la libspl.la -CPPCHECKTARGETS += libspl_assert.la libspl.la - -libspl_assert_la_SOURCES = \ - %D%/assert.c \ - %D%/backtrace.c - -libspl_la_SOURCES = \ - %D%/libspl_impl.h \ - %D%/atomic.c \ - %D%/getexecname.c \ - %D%/list.c \ - %D%/mkdirp.c \ - %D%/page.c \ - %D%/strlcat.c \ - %D%/strlcpy.c \ - %D%/timestamp.c \ - %D%/tunables.c \ - %D%/include/sys/list.h \ - %D%/include/sys/list_impl.h - -if BUILD_LINUX -libspl_la_SOURCES += \ - %D%/os/linux/getexecname.c \ - %D%/os/linux/gethostid.c \ - %D%/os/linux/getmntany.c \ - %D%/os/linux/zone.c -endif - -if BUILD_FREEBSD -libspl_la_SOURCES += \ - %D%/os/freebsd/getexecname.c \ - %D%/os/freebsd/gethostid.c \ - %D%/os/freebsd/getmntany.c \ - %D%/os/freebsd/mnttab.c \ - %D%/os/freebsd/zone.c -endif - -libspl_la_LIBADD = \ - libspl_assert.la - -libspl_la_LIBADD += $(LIBATOMIC_LIBS) $(LIBCLOCK_GETTIME) - -libspl_assert_la_LIBADD = $(BACKTRACE_LIBS) $(LIBUNWIND_LIBS) - -if BUILD_FREEBSD -libspl_assert_la_LIBADD += -lpthread -endif diff --git a/lib/libspl/assert.c b/lib/libspl/assert.c deleted file mode 100644 index 54d931104814..000000000000 --- a/lib/libspl/assert.c +++ /dev/null @@ -1,116 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -/* - * Copyright (c) 2024, Rob Norris <robn@despairlabs.com> - */ - -#include <assert.h> -#include <pthread.h> -#include <sys/backtrace.h> - -#if defined(__linux__) -#include <errno.h> -#include <sys/prctl.h> -#ifdef HAVE_GETTID -#define libspl_gettid() gettid() -#else -#include <sys/syscall.h> -#define libspl_gettid() ((pid_t)syscall(__NR_gettid)) -#endif -#define libspl_getprogname() (program_invocation_short_name) -#define libspl_getthreadname(buf, len) \ - prctl(PR_GET_NAME, (unsigned long)(buf), 0, 0, 0) -#elif defined(__FreeBSD__) || defined(__APPLE__) -#if !defined(__APPLE__) -#include <pthread_np.h> -#define libspl_gettid() pthread_getthreadid_np() -#endif -#define libspl_getprogname() getprogname() -#define libspl_getthreadname(buf, len) \ - pthread_getname_np(pthread_self(), buf, len); -#endif - -#if defined(__APPLE__) -static inline uint64_t -libspl_gettid(void) -{ - uint64_t tid; - - if (pthread_threadid_np(NULL, &tid) != 0) - tid = 0; - - return (tid); -} -#endif - -static boolean_t libspl_assert_ok = B_FALSE; - -void -libspl_set_assert_ok(boolean_t val) -{ - libspl_assert_ok = val; -} - -static pthread_mutex_t assert_lock = PTHREAD_MUTEX_INITIALIZER; - -/* printf version of libspl_assert */ -void -libspl_assertf(const char *file, const char *func, int line, - const char *format, ...) -{ - pthread_mutex_lock(&assert_lock); - - va_list args; - char tname[64]; - - libspl_getthreadname(tname, sizeof (tname)); - - fprintf(stderr, "ASSERT at %s:%d:%s()\n", file, line, func); - - va_start(args, format); - vfprintf(stderr, format, args); - va_end(args); - - fprintf(stderr, "\n" - " PID: %-8u COMM: %s\n" -#if defined(__APPLE__) - " TID: %-8" PRIu64 " NAME: %s\n", -#else - " TID: %-8u NAME: %s\n", -#endif - getpid(), libspl_getprogname(), - libspl_gettid(), tname); - - libspl_backtrace(STDERR_FILENO); - -#if !__has_feature(attribute_analyzer_noreturn) && !defined(__COVERITY__) - if (libspl_assert_ok) { - pthread_mutex_unlock(&assert_lock); - return; - } -#endif - abort(); -} diff --git a/lib/libspl/atomic.c b/lib/libspl/atomic.c deleted file mode 100644 index b5cc4ab2a55f..000000000000 --- a/lib/libspl/atomic.c +++ /dev/null @@ -1,373 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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) 2009 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include <atomic.h> - -/* - * These are the void returning variants - */ -#define ATOMIC_INC(name, type) \ - void atomic_inc_##name(volatile type *target) \ - { \ - (void) __atomic_add_fetch(target, 1, __ATOMIC_SEQ_CST); \ - } - -ATOMIC_INC(8, uint8_t) -ATOMIC_INC(16, uint16_t) -ATOMIC_INC(32, uint32_t) -ATOMIC_INC(64, uint64_t) -ATOMIC_INC(uchar, uchar_t) -ATOMIC_INC(ushort, ushort_t) -ATOMIC_INC(uint, uint_t) -ATOMIC_INC(ulong, ulong_t) - - -#define ATOMIC_DEC(name, type) \ - void atomic_dec_##name(volatile type *target) \ - { \ - (void) __atomic_sub_fetch(target, 1, __ATOMIC_SEQ_CST); \ - } - -ATOMIC_DEC(8, uint8_t) -ATOMIC_DEC(16, uint16_t) -ATOMIC_DEC(32, uint32_t) -ATOMIC_DEC(64, uint64_t) -ATOMIC_DEC(uchar, uchar_t) -ATOMIC_DEC(ushort, ushort_t) -ATOMIC_DEC(uint, uint_t) -ATOMIC_DEC(ulong, ulong_t) - - -#define ATOMIC_ADD(name, type1, type2) \ - void atomic_add_##name(volatile type1 *target, type2 bits) \ - { \ - (void) __atomic_add_fetch(target, bits, __ATOMIC_SEQ_CST); \ - } - -void -atomic_add_ptr(volatile void *target, ssize_t bits) -{ - (void) __atomic_add_fetch((void **)target, bits, __ATOMIC_SEQ_CST); -} - -ATOMIC_ADD(8, uint8_t, int8_t) -ATOMIC_ADD(16, uint16_t, int16_t) -ATOMIC_ADD(32, uint32_t, int32_t) -ATOMIC_ADD(64, uint64_t, int64_t) -ATOMIC_ADD(char, uchar_t, signed char) -ATOMIC_ADD(short, ushort_t, short) -ATOMIC_ADD(int, uint_t, int) -ATOMIC_ADD(long, ulong_t, long) - - -#define ATOMIC_SUB(name, type1, type2) \ - void atomic_sub_##name(volatile type1 *target, type2 bits) \ - { \ - (void) __atomic_sub_fetch(target, bits, __ATOMIC_SEQ_CST); \ - } - -void -atomic_sub_ptr(volatile void *target, ssize_t bits) -{ - (void) __atomic_sub_fetch((void **)target, bits, __ATOMIC_SEQ_CST); -} - -ATOMIC_SUB(8, uint8_t, int8_t) -ATOMIC_SUB(16, uint16_t, int16_t) -ATOMIC_SUB(32, uint32_t, int32_t) -ATOMIC_SUB(64, uint64_t, int64_t) -ATOMIC_SUB(char, uchar_t, signed char) -ATOMIC_SUB(short, ushort_t, short) -ATOMIC_SUB(int, uint_t, int) -ATOMIC_SUB(long, ulong_t, long) - - -#define ATOMIC_OR(name, type) \ - void atomic_or_##name(volatile type *target, type bits) \ - { \ - (void) __atomic_or_fetch(target, bits, __ATOMIC_SEQ_CST); \ - } - -ATOMIC_OR(8, uint8_t) -ATOMIC_OR(16, uint16_t) -ATOMIC_OR(32, uint32_t) -ATOMIC_OR(64, uint64_t) -ATOMIC_OR(uchar, uchar_t) -ATOMIC_OR(ushort, ushort_t) -ATOMIC_OR(uint, uint_t) -ATOMIC_OR(ulong, ulong_t) - - -#define ATOMIC_AND(name, type) \ - void atomic_and_##name(volatile type *target, type bits) \ - { \ - (void) __atomic_and_fetch(target, bits, __ATOMIC_SEQ_CST); \ - } - -ATOMIC_AND(8, uint8_t) -ATOMIC_AND(16, uint16_t) -ATOMIC_AND(32, uint32_t) -ATOMIC_AND(64, uint64_t) -ATOMIC_AND(uchar, uchar_t) -ATOMIC_AND(ushort, ushort_t) -ATOMIC_AND(uint, uint_t) -ATOMIC_AND(ulong, ulong_t) - - -/* - * New value returning variants - */ - -#define ATOMIC_INC_NV(name, type) \ - type atomic_inc_##name##_nv(volatile type *target) \ - { \ - return (__atomic_add_fetch(target, 1, __ATOMIC_SEQ_CST)); \ - } - -ATOMIC_INC_NV(8, uint8_t) -ATOMIC_INC_NV(16, uint16_t) -ATOMIC_INC_NV(32, uint32_t) -ATOMIC_INC_NV(64, uint64_t) -ATOMIC_INC_NV(uchar, uchar_t) -ATOMIC_INC_NV(ushort, ushort_t) -ATOMIC_INC_NV(uint, uint_t) -ATOMIC_INC_NV(ulong, ulong_t) - - -#define ATOMIC_DEC_NV(name, type) \ - type atomic_dec_##name##_nv(volatile type *target) \ - { \ - return (__atomic_sub_fetch(target, 1, __ATOMIC_SEQ_CST)); \ - } - -ATOMIC_DEC_NV(8, uint8_t) -ATOMIC_DEC_NV(16, uint16_t) -ATOMIC_DEC_NV(32, uint32_t) -ATOMIC_DEC_NV(64, uint64_t) -ATOMIC_DEC_NV(uchar, uchar_t) -ATOMIC_DEC_NV(ushort, ushort_t) -ATOMIC_DEC_NV(uint, uint_t) -ATOMIC_DEC_NV(ulong, ulong_t) - - -#define ATOMIC_ADD_NV(name, type1, type2) \ - type1 atomic_add_##name##_nv(volatile type1 *target, type2 bits) \ - { \ - return (__atomic_add_fetch(target, bits, __ATOMIC_SEQ_CST)); \ - } - -void * -atomic_add_ptr_nv(volatile void *target, ssize_t bits) -{ - return (__atomic_add_fetch((void **)target, bits, __ATOMIC_SEQ_CST)); -} - -ATOMIC_ADD_NV(8, uint8_t, int8_t) -ATOMIC_ADD_NV(16, uint16_t, int16_t) -ATOMIC_ADD_NV(32, uint32_t, int32_t) -ATOMIC_ADD_NV(64, uint64_t, int64_t) -ATOMIC_ADD_NV(char, uchar_t, signed char) -ATOMIC_ADD_NV(short, ushort_t, short) -ATOMIC_ADD_NV(int, uint_t, int) -ATOMIC_ADD_NV(long, ulong_t, long) - - -#define ATOMIC_SUB_NV(name, type1, type2) \ - type1 atomic_sub_##name##_nv(volatile type1 *target, type2 bits) \ - { \ - return (__atomic_sub_fetch(target, bits, __ATOMIC_SEQ_CST)); \ - } - -void * -atomic_sub_ptr_nv(volatile void *target, ssize_t bits) -{ - return (__atomic_sub_fetch((void **)target, bits, __ATOMIC_SEQ_CST)); -} - -ATOMIC_SUB_NV(8, uint8_t, int8_t) -ATOMIC_SUB_NV(char, uchar_t, signed char) -ATOMIC_SUB_NV(16, uint16_t, int16_t) -ATOMIC_SUB_NV(short, ushort_t, short) -ATOMIC_SUB_NV(32, uint32_t, int32_t) -ATOMIC_SUB_NV(int, uint_t, int) -ATOMIC_SUB_NV(long, ulong_t, long) -ATOMIC_SUB_NV(64, uint64_t, int64_t) - - -#define ATOMIC_OR_NV(name, type) \ - type atomic_or_##name##_nv(volatile type *target, type bits) \ - { \ - return (__atomic_or_fetch(target, bits, __ATOMIC_SEQ_CST)); \ - } - -ATOMIC_OR_NV(8, uint8_t) -ATOMIC_OR_NV(16, uint16_t) -ATOMIC_OR_NV(32, uint32_t) -ATOMIC_OR_NV(64, uint64_t) -ATOMIC_OR_NV(uchar, uchar_t) -ATOMIC_OR_NV(ushort, ushort_t) -ATOMIC_OR_NV(uint, uint_t) -ATOMIC_OR_NV(ulong, ulong_t) - - -#define ATOMIC_AND_NV(name, type) \ - type atomic_and_##name##_nv(volatile type *target, type bits) \ - { \ - return (__atomic_and_fetch(target, bits, __ATOMIC_SEQ_CST)); \ - } - -ATOMIC_AND_NV(8, uint8_t) -ATOMIC_AND_NV(16, uint16_t) -ATOMIC_AND_NV(32, uint32_t) -ATOMIC_AND_NV(64, uint64_t) -ATOMIC_AND_NV(uchar, uchar_t) -ATOMIC_AND_NV(ushort, ushort_t) -ATOMIC_AND_NV(uint, uint_t) -ATOMIC_AND_NV(ulong, ulong_t) - - -/* - * If *tgt == exp, set *tgt = des; return old value - * - * This may not look right on the first pass (or the sixteenth), but, - * from https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html: - * > If they are not equal, the operation is a read - * > and the current contents of *ptr are written into *expected. - * And, in the converse case, exp is already *target by definition. - */ - -#define ATOMIC_CAS(name, type) \ - type atomic_cas_##name(volatile type *target, type exp, type des) \ - { \ - __atomic_compare_exchange_n(target, &exp, des, B_FALSE, \ - __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \ - return (exp); \ - } - -void * -atomic_cas_ptr(volatile void *target, void *exp, void *des) -{ - - __atomic_compare_exchange_n((void **)target, &exp, des, B_FALSE, - __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); - return (exp); -} - -ATOMIC_CAS(8, uint8_t) -ATOMIC_CAS(16, uint16_t) -ATOMIC_CAS(32, uint32_t) -ATOMIC_CAS(64, uint64_t) -ATOMIC_CAS(uchar, uchar_t) -ATOMIC_CAS(ushort, ushort_t) -ATOMIC_CAS(uint, uint_t) -ATOMIC_CAS(ulong, ulong_t) - - -/* - * Swap target and return old value - */ - -#define ATOMIC_SWAP(name, type) \ - type atomic_swap_##name(volatile type *target, type bits) \ - { \ - return (__atomic_exchange_n(target, bits, __ATOMIC_SEQ_CST)); \ - } - -ATOMIC_SWAP(8, uint8_t) -ATOMIC_SWAP(16, uint16_t) -ATOMIC_SWAP(32, uint32_t) -ATOMIC_SWAP(64, uint64_t) -ATOMIC_SWAP(uchar, uchar_t) -ATOMIC_SWAP(ushort, ushort_t) -ATOMIC_SWAP(uint, uint_t) -ATOMIC_SWAP(ulong, ulong_t) - -void * -atomic_swap_ptr(volatile void *target, void *bits) -{ - return (__atomic_exchange_n((void **)target, bits, __ATOMIC_SEQ_CST)); -} - -#ifndef _LP64 -uint64_t -atomic_load_64(volatile uint64_t *target) -{ - return (__atomic_load_n(target, __ATOMIC_RELAXED)); -} - -void -atomic_store_64(volatile uint64_t *target, uint64_t bits) -{ - return (__atomic_store_n(target, bits, __ATOMIC_RELAXED)); -} -#endif - -int -atomic_set_long_excl(volatile ulong_t *target, uint_t value) -{ - ulong_t bit = 1UL << value; - ulong_t old = __atomic_fetch_or(target, bit, __ATOMIC_SEQ_CST); - return ((old & bit) ? -1 : 0); -} - -int -atomic_clear_long_excl(volatile ulong_t *target, uint_t value) -{ - ulong_t bit = 1UL << value; - ulong_t old = __atomic_fetch_and(target, ~bit, __ATOMIC_SEQ_CST); - return ((old & bit) ? 0 : -1); -} - -void -membar_enter(void) -{ - __atomic_thread_fence(__ATOMIC_SEQ_CST); -} - -void -membar_exit(void) -{ - __atomic_thread_fence(__ATOMIC_SEQ_CST); -} - -void -membar_sync(void) -{ - __atomic_thread_fence(__ATOMIC_SEQ_CST); -} - -void -membar_producer(void) -{ - __atomic_thread_fence(__ATOMIC_RELEASE); -} - -void -membar_consumer(void) -{ - __atomic_thread_fence(__ATOMIC_ACQUIRE); -} diff --git a/lib/libspl/backtrace.c b/lib/libspl/backtrace.c deleted file mode 100644 index c4a7006a9692..000000000000 --- a/lib/libspl/backtrace.c +++ /dev/null @@ -1,303 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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) 2024, Rob Norris <robn@despairlabs.com> - * Copyright (c) 2024, Klara Inc. - */ - -#include <sys/backtrace.h> -#include <sys/types.h> -#include <sys/debug.h> -#include <unistd.h> - -/* - * Output helpers. libspl_backtrace() must not block, must be thread-safe and - * must be safe to call from a signal handler. At least, that means not having - * printf, so we end up having to call write() directly on the fd. That's - * awkward, as we always have to pass through a length, and some systems will - * complain if we don't consume the return. So we have some macros to make - * things a little more palatable. - */ -#define spl_bt_write_n(fd, s, n) \ - do { ssize_t r __maybe_unused = write(fd, s, n); } while (0) -#define spl_bt_write(fd, s) spl_bt_write_n(fd, s, sizeof (s)-1) - -#ifdef HAVE_LIBUNWIND -/* - * libunwind-gcc and libunwind-llvm both list registers using an enum, - * unw_regnum_t, however they indicate the highest numbered register for - * a given architecture in different ways. We can check which one is defined - * and mark which libunwind is in use - */ -#ifdef IS_LIBUNWIND_LLVM -#include <libunwind.h> -#define LAST_REG_INDEX _LIBUNWIND_HIGHEST_DWARF_REGISTER -#else -/* - * Need to define UNW_LOCAL_ONLY before importing libunwind.h - * if using libgcc libunwind. - */ -#define UNW_LOCAL_ONLY -#include <libunwind.h> -#define LAST_REG_INDEX UNW_TDEP_LAST_REG -#endif - - -/* - * Convert `v` to ASCII hex characters. The bottom `n` nybbles (4-bits ie one - * hex digit) will be written, up to `buflen`. The buffer will not be - * null-terminated. Returns the number of digits written. - */ -static size_t -spl_bt_u64_to_hex_str(uint64_t v, size_t n, char *buf, size_t buflen) -{ - static const char hexdigits[] = { - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' - }; - - size_t pos = 0; - boolean_t want = (n == 0); - for (int i = 15; i >= 0; i--) { - const uint64_t d = v >> (i * 4) & 0xf; - if (!want && (d != 0 || n > i)) - want = B_TRUE; - if (want) { - buf[pos++] = hexdigits[d]; - if (pos == buflen) - break; - } - } - return (pos); -} - -void -libspl_backtrace(int fd) -{ - unw_context_t uc; - unw_cursor_t cp; - unw_word_t v; - char buf[128]; - size_t n; - int err; - - /* Snapshot the current frame and state. */ - unw_getcontext(&uc); - - /* - * TODO: walk back to the frame that tripped the assertion / the place - * where the signal was recieved. - */ - - /* - * Register dump. We're going to loop over all the registers in the - * top frame, and show them, with names, in a nice three-column - * layout, which keeps us within 80 columns. - */ - spl_bt_write(fd, "Registers:\n"); - - /* Initialise a frame cursor, starting at the current frame */ - unw_init_local(&cp, &uc); - - /* - * Iterate over all registers for the architecture. We've figured - * out the highest number above, however, not all register numbers in - * this range are defined by the architecture, and not all defined - * registers will be present on every implementation of that - * architecture. Moreover, libunwind provides nice names for most, but - * not all registers, but these are hardcoded; a name being available - * does not mean that register is available. - * - * So, we have to pull this all together here. We try to get the value - * of every possible register. If we get a value for it, then the - * register must exist, and so we get its name. If libunwind has no - * name for it, we synthesize something. These cases should be rare, - * and they're usually for uninteresting or niche registers, so it - * shouldn't really matter. We can see the value, and that's the main - * thing. - */ - uint_t cols = 0; - for (uint_t regnum = 0; regnum <= LAST_REG_INDEX; regnum++) { - /* - * Get the value. Any error probably means the register - * doesn't exist, and we skip it. LLVM libunwind iterates over - * fp registers in the same list, however they have to be - * accessed using unw_get_fpreg instead. Here, we just ignore - * them. - */ -#ifdef IS_LIBUNWIND_LLVM - if (unw_is_fpreg(&cp, regnum) || - unw_get_reg(&cp, regnum, &v) < 0) - continue; -#else - if (unw_get_reg(&cp, regnum, &v) < 0) - continue; -#endif - - /* - * Register name. If GCC libunwind doesn't have a name for it, - * it will return "???". As a shortcut, we just treat '?' - * is an alternate end-of-string character. LLVM libunwind will - * return the string 'unknown register', which we detect by - * checking if the register name is longer than 5 characters. - */ -#ifdef IS_LIBUNWIND_LLVM - const char *name = unw_regname(&cp, regnum); -#else - const char *name = unw_regname(regnum); -#endif - for (n = 0; name[n] != '\0' && name[n] != '?'; n++) {} - if (n == 0 || n > 5) { - /* - * No valid name, or likely llvm_libunwind returned - * unknown_register, so make one of the form "?xx", - * where "xx" is the two-char hex of libunwind's - * register number. - */ - buf[0] = '?'; - n = spl_bt_u64_to_hex_str(regnum, 2, - &buf[1], sizeof (buf)-1) + 1; - name = buf; - } - - /* - * Two spaces of padding before each column, plus extra - * spaces to align register names shorter than three chars. - */ - spl_bt_write_n(fd, " ", 5-MIN(n, 3)); - - /* Register name and column punctuation */ - spl_bt_write_n(fd, name, n); - spl_bt_write(fd, ": 0x"); - - /* - * Convert register value (from unw_get_reg()) to hex. We're - * assuming that all registers are 64-bits wide, which is - * probably fine for any general-purpose registers on any - * machine currently in use. A more generic way would be to - * look at the width of unw_word_t, but that would also - * complicate the column code a bit. This is fine. - */ - n = spl_bt_u64_to_hex_str(v, 16, buf, sizeof (buf)); - spl_bt_write_n(fd, buf, n); - - /* Every third column, emit a newline */ - if (!(++cols % 3)) - spl_bt_write(fd, "\n"); - } - - /* If we finished before the third column, emit a newline. */ - if (cols % 3) - spl_bt_write(fd, "\n"); - - /* Now the main event, the backtrace. */ - spl_bt_write(fd, "Call trace:\n"); - - /* Reset the cursor to the top again. */ - unw_init_local(&cp, &uc); - - do { - /* - * Getting the IP should never fail; libunwind handles it - * specially, because its used a lot internally. Still, no - * point being silly about it, as the last thing we want is - * our crash handler to crash. So if it ever does fail, we'll - * show an error line, but keep going to the next frame. - */ - if (unw_get_reg(&cp, UNW_REG_IP, &v) < 0) { - spl_bt_write(fd, " [couldn't get IP register; " - "corrupt frame?]"); - continue; - } - - /* IP & punctuation */ - n = spl_bt_u64_to_hex_str(v, 16, buf, sizeof (buf)); - spl_bt_write(fd, " [0x"); - spl_bt_write_n(fd, buf, n); - spl_bt_write(fd, "] "); - - /* - * Function ("procedure") name for the current frame. `v` - * receives the offset from the named function to the IP, which - * we show as a "+offset" suffix. - * - * If libunwind can't determine the name, we just show "???" - * instead. We've already displayed the IP above; that will - * have to do. - * - * unw_get_proc_name() will return ENOMEM if the buffer is too - * small, instead truncating the name. So we treat that as a - * success and use whatever is in the buffer. - */ - err = unw_get_proc_name(&cp, buf, sizeof (buf), &v); - if (err == 0 || err == -UNW_ENOMEM) { - for (n = 0; n < sizeof (buf) && buf[n] != '\0'; n++) {} - spl_bt_write_n(fd, buf, n); - - /* Offset from proc name */ - spl_bt_write(fd, "+0x"); - n = spl_bt_u64_to_hex_str(v, 2, buf, sizeof (buf)); - spl_bt_write_n(fd, buf, n); - } else - spl_bt_write(fd, "???"); - -#ifdef HAVE_LIBUNWIND_ELF - /* - * Newer libunwind has unw_get_elf_filename(), which gets - * the name of the ELF object that the frame was executing in. - * Like `unw_get_proc_name()`, `v` recieves the offset within - * the file, and UNW_ENOMEM indicates that a truncate filename - * was left in the buffer. - */ - err = unw_get_elf_filename(&cp, buf, sizeof (buf), &v); - if (err == 0 || err == -UNW_ENOMEM) { - for (n = 0; n < sizeof (buf) && buf[n] != '\0'; n++) {} - spl_bt_write(fd, " (in "); - spl_bt_write_n(fd, buf, n); - - /* Offset within file */ - spl_bt_write(fd, " +0x"); - n = spl_bt_u64_to_hex_str(v, 2, buf, sizeof (buf)); - spl_bt_write_n(fd, buf, n); - spl_bt_write(fd, ")"); - } -#endif - spl_bt_write(fd, "\n"); - } while (unw_step(&cp) > 0); -} -#elif defined(HAVE_BACKTRACE) -#include <execinfo.h> - -void -libspl_backtrace(int fd) -{ - void *btptrs[64]; - size_t nptrs = backtrace(btptrs, 64); - spl_bt_write(fd, "Call trace:\n"); - backtrace_symbols_fd(btptrs, nptrs, fd); -} -#else -void -libspl_backtrace(int fd __maybe_unused) -{ -} -#endif diff --git a/lib/libspl/getexecname.c b/lib/libspl/getexecname.c deleted file mode 100644 index 56ba5aa86058..000000000000 --- a/lib/libspl/getexecname.c +++ /dev/null @@ -1,60 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#include <limits.h> -#include <pthread.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include "libspl_impl.h" - - -const char * -getexecname(void) -{ - static char execname[PATH_MAX + 1] = ""; - static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; - - char *ptr = execname; - ssize_t rc; - - (void) pthread_mutex_lock(&mtx); - - if (strlen(execname) == 0) { - rc = getexecname_impl(execname); - if (rc == -1) { - execname[0] = '\0'; - ptr = NULL; - } else { - execname[rc] = '\0'; - } - } - - (void) pthread_mutex_unlock(&mtx); - return (ptr); -} diff --git a/lib/libspl/include/Makefile.am b/lib/libspl/include/Makefile.am deleted file mode 100644 index 21f0c70db9e7..000000000000 --- a/lib/libspl/include/Makefile.am +++ /dev/null @@ -1,108 +0,0 @@ -libspldir = $(includedir)/libspl -libspl_HEADERS = \ - %D%/assert.h \ - %D%/atomic.h \ - %D%/libgen.h \ - %D%/libshare.h \ - %D%/statcommon.h \ - %D%/stdlib.h \ - %D%/string.h \ - %D%/umem.h \ - %D%/unistd.h \ - %D%/zone.h - -if BUILD_FREEBSD -libspl_HEADERS += \ - %D%/os/freebsd/fcntl.h -endif - - -libspl_rpcdir = $(libspldir)/rpc -libspl_rpc_HEADERS = \ - %D%/rpc/xdr.h - - -libspl_sysdir = $(libspldir)/sys -libspl_sys_HEADERS = \ - %D%/sys/abd_os.h \ - %D%/sys/abd_impl_os.h \ - %D%/sys/acl.h \ - %D%/sys/acl_impl.h \ - %D%/sys/asm_linkage.h \ - %D%/sys/backtrace.h \ - %D%/sys/callb.h \ - %D%/sys/cmn_err.h \ - %D%/sys/cred.h \ - %D%/sys/debug.h \ - %D%/sys/dkio.h \ - %D%/sys/dklabel.h \ - %D%/sys/feature_tests.h \ - %D%/sys/inttypes.h \ - %D%/sys/isa_defs.h \ - %D%/sys/kmem.h \ - %D%/sys/kstat.h \ - %D%/sys/list.h \ - %D%/sys/list_impl.h \ - %D%/sys/mhd.h \ - %D%/sys/mkdev.h \ - %D%/sys/mod.h \ - %D%/sys/policy.h \ - %D%/sys/poll.h \ - %D%/sys/priv.h \ - %D%/sys/processor.h \ - %D%/sys/simd.h \ - %D%/sys/stack.h \ - %D%/sys/stdtypes.h \ - %D%/sys/string.h \ - %D%/sys/sunddi.h \ - %D%/sys/systeminfo.h \ - %D%/sys/time.h \ - %D%/sys/trace_spl.h \ - %D%/sys/trace_zfs.h \ - %D%/sys/tunables.h \ - %D%/sys/types.h \ - %D%/sys/types32.h \ - %D%/sys/uio.h \ - %D%/sys/vnode.h \ - %D%/sys/wmsum.h \ - %D%/sys/zone.h - -libspl_ia32dir = $(libspldir)/sys/ia32 - -if BUILD_LINUX -libspl_sys_HEADERS += \ - %D%/os/linux/sys/byteorder.h \ - %D%/os/linux/sys/errno.h \ - %D%/os/linux/sys/mnttab.h \ - %D%/os/linux/sys/mount.h \ - %D%/os/linux/sys/param.h \ - %D%/os/linux/sys/stat.h \ - %D%/os/linux/sys/sysmacros.h \ - %D%/os/linux/sys/zfs_context_os.h - -libspl_ia32_HEADERS = \ - %D%/os/linux/sys/ia32/asm_linkage.h -endif - -if BUILD_FREEBSD -libspl_sys_HEADERS += \ - %D%/os/freebsd/sys/byteorder.h \ - %D%/os/freebsd/sys/fcntl.h \ - %D%/os/freebsd/sys/file.h \ - %D%/os/freebsd/sys/mnttab.h \ - %D%/os/freebsd/sys/mount.h \ - %D%/os/freebsd/sys/param.h \ - %D%/os/freebsd/sys/stat.h \ - %D%/os/freebsd/sys/sysmacros.h \ - %D%/os/freebsd/sys/vfs.h \ - %D%/os/freebsd/sys/zfs_context_os.h - -libspl_ia32_HEADERS = \ - %D%/os/freebsd/sys/ia32/asm_linkage.h -endif - - -libspl_sys_dktpdir = $(libspl_sysdir)/dktp -libspl_sys_dktp_HEADERS = \ - %D%/sys/dktp/fdisk.h - diff --git a/lib/libspl/include/assert.h b/lib/libspl/include/assert.h deleted file mode 100644 index e704a899e748..000000000000 --- a/lib/libspl/include/assert.h +++ /dev/null @@ -1,275 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include_next <assert.h> - -#ifndef _LIBSPL_ASSERT_H -#define _LIBSPL_ASSERT_H - -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <sys/types.h> - -/* Workaround for non-Clang compilers */ -#ifndef __has_feature -#define __has_feature(x) 0 -#endif - -/* We need to workaround libspl_set_assert_ok() that we have for zdb */ -#if __has_feature(attribute_analyzer_noreturn) || defined(__COVERITY__) -#define NORETURN __attribute__((__noreturn__)) -#else -#define NORETURN -#endif - -/* Set to non-zero to avoid abort()ing on an assertion failure */ -extern void libspl_set_assert_ok(boolean_t val); - -/* printf version of libspl_assert */ -extern void libspl_assertf(const char *file, const char *func, int line, - const char *format, ...) NORETURN __attribute__((format(printf, 4, 5))); - -static inline int -libspl_assert(const char *buf, const char *file, const char *func, int line) -{ - libspl_assertf(file, func, line, "%s", buf); - return (0); -} - -#ifdef verify -#undef verify -#endif - -#define PANIC(fmt, a...) \ - libspl_assertf(__FILE__, __FUNCTION__, __LINE__, fmt, ## a) - -#define VERIFY(cond) \ - (void) ((!(cond)) && \ - libspl_assert(#cond, __FILE__, __FUNCTION__, __LINE__)) - -#define VERIFYF(cond, STR, ...) \ -do { \ - if (!(cond)) \ - libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "%s " STR, #cond, \ - __VA_ARGS__); \ -} while (0) - -#define verify(cond) \ - (void) ((!(cond)) && \ - libspl_assert(#cond, __FILE__, __FUNCTION__, __LINE__)) - -#define VERIFY3B(LEFT, OP, RIGHT) \ -do { \ - const boolean_t __left = (boolean_t)!!(LEFT); \ - const boolean_t __right = (boolean_t)!!(RIGHT); \ - if (!(__left OP __right)) \ - libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3B(%s, %s, %s) failed " \ - "(%d %s %d)", #LEFT, #OP, #RIGHT, \ - __left, #OP, __right); \ -} while (0) - -#define VERIFY3S(LEFT, OP, RIGHT) \ -do { \ - const int64_t __left = (int64_t)(LEFT); \ - const int64_t __right = (int64_t)(RIGHT); \ - if (!(__left OP __right)) \ - libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3S(%s, %s, %s) failed " \ - "(%lld %s 0x%lld)", #LEFT, #OP, #RIGHT, \ - (longlong_t)__left, #OP, (longlong_t)__right); \ -} while (0) - -#define VERIFY3U(LEFT, OP, RIGHT) \ -do { \ - const uint64_t __left = (uint64_t)(LEFT); \ - const uint64_t __right = (uint64_t)(RIGHT); \ - if (!(__left OP __right)) \ - libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3U(%s, %s, %s) failed " \ - "(%llu %s %llu)", #LEFT, #OP, #RIGHT, \ - (u_longlong_t)__left, #OP, (u_longlong_t)__right); \ -} while (0) - -#define VERIFY3P(LEFT, OP, RIGHT) \ -do { \ - const uintptr_t __left = (uintptr_t)(LEFT); \ - const uintptr_t __right = (uintptr_t)(RIGHT); \ - if (!(__left OP __right)) \ - libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3P(%s, %s, %s) failed " \ - "(%p %s %p)", #LEFT, #OP, #RIGHT, \ - (void *)__left, #OP, (void *)__right); \ -} while (0) - -#define VERIFY0(LEFT) \ -do { \ - const uint64_t __left = (uint64_t)(LEFT); \ - if (!(__left == 0)) \ - libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY0(%s) failed (%lld)", #LEFT, \ - (u_longlong_t)__left); \ -} while (0) - -#define VERIFY0P(LEFT) \ -do { \ - const uintptr_t __left = (uintptr_t)(LEFT); \ - if (!(__left == 0)) \ - libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY0P(%s) failed (%p)", #LEFT, \ - (void *)__left); \ -} while (0) - -/* - * This is just here because cstyle gets upset about #LEFT - * on a newline. - */ - -/* BEGIN CSTYLED */ -#define VERIFY3BF(LEFT, OP, RIGHT, STR, ...) \ -do { \ - const boolean_t __left = (boolean_t)!!(LEFT); \ - const boolean_t __right = (boolean_t)!!(RIGHT); \ - if (!(__left OP __right)) \ - libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3B(%s, %s, %s) failed " \ - "(%d %s %d) " STR, #LEFT, #OP, #RIGHT, \ - __left, #OP, __right, \ - __VA_ARGS__); \ -} while (0) - -#define VERIFY3SF(LEFT, OP, RIGHT, STR, ...) \ -do { \ - const int64_t __left = (int64_t)(LEFT); \ - const int64_t __right = (int64_t)(RIGHT); \ - if (!(__left OP __right)) \ - libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3S(%s, %s, %s) failed " \ - "(%lld %s %lld) " STR, #LEFT, #OP, #RIGHT, \ - (longlong_t)__left, #OP, (longlong_t)__right, \ - __VA_ARGS__); \ -} while (0) - -#define VERIFY3UF(LEFT, OP, RIGHT, STR, ...) \ -do { \ - const uint64_t __left = (uint64_t)(LEFT); \ - const uint64_t __right = (uint64_t)(RIGHT); \ - if (!(__left OP __right)) \ - libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3U(%s, %s, %s) failed " \ - "(%llu %s %llu) " STR, #LEFT, #OP, #RIGHT, \ - (u_longlong_t)__left, #OP, (u_longlong_t)__right, \ - __VA_ARGS__); \ -} while (0) - -#define VERIFY3PF(LEFT, OP, RIGHT, STR, ...) \ -do { \ - const uintptr_t __left = (uintptr_t)(LEFT); \ - const uintptr_t __right = (uintptr_t)(RIGHT); \ - if (!(__left OP __right)) \ - libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3P(%s, %s, %s) failed " \ - "(%p %s %p) " STR, #LEFT, #OP, #RIGHT, \ - (void *)__left, #OP, (void *)__right, \ - __VA_ARGS__); \ -} while (0) -/* END CSTYLED */ - -#define VERIFY0F(LEFT, STR, ...) \ -do { \ - const int64_t __left = (int64_t)(LEFT); \ - if (!(__left == 0)) \ - libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY0(%s) failed (%lld) " STR, #LEFT, \ - (longlong_t)__left, __VA_ARGS__); \ -} while (0) - -#define VERIFY0PF(LEFT, STR, ...) \ -do { \ - const uintptr_t __left = (uintptr_t)(LEFT); \ - if (!(__left == 0)) \ - libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY0P(%s) failed (%p) " STR, #LEFT, \ - (void *)__left, __VA_ARGS__); \ -} while (0) - -#ifdef assert -#undef assert -#endif - -#ifdef NDEBUG -#define ASSERT3B(x, y, z) \ - ((void) sizeof ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z))) -#define ASSERT3S(x, y, z) \ - ((void) sizeof ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z))) -#define ASSERT3U(x, y, z) \ - ((void) sizeof ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z))) -#define ASSERT3P(x, y, z) \ - ((void) sizeof ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z))) -#define ASSERT0(x) ((void) sizeof ((uintptr_t)(x))) -#define ASSERT0P(x) ((void) sizeof ((uintptr_t)(x))) -#define ASSERT3BF(x, y, z, str, ...) ASSERT3B(x, y, z) -#define ASSERT3SF(x, y, z, str, ...) ASSERT3S(x, y, z) -#define ASSERT3UF(x, y, z, str, ...) ASSERT3U(x, y, z) -#define ASSERT3PF(x, y, z, str, ...) ASSERT3P(x, y, z) -#define ASSERT0P(x) ((void) sizeof ((uintptr_t)(x))) -#define ASSERT0PF(x, str, ...) ASSERT0P(x) -#define ASSERT0F(x, str, ...) ASSERT0(x) -#define ASSERT(x) ((void) sizeof ((uintptr_t)(x))) -#define ASSERTF(x, str, ...) ASSERT(x) -#define assert(x) ((void) sizeof ((uintptr_t)(x))) -#define IMPLY(A, B) \ - ((void) sizeof ((uintptr_t)(A)), (void) sizeof ((uintptr_t)(B))) -#define EQUIV(A, B) \ - ((void) sizeof ((uintptr_t)(A)), (void) sizeof ((uintptr_t)(B))) -#else -#define ASSERT3B VERIFY3B -#define ASSERT3S VERIFY3S -#define ASSERT3U VERIFY3U -#define ASSERT3P VERIFY3P -#define ASSERT0 VERIFY0 -#define ASSERT0P VERIFY0P -#define ASSERT3BF VERIFY3BF -#define ASSERT3SF VERIFY3SF -#define ASSERT3UF VERIFY3UF -#define ASSERT3PF VERIFY3PF -#define ASSERT0PF VERIFY0PF -#define ASSERT0F VERIFY0F -#define ASSERT VERIFY -#define ASSERTF VERIFYF -#define assert VERIFY -#define IMPLY(A, B) \ - ((void)(((!(A)) || (B)) || \ - libspl_assert("(" #A ") implies (" #B ")", \ - __FILE__, __FUNCTION__, __LINE__))) -#define EQUIV(A, B) VERIFY3B(A, ==, B) - -#endif /* NDEBUG */ - -#endif /* _LIBSPL_ASSERT_H */ diff --git a/lib/libspl/include/atomic.h b/lib/libspl/include/atomic.h deleted file mode 100644 index cc6f2e2ce988..000000000000 --- a/lib/libspl/include/atomic.h +++ /dev/null @@ -1,347 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_ATOMIC_H -#define _SYS_ATOMIC_H - -#include <sys/types.h> -#include <sys/inttypes.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(__STDC__) -/* - * Increment target. - */ -extern void atomic_inc_8(volatile uint8_t *); -extern void atomic_inc_uchar(volatile uchar_t *); -extern void atomic_inc_16(volatile uint16_t *); -extern void atomic_inc_ushort(volatile ushort_t *); -extern void atomic_inc_32(volatile uint32_t *); -extern void atomic_inc_uint(volatile uint_t *); -extern void atomic_inc_ulong(volatile ulong_t *); -#if defined(_INT64_TYPE) -extern void atomic_inc_64(volatile uint64_t *); -#endif - -/* - * Decrement target - */ -extern void atomic_dec_8(volatile uint8_t *); -extern void atomic_dec_uchar(volatile uchar_t *); -extern void atomic_dec_16(volatile uint16_t *); -extern void atomic_dec_ushort(volatile ushort_t *); -extern void atomic_dec_32(volatile uint32_t *); -extern void atomic_dec_uint(volatile uint_t *); -extern void atomic_dec_ulong(volatile ulong_t *); -#if defined(_INT64_TYPE) -extern void atomic_dec_64(volatile uint64_t *); -#endif - -/* - * Add delta to target - */ -extern void atomic_add_8(volatile uint8_t *, int8_t); -extern void atomic_add_char(volatile uchar_t *, signed char); -extern void atomic_add_16(volatile uint16_t *, int16_t); -extern void atomic_add_short(volatile ushort_t *, short); -extern void atomic_add_32(volatile uint32_t *, int32_t); -extern void atomic_add_int(volatile uint_t *, int); -extern void atomic_add_ptr(volatile void *, ssize_t); -extern void atomic_add_long(volatile ulong_t *, long); -#if defined(_INT64_TYPE) -extern void atomic_add_64(volatile uint64_t *, int64_t); -#endif - -/* - * Subtract delta from target - */ -extern void atomic_sub_8(volatile uint8_t *, int8_t); -extern void atomic_sub_char(volatile uchar_t *, signed char); -extern void atomic_sub_16(volatile uint16_t *, int16_t); -extern void atomic_sub_short(volatile ushort_t *, short); -extern void atomic_sub_32(volatile uint32_t *, int32_t); -extern void atomic_sub_int(volatile uint_t *, int); -extern void atomic_sub_ptr(volatile void *, ssize_t); -extern void atomic_sub_long(volatile ulong_t *, long); -#if defined(_INT64_TYPE) -extern void atomic_sub_64(volatile uint64_t *, int64_t); -#endif - -/* - * logical OR bits with target - */ -extern void atomic_or_8(volatile uint8_t *, uint8_t); -extern void atomic_or_uchar(volatile uchar_t *, uchar_t); -extern void atomic_or_16(volatile uint16_t *, uint16_t); -extern void atomic_or_ushort(volatile ushort_t *, ushort_t); -extern void atomic_or_32(volatile uint32_t *, uint32_t); -extern void atomic_or_uint(volatile uint_t *, uint_t); -extern void atomic_or_ulong(volatile ulong_t *, ulong_t); -#if defined(_INT64_TYPE) -extern void atomic_or_64(volatile uint64_t *, uint64_t); -#endif - -/* - * logical AND bits with target - */ -extern void atomic_and_8(volatile uint8_t *, uint8_t); -extern void atomic_and_uchar(volatile uchar_t *, uchar_t); -extern void atomic_and_16(volatile uint16_t *, uint16_t); -extern void atomic_and_ushort(volatile ushort_t *, ushort_t); -extern void atomic_and_32(volatile uint32_t *, uint32_t); -extern void atomic_and_uint(volatile uint_t *, uint_t); -extern void atomic_and_ulong(volatile ulong_t *, ulong_t); -#if defined(_INT64_TYPE) -extern void atomic_and_64(volatile uint64_t *, uint64_t); -#endif - -/* - * As above, but return the new value. Note that these _nv() variants are - * substantially more expensive on some platforms than the no-return-value - * versions above, so don't use them unless you really need to know the - * new value *atomically* (e.g. when decrementing a reference count and - * checking whether it went to zero). - */ - -/* - * Increment target and return new value. - */ -extern uint8_t atomic_inc_8_nv(volatile uint8_t *); -extern uchar_t atomic_inc_uchar_nv(volatile uchar_t *); -extern uint16_t atomic_inc_16_nv(volatile uint16_t *); -extern ushort_t atomic_inc_ushort_nv(volatile ushort_t *); -extern uint32_t atomic_inc_32_nv(volatile uint32_t *); -extern uint_t atomic_inc_uint_nv(volatile uint_t *); -extern ulong_t atomic_inc_ulong_nv(volatile ulong_t *); -#if defined(_INT64_TYPE) -extern uint64_t atomic_inc_64_nv(volatile uint64_t *); -#endif - -/* - * Decrement target and return new value. - */ -extern uint8_t atomic_dec_8_nv(volatile uint8_t *); -extern uchar_t atomic_dec_uchar_nv(volatile uchar_t *); -extern uint16_t atomic_dec_16_nv(volatile uint16_t *); -extern ushort_t atomic_dec_ushort_nv(volatile ushort_t *); -extern uint32_t atomic_dec_32_nv(volatile uint32_t *); -extern uint_t atomic_dec_uint_nv(volatile uint_t *); -extern ulong_t atomic_dec_ulong_nv(volatile ulong_t *); -#if defined(_INT64_TYPE) -extern uint64_t atomic_dec_64_nv(volatile uint64_t *); -#endif - -/* - * Add delta to target - */ -extern uint8_t atomic_add_8_nv(volatile uint8_t *, int8_t); -extern uchar_t atomic_add_char_nv(volatile uchar_t *, signed char); -extern uint16_t atomic_add_16_nv(volatile uint16_t *, int16_t); -extern ushort_t atomic_add_short_nv(volatile ushort_t *, short); -extern uint32_t atomic_add_32_nv(volatile uint32_t *, int32_t); -extern uint_t atomic_add_int_nv(volatile uint_t *, int); -extern void *atomic_add_ptr_nv(volatile void *, ssize_t); -extern ulong_t atomic_add_long_nv(volatile ulong_t *, long); -#if defined(_INT64_TYPE) -extern uint64_t atomic_add_64_nv(volatile uint64_t *, int64_t); -#endif - -/* - * Subtract delta from target - */ -extern uint8_t atomic_sub_8_nv(volatile uint8_t *, int8_t); -extern uchar_t atomic_sub_char_nv(volatile uchar_t *, signed char); -extern uint16_t atomic_sub_16_nv(volatile uint16_t *, int16_t); -extern ushort_t atomic_sub_short_nv(volatile ushort_t *, short); -extern uint32_t atomic_sub_32_nv(volatile uint32_t *, int32_t); -extern uint_t atomic_sub_int_nv(volatile uint_t *, int); -extern void *atomic_sub_ptr_nv(volatile void *, ssize_t); -extern ulong_t atomic_sub_long_nv(volatile ulong_t *, long); -#if defined(_INT64_TYPE) -extern uint64_t atomic_sub_64_nv(volatile uint64_t *, int64_t); -#endif - -/* - * logical OR bits with target and return new value. - */ -extern uint8_t atomic_or_8_nv(volatile uint8_t *, uint8_t); -extern uchar_t atomic_or_uchar_nv(volatile uchar_t *, uchar_t); -extern uint16_t atomic_or_16_nv(volatile uint16_t *, uint16_t); -extern ushort_t atomic_or_ushort_nv(volatile ushort_t *, ushort_t); -extern uint32_t atomic_or_32_nv(volatile uint32_t *, uint32_t); -extern uint_t atomic_or_uint_nv(volatile uint_t *, uint_t); -extern ulong_t atomic_or_ulong_nv(volatile ulong_t *, ulong_t); -#if defined(_INT64_TYPE) -extern uint64_t atomic_or_64_nv(volatile uint64_t *, uint64_t); -#endif - -/* - * logical AND bits with target and return new value. - */ -extern uint8_t atomic_and_8_nv(volatile uint8_t *, uint8_t); -extern uchar_t atomic_and_uchar_nv(volatile uchar_t *, uchar_t); -extern uint16_t atomic_and_16_nv(volatile uint16_t *, uint16_t); -extern ushort_t atomic_and_ushort_nv(volatile ushort_t *, ushort_t); -extern uint32_t atomic_and_32_nv(volatile uint32_t *, uint32_t); -extern uint_t atomic_and_uint_nv(volatile uint_t *, uint_t); -extern ulong_t atomic_and_ulong_nv(volatile ulong_t *, ulong_t); -#if defined(_INT64_TYPE) -extern uint64_t atomic_and_64_nv(volatile uint64_t *, uint64_t); -#endif - -/* - * If *arg1 == arg2, set *arg1 = arg3; return old value - */ -extern uint8_t atomic_cas_8(volatile uint8_t *, uint8_t, uint8_t); -extern uchar_t atomic_cas_uchar(volatile uchar_t *, uchar_t, uchar_t); -extern uint16_t atomic_cas_16(volatile uint16_t *, uint16_t, uint16_t); -extern ushort_t atomic_cas_ushort(volatile ushort_t *, ushort_t, ushort_t); -extern uint32_t atomic_cas_32(volatile uint32_t *, uint32_t, uint32_t); -extern uint_t atomic_cas_uint(volatile uint_t *, uint_t, uint_t); -extern void *atomic_cas_ptr(volatile void *, void *, void *); -extern ulong_t atomic_cas_ulong(volatile ulong_t *, ulong_t, ulong_t); -#if defined(_INT64_TYPE) -extern uint64_t atomic_cas_64(volatile uint64_t *, uint64_t, uint64_t); -#endif - -/* - * Swap target and return old value - */ -extern uint8_t atomic_swap_8(volatile uint8_t *, uint8_t); -extern uchar_t atomic_swap_uchar(volatile uchar_t *, uchar_t); -extern uint16_t atomic_swap_16(volatile uint16_t *, uint16_t); -extern ushort_t atomic_swap_ushort(volatile ushort_t *, ushort_t); -extern uint32_t atomic_swap_32(volatile uint32_t *, uint32_t); -extern uint_t atomic_swap_uint(volatile uint_t *, uint_t); -extern void *atomic_swap_ptr(volatile void *, void *); -extern ulong_t atomic_swap_ulong(volatile ulong_t *, ulong_t); -#if defined(_INT64_TYPE) -extern uint64_t atomic_swap_64(volatile uint64_t *, uint64_t); -#endif - -/* - * Atomically read variable. - */ -#define atomic_load_char(p) (*(volatile uchar_t *)(p)) -#define atomic_load_short(p) (*(volatile ushort_t *)(p)) -#define atomic_load_int(p) (*(volatile uint_t *)(p)) -#define atomic_load_long(p) (*(volatile ulong_t *)(p)) -#define atomic_load_ptr(p) (*(volatile __typeof(*p) *)(p)) -#define atomic_load_8(p) (*(volatile uint8_t *)(p)) -#define atomic_load_16(p) (*(volatile uint16_t *)(p)) -#define atomic_load_32(p) (*(volatile uint32_t *)(p)) -#ifdef _LP64 -#define atomic_load_64(p) (*(volatile uint64_t *)(p)) -#elif defined(_INT64_TYPE) -extern uint64_t atomic_load_64(volatile uint64_t *); -#endif - -/* - * Atomically write variable. - */ -#define atomic_store_char(p, v) \ - (*(volatile uchar_t *)(p) = (uchar_t)(v)) -#define atomic_store_short(p, v) \ - (*(volatile ushort_t *)(p) = (ushort_t)(v)) -#define atomic_store_int(p, v) \ - (*(volatile uint_t *)(p) = (uint_t)(v)) -#define atomic_store_long(p, v) \ - (*(volatile ulong_t *)(p) = (ulong_t)(v)) -#define atomic_store_ptr(p, v) \ - (*(volatile __typeof(*p) *)(p) = (v)) -#define atomic_store_8(p, v) \ - (*(volatile uint8_t *)(p) = (uint8_t)(v)) -#define atomic_store_16(p, v) \ - (*(volatile uint16_t *)(p) = (uint16_t)(v)) -#define atomic_store_32(p, v) \ - (*(volatile uint32_t *)(p) = (uint32_t)(v)) -#ifdef _LP64 -#define atomic_store_64(p, v) \ - (*(volatile uint64_t *)(p) = (uint64_t)(v)) -#elif defined(_INT64_TYPE) -extern void atomic_store_64(volatile uint64_t *, uint64_t); -#endif - -/* - * Perform an exclusive atomic bit set/clear on a target. - * Returns 0 if bit was successfully set/cleared, or -1 - * if the bit was already set/cleared. - */ -extern int atomic_set_long_excl(volatile ulong_t *, uint_t); -extern int atomic_clear_long_excl(volatile ulong_t *, uint_t); - -/* - * Generic memory barrier used during lock entry, placed after the - * memory operation that acquires the lock to guarantee that the lock - * protects its data. No stores from after the memory barrier will - * reach visibility, and no loads from after the barrier will be - * resolved, before the lock acquisition reaches global visibility. - */ -extern void membar_enter(void); - -/* - * Generic memory barrier used during lock exit, placed before the - * memory operation that releases the lock to guarantee that the lock - * protects its data. All loads and stores issued before the barrier - * will be resolved before the subsequent lock update reaches visibility. - */ -extern void membar_exit(void); - -/* - * Make all stores and loads emitted prior to the the barrier complete before - * crossing it, while also making sure stores and loads emitted after the - * barrier only start being executed after crossing it. - */ -extern void membar_sync(void); - -/* - * Arrange that all stores issued before this point in the code reach - * global visibility before any stores that follow; useful in producer - * modules that update a data item, then set a flag that it is available. - * The memory barrier guarantees that the available flag is not visible - * earlier than the updated data, i.e. it imposes store ordering. - */ -extern void membar_producer(void); - -/* - * Arrange that all loads issued before this point in the code are - * completed before any subsequent loads; useful in consumer modules - * that check to see if data is available and read the data. - * The memory barrier guarantees that the data is not sampled until - * after the available flag has been seen, i.e. it imposes load ordering. - */ -extern void membar_consumer(void); -#endif /* __STDC__ */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_ATOMIC_H */ diff --git a/lib/libspl/include/libgen.h b/lib/libspl/include/libgen.h deleted file mode 100644 index 18d3e1d891b8..000000000000 --- a/lib/libspl/include/libgen.h +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_LIBGEN_H -#define _LIBSPL_LIBGEN_H - -#include <sys/types.h> -#include_next <libgen.h> - -extern int mkdirp(const char *, mode_t); - -#endif /* _LIBSPL_LIBGEN_H */ diff --git a/lib/libspl/include/libshare.h b/lib/libspl/include/libshare.h deleted file mode 100644 index bfa78bffd461..000000000000 --- a/lib/libspl/include/libshare.h +++ /dev/null @@ -1,97 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * Copyright (c) 2019, 2022 by Delphix. All rights reserved. - */ -#ifndef _LIBSPL_LIBSHARE_H -#define _LIBSPL_LIBSHARE_H extern __attribute__((visibility("default"))) - -#include <sys/types.h> - -/* - * defined error values - */ -#define SA_OK 0 -#define SA_SYSTEM_ERR 7 /* system error, use errno */ -#define SA_SYNTAX_ERR 8 /* syntax error on command line */ -#define SA_NO_MEMORY 2 /* no memory for data structures */ -#define SA_INVALID_PROTOCOL 13 /* specified protocol not valid */ -#define SA_NOT_SUPPORTED 21 /* operation not supported for proto */ - -/* The following errors are never returned by libshare */ -#define SA_NO_SUCH_PATH 1 /* provided path doesn't exist */ -#define SA_DUPLICATE_NAME 3 /* object name is already in use */ -#define SA_BAD_PATH 4 /* not a full path */ -#define SA_NO_SUCH_GROUP 5 /* group is not defined */ -#define SA_CONFIG_ERR 6 /* system configuration error */ -#define SA_NO_PERMISSION 9 /* no permission for operation */ -#define SA_BUSY 10 /* resource is busy */ -#define SA_NO_SUCH_PROP 11 /* property doesn't exist */ -#define SA_INVALID_NAME 12 /* name of object is invalid */ -#define SA_NOT_ALLOWED 14 /* operation not allowed */ -#define SA_BAD_VALUE 15 /* bad value for property */ -#define SA_INVALID_SECURITY 16 /* invalid security type */ -#define SA_NO_SUCH_SECURITY 17 /* security set not found */ -#define SA_VALUE_CONFLICT 18 /* property value conflict */ -#define SA_NOT_IMPLEMENTED 19 /* plugin interface not implemented */ -#define SA_INVALID_PATH 20 /* path is sub-dir of existing share */ -#define SA_PROP_SHARE_ONLY 22 /* property valid on share only */ -#define SA_NOT_SHARED 23 /* path is not shared */ -#define SA_NO_SUCH_RESOURCE 24 /* resource not found */ -#define SA_RESOURCE_REQUIRED 25 /* resource name is required */ -#define SA_MULTIPLE_ERROR 26 /* multiple protocols reported error */ -#define SA_PATH_IS_SUBDIR 27 /* check_path found path is subdir */ -#define SA_PATH_IS_PARENTDIR 28 /* check_path found path is parent */ -#define SA_NO_SECTION 29 /* protocol requires section info */ -#define SA_NO_SUCH_SECTION 30 /* no section found */ -#define SA_NO_PROPERTIES 31 /* no properties found */ -#define SA_PASSWORD_ENC 32 /* passwords must be encrypted */ -#define SA_SHARE_EXISTS 33 /* path or file is already shared */ - -/* initialization */ -_LIBSPL_LIBSHARE_H const char *sa_errorstr(int); - -/* available protocols */ -enum sa_protocol { - SA_PROTOCOL_NFS, - SA_PROTOCOL_SMB, /* ABI: add before _COUNT */ - SA_PROTOCOL_COUNT, -}; - -/* lower-case */ -_LIBSPL_LIBSHARE_H const char *const sa_protocol_names[SA_PROTOCOL_COUNT]; - -/* share control */ -_LIBSPL_LIBSHARE_H int sa_enable_share(const char *, const char *, const char *, - enum sa_protocol); -_LIBSPL_LIBSHARE_H int sa_disable_share(const char *, enum sa_protocol); -_LIBSPL_LIBSHARE_H boolean_t sa_is_shared(const char *, enum sa_protocol); -_LIBSPL_LIBSHARE_H void sa_commit_shares(enum sa_protocol); -_LIBSPL_LIBSHARE_H void sa_truncate_shares(enum sa_protocol); - -/* protocol specific interfaces */ -_LIBSPL_LIBSHARE_H int sa_validate_shareopts(const char *, enum sa_protocol); - -#endif /* _LIBSPL_LIBSHARE_H */ diff --git a/lib/libspl/include/os/freebsd/fcntl.h b/lib/libspl/include/os/freebsd/fcntl.h deleted file mode 100644 index 1222b3d7a6b5..000000000000 --- a/lib/libspl/include/os/freebsd/fcntl.h +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2021 iXsystems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _LIBSPL_FCNTL_H_ -#define _LIBSPL_FCNTL_H_ - -#include_next <fcntl.h> - -#include <sys/fcntl.h> - -#endif /* _LIBSPL_FCNTL_H_ */ diff --git a/lib/libspl/include/os/freebsd/sys/byteorder.h b/lib/libspl/include/os/freebsd/sys/byteorder.h deleted file mode 100644 index 116ce991b89b..000000000000 --- a/lib/libspl/include/os/freebsd/sys/byteorder.h +++ /dev/null @@ -1,207 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * University Copyright- Copyright (c) 1982, 1986, 1988 - * The Regents of the University of California - * All Rights Reserved - * - * University Acknowledgment- Portions of this document are derived from - * software developed by the University of California, Berkeley, and its - * contributors. - */ - -#ifndef _SYS_BYTEORDER_H -#define _SYS_BYTEORDER_H - -#include <sys/endian.h> -#include <netinet/in.h> -#include <sys/isa_defs.h> -#include <inttypes.h> - -#if defined(__GNUC__) && defined(_ASM_INLINES) && \ - (defined(__i386) || defined(__amd64)) -#include <asm/byteorder.h> -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * macros for conversion between host and (internet) network byte order - */ -#if !defined(_XPG4_2) || defined(__EXTENSIONS__) - -#ifdef __COVERITY__ -/* - * Coverity's taint warnings from byteswapping are false positives for us. - * Suppress them by hiding byteswapping from Coverity. - */ -#define BSWAP_8(x) ((x) & 0xff) -#define BSWAP_16(x) ((x) & 0xffff) -#define BSWAP_32(x) ((x) & 0xffffffff) -#define BSWAP_64(x) (x) - -#else /* __COVERITY__ */ - -/* - * Macros to reverse byte order - */ -#define BSWAP_8(x) ((x) & 0xff) -#define BSWAP_16(x) ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8)) -#define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16)) -#define BSWAP_64(x) ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32)) - -#endif /* __COVERITY__ */ - -#define BMASK_8(x) ((x) & 0xff) -#define BMASK_16(x) ((x) & 0xffff) -#define BMASK_32(x) ((x) & 0xffffffff) -#define BMASK_64(x) (x) - -/* - * Macros to convert from a specific byte order to/from native byte order - */ -#ifdef _ZFS_BIG_ENDIAN -#define BE_8(x) BMASK_8(x) -#define BE_16(x) BMASK_16(x) -#define BE_32(x) BMASK_32(x) -#define BE_64(x) BMASK_64(x) -#define LE_8(x) BSWAP_8(x) -#define LE_16(x) BSWAP_16(x) -#define LE_32(x) BSWAP_32(x) -#define LE_64(x) BSWAP_64(x) -#else -#define LE_8(x) BMASK_8(x) -#define LE_16(x) BMASK_16(x) -#define LE_32(x) BMASK_32(x) -#define LE_64(x) BMASK_64(x) -#define BE_8(x) BSWAP_8(x) -#define BE_16(x) BSWAP_16(x) -#define BE_32(x) BSWAP_32(x) -#define BE_64(x) BSWAP_64(x) -#endif - -#ifdef _ZFS_BIG_ENDIAN -static __inline__ uint64_t -htonll(uint64_t n) -{ - return (n); -} - -static __inline__ uint64_t -ntohll(uint64_t n) -{ - return (n); -} -#else -static __inline__ uint64_t -htonll(uint64_t n) -{ - return ((((uint64_t)htonl(n)) << 32) + htonl(n >> 32)); -} - -static __inline__ uint64_t -ntohll(uint64_t n) -{ - return ((((uint64_t)ntohl(n)) << 32) + ntohl(n >> 32)); -} -#endif - -/* - * Macros to read unaligned values from a specific byte order to - * native byte order - */ - -#define BE_IN8(xa) \ - *((uint8_t *)(xa)) - -#define BE_IN16(xa) \ - (((uint16_t)BE_IN8(xa) << 8) | BE_IN8((uint8_t *)(xa)+1)) - -#define BE_IN32(xa) \ - (((uint32_t)BE_IN16(xa) << 16) | BE_IN16((uint8_t *)(xa)+2)) - -#define BE_IN64(xa) \ - (((uint64_t)BE_IN32(xa) << 32) | BE_IN32((uint8_t *)(xa)+4)) - -#define LE_IN8(xa) \ - *((uint8_t *)(xa)) - -#define LE_IN16(xa) \ - (((uint16_t)LE_IN8((uint8_t *)(xa) + 1) << 8) | LE_IN8(xa)) - -#define LE_IN32(xa) \ - (((uint32_t)LE_IN16((uint8_t *)(xa) + 2) << 16) | LE_IN16(xa)) - -#define LE_IN64(xa) \ - (((uint64_t)LE_IN32((uint8_t *)(xa) + 4) << 32) | LE_IN32(xa)) - -/* - * Macros to write unaligned values from native byte order to a specific byte - * order. - */ - -#define BE_OUT8(xa, yv) *((uint8_t *)(xa)) = (uint8_t)(yv); - -#define BE_OUT16(xa, yv) \ - BE_OUT8((uint8_t *)(xa) + 1, yv); \ - BE_OUT8((uint8_t *)(xa), (yv) >> 8); - -#define BE_OUT32(xa, yv) \ - BE_OUT16((uint8_t *)(xa) + 2, yv); \ - BE_OUT16((uint8_t *)(xa), (yv) >> 16); - -#define BE_OUT64(xa, yv) \ - BE_OUT32((uint8_t *)(xa) + 4, yv); \ - BE_OUT32((uint8_t *)(xa), (yv) >> 32); - -#define LE_OUT8(xa, yv) *((uint8_t *)(xa)) = (uint8_t)(yv); - -#define LE_OUT16(xa, yv) \ - LE_OUT8((uint8_t *)(xa), yv); \ - LE_OUT8((uint8_t *)(xa) + 1, (yv) >> 8); - -#define LE_OUT32(xa, yv) \ - LE_OUT16((uint8_t *)(xa), yv); \ - LE_OUT16((uint8_t *)(xa) + 2, (yv) >> 16); - -#define LE_OUT64(xa, yv) \ - LE_OUT32((uint8_t *)(xa), yv); \ - LE_OUT32((uint8_t *)(xa) + 4, (yv) >> 32); - -#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_BYTEORDER_H */ diff --git a/lib/libspl/include/os/freebsd/sys/fcntl.h b/lib/libspl/include/os/freebsd/sys/fcntl.h deleted file mode 100644 index 64dd4d7ebe45..000000000000 --- a/lib/libspl/include/os/freebsd/sys/fcntl.h +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2021 iXsystems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _LIBSPL_SYS_FCNTL_H_ -#define _LIBSPL_SYS_FCNTL_H_ - -#include_next <sys/fcntl.h> - -#define O_LARGEFILE 0 -#define O_RSYNC 0 - -#ifndef O_DSYNC -#define O_DSYNC 0 -#endif - -#endif /* _LIBSPL_SYS_FCNTL_H_ */ diff --git a/lib/libspl/include/os/freebsd/sys/file.h b/lib/libspl/include/os/freebsd/sys/file.h deleted file mode 100644 index 75c3b23860bb..000000000000 --- a/lib/libspl/include/os/freebsd/sys/file.h +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_FILE_H -#define _LIBSPL_SYS_FILE_H - -#include_next <sys/file.h> - -#define FIGNORECASE 0x80000 /* request case-insensitive lookups */ - -#endif diff --git a/lib/libspl/include/os/freebsd/sys/ia32/asm_linkage.h b/lib/libspl/include/os/freebsd/sys/ia32/asm_linkage.h deleted file mode 100644 index f9c34d282d46..000000000000 --- a/lib/libspl/include/os/freebsd/sys/ia32/asm_linkage.h +++ /dev/null @@ -1,185 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _IA32_SYS_ASM_LINKAGE_H -#define _IA32_SYS_ASM_LINKAGE_H - -#if defined(__linux__) && defined(CONFIG_SLS) -#define RET ret; int3 -#else -#define RET ret -#endif - -/* Tell compiler to call assembler like Unix */ -#undef ASMABI -#define ASMABI __attribute__((sysv_abi)) - -#define ENDBR - -#define SECTION_TEXT .text -#define SECTION_STATIC .section .rodata - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _ASM /* The remainder of this file is only for assembly files */ - -/* - * make annoying differences in assembler syntax go away - */ - -/* - * D16 and A16 are used to insert instructions prefixes; the - * macros help the assembler code be slightly more portable. - */ -#if !defined(__GNUC_AS__) -/* - * /usr/ccs/bin/as prefixes are parsed as separate instructions - */ -#define D16 data16; -#define A16 addr16; - -/* - * (There are some weird constructs in constant expressions) - */ -#define _CONST(const) [const] -#define _BITNOT(const) -1!_CONST(const) -#define _MUL(a, b) _CONST(a \* b) - -#else -/* - * Why not use the 'data16' and 'addr16' prefixes .. well, the - * assembler doesn't quite believe in real mode, and thus argues with - * us about what we're trying to do. - */ -#define D16 .byte 0x66; -#define A16 .byte 0x67; - -#define _CONST(const) (const) -#define _BITNOT(const) ~_CONST(const) -#define _MUL(a, b) _CONST(a * b) - -#endif - -/* - * C pointers are different sizes between i386 and amd64. - * These constants can be used to compute offsets into pointer arrays. - */ -#if defined(__amd64) -#define CLONGSHIFT 3 -#define CLONGSIZE 8 -#define CLONGMASK 7 -#elif defined(__i386) -#define CLONGSHIFT 2 -#define CLONGSIZE 4 -#define CLONGMASK 3 -#endif - -/* - * Since we know we're either ILP32 or LP64 .. - */ -#define CPTRSHIFT CLONGSHIFT -#define CPTRSIZE CLONGSIZE -#define CPTRMASK CLONGMASK - -#if CPTRSIZE != (1 << CPTRSHIFT) || CLONGSIZE != (1 << CLONGSHIFT) -#error "inconsistent shift constants" -#endif - -#if CPTRMASK != (CPTRSIZE - 1) || CLONGMASK != (CLONGSIZE - 1) -#error "inconsistent mask constants" -#endif - -#define ASM_ENTRY_ALIGN 16 - -/* - * SSE register alignment and save areas - */ - -#define XMM_SIZE 16 -#define XMM_ALIGN 16 - -/* - * ENTRY provides the standard procedure entry code and an easy way to - * insert the calls to mcount for profiling. ENTRY_NP is identical, but - * never calls mcount. - */ -#define ENTRY(x) \ - .text; \ - .balign ASM_ENTRY_ALIGN; \ - .globl x; \ -x: MCOUNT(x) - -#define ENTRY_NP(x) \ - .text; \ - .balign ASM_ENTRY_ALIGN; \ - .globl x; \ -x: - -#define ENTRY_ALIGN(x, a) \ - .text; \ - .balign a; \ - .globl x; \ -x: - -#define FUNCTION(x) \ - .type x, @function; \ -x: - -/* - * ENTRY2 is identical to ENTRY but provides two labels for the entry point. - */ -#define ENTRY2(x, y) \ - .text; \ - .balign ASM_ENTRY_ALIGN; \ - .globl x, y; \ -x:; \ -y: MCOUNT(x) - -#define ENTRY_NP2(x, y) \ - .text; \ - .balign ASM_ENTRY_ALIGN; \ - .globl x, y; \ -x:; \ -y: - - -/* - * SET_SIZE trails a function and set the size for the ELF symbol table. - */ -#define SET_SIZE(x) - -#define SET_OBJ(x) - -#endif /* _ASM */ - -#ifdef __cplusplus -} -#endif - -#endif /* _IA32_SYS_ASM_LINKAGE_H */ diff --git a/lib/libspl/include/os/freebsd/sys/mnttab.h b/lib/libspl/include/os/freebsd/sys/mnttab.h deleted file mode 100644 index e520bf5ef3bb..000000000000 --- a/lib/libspl/include/os/freebsd/sys/mnttab.h +++ /dev/null @@ -1,86 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -/* Copyright 2006 Ricardo Correia */ - -#ifndef _SYS_MNTTAB_H -#define _SYS_MNTTAB_H - -#include <stdio.h> -#include <sys/types.h> - -#ifdef MNTTAB -#undef MNTTAB -#endif /* MNTTAB */ - -#include <paths.h> -#include <sys/mount.h> -#define MNTTAB _PATH_DEVZERO -#define MS_NOMNTTAB 0x0 -#define MS_RDONLY 0x1 -#define umount2(p, f) unmount(p, f) -#define MNT_LINE_MAX 4108 - -#define MNT_TOOLONG 1 /* entry exceeds MNT_LINE_MAX */ -#define MNT_TOOMANY 2 /* too many fields in line */ -#define MNT_TOOFEW 3 /* too few fields in line */ - -struct mnttab { - char *mnt_special; - char *mnt_mountp; - char *mnt_fstype; - char *mnt_mntopts; -}; - -/* - * NOTE: fields in extmnttab should match struct mnttab till new fields - * are encountered, this allows hasmntopt to work properly when its arg is - * a pointer to an extmnttab struct cast to a mnttab struct pointer. - */ - -struct extmnttab { - char *mnt_special; - char *mnt_mountp; - char *mnt_fstype; - char *mnt_mntopts; - uint_t mnt_major; - uint_t mnt_minor; -}; - -struct stat64; -struct statfs; - -extern int getmntany(FILE *fp, struct mnttab *mp, struct mnttab *mpref); -extern int _sol_getmntent(FILE *fp, struct mnttab *mp); -extern int getextmntent(const char *path, struct extmnttab *entry, - struct stat64 *statbuf); -extern void statfs2mnttab(struct statfs *sfs, struct mnttab *mp); -extern char *hasmntopt(struct mnttab *mnt, const char *opt); -extern int getmntent(FILE *fp, struct mnttab *mp); - -#endif diff --git a/lib/libspl/include/os/freebsd/sys/mount.h b/lib/libspl/include/os/freebsd/sys/mount.h deleted file mode 100644 index 231c250d3410..000000000000 --- a/lib/libspl/include/os/freebsd/sys/mount.h +++ /dev/null @@ -1,105 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#ifndef _LIBSPL_SYS_MOUNT_H -#define _LIBSPL_SYS_MOUNT_H - -#undef _SYS_MOUNT_H_ -#include_next <sys/mount.h> - -#include <assert.h> -#include <string.h> -#include <stdlib.h> - -#if !defined(BLKGETSIZE64) -#define BLKGETSIZE64 DIOCGMEDIASIZE -#endif - -/* - * Some old glibc headers don't correctly define MS_DIRSYNC and - * instead use the enum name S_WRITE. When using these older - * headers define MS_DIRSYNC to be S_WRITE. - */ -#if !defined(MS_DIRSYNC) -#define MS_DIRSYNC S_WRITE -#endif - -/* - * Some old glibc headers don't correctly define MS_POSIXACL and - * instead leave it undefined. When using these older headers define - * MS_POSIXACL to the reserved value of (1<<16). - */ -#if !defined(MS_POSIXACL) -#define MS_POSIXACL (1<<16) -#endif - -#define MS_NOSUID MNT_NOSUID -#define MS_NOEXEC MNT_NOEXEC -#define MS_NODEV 0 -#define S_WRITE 0 -#define MS_BIND 0 -#define MS_REMOUNT 0 -#define MS_SYNCHRONOUS MNT_SYNCHRONOUS - -#define MS_USERS (MS_NOEXEC|MS_NOSUID|MS_NODEV) -#define MS_OWNER (MS_NOSUID|MS_NODEV) -#define MS_GROUP (MS_NOSUID|MS_NODEV) -#define MS_COMMENT 0 - -/* - * Older glibc <sys/mount.h> headers did not define all the available - * umount2(2) flags. Both MNT_FORCE and MNT_DETACH are supported in the - * kernel back to 2.4.11 so we define them correctly if they are missing. - */ -#ifdef MNT_FORCE -#define MS_FORCE MNT_FORCE -#else -#define MS_FORCE 0x00000001 -#endif /* MNT_FORCE */ - -#ifdef MNT_DETACH -#define MS_DETACH MNT_DETACH -#else -#define MS_DETACH 0x00000002 -#endif /* MNT_DETACH */ - -/* - * Overlay mount is default in Linux, but for solaris/zfs - * compatibility, MS_OVERLAY is defined to explicitly have the user - * provide a flag (-O) to mount over a non empty directory. - */ -#define MS_OVERLAY 0x00000004 - -/* - * MS_CRYPT indicates that encryption keys should be loaded if they are not - * already available. This is not defined in glibc, but it is never seen by - * the kernel so it will not cause any problems. - */ -#define MS_CRYPT 0x00000008 - -#endif /* _LIBSPL_SYS_MOUNT_H */ diff --git a/lib/libspl/include/os/freebsd/sys/param.h b/lib/libspl/include/os/freebsd/sys/param.h deleted file mode 100644 index 55fa1de0e8ff..000000000000 --- a/lib/libspl/include/os/freebsd/sys/param.h +++ /dev/null @@ -1,65 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_PARAM_H -#define _LIBSPL_SYS_PARAM_H - -#include_next <sys/param.h> -#include <unistd.h> - -/* - * File system parameters and macros. - * - * The file system is made out of blocks of at most MAXBSIZE units, - * with smaller units (fragments) only in the last direct block. - * MAXBSIZE primarily determines the size of buffers in the buffer - * pool. It may be made larger without any effect on existing - * file systems; however making it smaller may make some file - * systems unmountable. - * - * Note that the blocked devices are assumed to have DEV_BSIZE - * "sectors" and that fragments must be some multiple of this size. - */ -#define MAXNAMELEN 256 - -#define UID_NOACCESS 60002 /* user ID no access */ - -#define MAXUID UINT32_MAX /* max user id */ -#define MAXPROJID MAXUID /* max project id */ - -#ifdef PAGESIZE -#undef PAGESIZE -#endif /* PAGESIZE */ - -extern size_t spl_pagesize(void); -#define PAGESIZE (spl_pagesize()) - -#ifndef HAVE_EXECVPE -extern int execvpe(const char *name, char * const argv[], char * const envp[]); -#endif - -#endif diff --git a/lib/libspl/include/os/freebsd/sys/stat.h b/lib/libspl/include/os/freebsd/sys/stat.h deleted file mode 100644 index 666f2ec6d760..000000000000 --- a/lib/libspl/include/os/freebsd/sys/stat.h +++ /dev/null @@ -1,90 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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) 2010, Oracle and/or its affiliates. All rights reserved. - */ - -#ifndef _LIBSPL_SYS_STAT_H -#define _LIBSPL_SYS_STAT_H - -#include_next <sys/stat.h> - -/* Note: this file can be used on linux/macOS when bootstrapping tools. */ - -#if defined(__FreeBSD__) -#include <sys/mount.h> /* for BLKGETSIZE64 */ - -#define stat64 stat - -#define MAXOFFSET_T OFF_MAX - -#ifndef _KERNEL -#include <sys/disk.h> - -static __inline int -fstat64(int fd, struct stat *sb) -{ - int ret; - - ret = fstat(fd, sb); - if (ret == 0) { - if (S_ISCHR(sb->st_mode)) - (void) ioctl(fd, DIOCGMEDIASIZE, &sb->st_size); - } - return (ret); -} -#endif - -/* - * Emulate Solaris' behavior of returning the block device size in fstat64(). - */ -static inline int -fstat64_blk(int fd, struct stat64 *st) -{ - if (fstat64(fd, st) == -1) - return (-1); - - /* In Linux we need to use an ioctl to get the size of a block device */ - if (S_ISBLK(st->st_mode)) { - if (ioctl(fd, BLKGETSIZE64, &st->st_size) != 0) - return (-1); - } - - return (0); -} -#endif /* defined(__FreeBSD__) */ - -/* - * Only Intel-based Macs have a separate stat64; Arm-based Macs are like - * FreeBSD and have a full 64-bit stat from the start. - * - * On Linux, musl libc is full 64-bit too and has deprecated its own version - * of these defines since version 1.2.4. - */ -#if (defined(__APPLE__) && !(defined(__i386__) || defined(__x86_64__))) || \ - (defined(__linux__) && !defined(__GLIBC__)) -#define stat64 stat -#define fstat64 fstat -#endif - -#endif /* _LIBSPL_SYS_STAT_H */ diff --git a/lib/libspl/include/os/freebsd/sys/sysmacros.h b/lib/libspl/include/os/freebsd/sys/sysmacros.h deleted file mode 100644 index d9639d27b60e..000000000000 --- a/lib/libspl/include/os/freebsd/sys/sysmacros.h +++ /dev/null @@ -1 +0,0 @@ -/* keep me */ diff --git a/lib/libspl/include/os/freebsd/sys/vfs.h b/lib/libspl/include/os/freebsd/sys/vfs.h deleted file mode 100644 index 228ec5905240..000000000000 --- a/lib/libspl/include/os/freebsd/sys/vfs.h +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2020 iXsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef ZFS_SYS_VFS_H_ -#define ZFS_SYS_VFS_H_ - -#include_next <sys/statvfs.h> - -int fsshare(const char *, const char *, const char *); -int fsunshare(const char *, const char *); - -#endif /* !ZFS_SYS_VFS_H_ */ diff --git a/lib/libspl/include/os/freebsd/sys/zfs_context_os.h b/lib/libspl/include/os/freebsd/sys/zfs_context_os.h deleted file mode 100644 index 1dd036d02ac6..000000000000 --- a/lib/libspl/include/os/freebsd/sys/zfs_context_os.h +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2020 iXsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef ZFS_CONTEXT_OS_H_ -#define ZFS_CONTEXT_OS_H_ - -#define HAVE_LARGE_STACKS 1 - -#endif diff --git a/lib/libspl/include/os/linux/sys/byteorder.h b/lib/libspl/include/os/linux/sys/byteorder.h deleted file mode 100644 index 4fba62addd3b..000000000000 --- a/lib/libspl/include/os/linux/sys/byteorder.h +++ /dev/null @@ -1,238 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * University Copyright- Copyright (c) 1982, 1986, 1988 - * The Regents of the University of California - * All Rights Reserved - * - * University Acknowledgment- Portions of this document are derived from - * software developed by the University of California, Berkeley, and its - * contributors. - */ - -#ifndef _SYS_BYTEORDER_H -#define _SYS_BYTEORDER_H - -#if defined(__GNUC__) && defined(_ASM_INLINES) && \ - (defined(__i386) || defined(__amd64)) -#include <asm/byteorder.h> -#endif - -#include <sys/isa_defs.h> -#include <inttypes.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * macros for conversion between host and (internet) network byte order - */ - -#if defined(_ZFS_BIG_ENDIAN) && !defined(ntohl) && !defined(__lint) -/* big-endian */ -#define ntohl(x) (x) -#define ntohs(x) (x) -#define htonl(x) (x) -#define htons(x) (x) - -#elif !defined(ntohl) /* little-endian */ - -#ifndef _IN_PORT_T -#define _IN_PORT_T -typedef uint16_t in_port_t; -#endif - -#ifndef _IN_ADDR_T -#define _IN_ADDR_T -typedef uint32_t in_addr_t; -#endif - -#if !defined(_XPG4_2) || defined(__EXTENSIONS__) || defined(_XPG5) -extern uint32_t htonl(uint32_t); -extern uint16_t htons(uint16_t); -extern uint32_t ntohl(uint32_t); -extern uint16_t ntohs(uint16_t); -#else -extern in_addr_t htonl(in_addr_t); -extern in_port_t htons(in_port_t); -extern in_addr_t ntohl(in_addr_t); -extern in_port_t ntohs(in_port_t); -#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) || defined(_XPG5) */ -#endif - -#if !defined(_XPG4_2) || defined(__EXTENSIONS__) - -#ifdef __COVERITY__ -/* - * Coverity's taint warnings from byteswapping are false positives for us. - * Suppress them by hiding byteswapping from Coverity. - */ -#define BSWAP_8(x) ((x) & 0xff) -#define BSWAP_16(x) ((x) & 0xffff) -#define BSWAP_32(x) ((x) & 0xffffffff) -#define BSWAP_64(x) (x) - -#else /* __COVERITY__ */ - -/* - * Macros to reverse byte order - */ -#define BSWAP_8(x) ((x) & 0xff) -#define BSWAP_16(x) ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8)) -#define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16)) -#define BSWAP_64(x) ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32)) - -#endif /* __COVERITY__ */ - -#define BMASK_8(x) ((x) & 0xff) -#define BMASK_16(x) ((x) & 0xffff) -#define BMASK_32(x) ((x) & 0xffffffff) -#define BMASK_64(x) (x) - -/* - * Macros to convert from a specific byte order to/from native byte order - */ -#ifdef _ZFS_BIG_ENDIAN -#define BE_8(x) BMASK_8(x) -#define BE_16(x) BMASK_16(x) -#define BE_32(x) BMASK_32(x) -#define BE_64(x) BMASK_64(x) -#define LE_8(x) BSWAP_8(x) -#define LE_16(x) BSWAP_16(x) -#define LE_32(x) BSWAP_32(x) -#define LE_64(x) BSWAP_64(x) -#else -#define LE_8(x) BMASK_8(x) -#define LE_16(x) BMASK_16(x) -#define LE_32(x) BMASK_32(x) -#define LE_64(x) BMASK_64(x) -#define BE_8(x) BSWAP_8(x) -#define BE_16(x) BSWAP_16(x) -#define BE_32(x) BSWAP_32(x) -#define BE_64(x) BSWAP_64(x) -#endif - -#ifdef _ZFS_BIG_ENDIAN -static __inline__ uint64_t -htonll(uint64_t n) -{ - return (n); -} - -static __inline__ uint64_t -ntohll(uint64_t n) -{ - return (n); -} -#else -static __inline__ uint64_t -htonll(uint64_t n) -{ - return ((((uint64_t)htonl(n)) << 32) + htonl(n >> 32)); -} - -static __inline__ uint64_t -ntohll(uint64_t n) -{ - return ((((uint64_t)ntohl(n)) << 32) + ntohl(n >> 32)); -} -#endif - -/* - * Macros to read unaligned values from a specific byte order to - * native byte order - */ - -#define BE_IN8(xa) \ - *((uint8_t *)(xa)) - -#define BE_IN16(xa) \ - (((uint16_t)BE_IN8(xa) << 8) | BE_IN8((uint8_t *)(xa)+1)) - -#define BE_IN32(xa) \ - (((uint32_t)BE_IN16(xa) << 16) | BE_IN16((uint8_t *)(xa)+2)) - -#define BE_IN64(xa) \ - (((uint64_t)BE_IN32(xa) << 32) | BE_IN32((uint8_t *)(xa)+4)) - -#define LE_IN8(xa) \ - *((uint8_t *)(xa)) - -#define LE_IN16(xa) \ - (((uint16_t)LE_IN8((uint8_t *)(xa) + 1) << 8) | LE_IN8(xa)) - -#define LE_IN32(xa) \ - (((uint32_t)LE_IN16((uint8_t *)(xa) + 2) << 16) | LE_IN16(xa)) - -#define LE_IN64(xa) \ - (((uint64_t)LE_IN32((uint8_t *)(xa) + 4) << 32) | LE_IN32(xa)) - -/* - * Macros to write unaligned values from native byte order to a specific byte - * order. - */ - -#define BE_OUT8(xa, yv) *((uint8_t *)(xa)) = (uint8_t)(yv); - -#define BE_OUT16(xa, yv) \ - BE_OUT8((uint8_t *)(xa) + 1, yv); \ - BE_OUT8((uint8_t *)(xa), (yv) >> 8); - -#define BE_OUT32(xa, yv) \ - BE_OUT16((uint8_t *)(xa) + 2, yv); \ - BE_OUT16((uint8_t *)(xa), (yv) >> 16); - -#define BE_OUT64(xa, yv) \ - BE_OUT32((uint8_t *)(xa) + 4, yv); \ - BE_OUT32((uint8_t *)(xa), (yv) >> 32); - -#define LE_OUT8(xa, yv) *((uint8_t *)(xa)) = (uint8_t)(yv); - -#define LE_OUT16(xa, yv) \ - LE_OUT8((uint8_t *)(xa), yv); \ - LE_OUT8((uint8_t *)(xa) + 1, (yv) >> 8); - -#define LE_OUT32(xa, yv) \ - LE_OUT16((uint8_t *)(xa), yv); \ - LE_OUT16((uint8_t *)(xa) + 2, (yv) >> 16); - -#define LE_OUT64(xa, yv) \ - LE_OUT32((uint8_t *)(xa), yv); \ - LE_OUT32((uint8_t *)(xa) + 4, (yv) >> 32); - -#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_BYTEORDER_H */ diff --git a/lib/libspl/include/os/linux/sys/errno.h b/lib/libspl/include/os/linux/sys/errno.h deleted file mode 100644 index dd0120100a3d..000000000000 --- a/lib/libspl/include/os/linux/sys/errno.h +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2017 Zettabyte Software, LLC. All rights reserved. - * Use is subject to license terms. - */ - -/* - * Compiling against musl correctly points out that including sys/errno.h is - * disallowed by the Single UNIX Specification when building in userspace, so - * we implement a dummy header to redirect the include to the proper header. - */ -#ifndef _LIBSPL_SYS_ERRNO_H -#define _LIBSPL_SYS_ERRNO_H - -#include <errno.h> -/* - * We'll take the unused errnos, 'EBADE' and 'EBADR' (from the Convergent - * graveyard) to indicate checksum errors and fragmentation. - */ -#define ECKSUM EBADE -#define EFRAGS EBADR - -/* Similar for ENOACTIVE */ -#define ENOTACTIVE ENOANO - -#endif /* _LIBSPL_SYS_ERRNO_H */ diff --git a/lib/libspl/include/os/linux/sys/ia32/asm_linkage.h b/lib/libspl/include/os/linux/sys/ia32/asm_linkage.h deleted file mode 100644 index e1d25346b13e..000000000000 --- a/lib/libspl/include/os/linux/sys/ia32/asm_linkage.h +++ /dev/null @@ -1,212 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _IA32_SYS_ASM_LINKAGE_H -#define _IA32_SYS_ASM_LINKAGE_H - -#if defined(_KERNEL) && defined(__linux__) -#include <linux/linkage.h> -#endif - -#ifndef ENDBR -#if defined(__ELF__) && defined(__CET__) && defined(__has_include) -/* CSTYLED */ -#if __has_include(<cet.h>) - -#include <cet.h> - -#ifdef _CET_ENDBR -#define ENDBR _CET_ENDBR -#endif /* _CET_ENDBR */ - -#endif /* <cet.h> */ -#endif /* __ELF__ && __CET__ && __has_include */ -#endif /* !ENDBR */ - -#ifndef ENDBR -#define ENDBR -#endif -#ifndef RET -#define RET ret -#endif - -/* You can set to nothing on Unix platforms */ -#undef ASMABI -#define ASMABI __attribute__((sysv_abi)) - -#define SECTION_TEXT .text -#define SECTION_STATIC .section .rodata - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _ASM /* The remainder of this file is only for assembly files */ - -/* - * make annoying differences in assembler syntax go away - */ - -/* - * D16 and A16 are used to insert instructions prefixes; the - * macros help the assembler code be slightly more portable. - */ -#if !defined(__GNUC_AS__) -/* - * /usr/ccs/bin/as prefixes are parsed as separate instructions - */ -#define D16 data16; -#define A16 addr16; - -/* - * (There are some weird constructs in constant expressions) - */ -#define _CONST(const) [const] -#define _BITNOT(const) -1!_CONST(const) -#define _MUL(a, b) _CONST(a \* b) - -#else -/* - * Why not use the 'data16' and 'addr16' prefixes .. well, the - * assembler doesn't quite believe in real mode, and thus argues with - * us about what we're trying to do. - */ -#define D16 .byte 0x66; -#define A16 .byte 0x67; - -#define _CONST(const) (const) -#define _BITNOT(const) ~_CONST(const) -#define _MUL(a, b) _CONST(a * b) - -#endif - -/* - * C pointers are different sizes between i386 and amd64. - * These constants can be used to compute offsets into pointer arrays. - */ -#if defined(__amd64) -#define CLONGSHIFT 3 -#define CLONGSIZE 8 -#define CLONGMASK 7 -#elif defined(__i386) -#define CLONGSHIFT 2 -#define CLONGSIZE 4 -#define CLONGMASK 3 -#endif - -/* - * Since we know we're either ILP32 or LP64 .. - */ -#define CPTRSHIFT CLONGSHIFT -#define CPTRSIZE CLONGSIZE -#define CPTRMASK CLONGMASK - -#if CPTRSIZE != (1 << CPTRSHIFT) || CLONGSIZE != (1 << CLONGSHIFT) -#error "inconsistent shift constants" -#endif - -#if CPTRMASK != (CPTRSIZE - 1) || CLONGMASK != (CLONGSIZE - 1) -#error "inconsistent mask constants" -#endif - -#define ASM_ENTRY_ALIGN 16 - -/* - * SSE register alignment and save areas - */ - -#define XMM_SIZE 16 -#define XMM_ALIGN 16 - -/* - * ENTRY provides the standard procedure entry code and an easy way to - * insert the calls to mcount for profiling. ENTRY_NP is identical, but - * never calls mcount. - */ -#undef ENTRY -#define ENTRY(x) \ - .text; \ - .balign ASM_ENTRY_ALIGN; \ - .globl x; \ - .type x, @function; \ -x: MCOUNT(x) - -#define ENTRY_NP(x) \ - .text; \ - .balign ASM_ENTRY_ALIGN; \ - .globl x; \ - .type x, @function; \ -x: - -#define ENTRY_ALIGN(x, a) \ - .text; \ - .balign a; \ - .globl x; \ - .type x, @function; \ -x: - -#define FUNCTION(x) \ - .type x, @function; \ -x: - -/* - * ENTRY2 is identical to ENTRY but provides two labels for the entry point. - */ -#define ENTRY2(x, y) \ - .text; \ - .balign ASM_ENTRY_ALIGN; \ - .globl x, y; \ - .type x, @function; \ - .type y, @function; \ -x:; \ -y: MCOUNT(x) - -#define ENTRY_NP2(x, y) \ - .text; \ - .balign ASM_ENTRY_ALIGN; \ - .globl x, y; \ - .type x, @function; \ - .type y, @function; \ -x:; \ -y: - - -/* - * SET_SIZE trails a function and set the size for the ELF symbol table. - */ -#define SET_SIZE(x) \ - .size x, [.-x] - -#define SET_OBJ(x) .type x, @object - -#endif /* _ASM */ - -#ifdef __cplusplus -} -#endif - -#endif /* _IA32_SYS_ASM_LINKAGE_H */ diff --git a/lib/libspl/include/os/linux/sys/mnttab.h b/lib/libspl/include/os/linux/sys/mnttab.h deleted file mode 100644 index c1b7f3b389c0..000000000000 --- a/lib/libspl/include/os/linux/sys/mnttab.h +++ /dev/null @@ -1,90 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -/* Copyright 2006 Ricardo Correia */ - -#ifndef _SYS_MNTTAB_H -#define _SYS_MNTTAB_H - -#include <stdio.h> -#include <mntent.h> -#include <sys/stat.h> -#include <sys/types.h> - -#ifdef MNTTAB -#undef MNTTAB -#endif /* MNTTAB */ - -#define MNTTAB "/proc/self/mounts" -#define MNT_LINE_MAX 4108 - -#define MNT_TOOLONG 1 /* entry exceeds MNT_LINE_MAX */ -#define MNT_TOOMANY 2 /* too many fields in line */ -#define MNT_TOOFEW 3 /* too few fields in line */ - -struct mnttab { - char *mnt_special; - char *mnt_mountp; - char *mnt_fstype; - char *mnt_mntopts; -}; - -/* - * NOTE: fields in extmnttab should match struct mnttab till new fields - * are encountered, this allows hasmntopt to work properly when its arg is - * a pointer to an extmnttab struct cast to a mnttab struct pointer. - */ - -struct extmnttab { - char *mnt_special; - char *mnt_mountp; - char *mnt_fstype; - char *mnt_mntopts; - uint_t mnt_major; - uint_t mnt_minor; -}; - -struct statfs; - -extern int getmntany(FILE *fp, struct mnttab *mp, struct mnttab *mpref); -extern int _sol_getmntent(FILE *fp, struct mnttab *mp); -extern int getextmntent(const char *path, struct extmnttab *mp, - struct stat64 *statbuf); -static inline char *_sol_hasmntopt(struct mnttab *mnt, const char *opt) -{ - struct mntent mnt_new; - - mnt_new.mnt_opts = mnt->mnt_mntopts; - - return (hasmntopt(&mnt_new, opt)); -} - -#define hasmntopt _sol_hasmntopt -#define getmntent _sol_getmntent - -#endif diff --git a/lib/libspl/include/os/linux/sys/mount.h b/lib/libspl/include/os/linux/sys/mount.h deleted file mode 100644 index c4a291f5c22d..000000000000 --- a/lib/libspl/include/os/linux/sys/mount.h +++ /dev/null @@ -1,99 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include_next <sys/mount.h> - -#ifndef _LIBSPL_SYS_MOUNT_H -#define _LIBSPL_SYS_MOUNT_H - -#include <assert.h> -#include <string.h> -#include <stdlib.h> - -/* - * Some old glibc headers don't define BLKGETSIZE64 - * and we don't want to require the kernel headers - */ -#if !defined(BLKGETSIZE64) -#define BLKGETSIZE64 _IOR(0x12, 114, size_t) -#endif - -/* - * Some old glibc headers don't correctly define MS_DIRSYNC and - * instead use the enum name S_WRITE. When using these older - * headers define MS_DIRSYNC to be S_WRITE. - */ -#if !defined(MS_DIRSYNC) -#define MS_DIRSYNC S_WRITE -#endif - -/* - * Some old glibc headers don't correctly define MS_POSIXACL and - * instead leave it undefined. When using these older headers define - * MS_POSIXACL to the reserved value of (1<<16). - */ -#if !defined(MS_POSIXACL) -#define MS_POSIXACL (1<<16) -#endif - -#define MS_USERS (MS_NOEXEC|MS_NOSUID|MS_NODEV) -#define MS_OWNER (MS_NOSUID|MS_NODEV) -#define MS_GROUP (MS_NOSUID|MS_NODEV) -#define MS_COMMENT 0 - -/* - * Older glibc <sys/mount.h> headers did not define all the available - * umount2(2) flags. Both MNT_FORCE and MNT_DETACH are supported in the - * kernel back to 2.4.11 so we define them correctly if they are missing. - */ -#ifdef MNT_FORCE -#define MS_FORCE MNT_FORCE -#else -#define MS_FORCE 0x00000001 -#endif /* MNT_FORCE */ - -#ifdef MNT_DETACH -#define MS_DETACH MNT_DETACH -#else -#define MS_DETACH 0x00000002 -#endif /* MNT_DETACH */ - -/* - * Overlay mount is default in Linux, but for solaris/zfs - * compatibility, MS_OVERLAY is defined to explicitly have the user - * provide a flag (-O) to mount over a non empty directory. - */ -#define MS_OVERLAY 0x00000004 - -/* - * MS_CRYPT indicates that encryption keys should be loaded if they are not - * already available. This is not defined in glibc, but it is never seen by - * the kernel so it will not cause any problems. - */ -#define MS_CRYPT 0x00000008 - -#endif /* _LIBSPL_SYS_MOUNT_H */ diff --git a/lib/libspl/include/os/linux/sys/param.h b/lib/libspl/include/os/linux/sys/param.h deleted file mode 100644 index 814f8feaf37f..000000000000 --- a/lib/libspl/include/os/linux/sys/param.h +++ /dev/null @@ -1,68 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_PARAM_H -#define _LIBSPL_SYS_PARAM_H - -#include_next <sys/param.h> -#include <unistd.h> - -/* - * File system parameters and macros. - * - * The file system is made out of blocks of at most MAXBSIZE units, - * with smaller units (fragments) only in the last direct block. - * MAXBSIZE primarily determines the size of buffers in the buffer - * pool. It may be made larger without any effect on existing - * file systems; however making it smaller may make some file - * systems unmountable. - * - * Note that the blocked devices are assumed to have DEV_BSIZE - * "sectors" and that fragments must be some multiple of this size. - */ -#define MAXBSIZE 8192 -#define DEV_BSIZE 512 -#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ - -#define MAXNAMELEN 256 -#define MAXOFFSET_T LLONG_MAX - -#define UID_NOBODY 60001 /* user ID no body */ -#define GID_NOBODY UID_NOBODY -#define UID_NOACCESS 60002 /* user ID no access */ - -#define MAXUID UINT32_MAX /* max user id */ -#define MAXPROJID MAXUID /* max project id */ - -#ifdef PAGESIZE -#undef PAGESIZE -#endif /* PAGESIZE */ - -extern size_t spl_pagesize(void); -#define PAGESIZE (spl_pagesize()) - -#endif diff --git a/lib/libspl/include/os/linux/sys/stat.h b/lib/libspl/include/os/linux/sys/stat.h deleted file mode 100644 index 13cc0b46ac93..000000000000 --- a/lib/libspl/include/os/linux/sys/stat.h +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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) 2010, Oracle and/or its affiliates. All rights reserved. - */ - -#ifndef _LIBSPL_SYS_STAT_H -#define _LIBSPL_SYS_STAT_H - -#include_next <sys/stat.h> - -#include <sys/mount.h> /* for BLKGETSIZE64 */ - -#ifdef HAVE_STATX -#include <fcntl.h> -#include <sys/stat.h> -#endif - -/* - * Emulate Solaris' behavior of returning the block device size in fstat64(). - */ -static inline int -fstat64_blk(int fd, struct stat64 *st) -{ - if (fstat64(fd, st) == -1) - return (-1); - - /* In Linux we need to use an ioctl to get the size of a block device */ - if (S_ISBLK(st->st_mode)) { - if (ioctl(fd, BLKGETSIZE64, &st->st_size) != 0) - return (-1); - } - - return (0); -} -#endif /* _LIBSPL_SYS_STAT_H */ diff --git a/lib/libspl/include/os/linux/sys/sysmacros.h b/lib/libspl/include/os/linux/sys/sysmacros.h deleted file mode 100644 index 66e0da6b5afe..000000000000 --- a/lib/libspl/include/os/linux/sys/sysmacros.h +++ /dev/null @@ -1,103 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_SYSMACROS_H -#define _LIBSPL_SYS_SYSMACROS_H - -#include_next <sys/sysmacros.h> - -/* common macros */ -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a, b) ((a) < (b) ? (b) : (a)) -#endif -#ifndef ABS -#define ABS(a) ((a) < 0 ? -(a) : (a)) -#endif -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0])) -#endif -#ifndef DIV_ROUND_UP -#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) -#endif - -#define makedevice(maj, min) makedev(maj, min) -#define _sysconf(a) sysconf(a) - -/* - * Compatibility macros/typedefs needed for Solaris -> Linux port - */ -// Deprecated. Use P2ALIGN_TYPED instead. -// #define P2ALIGN(x, align) ((x) & -(align)) -#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1) -#define P2ROUNDUP(x, align) ((((x) - 1) | ((align) - 1)) + 1) -#define P2BOUNDARY(off, len, align) \ - (((off) ^ ((off) + (len) - 1)) > (align) - 1) -#define P2PHASE(x, align) ((x) & ((align) - 1)) -#define P2NPHASE(x, align) (-(x) & ((align) - 1)) -#define P2NPHASE_TYPED(x, align, type) \ - (-(type)(x) & ((type)(align) - 1)) -#define ISP2(x) (((x) & ((x) - 1)) == 0) -#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0) - -/* - * Typed version of the P2* macros. These macros should be used to ensure - * that the result is correctly calculated based on the data type of (x), - * which is passed in as the last argument, regardless of the data - * type of the alignment. For example, if (x) is of type uint64_t, - * and we want to round it up to a page boundary using "PAGESIZE" as - * the alignment, we can do either - * P2ROUNDUP(x, (uint64_t)PAGESIZE) - * or - * P2ROUNDUP_TYPED(x, PAGESIZE, uint64_t) - */ -#define P2ALIGN_TYPED(x, align, type) \ - ((type)(x) & -(type)(align)) -#define P2PHASE_TYPED(x, align, type) \ - ((type)(x) & ((type)(align) - 1)) -#define P2NPHASE_TYPED(x, align, type) \ - (-(type)(x) & ((type)(align) - 1)) -#define P2ROUNDUP_TYPED(x, align, type) \ - ((((type)(x) - 1) | ((type)(align) - 1)) + 1) -#define P2END_TYPED(x, align, type) \ - (-(~(type)(x) & -(type)(align))) -#define P2PHASEUP_TYPED(x, align, phase, type) \ - ((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align))) -#define P2CROSS_TYPED(x, y, align, type) \ - (((type)(x) ^ (type)(y)) > (type)(align) - 1) -#define P2SAMEHIGHBIT_TYPED(x, y, type) \ - (((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y))) - - -/* avoid any possibility of clashing with <stddef.h> version */ -#if defined(_KERNEL) && !defined(_KMEMUSER) && !defined(offsetof) -#define offsetof(s, m) ((size_t)(&(((s *)0)->m))) -#endif - -#endif /* _LIBSPL_SYS_SYSMACROS_H */ diff --git a/lib/libspl/include/os/linux/sys/zfs_context_os.h b/lib/libspl/include/os/linux/sys/zfs_context_os.h deleted file mode 100644 index bbfb4d17e06d..000000000000 --- a/lib/libspl/include/os/linux/sys/zfs_context_os.h +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 - */ - -#ifndef ZFS_CONTEXT_OS_H -#define ZFS_CONTEXT_OS_H - -#define HAVE_LARGE_STACKS 1 - -#endif diff --git a/lib/libspl/include/rpc/xdr.h b/lib/libspl/include/rpc/xdr.h deleted file mode 100644 index 85f718c275a5..000000000000 --- a/lib/libspl/include/rpc/xdr.h +++ /dev/null @@ -1,69 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T - * All Rights Reserved - * - * Portions of this source code were derived from Berkeley 4.3 BSD - * under license from the Regents of the University of California. - */ - -#ifndef LIBSPL_RPC_XDR_H -#define LIBSPL_RPC_XDR_H - -#include_next <rpc/xdr.h> - -#ifdef xdr_control /* if e.g. using tirpc */ -#undef xdr_control -#endif - -#define XDR_GET_BYTES_AVAIL 1 - -#ifndef HAVE_XDR_BYTESREC -struct xdr_bytesrec { - bool_t xc_is_last_record; - size_t xc_num_avail; -}; -#endif -typedef struct xdr_bytesrec xdr_bytesrec_t; - -/* - * This functionality is not required and is disabled in user space. - */ -static inline bool_t -xdr_control(XDR *xdrs, int request, void *info) -{ - xdr_bytesrec_t *xptr; - - ASSERT3U(request, ==, XDR_GET_BYTES_AVAIL); - - xptr = (xdr_bytesrec_t *)info; - xptr->xc_is_last_record = TRUE; - xptr->xc_num_avail = xdrs->x_handy; - - return (TRUE); -} - -#endif /* LIBSPL_RPC_XDR_H */ diff --git a/lib/libspl/include/statcommon.h b/lib/libspl/include/statcommon.h deleted file mode 100644 index 21c64ed4a9f8..000000000000 --- a/lib/libspl/include/statcommon.h +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * Common routines for acquiring snapshots of kstats for - * iostat, mpstat, and vmstat. - */ - -#ifndef _STATCOMMON_H -#define _STATCOMMON_H - -#include <sys/types.h> - -#define NODATE 0 /* Default: No time stamp */ -#define DDATE 1 /* Standard date format */ -#define UDATE 2 /* Internal representation of Unix time */ - -/* Print a timestamp in either Unix or standard format. */ -void print_timestamp(uint_t); -/* Return timestamp in either Unix or standard format in provided buffer */ -void get_timestamp(uint_t, char *, int); -/* convert time_t to standard format */ -void format_timestamp(time_t, char *, int); - -#endif /* _STATCOMMON_H */ diff --git a/lib/libspl/include/stdlib.h b/lib/libspl/include/stdlib.h deleted file mode 100644 index f381f21345fa..000000000000 --- a/lib/libspl/include/stdlib.h +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include_next <stdlib.h> - -#ifndef _LIBSPL_STDLIB_H -#define _LIBSPL_STDLIB_H - -extern const char *getexecname(void); - -#endif diff --git a/lib/libspl/include/string.h b/lib/libspl/include/string.h deleted file mode 100644 index 52f268b1d931..000000000000 --- a/lib/libspl/include/string.h +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_STRING_H -#define _LIBSPL_STRING_H - -#include_next <string.h> - -#ifndef HAVE_STRLCAT -extern size_t strlcat(char *dst, const char *src, size_t dstsize); -#endif - -#ifndef HAVE_STRLCPY -extern size_t strlcpy(char *dst, const char *src, size_t len); -#endif - -#endif diff --git a/lib/libspl/include/sys/abd_impl_os.h b/lib/libspl/include/sys/abd_impl_os.h deleted file mode 100644 index dee95652c71c..000000000000 --- a/lib/libspl/include/sys/abd_impl_os.h +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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) 2014 by Chunwei Chen. All rights reserved. - * Copyright (c) 2016, 2019 by Delphix. All rights reserved. - * Copyright (c) 2023, 2024, Klara Inc. - */ - -#ifndef _ABD_IMPL_OS_H -#define _ABD_IMPL_OS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define abd_enter_critical(flags) ((void)0) -#define abd_exit_critical(flags) ((void)0) - -#ifdef __cplusplus -} -#endif - -#endif /* _ABD_IMPL_OS_H */ diff --git a/lib/libspl/include/sys/abd_os.h b/lib/libspl/include/sys/abd_os.h deleted file mode 100644 index 80ce46e99a8e..000000000000 --- a/lib/libspl/include/sys/abd_os.h +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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) 2014 by Chunwei Chen. All rights reserved. - * Copyright (c) 2016, 2019 by Delphix. All rights reserved. - */ - -#ifndef _ABD_OS_H -#define _ABD_OS_H - -#ifdef __cplusplus -extern "C" { -#endif - -struct abd_scatter { - uint_t abd_offset; - uint_t abd_iovcnt; - struct iovec abd_iov[1]; /* actually variable-length */ -}; - -struct abd_linear { - void *abd_buf; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* _ABD_H */ diff --git a/lib/libspl/include/sys/acl.h b/lib/libspl/include/sys/acl.h deleted file mode 100644 index 602043bbb196..000000000000 --- a/lib/libspl/include/sys/acl.h +++ /dev/null @@ -1,304 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * Copyright 2014 Garrett D'Amore <garrett@damore.org> - * Copyright 2014 Nexenta Systems, Inc. All rights reserved. - * Copyright 2017 RackTop Systems. - */ - -#ifndef _SYS_ACL_H -#define _SYS_ACL_H - -#include <sys/types.h> -#include <sys/acl_impl.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define MAX_ACL_ENTRIES (1024) /* max entries of each type */ -typedef struct acl { - int a_type; /* the type of ACL entry */ - uid_t a_id; /* the entry in -uid or gid */ - o_mode_t a_perm; /* the permission field */ -} aclent_t; - -typedef struct ace { - uid_t a_who; /* uid or gid */ - uint32_t a_access_mask; /* read,write,... */ - uint16_t a_flags; /* see below */ - uint16_t a_type; /* allow or deny */ -} ace_t; - -typedef struct acl_info acl_t; - -/* - * The following are Defined types for an aclent_t. - */ -#define USER_OBJ (0x01) /* object owner */ -#define USER (0x02) /* additional users */ -#define GROUP_OBJ (0x04) /* owning group of the object */ -#define GROUP (0x08) /* additional groups */ -#define CLASS_OBJ (0x10) /* file group class and mask entry */ -#define OTHER_OBJ (0x20) /* other entry for the object */ -#define ACL_DEFAULT (0x1000) /* default flag */ -/* default object owner */ -#define DEF_USER_OBJ (ACL_DEFAULT | USER_OBJ) -/* default additional users */ -#define DEF_USER (ACL_DEFAULT | USER) -/* default owning group */ -#define DEF_GROUP_OBJ (ACL_DEFAULT | GROUP_OBJ) -/* default additional groups */ -#define DEF_GROUP (ACL_DEFAULT | GROUP) -/* default mask entry */ -#define DEF_CLASS_OBJ (ACL_DEFAULT | CLASS_OBJ) -/* default other entry */ -#define DEF_OTHER_OBJ (ACL_DEFAULT | OTHER_OBJ) - -/* - * The following are defined for ace_t. - */ -#define ACE_READ_DATA 0x00000001 /* file: read data */ -#define ACE_LIST_DIRECTORY 0x00000001 /* dir: list files */ -#define ACE_WRITE_DATA 0x00000002 /* file: write data */ -#define ACE_ADD_FILE 0x00000002 /* dir: create file */ -#define ACE_APPEND_DATA 0x00000004 /* file: append data */ -#define ACE_ADD_SUBDIRECTORY 0x00000004 /* dir: create subdir */ -#define ACE_READ_NAMED_ATTRS 0x00000008 /* FILE_READ_EA */ -#define ACE_WRITE_NAMED_ATTRS 0x00000010 /* FILE_WRITE_EA */ -#define ACE_EXECUTE 0x00000020 /* file: execute */ -#define ACE_TRAVERSE 0x00000020 /* dir: lookup name */ -#define ACE_DELETE_CHILD 0x00000040 /* dir: unlink child */ -#define ACE_READ_ATTRIBUTES 0x00000080 /* (all) stat, etc. */ -#define ACE_WRITE_ATTRIBUTES 0x00000100 /* (all) utimes, etc. */ -#define ACE_DELETE 0x00010000 /* (all) unlink self */ -#define ACE_READ_ACL 0x00020000 /* (all) getsecattr */ -#define ACE_WRITE_ACL 0x00040000 /* (all) setsecattr */ -#define ACE_WRITE_OWNER 0x00080000 /* (all) chown */ -#define ACE_SYNCHRONIZE 0x00100000 /* (all) */ - -#define ACE_FILE_INHERIT_ACE 0x0001 -#define ACE_DIRECTORY_INHERIT_ACE 0x0002 -#define ACE_NO_PROPAGATE_INHERIT_ACE 0x0004 -#define ACE_INHERIT_ONLY_ACE 0x0008 -#define ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x0010 -#define ACE_FAILED_ACCESS_ACE_FLAG 0x0020 -#define ACE_IDENTIFIER_GROUP 0x0040 -#define ACE_INHERITED_ACE 0x0080 -#define ACE_OWNER 0x1000 -#define ACE_GROUP 0x2000 -#define ACE_EVERYONE 0x4000 - -#define ACE_ACCESS_ALLOWED_ACE_TYPE 0x0000 -#define ACE_ACCESS_DENIED_ACE_TYPE 0x0001 -#define ACE_SYSTEM_AUDIT_ACE_TYPE 0x0002 -#define ACE_SYSTEM_ALARM_ACE_TYPE 0x0003 - -#define ACL_AUTO_INHERIT 0x0001 -#define ACL_PROTECTED 0x0002 -#define ACL_DEFAULTED 0x0004 -#define ACL_FLAGS_ALL (ACL_AUTO_INHERIT|ACL_PROTECTED| \ - ACL_DEFAULTED) - -/* - * These are only applicable in a CIFS context. - */ -#define ACE_ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x04 -#define ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x05 -#define ACE_ACCESS_DENIED_OBJECT_ACE_TYPE 0x06 -#define ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE 0x07 -#define ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE 0x08 -#define ACE_ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x09 -#define ACE_ACCESS_DENIED_CALLBACK_ACE_TYPE 0x0A -#define ACE_ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0x0B -#define ACE_ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0x0C -#define ACE_SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0x0D -#define ACE_SYSTEM_ALARM_CALLBACK_ACE_TYPE 0x0E -#define ACE_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0x0F -#define ACE_SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10 - -#define ACE_ALL_TYPES 0x001F - -#if defined(_KERNEL) - -typedef struct ace_object { - uid_t a_who; /* uid or gid */ - uint32_t a_access_mask; /* read,write,... */ - uint16_t a_flags; /* see below */ - uint16_t a_type; /* allow or deny */ - uint8_t a_obj_type[16]; /* obj type */ - uint8_t a_inherit_obj_type[16]; /* inherit obj */ -} ace_object_t; - -#endif - -#define ACE_ALL_PERMS (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \ - ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \ - ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \ - ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_WRITE_ACL| \ - ACE_WRITE_OWNER|ACE_SYNCHRONIZE) - -#define ACE_ALL_WRITE_PERMS (ACE_WRITE_DATA|ACE_APPEND_DATA| \ - ACE_WRITE_ATTRIBUTES|ACE_WRITE_NAMED_ATTRS|ACE_WRITE_ACL| \ - ACE_WRITE_OWNER|ACE_DELETE|ACE_DELETE_CHILD) - -#define ACE_READ_PERMS (ACE_READ_DATA|ACE_READ_ACL|ACE_READ_ATTRIBUTES| \ - ACE_READ_NAMED_ATTRS) - -#define ACE_WRITE_PERMS (ACE_WRITE_DATA|ACE_APPEND_DATA|ACE_WRITE_ATTRIBUTES| \ - ACE_WRITE_NAMED_ATTRS) - -#define ACE_MODIFY_PERMS (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \ - ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \ - ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \ - ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_SYNCHRONIZE) - -/* - * The following flags are supported by both NFSv4 ACLs and ace_t. - */ -#define ACE_NFSV4_SUP_FLAGS (ACE_FILE_INHERIT_ACE | \ - ACE_DIRECTORY_INHERIT_ACE | \ - ACE_NO_PROPAGATE_INHERIT_ACE | \ - ACE_INHERIT_ONLY_ACE | \ - ACE_IDENTIFIER_GROUP) - -#define ACE_TYPE_FLAGS (ACE_OWNER|ACE_GROUP|ACE_EVERYONE| \ - ACE_IDENTIFIER_GROUP) -#define ACE_INHERIT_FLAGS (ACE_FILE_INHERIT_ACE| \ - ACE_DIRECTORY_INHERIT_ACE|ACE_NO_PROPAGATE_INHERIT_ACE|ACE_INHERIT_ONLY_ACE) - -/* cmd args to acl(2) for aclent_t */ -#define GETACL 1 -#define SETACL 2 -#define GETACLCNT 3 - -/* cmd's to manipulate ace acls. */ -#define ACE_GETACL 4 -#define ACE_SETACL 5 -#define ACE_GETACLCNT 6 - -/* minimal acl entries from GETACLCNT */ -#define MIN_ACL_ENTRIES 4 - -#if !defined(_KERNEL) - -/* acl check errors */ -#define GRP_ERROR 1 -#define USER_ERROR 2 -#define OTHER_ERROR 3 -#define CLASS_ERROR 4 -#define DUPLICATE_ERROR 5 -#define MISS_ERROR 6 -#define MEM_ERROR 7 -#define ENTRY_ERROR 8 - - -/* - * similar to ufs_acl.h: changed to char type for user commands (tar, cpio) - * Attribute types - */ -#define UFSD_FREE ('0') /* Free entry */ -#define UFSD_ACL ('1') /* Access Control Lists */ -#define UFSD_DFACL ('2') /* reserved for future use */ -#define ACE_ACL ('3') /* ace_t style acls */ - -/* - * flag to [f]acl_get() - * controls whether a trivial acl should be returned. - */ -#define ACL_NO_TRIVIAL 0x2 - - -/* - * Flags to control acl_totext() - */ - -#define ACL_APPEND_ID 0x1 /* append uid/gid to user/group entries */ -#define ACL_COMPACT_FMT 0x2 /* build ACL in ls -V format */ -#define ACL_NORESOLVE 0x4 /* don't do name service lookups */ -#define ACL_SID_FMT 0x8 /* use usersid/groupsid when appropriate */ - -/* - * Legacy aclcheck errors for aclent_t ACLs - */ -#define EACL_GRP_ERROR GRP_ERROR -#define EACL_USER_ERROR USER_ERROR -#define EACL_OTHER_ERROR OTHER_ERROR -#define EACL_CLASS_ERROR CLASS_ERROR -#define EACL_DUPLICATE_ERROR DUPLICATE_ERROR -#define EACL_MISS_ERROR MISS_ERROR -#define EACL_MEM_ERROR MEM_ERROR -#define EACL_ENTRY_ERROR ENTRY_ERROR - -#define EACL_INHERIT_ERROR 9 /* invalid inherit flags */ -#define EACL_FLAGS_ERROR 10 /* unknown flag value */ -#define EACL_PERM_MASK_ERROR 11 /* unknown permission */ -#define EACL_COUNT_ERROR 12 /* invalid acl count */ - -#define EACL_INVALID_SLOT 13 /* invalid acl slot */ -#define EACL_NO_ACL_ENTRY 14 /* Entry doesn't exist */ -#define EACL_DIFF_TYPE 15 /* acls aren't same type */ - -#define EACL_INVALID_USER_GROUP 16 /* need user/group name */ -#define EACL_INVALID_STR 17 /* invalid acl string */ -#define EACL_FIELD_NOT_BLANK 18 /* can't have blank field */ -#define EACL_INVALID_ACCESS_TYPE 19 /* invalid access type */ -#define EACL_UNKNOWN_DATA 20 /* Unrecognized data in ACL */ -#define EACL_MISSING_FIELDS 21 /* missing fields in acl */ - -#define EACL_INHERIT_NOTDIR 22 /* Need dir for inheritance */ - -extern int aclcheck(aclent_t *, int, int *); -extern int acltomode(aclent_t *, int, mode_t *); -extern int aclfrommode(aclent_t *, int, mode_t *); -extern int aclsort(int, int, aclent_t *); -extern char *acltotext(aclent_t *, int); -extern aclent_t *aclfromtext(char *, int *); -extern void acl_free(acl_t *); -extern int acl_get(const char *, int, acl_t **); -extern int facl_get(int, int, acl_t **); -extern int acl_set(const char *, acl_t *acl); -extern int facl_set(int, acl_t *acl); -extern int acl_strip(const char *, uid_t, gid_t, mode_t); -extern int acl_trivial(const char *); -extern char *acl_totext(acl_t *, int); -extern int acl_fromtext(const char *, acl_t **); -extern int acl_check(acl_t *, int); - -#else /* !defined(_KERNEL) */ - -extern void ksort(caddr_t, int, int, int (*)(void *, void *)); -extern int cmp2acls(void *, void *); - -#endif /* !defined(_KERNEL) */ - -extern int acl(const char *path, int cmd, int cnt, void *buf); -extern int facl(int fd, int cmd, int cnt, void *buf); - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_ACL_H */ diff --git a/lib/libspl/include/sys/acl_impl.h b/lib/libspl/include/sys/acl_impl.h deleted file mode 100644 index 2850eacf61f4..000000000000 --- a/lib/libspl/include/sys/acl_impl.h +++ /dev/null @@ -1,60 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_ACL_IMPL_H -#define _SYS_ACL_IMPL_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * acl flags - * - * ACL_AUTO_INHERIT, ACL_PROTECTED and ACL_DEFAULTED - * flags can also be stored in this field. - */ -#define ACL_IS_TRIVIAL 0x10000 -#define ACL_IS_DIR 0x20000 - -typedef enum acl_type { - ACLENT_T = 0, - ACE_T = 1 -} acl_type_t; - -struct acl_info { - acl_type_t acl_type; /* style of acl */ - int acl_cnt; /* number of acl entries */ - int acl_entry_size; /* sizeof acl entry */ - int acl_flags; /* special flags about acl */ - void *acl_aclp; /* the acl */ -}; - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_ACL_IMPL_H */ diff --git a/lib/libspl/include/sys/asm_linkage.h b/lib/libspl/include/sys/asm_linkage.h deleted file mode 100644 index 1a0f2864a178..000000000000 --- a/lib/libspl/include/sys/asm_linkage.h +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_ASM_LINKAGE_H -#define _SYS_ASM_LINKAGE_H - -#if defined(__i386) || defined(__amd64) - -#include <sys/ia32/asm_linkage.h> /* XX64 x86/sys/asm_linkage.h */ - -#endif - -#if defined(_KERNEL) && defined(HAVE_KERNEL_OBJTOOL) - -#include <asm/frame.h> - -#else /* userspace */ -#define FRAME_BEGIN -#define FRAME_END -#endif - - -#endif /* _SYS_ASM_LINKAGE_H */ diff --git a/lib/libspl/include/sys/backtrace.h b/lib/libspl/include/sys/backtrace.h deleted file mode 100644 index 3a2077f32e6c..000000000000 --- a/lib/libspl/include/sys/backtrace.h +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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) 2024, Rob Norris <robn@despairlabs.com> - * Copyright (c) 2024, Klara Inc. - */ - -#ifndef _LIBSPL_SYS_BACKTRACE_H -#define _LIBSPL_SYS_BACKTRACE_H - -void libspl_backtrace(int fd); - -#endif diff --git a/lib/libspl/include/sys/callb.h b/lib/libspl/include/sys/callb.h deleted file mode 100644 index 46ed166e52f8..000000000000 --- a/lib/libspl/include/sys/callb.h +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_CALLB_H -#define _SYS_CALLB_H - -#endif diff --git a/lib/libspl/include/sys/cmn_err.h b/lib/libspl/include/sys/cmn_err.h deleted file mode 100644 index 32930adaeffa..000000000000 --- a/lib/libspl/include/sys/cmn_err.h +++ /dev/null @@ -1,65 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_CMN_ERR_H -#define _LIBSPL_SYS_CMN_ERR_H - -#include <atomic.h> - -#define cmn_err_once(ce, ...) \ -do { \ - static volatile uint32_t printed = 0; \ - if (atomic_cas_32(&printed, 0, 1) == 0) { \ - cmn_err(ce, __VA_ARGS__); \ - } \ -} while (0) - -#define vcmn_err_once(ce, fmt, ap) \ -do { \ - static volatile uint32_t printed = 0; \ - if (atomic_cas_32(&printed, 0, 1) == 0) { \ - vcmn_err(ce, fmt, ap); \ - } \ -} while (0) - -#define zcmn_err_once(zone, ce, ...) \ -do { \ - static volatile uint32_t printed = 0; \ - if (atomic_cas_32(&printed, 0, 1) == 0) { \ - zcmn_err(zone, ce, __VA_ARGS__); \ - } \ -} while (0) - -#define vzcmn_err_once(zone, ce, fmt, ap) \ -do { \ - static volatile uint32_t printed = 0; \ - if (atomic_cas_32(&printed, 0, 1) == 0) { \ - vzcmn_err(zone, ce, fmt, ap); \ - } \ -} while (0) - -#endif diff --git a/lib/libspl/include/sys/cred.h b/lib/libspl/include/sys/cred.h deleted file mode 100644 index 4f6183762a0a..000000000000 --- a/lib/libspl/include/sys/cred.h +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_CRED_H -#define _LIBSPL_SYS_CRED_H - -typedef struct cred cred_t; - -#endif diff --git a/lib/libspl/include/sys/debug.h b/lib/libspl/include/sys/debug.h deleted file mode 100644 index 02f33a68b75b..000000000000 --- a/lib/libspl/include/sys/debug.h +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_DEBUG_H -#define _LIBSPL_SYS_DEBUG_H - -#include <assert.h> - -#ifndef __printflike -#define __printflike(x, y) __attribute__((__format__(__printf__, x, y))) -#endif - -#ifndef __maybe_unused -#define __maybe_unused __attribute__((unused)) -#endif - -#ifndef __must_check -#define __must_check __attribute__((warn_unused_result)) -#endif - -#endif diff --git a/lib/libspl/include/sys/dkio.h b/lib/libspl/include/sys/dkio.h deleted file mode 100644 index 4ae1026d4d5f..000000000000 --- a/lib/libspl/include/sys/dkio.h +++ /dev/null @@ -1,484 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_DKIO_H -#define _SYS_DKIO_H - - - -#include <sys/dklabel.h> /* Needed for NDKMAP define */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Structures and definitions for disk io control commands - */ - -/* - * Structures used as data by ioctl calls. - */ - -#define DK_DEVLEN 16 /* device name max length, including */ - /* unit # & NULL (ie - "xyc1") */ - -/* - * Used for controller info - */ -struct dk_cinfo { - char dki_cname[DK_DEVLEN]; /* controller name (no unit #) */ - ushort_t dki_ctype; /* controller type */ - ushort_t dki_flags; /* flags */ - ushort_t dki_cnum; /* controller number */ - uint_t dki_addr; /* controller address */ - uint_t dki_space; /* controller bus type */ - uint_t dki_prio; /* interrupt priority */ - uint_t dki_vec; /* interrupt vector */ - char dki_dname[DK_DEVLEN]; /* drive name (no unit #) */ - uint_t dki_unit; /* unit number */ - ushort_t dki_partition; /* partition number */ - ushort_t dki_maxtransfer; /* max. transfer size in DEV_BSIZE */ -}; - -/* - * Controller types - */ -#define DKC_UNKNOWN 0 -#define DKC_CDROM 1 /* CD-ROM, SCSI or otherwise */ -#define DKC_WDC2880 2 -#define DKC_XXX_0 3 /* unassigned */ -#define DKC_XXX_1 4 /* unassigned */ -#define DKC_DSD5215 5 -#define DKC_ACB4000 7 -#define DKC_MD21 8 -#define DKC_XXX_2 9 /* unassigned */ -#define DKC_NCRFLOPPY 10 -#define DKC_SMSFLOPPY 12 -#define DKC_SCSI_CCS 13 /* SCSI CCS compatible */ -#define DKC_INTEL82072 14 /* native floppy chip */ -#define DKC_MD 16 /* meta-disk (virtual-disk) driver */ -#define DKC_INTEL82077 19 /* 82077 floppy disk controller */ -#define DKC_DIRECT 20 /* Intel direct attached device i.e. IDE */ -#define DKC_PCMCIA_MEM 21 /* PCMCIA memory disk-like type */ -#define DKC_PCMCIA_ATA 22 /* PCMCIA AT Attached type */ -#define DKC_VBD 23 /* virtual block device */ - -/* - * Sun reserves up through 1023 - */ - -#define DKC_CUSTOMER_BASE 1024 - -/* - * Flags - */ -#define DKI_BAD144 0x01 /* use DEC std 144 bad sector fwding */ -#define DKI_MAPTRK 0x02 /* controller does track mapping */ -#define DKI_FMTTRK 0x04 /* formats only full track at a time */ -#define DKI_FMTVOL 0x08 /* formats only full volume at a time */ -#define DKI_FMTCYL 0x10 /* formats only full cylinders at a time */ -#define DKI_HEXUNIT 0x20 /* unit number is printed as 3 hex digits */ -#define DKI_PCMCIA_PFD 0x40 /* PCMCIA pseudo-floppy memory card */ - -/* - * Used for all partitions - */ -struct dk_allmap { - struct dk_map dka_map[NDKMAP]; -}; - -#if defined(_SYSCALL32) -struct dk_allmap32 { - struct dk_map32 dka_map[NDKMAP]; -}; -#endif /* _SYSCALL32 */ - -/* - * Definition of a disk's geometry - */ -struct dk_geom { - unsigned short dkg_ncyl; /* # of data cylinders */ - unsigned short dkg_acyl; /* # of alternate cylinders */ - unsigned short dkg_bcyl; /* cyl offset (for fixed head area) */ - unsigned short dkg_nhead; /* # of heads */ - unsigned short dkg_obs1; /* obsolete */ - unsigned short dkg_nsect; /* # of data sectors per track */ - unsigned short dkg_intrlv; /* interleave factor */ - unsigned short dkg_obs2; /* obsolete */ - unsigned short dkg_obs3; /* obsolete */ - unsigned short dkg_apc; /* alternates per cyl (SCSI only) */ - unsigned short dkg_rpm; /* revolutions per minute */ - unsigned short dkg_pcyl; /* # of physical cylinders */ - unsigned short dkg_write_reinstruct; /* # sectors to skip, writes */ - unsigned short dkg_read_reinstruct; /* # sectors to skip, reads */ - unsigned short dkg_extra[7]; /* for compatible expansion */ -}; - -/* - * These defines are for historic compatibility with old drivers. - */ -#define dkg_bhead dkg_obs1 /* used to be head offset */ -#define dkg_gap1 dkg_obs2 /* used to be gap1 */ -#define dkg_gap2 dkg_obs3 /* used to be gap2 */ - -/* - * Disk io control commands - * Warning: some other ioctls with the DIOC prefix exist elsewhere. - * The Generic DKIOC numbers are from 0 - 50. - * The Floppy Driver uses 51 - 100. - * The Hard Disk (except SCSI) 101 - 106. (these are obsolete) - * The CDROM Driver 151 - 200. - * The USCSI ioctl 201 - 250. - */ -#define DKIOC (0x04 << 8) - -/* - * The following ioctls are generic in nature and need to be - * supported as appropriate by all disk drivers - */ -#define DKIOCGGEOM (DKIOC|1) /* Get geometry */ -#define DKIOCINFO (DKIOC|3) /* Get info */ -#define DKIOCEJECT (DKIOC|6) /* Generic 'eject' */ -#define DKIOCGVTOC (DKIOC|11) /* Get VTOC */ -#define DKIOCSVTOC (DKIOC|12) /* Set VTOC & Write to Disk */ - -/* - * Disk Cache Controls. These ioctls should be supported by - * all disk drivers. - * - * DKIOCFLUSHWRITECACHE when used from user-mode ignores the ioctl - * argument, but it should be passed as NULL to allow for future - * reinterpretation. From user-mode, this ioctl request is synchronous. - * - * When invoked from within the kernel, the arg can be NULL to indicate - * a synchronous request or can be the address of a struct dk_callback - * to request an asynchronous callback when the flush request is complete. - * In this case, the flag to the ioctl must include FKIOCTL and the - * dkc_callback field of the pointed to struct must be non-null or the - * request is made synchronously. - * - * In the callback case: if the ioctl returns 0, a callback WILL be performed. - * If the ioctl returns non-zero, a callback will NOT be performed. - * NOTE: In some cases, the callback may be done BEFORE the ioctl call - * returns. The caller's locking strategy should be prepared for this case. - */ -#define DKIOCFLUSHWRITECACHE (DKIOC|34) /* flush cache to phys medium */ - -struct dk_callback { - void (*dkc_callback)(void *dkc_cookie, int error); - void *dkc_cookie; - int dkc_flag; -}; - -/* bit flag definitions for dkc_flag */ -#define FLUSH_VOLATILE 0x1 /* Bit 0: if set, only flush */ - /* volatile cache; otherwise, flush */ - /* volatile and non-volatile cache */ - -#define DKIOCGETWCE (DKIOC|36) /* Get current write cache */ - /* enablement status */ -#define DKIOCSETWCE (DKIOC|37) /* Enable/Disable write cache */ - -/* - * The following ioctls are used by Sun drivers to communicate - * with their associated format routines. Support of these ioctls - * is not required of foreign drivers - */ -#define DKIOCSGEOM (DKIOC|2) /* Set geometry */ -#define DKIOCSAPART (DKIOC|4) /* Set all partitions */ -#define DKIOCGAPART (DKIOC|5) /* Get all partitions */ -#define DKIOCG_PHYGEOM (DKIOC|32) /* get physical geometry */ -#define DKIOCG_VIRTGEOM (DKIOC|33) /* get virtual geometry */ - -/* - * The following ioctl's are removable media support - */ -#define DKIOCLOCK (DKIOC|7) /* Generic 'lock' */ -#define DKIOCUNLOCK (DKIOC|8) /* Generic 'unlock' */ -#define DKIOCSTATE (DKIOC|13) /* Inquire insert/eject state */ -#define DKIOCREMOVABLE (DKIOC|16) /* is media removable */ - - -/* - * ioctl for hotpluggable devices - */ -#define DKIOCHOTPLUGGABLE (DKIOC|35) /* is hotpluggable */ - -/* - * Ioctl to force driver to re-read the alternate partition and rebuild - * the internal defect map. - */ -#define DKIOCADDBAD (DKIOC|20) /* Re-read the alternate map (IDE) */ -#define DKIOCGETDEF (DKIOC|21) /* read defect list (IDE) */ - -/* - * Used by applications to get disk defect information from IDE - * drives. - */ -#ifdef _SYSCALL32 -struct defect_header32 { - int head; - caddr32_t buffer; -}; -#endif /* _SYSCALL32 */ - -struct defect_header { - int head; - caddr_t buffer; -}; - -#define DKIOCPARTINFO (DKIOC|22) /* Get partition or slice parameters */ - -/* - * Used by applications to get partition or slice information - */ -#ifdef _SYSCALL32 -struct part_info32 { - uint32_t p_start; - int p_length; -}; -#endif /* _SYSCALL32 */ - -struct part_info { - uint64_t p_start; - int p_length; -}; - -/* The following ioctls are for Optical Memory Device */ -#define DKIOC_EBP_ENABLE (DKIOC|40) /* enable by pass erase on write */ -#define DKIOC_EBP_DISABLE (DKIOC|41) /* disable by pass erase on write */ - -/* - * This state enum is the argument passed to the DKIOCSTATE ioctl. - */ -enum dkio_state { DKIO_NONE, DKIO_EJECTED, DKIO_INSERTED, DKIO_DEV_GONE }; - -#define DKIOCGMEDIAINFO (DKIOC|42) /* get information about the media */ - -/* - * ioctls to read/write mboot info. - */ -#define DKIOCGMBOOT (DKIOC|43) /* get mboot info */ -#define DKIOCSMBOOT (DKIOC|44) /* set mboot info */ - -/* - * ioctl to get the device temperature. - */ -#define DKIOCGTEMPERATURE (DKIOC|45) /* get temperature */ - -/* - * Used for providing the temperature. - */ - -struct dk_temperature { - uint_t dkt_flags; /* Flags */ - short dkt_cur_temp; /* Current disk temperature */ - short dkt_ref_temp; /* reference disk temperature */ -}; - -#define DKT_BYPASS_PM 0x1 -#define DKT_INVALID_TEMP 0xFFFF - - -/* - * Used for Media info or the current profile info - */ -struct dk_minfo { - uint_t dki_media_type; /* Media type or profile info */ - uint_t dki_lbsize; /* Logical blocksize of media */ - diskaddr_t dki_capacity; /* Capacity as # of dki_lbsize blks */ -}; - -/* - * Media types or profiles known - */ -#define DK_UNKNOWN 0x00 /* Media inserted - type unknown */ - - -/* - * SFF 8090 Specification Version 3, media types 0x01 - 0xfffe are retained to - * maintain compatibility with SFF8090. The following define the - * optical media type. - */ -#define DK_REMOVABLE_DISK 0x02 /* Removable Disk */ -#define DK_MO_ERASABLE 0x03 /* MO Erasable */ -#define DK_MO_WRITEONCE 0x04 /* MO Write once */ -#define DK_AS_MO 0x05 /* AS MO */ -#define DK_CDROM 0x08 /* CDROM */ -#define DK_CDR 0x09 /* CD-R */ -#define DK_CDRW 0x0A /* CD-RW */ -#define DK_DVDROM 0x10 /* DVD-ROM */ -#define DK_DVDR 0x11 /* DVD-R */ -#define DK_DVDRAM 0x12 /* DVD_RAM or DVD-RW */ - -/* - * Media types for other rewritable magnetic media - */ -#define DK_FIXED_DISK 0x10001 /* Fixed disk SCSI or otherwise */ -#define DK_FLOPPY 0x10002 /* Floppy media */ -#define DK_ZIP 0x10003 /* IOMEGA ZIP media */ -#define DK_JAZ 0x10004 /* IOMEGA JAZ media */ - -#define DKIOCSETEFI (DKIOC|17) /* Set EFI info */ -#define DKIOCGETEFI (DKIOC|18) /* Get EFI info */ - -#define DKIOCPARTITION (DKIOC|9) /* Get partition info */ - -/* - * Ioctls to get/set volume capabilities related to Logical Volume Managers. - * They include the ability to get/set capabilities and to issue a read to a - * specific underlying device of a replicated device. - */ - -#define DKIOCGETVOLCAP (DKIOC | 25) /* Get volume capabilities */ -#define DKIOCSETVOLCAP (DKIOC | 26) /* Set volume capabilities */ -#define DKIOCDMR (DKIOC | 27) /* Issue a directed read */ - -typedef uint_t volcapinfo_t; - -typedef uint_t volcapset_t; - -#define DKV_ABR_CAP 0x00000001 /* Support Appl.Based Recovery */ -#define DKV_DMR_CAP 0x00000002 /* Support Directed Mirror Read */ - -typedef struct volcap { - volcapinfo_t vc_info; /* Capabilities available */ - volcapset_t vc_set; /* Capabilities set */ -} volcap_t; - -#define VOL_SIDENAME 256 - -typedef struct vol_directed_rd { - int vdr_flags; - offset_t vdr_offset; - size_t vdr_nbytes; - size_t vdr_bytesread; - void *vdr_data; - int vdr_side; - char vdr_side_name[VOL_SIDENAME]; -} vol_directed_rd_t; - -#define DKV_SIDE_INIT (-1) -#define DKV_DMR_NEXT_SIDE 0x00000001 -#define DKV_DMR_DONE 0x00000002 -#define DKV_DMR_ERROR 0x00000004 -#define DKV_DMR_SUCCESS 0x00000008 -#define DKV_DMR_SHORT 0x00000010 - -#ifdef _MULTI_DATAMODEL -#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 -#pragma pack(4) -#endif -typedef struct vol_directed_rd32 { - int32_t vdr_flags; - offset_t vdr_offset; /* 64-bit element on 32-bit alignment */ - size32_t vdr_nbytes; - size32_t vdr_bytesread; - caddr32_t vdr_data; - int32_t vdr_side; - char vdr_side_name[VOL_SIDENAME]; -} vol_directed_rd32_t; -#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 -#pragma pack() -#endif -#endif /* _MULTI_DATAMODEL */ - -/* - * The ioctl is used to fetch disk's device type, vendor ID, - * model number/product ID, firmware revision and serial number together. - * - * Currently there are two device types - DKD_ATA_TYPE which means the - * disk is driven by cmdk/ata or dad/uata driver, and DKD_SCSI_TYPE - * which means the disk is driven by sd/scsi hba driver. - */ -#define DKIOC_GETDISKID (DKIOC|46) - -/* These two labels are for dkd_dtype of dk_disk_id_t */ -#define DKD_ATA_TYPE 0x01 /* ATA disk or legacy mode SATA disk */ -#define DKD_SCSI_TYPE 0x02 /* SCSI disk or native mode SATA disk */ - -#define DKD_ATA_MODEL 40 /* model number length */ -#define DKD_ATA_FWVER 8 /* firmware revision length */ -#define DKD_ATA_SERIAL 20 /* serial number length */ - -#define DKD_SCSI_VENDOR 8 /* vendor ID length */ -#define DKD_SCSI_PRODUCT 16 /* product ID length */ -#define DKD_SCSI_REVLEVEL 4 /* revision level length */ -#define DKD_SCSI_SERIAL 12 /* serial number length */ - -/* - * The argument type for DKIOC_GETDISKID ioctl. - */ -typedef struct dk_disk_id { - uint_t dkd_dtype; - union { - struct { - char dkd_amodel[DKD_ATA_MODEL]; /* 40 bytes */ - char dkd_afwver[DKD_ATA_FWVER]; /* 8 bytes */ - char dkd_aserial[DKD_ATA_SERIAL]; /* 20 bytes */ - } ata_disk_id; - struct { - char dkd_svendor[DKD_SCSI_VENDOR]; /* 8 bytes */ - char dkd_sproduct[DKD_SCSI_PRODUCT]; /* 16 bytes */ - char dkd_sfwver[DKD_SCSI_REVLEVEL]; /* 4 bytes */ - char dkd_sserial[DKD_SCSI_SERIAL]; /* 12 bytes */ - } scsi_disk_id; - } disk_id; -} dk_disk_id_t; - -/* - * The ioctl is used to update the firmware of device. - */ -#define DKIOC_UPDATEFW (DKIOC|47) - -/* The argument type for DKIOC_UPDATEFW ioctl */ -typedef struct dk_updatefw { - caddr_t dku_ptrbuf; /* pointer to firmware buf */ - uint_t dku_size; /* firmware buf length */ - uint8_t dku_type; /* firmware update type */ -} dk_updatefw_t; - -#ifdef _SYSCALL32 -typedef struct dk_updatefw_32 { - caddr32_t dku_ptrbuf; /* pointer to firmware buf */ - uint_t dku_size; /* firmware buf length */ - uint8_t dku_type; /* firmware update type */ -} dk_updatefw_32_t; -#endif /* _SYSCALL32 */ - -/* - * firmware update type - temporary or permanent use - */ -#define FW_TYPE_TEMP 0x0 /* temporary use */ -#define FW_TYPE_PERM 0x1 /* permanent use */ - - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_DKIO_H */ diff --git a/lib/libspl/include/sys/dklabel.h b/lib/libspl/include/sys/dklabel.h deleted file mode 100644 index 409d337e9adf..000000000000 --- a/lib/libspl/include/sys/dklabel.h +++ /dev/null @@ -1,268 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 1990-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_DKLABEL_H -#define _SYS_DKLABEL_H - - - -#include <sys/isa_defs.h> -#include <sys/types32.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Miscellaneous defines - */ -#define DKL_MAGIC 0xDABE /* magic number */ -#define FKL_MAGIC 0xff /* magic number for DOS floppies */ - -#if defined(_SUNOS_VTOC_16) -#define NDKMAP 16 /* # of logical partitions */ -#define DK_LABEL_LOC 1 /* location of disk label */ -#elif defined(_SUNOS_VTOC_8) -#define NDKMAP 8 /* # of logical partitions */ -#define DK_LABEL_LOC 0 /* location of disk label */ -#else -#error "No VTOC format defined." -#endif - -#define LEN_DKL_ASCII 128 /* length of dkl_asciilabel */ -#define LEN_DKL_VVOL 8 /* length of v_volume */ -#define DK_LABEL_SIZE 512 /* size of disk label */ -#define DK_MAX_BLOCKS 0x7fffffff /* max # of blocks handled */ - -/* - * Reserve two cylinders on SCSI disks. - * One is for the backup disk label and the other is for the deviceid. - * - * IPI disks only reserve one cylinder, but they will go away soon. - * CDROMs do not reserve any cylinders. - */ -#define DK_ACYL 2 - -/* - * Format of a Sun disk label. - * Resides in cylinder 0, head 0, sector 0. - * - * sizeof (struct dk_label) should be 512 (the current sector size), - * but should the sector size increase, this structure should remain - * at the beginning of the sector. - */ - -/* - * partition headers: section 1 - * Returned in struct dk_allmap by ioctl DKIOC[SG]APART (dkio(7I)) - */ -struct dk_map { - uint64_t dkl_cylno; /* starting cylinder */ - uint64_t dkl_nblk; /* number of blocks; if == 0, */ - /* partition is undefined */ -}; - -/* - * partition headers: section 1 - * Fixed size for on-disk dk_label - */ -struct dk_map32 { - daddr32_t dkl_cylno; /* starting cylinder */ - daddr32_t dkl_nblk; /* number of blocks; if == 0, */ - /* partition is undefined */ -}; - -/* - * partition headers: section 2, - * brought over from AT&T SVr4 vtoc structure. - */ -struct dk_map2 { - uint16_t p_tag; /* ID tag of partition */ - uint16_t p_flag; /* permission flag */ -}; - -struct dkl_partition { - uint16_t p_tag; /* ID tag of partition */ - uint16_t p_flag; /* permission flags */ - daddr32_t p_start; /* start sector no of partition */ - int32_t p_size; /* # of blocks in partition */ -}; - - -/* - * VTOC inclusions from AT&T SVr4 - * Fixed sized types for on-disk VTOC - */ - -struct dk_vtoc { -#if defined(_SUNOS_VTOC_16) - uint32_t v_bootinfo[3]; /* info for mboot (unsupported) */ - uint32_t v_sanity; /* to verify vtoc sanity */ - uint32_t v_version; /* layout version */ - char v_volume[LEN_DKL_VVOL]; /* volume name */ - uint16_t v_sectorsz; /* sector size in bytes */ - uint16_t v_nparts; /* number of partitions */ - uint32_t v_reserved[10]; /* free space */ - struct dkl_partition v_part[NDKMAP]; /* partition headers */ - time32_t timestamp[NDKMAP]; /* partition timestamp (unsupported) */ - char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */ -#elif defined(_SUNOS_VTOC_8) - uint32_t v_version; /* layout version */ - char v_volume[LEN_DKL_VVOL]; /* volume name */ - uint16_t v_nparts; /* number of partitions */ - struct dk_map2 v_part[NDKMAP]; /* partition hdrs, sec 2 */ - uint32_t v_bootinfo[3]; /* info needed by mboot */ - uint32_t v_sanity; /* to verify vtoc sanity */ - uint32_t v_reserved[10]; /* free space */ - time32_t v_timestamp[NDKMAP]; /* partition timestamp */ -#else -#error "No VTOC format defined." -#endif -}; - -/* - * define the amount of disk label padding needed to make - * the entire structure occupy 512 bytes. - */ -#if defined(_SUNOS_VTOC_16) -#define LEN_DKL_PAD (DK_LABEL_SIZE - \ - ((sizeof (struct dk_vtoc) + \ - (4 * sizeof (uint32_t)) + \ - (12 * sizeof (uint16_t)) + \ - (2 * (sizeof (uint16_t)))))) -#elif defined(_SUNOS_VTOC_8) -#define LEN_DKL_PAD (DK_LABEL_SIZE \ - - ((LEN_DKL_ASCII) + \ - (sizeof (struct dk_vtoc)) + \ - (sizeof (struct dk_map32) * NDKMAP) + \ - (14 * (sizeof (uint16_t))) + \ - (2 * (sizeof (uint16_t))))) -#else -#error "No VTOC format defined." -#endif - - -struct dk_label { -#if defined(_SUNOS_VTOC_16) - struct dk_vtoc dkl_vtoc; /* vtoc inclusions from AT&T SVr4 */ - uint32_t dkl_pcyl; /* # of physical cylinders */ - uint32_t dkl_ncyl; /* # of data cylinders */ - uint16_t dkl_acyl; /* # of alternate cylinders */ - uint16_t dkl_bcyl; /* cyl offset (for fixed head area) */ - uint32_t dkl_nhead; /* # of heads */ - uint32_t dkl_nsect; /* # of data sectors per track */ - uint16_t dkl_intrlv; /* interleave factor */ - uint16_t dkl_skew; /* skew factor */ - uint16_t dkl_apc; /* alternates per cyl (SCSI only) */ - uint16_t dkl_rpm; /* revolutions per minute */ - uint16_t dkl_write_reinstruct; /* # sectors to skip, writes */ - uint16_t dkl_read_reinstruct; /* # sectors to skip, reads */ - uint16_t dkl_extra[4]; /* for compatible expansion */ - char dkl_pad[LEN_DKL_PAD]; /* unused part of 512 bytes */ -#elif defined(_SUNOS_VTOC_8) - char dkl_asciilabel[LEN_DKL_ASCII]; /* for compatibility */ - struct dk_vtoc dkl_vtoc; /* vtoc inclusions from AT&T SVr4 */ - uint16_t dkl_write_reinstruct; /* # sectors to skip, writes */ - uint16_t dkl_read_reinstruct; /* # sectors to skip, reads */ - char dkl_pad[LEN_DKL_PAD]; /* unused part of 512 bytes */ - uint16_t dkl_rpm; /* rotations per minute */ - uint16_t dkl_pcyl; /* # physical cylinders */ - uint16_t dkl_apc; /* alternates per cylinder */ - uint16_t dkl_obs1; /* obsolete */ - uint16_t dkl_obs2; /* obsolete */ - uint16_t dkl_intrlv; /* interleave factor */ - uint16_t dkl_ncyl; /* # of data cylinders */ - uint16_t dkl_acyl; /* # of alternate cylinders */ - uint16_t dkl_nhead; /* # of heads in this partition */ - uint16_t dkl_nsect; /* # of 512 byte sectors per track */ - uint16_t dkl_obs3; /* obsolete */ - uint16_t dkl_obs4; /* obsolete */ - struct dk_map32 dkl_map[NDKMAP]; /* logical partition headers */ -#else -#error "No VTOC format defined." -#endif - uint16_t dkl_magic; /* identifies this label format */ - uint16_t dkl_cksum; /* xor checksum of sector */ -}; - -#if defined(_SUNOS_VTOC_16) -#define dkl_asciilabel dkl_vtoc.v_asciilabel -#define v_timestamp timestamp - -#elif defined(_SUNOS_VTOC_8) - -/* - * These defines are for historic compatibility with old drivers. - */ -#define dkl_gap1 dkl_obs1 /* used to be gap1 */ -#define dkl_gap2 dkl_obs2 /* used to be gap2 */ -#define dkl_bhead dkl_obs3 /* used to be label head offset */ -#define dkl_ppart dkl_obs4 /* used to by physical partition */ -#else -#error "No VTOC format defined." -#endif - -struct fk_label { /* DOS floppy label */ - uchar_t fkl_type; - uchar_t fkl_magich; - uchar_t fkl_magicl; - uchar_t filler; -}; - -/* - * Layout of stored fabricated device id (on-disk) - */ -#define DK_DEVID_BLKSIZE (512) -#define DK_DEVID_SIZE (DK_DEVID_BLKSIZE - ((sizeof (uchar_t) * 7))) -#define DK_DEVID_REV_MSB (0) -#define DK_DEVID_REV_LSB (1) - -struct dk_devid { - uchar_t dkd_rev_hi; /* revision (MSB) */ - uchar_t dkd_rev_lo; /* revision (LSB) */ - uchar_t dkd_flags; /* flags (not used yet) */ - uchar_t dkd_devid[DK_DEVID_SIZE]; /* devid stored here */ - uchar_t dkd_checksum3; /* checksum (MSB) */ - uchar_t dkd_checksum2; - uchar_t dkd_checksum1; - uchar_t dkd_checksum0; /* checksum (LSB) */ -}; - -#define DKD_GETCHKSUM(dkd) ((dkd)->dkd_checksum3 << 24) + \ - ((dkd)->dkd_checksum2 << 16) + \ - ((dkd)->dkd_checksum1 << 8) + \ - ((dkd)->dkd_checksum0) - -#define DKD_FORMCHKSUM(c, dkd) (dkd)->dkd_checksum3 = hibyte(hiword((c))); \ - (dkd)->dkd_checksum2 = lobyte(hiword((c))); \ - (dkd)->dkd_checksum1 = hibyte(loword((c))); \ - (dkd)->dkd_checksum0 = lobyte(loword((c))); -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_DKLABEL_H */ diff --git a/lib/libspl/include/sys/dktp/fdisk.h b/lib/libspl/include/sys/dktp/fdisk.h deleted file mode 100644 index 5e5db04cccfc..000000000000 --- a/lib/libspl/include/sys/dktp/fdisk.h +++ /dev/null @@ -1,174 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -/* Copyright (c) 1984, 1986, 1987, 1988 AT&T */ -/* All Rights Reserved */ - - -#ifndef _SYS_DKTP_FDISK_H -#define _SYS_DKTP_FDISK_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * fdisk.h - * This file defines the structure of physical disk sector 0 for use on - * AT386 systems. The format of this sector is constrained by the ROM - * BIOS and MS-DOS conventions. - * Note that this block does not define the partitions used by the unix - * driver. The unix partitions are obtained from the VTOC. - */ - -/* - * the MAX values are the maximum usable values for BIOS chs values - * The MAX_CYL value of 1022 is the maximum usable value - * the value of 1023 is a fence value, - * indicating no CHS geometry exists for the corresponding LBA value. - * HEAD range [ 0 .. MAX_HEAD ], so number of heads is (MAX_HEAD + 1) - * SECT range [ 1 .. MAX_SECT ], so number of sectors is (MAX_SECT) - */ -#define MAX_SECT (63) -#define MAX_CYL (1022) -#define MAX_HEAD (254) - -/* - * BOOTSZ was reduced from 446 to 440 bytes to NOT overwrite the Windows - * Vista DISKID. Otherwise Vista won't boot from Solaris GRUB in a dual-boot - * setup. - * The actual size of mboot code is 425 bytes while that of GRUB stage1 is - * 423 bytes. So this changes does not harm them. - */ -#define BOOTSZ 440 /* size of boot code in master boot block */ -#define FD_NUMPART 4 /* number of 'partitions' in fdisk table */ -#define MBB_MAGIC 0xAA55 /* magic number for mboot.signature */ -#define DEFAULT_INTLV 4 /* default interleave for testing tracks */ -#define MINPSIZE 4 /* minimum number of cylinders in a partition */ -#define TSTPAT 0xE5 /* test pattern for verifying disk */ - -/* - * structure to hold the fdisk partition table - */ -struct ipart { - unsigned char bootid; /* bootable or not */ - unsigned char beghead; /* beginning head, sector, cylinder */ - unsigned char begsect; /* begcyl is a 10-bit number. High 2 bits */ - unsigned char begcyl; /* are in begsect. */ - unsigned char systid; /* OS type */ - unsigned char endhead; /* ending head, sector, cylinder */ - unsigned char endsect; /* endcyl is a 10-bit number. High 2 bits */ - unsigned char endcyl; /* are in endsect. */ - uint32_t relsect; /* first sector relative to start of disk */ - uint32_t numsect; /* number of sectors in partition */ -}; -/* - * Values for bootid. - */ -#define NOTACTIVE 0 -#define ACTIVE 128 -/* - * Values for systid. - */ -#define UNUSED 0 /* Empty Partition */ -#define DOSOS12 1 /* DOS partition, 12-bit FAT */ -#define PCIXOS 2 /* PC/IX partition */ -#define DOSOS16 4 /* DOS partition, 16-bit FAT */ -#define EXTDOS 5 /* EXT-DOS partition */ -#define DOSHUGE 6 /* Huge DOS partition > 32MB */ -#define FDISK_IFS 7 /* Installable File System (IFS): HPFS & NTFS */ -#define FDISK_AIXBOOT 8 /* AIX Boot */ -#define FDISK_AIXDATA 9 /* AIX Data */ -#define FDISK_OS2BOOT 10 /* OS/2 Boot Manager */ -#define FDISK_WINDOWS 11 /* Windows 95 FAT32 (up to 2047GB) */ -#define FDISK_EXT_WIN 12 /* Windows 95 FAT32 (extended-INT13) */ -#define FDISK_FAT95 14 /* DOS 16-bit FAT, LBA-mapped */ -#define FDISK_EXTLBA 15 /* Extended partition, LBA-mapped */ -#define DIAGPART 18 /* Diagnostic boot partition (OS independent) */ -#define FDISK_LINUX 65 /* Linux */ -#define FDISK_LINUXDSWAP 66 /* Linux swap (sharing disk w/ DRDOS) */ -#define FDISK_LINUXDNAT 67 /* Linux native (sharing disk with DRDOS) */ -#define FDISK_CPM 82 /* CP/M */ -#define DOSDATA 86 /* DOS data partition */ -#define OTHEROS 98 /* part. type for appl. (DB?) needs */ - /* raw partition. ID was 0 but conflicted */ - /* with DOS 3.3 fdisk */ -#define UNIXOS 99 /* UNIX V.x partition */ -#define FDISK_NOVELL2 100 /* Novell Netware 286 */ -#define FDISK_NOVELL3 101 /* Novell Netware 3.x and later */ -#define FDISK_QNX4 119 /* QNX 4.x */ -#define FDISK_QNX42 120 /* QNX 4.x 2nd part */ -#define FDISK_QNX43 121 /* QNX 4.x 3rd part */ -#define SUNIXOS 130 /* Solaris UNIX partition */ -#define FDISK_LINUXNAT 131 /* Linux native */ -#define FDISK_NTFSVOL1 134 /* NTFS volume set 1 */ -#define FDISK_NTFSVOL2 135 /* NTFS volume set 2 */ -#define FDISK_BSD 165 /* BSD/386, 386BSD, NetBSD, FreeBSD, OpenBSD */ -#define FDISK_NEXTSTEP 167 /* NeXTSTEP */ -#define FDISK_BSDIFS 183 /* BSDI file system */ -#define FDISK_BSDISWAP 184 /* BSDI swap */ -#define X86BOOT 190 /* x86 Solaris boot partition */ -#define SUNIXOS2 191 /* Solaris UNIX partition */ -#define EFI_PMBR 238 /* EFI PMBR */ -#define EFI_FS 239 /* EFI File System (System Partition) */ -#define MAXDOS 65535L /* max size (sectors) for DOS partition */ - -/* - * structure to hold master boot block in physical sector 0 of the disk. - * Note that partitions stuff can't be directly included in the structure - * because of lameo '386 compiler alignment design. - * Alignment issues also force us to have 2 16bit entities for a single - * 32bit win_volserno. It is not used anywhere anyway. - */ - -struct mboot { /* master boot block */ - char bootinst[BOOTSZ]; - uint16_t win_volserno_lo; - uint16_t win_volserno_hi; - uint16_t reserved; - char parts[FD_NUMPART * sizeof (struct ipart)]; - ushort_t signature; -}; - -#if defined(__i386) || defined(__amd64) - -/* Byte offset of the start of the partition table within the sector */ -#define FDISK_PART_TABLE_START 446 - -/* Maximum number of valid partitions assumed as 32 */ -#define MAX_EXT_PARTS 32 - -#else - -#define MAX_EXT_PARTS 0 - -#endif /* if defined(__i386) || defined(__amd64) */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_DKTP_FDISK_H */ diff --git a/lib/libspl/include/sys/feature_tests.h b/lib/libspl/include/sys/feature_tests.h deleted file mode 100644 index be7d4ebf9210..000000000000 --- a/lib/libspl/include/sys/feature_tests.h +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_FEATURE_TESTS_H -#define _SYS_FEATURE_TESTS_H - -#define ____cacheline_aligned - -#if !defined(zfs_fallthrough) && !defined(_LIBCPP_VERSION) -#if defined(HAVE_IMPLICIT_FALLTHROUGH) -#define zfs_fallthrough __attribute__((__fallthrough__)) -#else -#define zfs_fallthrough ((void)0) -#endif -#endif - -#endif diff --git a/lib/libspl/include/sys/inttypes.h b/lib/libspl/include/sys/inttypes.h deleted file mode 100644 index 66cf97ac8b5c..000000000000 --- a/lib/libspl/include/sys/inttypes.h +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SOL_SYS_INTTYPES_H -#define _SOL_SYS_INTTYPES_H - -#include <inttypes.h> - -#define _INT64_TYPE - -#endif diff --git a/lib/libspl/include/sys/isa_defs.h b/lib/libspl/include/sys/isa_defs.h deleted file mode 100644 index 99dbc70e4617..000000000000 --- a/lib/libspl/include/sys/isa_defs.h +++ /dev/null @@ -1,294 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_ISA_DEFS_H -#define _SYS_ISA_DEFS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* x86_64 arch specific defines */ -#if defined(__x86_64) || defined(__x86_64__) - -#if !defined(__x86_64) -#define __x86_64 -#endif - -#if !defined(__amd64) -#define __amd64 -#endif - -#if !defined(__x86) -#define __x86 -#endif - -#if defined(_ILP32) -/* x32-specific defines; careful to *not* define _LP64 here */ -#else -#if !defined(_LP64) -#define _LP64 -#endif -#endif - -#if !defined(_ZFS_LITTLE_ENDIAN) -#define _ZFS_LITTLE_ENDIAN -#endif - -#define _SUNOS_VTOC_16 -#define HAVE_EFFICIENT_UNALIGNED_ACCESS - -/* i386 arch specific defines */ -#elif defined(__i386) || defined(__i386__) - -#if !defined(__i386) -#define __i386 -#endif - -#if !defined(__x86) -#define __x86 -#endif - -#if !defined(_ILP32) -#define _ILP32 -#endif - -#if !defined(_ZFS_LITTLE_ENDIAN) -#define _ZFS_LITTLE_ENDIAN -#endif - -#define _SUNOS_VTOC_16 -#define HAVE_EFFICIENT_UNALIGNED_ACCESS - -/* powerpc arch specific defines */ -#elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) - -#if !defined(__powerpc) -#define __powerpc -#endif - -#if !defined(__powerpc__) -#define __powerpc__ -#endif - -#if defined(__powerpc64__) -#if !defined(_LP64) -#define _LP64 -#endif -#else -#if !defined(_ILP32) -#define _ILP32 -#endif -#endif - -#define _SUNOS_VTOC_16 -#define HAVE_EFFICIENT_UNALIGNED_ACCESS - -#if defined(__BYTE_ORDER) -#if defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN -#define _ZFS_BIG_ENDIAN -#elif defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN -#define _ZFS_LITTLE_ENDIAN -#endif -#elif defined(_BYTE_ORDER) -#if defined(_BIG_ENDIAN) && _BYTE_ORDER == _BIG_ENDIAN -#define _ZFS_BIG_ENDIAN -#elif defined(_LITTLE_ENDIAN) && _BYTE_ORDER == _LITTLE_ENDIAN -#define _ZFS_LITTLE_ENDIAN -#endif -#elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) -#define _ZFS_BIG_ENDIAN -#elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) -#define _ZFS_LITTLE_ENDIAN -#endif - -/* arm arch specific defines */ -#elif defined(__arm) || defined(__arm__) - -#if !defined(__arm) -#define __arm -#endif - -#if !defined(__arm__) -#define __arm__ -#endif - -#if !defined(_ILP32) -#define _ILP32 -#endif - -#if defined(__ARMEL__) -#define _ZFS_LITTLE_ENDIAN -#else -#define _ZFS_BIG_ENDIAN -#endif - -#define _SUNOS_VTOC_16 - -#if defined(__ARM_FEATURE_UNALIGNED) -#define HAVE_EFFICIENT_UNALIGNED_ACCESS -#endif - -/* aarch64 arch specific defines */ -#elif defined(__aarch64__) - -#if !defined(_LP64) -#define _LP64 -#endif - -#if defined(__AARCH64EL__) -#define _ZFS_LITTLE_ENDIAN -#else -#define _ZFS_BIG_ENDIAN -#endif - -#define _SUNOS_VTOC_16 - -/* sparc arch specific defines */ -#elif defined(__sparc) || defined(__sparc__) - -#if !defined(__sparc) -#define __sparc -#endif - -#if !defined(__sparc__) -#define __sparc__ -#endif - -#define _ZFS_BIG_ENDIAN -#define _SUNOS_VTOC_16 - -#if defined(__arch64__) -#if !defined(_LP64) -#define _LP64 -#endif -#else -#if !defined(_ILP32) -#define _ILP32 -#endif -#endif - -/* s390 arch specific defines */ -#elif defined(__s390__) -#if defined(__s390x__) -#if !defined(_LP64) -#define _LP64 -#endif -#else -#if !defined(_ILP32) -#define _ILP32 -#endif -#endif - -#define _ZFS_BIG_ENDIAN -#define _SUNOS_VTOC_16 - -/* MIPS arch specific defines */ -#elif defined(__mips__) - -#if defined(__MIPSEB__) -#define _ZFS_BIG_ENDIAN -#elif defined(__MIPSEL__) -#define _ZFS_LITTLE_ENDIAN -#else -#error MIPS no endian specified -#endif - -#if !defined(_LP64) && !defined(_ILP32) -#define _ILP32 -#endif - -#define _SUNOS_VTOC_16 - -/* - * RISC-V arch specific defines - * only RV64G (including atomic) LP64 is supported yet - */ -#elif defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64 && \ - defined(__riscv_atomic) && __riscv_atomic - -#if !defined(_LP64) -#define _LP64 1 -#endif - -#ifndef __riscv__ -#define __riscv__ -#endif - -#ifndef __rv64g__ -#define __rv64g__ -#endif - -#define _ZFS_LITTLE_ENDIAN - -#define _SUNOS_VTOC_16 - -/* - * LoongArch arch specific defines - * only LoongArch64 is supported yet - */ -#elif defined(__loongarch__) && defined(__loongarch_lp64) - -#if !defined(_LP64) -#define _LP64 -#endif - -#define _ZFS_LITTLE_ENDIAN -#define _SUNOS_VTOC_16 - -/* not all LoongArch cores support unaligned accesses in hardware */ -#define _ALIGNMENT_REQUIRED 1 - -#else -/* - * Currently supported: - * x86_64, x32, i386, arm, powerpc, s390, sparc, mips, RV64G, and LoongArch64 - */ -#error "Unsupported ISA type" -#endif - -#if defined(_ILP32) && defined(_LP64) -#error "Both _ILP32 and _LP64 are defined" -#endif - -#if !defined(_ILP32) && !defined(_LP64) -#error "Neither _ILP32 or _LP64 are defined" -#endif - -#if defined(_ZFS_LITTLE_ENDIAN) && defined(_ZFS_BIG_ENDIAN) -#error "Both _ZFS_LITTLE_ENDIAN and _ZFS_BIG_ENDIAN are defined" -#endif - -#if !defined(_ZFS_LITTLE_ENDIAN) && !defined(_ZFS_BIG_ENDIAN) -#error "Neither _ZFS_LITTLE_ENDIAN nor _ZFS_BIG_ENDIAN are defined" -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_ISA_DEFS_H */ diff --git a/lib/libspl/include/sys/kmem.h b/lib/libspl/include/sys/kmem.h deleted file mode 100644 index 279461f8d4c1..000000000000 --- a/lib/libspl/include/sys/kmem.h +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_KMEM_H -#define _SYS_KMEM_H - -#include <stdlib.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define KM_SLEEP 0x00000000 /* same as KM_SLEEP */ -#define KM_NOSLEEP 0x00000001 /* same as KM_NOSLEEP */ - -#define kmem_alloc(size, flags) ((void) sizeof (flags), malloc(size)) -#define kmem_free(ptr, size) ((void) sizeof (size), free(ptr)) - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_KMEM_H */ diff --git a/lib/libspl/include/sys/kstat.h b/lib/libspl/include/sys/kstat.h deleted file mode 100644 index 7777888c31eb..000000000000 --- a/lib/libspl/include/sys/kstat.h +++ /dev/null @@ -1,784 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_KSTAT_H -#define _SYS_KSTAT_H - - - -/* - * Definition of general kernel statistics structures and /dev/kstat ioctls - */ - -#include <sys/types.h> -#include <sys/time.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef int kid_t; /* unique kstat id */ - -/* - * Kernel statistics driver (/dev/kstat) ioctls - */ - -#define KSTAT_IOC_BASE ('K' << 8) - -#define KSTAT_IOC_CHAIN_ID KSTAT_IOC_BASE | 0x01 -#define KSTAT_IOC_READ KSTAT_IOC_BASE | 0x02 -#define KSTAT_IOC_WRITE KSTAT_IOC_BASE | 0x03 - -/* - * /dev/kstat ioctl usage (kd denotes /dev/kstat descriptor): - * - * kcid = ioctl(kd, KSTAT_IOC_CHAIN_ID, NULL); - * kcid = ioctl(kd, KSTAT_IOC_READ, kstat_t *); - * kcid = ioctl(kd, KSTAT_IOC_WRITE, kstat_t *); - */ - -#define KSTAT_STRLEN 255 /* 254 chars + NULL; must be 16 * n - 1 */ - -/* - * The generic kstat header - */ - -typedef struct kstat { - /* - * Fields relevant to both kernel and user - */ - hrtime_t ks_crtime; /* creation time (from gethrtime()) */ - struct kstat *ks_next; /* kstat chain linkage */ - kid_t ks_kid; /* unique kstat ID */ - char ks_module[KSTAT_STRLEN]; /* provider module name */ - uchar_t ks_resv; /* reserved, currently just padding */ - int ks_instance; /* provider module's instance */ - char ks_name[KSTAT_STRLEN]; /* kstat name */ - uchar_t ks_type; /* kstat data type */ - char ks_class[KSTAT_STRLEN]; /* kstat class */ - uchar_t ks_flags; /* kstat flags */ - void *ks_data; /* kstat type-specific data */ - uint_t ks_ndata; /* # of type-specific data records */ - size_t ks_data_size; /* total size of kstat data section */ - hrtime_t ks_snaptime; /* time of last data snapshot */ - /* - * Fields relevant to kernel only - */ - int (*ks_update)(struct kstat *, int); /* dynamic update */ - void *ks_private; /* arbitrary provider-private data */ - int (*ks_snapshot)(struct kstat *, void *, int); - void *ks_lock; /* protects this kstat's data */ -} kstat_t; - -/* - * kstat structure and locking strategy - * - * Each kstat consists of a header section (a kstat_t) and a data section. - * The system maintains a set of kstats, protected by kstat_chain_lock. - * kstat_chain_lock protects all additions to/deletions from this set, - * as well as all changes to kstat headers. kstat data sections are - * *optionally* protected by the per-kstat ks_lock. If ks_lock is non-NULL, - * kstat clients (e.g. /dev/kstat) will acquire this lock for all of their - * operations on that kstat. It is up to the kstat provider to decide whether - * guaranteeing consistent data to kstat clients is sufficiently important - * to justify the locking cost. Note, however, that most statistic updates - * already occur under one of the provider's mutexes, so if the provider sets - * ks_lock to point to that mutex, then kstat data locking is free. - * - * NOTE: variable-size kstats MUST employ kstat data locking, to prevent - * data-size races with kstat clients. - * - * NOTE: ks_lock is really of type (kmutex_t *); it is declared as (void *) - * in the kstat header so that users don't have to be exposed to all of the - * kernel's lock-related data structures. - */ - -#if defined(_KERNEL) - -#define KSTAT_ENTER(k) \ - { kmutex_t *lp = (k)->ks_lock; if (lp) mutex_enter(lp); } - -#define KSTAT_EXIT(k) \ - { kmutex_t *lp = (k)->ks_lock; if (lp) mutex_exit(lp); } - -#define KSTAT_UPDATE(k, rw) (*(k)->ks_update)((k), (rw)) - -#define KSTAT_SNAPSHOT(k, buf, rw) (*(k)->ks_snapshot)((k), (buf), (rw)) - -#endif /* defined(_KERNEL) */ - -/* - * kstat time - * - * All times associated with kstats (e.g. creation time, snapshot time, - * kstat_timer_t and kstat_io_t timestamps, etc.) are 64-bit nanosecond values, - * as returned by gethrtime(). The accuracy of these timestamps is machine - * dependent, but the precision (units) is the same across all platforms. - */ - -/* - * kstat identity (KID) - * - * Each kstat is assigned a unique KID (kstat ID) when it is added to the - * global kstat chain. The KID is used as a cookie by /dev/kstat to - * request information about the corresponding kstat. There is also - * an identity associated with the entire kstat chain, kstat_chain_id, - * which is bumped each time a kstat is added or deleted. /dev/kstat uses - * the chain ID to detect changes in the kstat chain (e.g., a new disk - * coming online) between ioctl()s. - */ - -/* - * kstat module, kstat instance - * - * ks_module and ks_instance contain the name and instance of the module - * that created the kstat. In cases where there can only be one instance, - * ks_instance is 0. The kernel proper (/kernel/unix) uses "unix" as its - * module name. - */ - -/* - * kstat name - * - * ks_name gives a meaningful name to a kstat. The full kstat namespace - * is module.instance.name, so the name only need be unique within a - * module. kstat_create() will fail if you try to create a kstat with - * an already-used (ks_module, ks_instance, ks_name) triplet. Spaces are - * allowed in kstat names, but strongly discouraged, since they hinder - * awk-style processing at user level. - */ - -/* - * kstat type - * - * The kstat mechanism provides several flavors of kstat data, defined - * below. The "raw" kstat type is just treated as an array of bytes; you - * can use this to export any kind of data you want. - * - * Some kstat types allow multiple data structures per kstat, e.g. - * KSTAT_TYPE_NAMED; others do not. This is part of the spec for each - * kstat data type. - * - * User-level tools should *not* rely on the #define KSTAT_NUM_TYPES. To - * get this information, read out the standard system kstat "kstat_types". - */ - -#define KSTAT_TYPE_RAW 0 /* can be anything */ - /* ks_ndata >= 1 */ -#define KSTAT_TYPE_NAMED 1 /* name/value pair */ - /* ks_ndata >= 1 */ -#define KSTAT_TYPE_INTR 2 /* interrupt statistics */ - /* ks_ndata == 1 */ -#define KSTAT_TYPE_IO 3 /* I/O statistics */ - /* ks_ndata == 1 */ -#define KSTAT_TYPE_TIMER 4 /* event timer */ - /* ks_ndata >= 1 */ - -#define KSTAT_NUM_TYPES 5 - -/* - * kstat class - * - * Each kstat can be characterized as belonging to some broad class - * of statistics, e.g. disk, tape, net, vm, streams, etc. This field - * can be used as a filter to extract related kstats. The following - * values are currently in use: disk, tape, net, controller, vm, kvm, - * hat, streams, kstat, and misc. (The kstat class encompasses things - * like kstat_types.) - */ - -/* - * kstat flags - * - * Any of the following flags may be passed to kstat_create(). They are - * all zero by default. - * - * KSTAT_FLAG_VIRTUAL: - * - * Tells kstat_create() not to allocate memory for the - * kstat data section; instead, you will set the ks_data - * field to point to the data you wish to export. This - * provides a convenient way to export existing data - * structures. - * - * KSTAT_FLAG_VAR_SIZE: - * - * The size of the kstat you are creating will vary over time. - * For example, you may want to use the kstat mechanism to - * export a linked list. NOTE: The kstat framework does not - * manage the data section, so all variable-size kstats must be - * virtual kstats. Moreover, variable-size kstats MUST employ - * kstat data locking to prevent data-size races with kstat - * clients. See the section on "kstat snapshot" for details. - * - * KSTAT_FLAG_WRITABLE: - * - * Makes the kstat's data section writable by root. - * The ks_snapshot routine (see below) does not need to check for - * this; permission checking is handled in the kstat driver. - * - * KSTAT_FLAG_PERSISTENT: - * - * Indicates that this kstat is to be persistent over time. - * For persistent kstats, kstat_delete() simply marks the - * kstat as dormant; a subsequent kstat_create() reactivates - * the kstat. This feature is provided so that statistics - * are not lost across driver close/open (e.g., raw disk I/O - * on a disk with no mounted partitions.) - * NOTE: Persistent kstats cannot be virtual, since ks_data - * points to garbage as soon as the driver goes away. - * - * The following flags are maintained by the kstat framework: - * - * KSTAT_FLAG_DORMANT: - * - * For persistent kstats, indicates that the kstat is in the - * dormant state (e.g., the corresponding device is closed). - * - * KSTAT_FLAG_INVALID: - * - * This flag is set when a kstat is in a transitional state, - * e.g. between kstat_create() and kstat_install(). - * kstat clients must not attempt to access the kstat's data - * if this flag is set. - */ - -#define KSTAT_FLAG_VIRTUAL 0x01 -#define KSTAT_FLAG_VAR_SIZE 0x02 -#define KSTAT_FLAG_WRITABLE 0x04 -#define KSTAT_FLAG_PERSISTENT 0x08 -#define KSTAT_FLAG_DORMANT 0x10 -#define KSTAT_FLAG_INVALID 0x20 -#define KSTAT_FLAG_LONGSTRINGS 0x40 -#define KSTAT_FLAG_NO_HEADERS 0x80 - -/* - * Dynamic update support - * - * The kstat mechanism allows for an optional ks_update function to update - * kstat data. This is useful for drivers where the underlying device - * keeps cheap hardware stats, but extraction is expensive. Instead of - * constantly keeping the kstat data section up to date, you can supply a - * ks_update function which updates the kstat's data section on demand. - * To take advantage of this feature, simply set the ks_update field before - * calling kstat_install(). - * - * The ks_update function, if supplied, must have the following structure: - * - * int - * foo_kstat_update(kstat_t *ksp, int rw) - * { - * if (rw == KSTAT_WRITE) { - * ... update the native stats from ksp->ks_data; - * return EACCES if you don't support this - * } else { - * ... update ksp->ks_data from the native stats - * } - * } - * - * The ks_update return codes are: 0 for success, EACCES if you don't allow - * KSTAT_WRITE, and EIO for any other type of error. - * - * In general, the ks_update function may need to refer to provider-private - * data; for example, it may need a pointer to the provider's raw statistics. - * The ks_private field is available for this purpose. Its use is entirely - * at the provider's discretion. - * - * All variable-size kstats MUST supply a ks_update routine, which computes - * and sets ks_data_size (and ks_ndata if that is meaningful), since these - * are needed to perform kstat snapshots (see below). - * - * No kstat locking should be done inside the ks_update routine. The caller - * will already be holding the kstat's ks_lock (to ensure consistent data). - */ - -#define KSTAT_READ 0 -#define KSTAT_WRITE 1 - -/* - * Kstat snapshot - * - * In order to get a consistent view of a kstat's data, clients must obey - * the kstat's locking strategy. However, these clients may need to perform - * operations on the data which could cause a fault (e.g. copyout()), or - * operations which are simply expensive. Doing so could cause deadlock - * (e.g. if you're holding a disk's kstat lock which is ultimately required - * to resolve a copyout() fault), performance degradation (since the providers' - * activity is serialized at the kstat lock), device timing problems, etc. - * - * To avoid these problems, kstat data is provided via snapshots. Taking - * a snapshot is a simple process: allocate a wired-down kernel buffer, - * acquire the kstat's data lock, copy the data into the buffer ("take the - * snapshot"), and release the lock. This ensures that the kstat's data lock - * will be held as briefly as possible, and that no faults will occur while - * the lock is held. - * - * Normally, the snapshot is taken by default_kstat_snapshot(), which - * timestamps the data (sets ks_snaptime), copies it, and does a little - * massaging to deal with incomplete transactions on i/o kstats. However, - * this routine only works for kstats with contiguous data (the typical case). - * If you create a kstat whose data is, say, a linked list, you must provide - * your own ks_snapshot routine. The routine you supply must have the - * following prototype (replace "foo" with something appropriate): - * - * int foo_kstat_snapshot(kstat_t *ksp, void *buf, int rw); - * - * The minimal snapshot routine -- one which copies contiguous data that - * doesn't need any massaging -- would be this: - * - * ksp->ks_snaptime = gethrtime(); - * if (rw == KSTAT_WRITE) - * memcpy(ksp->ks_data, buf, ksp->ks_data_size); - * else - * memcpy(buf, ksp->ks_data, ksp->ks_data_size); - * return (0); - * - * A more illuminating example is taking a snapshot of a linked list: - * - * ksp->ks_snaptime = gethrtime(); - * if (rw == KSTAT_WRITE) - * return (EACCES); ... See below ... - * for (foo = first_foo; foo; foo = foo->next) { - * memcpy(buf, foo, sizeof (struct foo)); - * buf = ((struct foo *) buf) + 1; - * } - * return (0); - * - * In the example above, we have decided that we don't want to allow - * KSTAT_WRITE access, so we return EACCES if this is attempted. - * - * The key points are: - * - * (1) ks_snaptime must be set (via gethrtime()) to timestamp the data. - * (2) Data gets copied from the kstat to the buffer on KSTAT_READ, - * and from the buffer to the kstat on KSTAT_WRITE. - * (3) ks_snapshot return values are: 0 for success, EACCES if you - * don't allow KSTAT_WRITE, and EIO for any other type of error. - * - * Named kstats (see section on "Named statistics" below) containing long - * strings (KSTAT_DATA_STRING) need special handling. The kstat driver - * assumes that all strings are copied into the buffer after the array of - * named kstats, and the pointers (KSTAT_NAMED_STR_PTR()) are updated to point - * into the copy within the buffer. The default snapshot routine does this, - * but overriding routines should contain at least the following: - * - * if (rw == KSTAT_READ) { - * kstat_named_t *knp = buf; - * char *end = knp + ksp->ks_ndata; - * uint_t i; - * - * ... Do the regular copy ... - * memcpy(buf, ksp->ks_data, sizeof (kstat_named_t) * ksp->ks_ndata); - * - * for (i = 0; i < ksp->ks_ndata; i++, knp++) { - * if (knp[i].data_type == KSTAT_DATA_STRING && - * KSTAT_NAMED_STR_PTR(knp) != NULL) { - * memcpy(end, KSTAT_NAMED_STR_PTR(knp), - * KSTAT_NAMED_STR_BUFLEN(knp)); - * KSTAT_NAMED_STR_PTR(knp) = end; - * end += KSTAT_NAMED_STR_BUFLEN(knp); - * } - * } - */ - -/* - * Named statistics. - * - * List of arbitrary name=value statistics. - */ - -typedef struct kstat_named { - char name[KSTAT_STRLEN]; /* name of counter */ - uchar_t data_type; /* data type */ - union { - char c[16]; /* enough for 128-bit ints */ - int32_t i32; - uint32_t ui32; - struct { - union { - char *ptr; /* NULL-term string */ -#if defined(_KERNEL) && defined(_MULTI_DATAMODEL) - caddr32_t ptr32; -#endif - char __pad[8]; /* 64-bit padding */ - } addr; - uint32_t len; /* # bytes for strlen + '\0' */ - } str; -/* - * The int64_t and uint64_t types are not valid for a maximally conformant - * 32-bit compilation environment (cc -Xc) using compilers prior to the - * introduction of C99 conforming compiler (reference ISO/IEC 9899:1990). - * In these cases, the visibility of i64 and ui64 is only permitted for - * 64-bit compilation environments or 32-bit non-maximally conformant - * C89 or C90 ANSI C compilation environments (cc -Xt and cc -Xa). In the - * C99 ANSI C compilation environment, the long long type is supported. - * The _INT64_TYPE is defined by the implementation (see sys/inttypes.h). - */ -#if defined(_INT64_TYPE) - int64_t i64; - uint64_t ui64; -#endif - long l; - ulong_t ul; - - /* These structure members are obsolete */ - - longlong_t ll; - u_longlong_t ull; - float f; - double d; - } value; /* value of counter */ -} kstat_named_t; - -#define KSTAT_DATA_CHAR 0 -#define KSTAT_DATA_INT32 1 -#define KSTAT_DATA_UINT32 2 -#define KSTAT_DATA_INT64 3 -#define KSTAT_DATA_UINT64 4 - -#if !defined(_LP64) -#define KSTAT_DATA_LONG KSTAT_DATA_INT32 -#define KSTAT_DATA_ULONG KSTAT_DATA_UINT32 -#else -#if !defined(_KERNEL) -#define KSTAT_DATA_LONG KSTAT_DATA_INT64 -#define KSTAT_DATA_ULONG KSTAT_DATA_UINT64 -#else -#define KSTAT_DATA_LONG 7 /* only visible to the kernel */ -#define KSTAT_DATA_ULONG 8 /* only visible to the kernel */ -#endif /* !_KERNEL */ -#endif /* !_LP64 */ - -/* - * Statistics exporting named kstats with long strings (KSTAT_DATA_STRING) - * may not make the assumption that ks_data_size is equal to (ks_ndata * sizeof - * (kstat_named_t)). ks_data_size in these cases is equal to the sum of the - * amount of space required to store the strings (ie, the sum of - * KSTAT_NAMED_STR_BUFLEN() for all KSTAT_DATA_STRING statistics) plus the - * space required to store the kstat_named_t's. - * - * The default update routine will update ks_data_size automatically for - * variable-length kstats containing long strings (using the default update - * routine only makes sense if the string is the only thing that is changing - * in size, and ks_ndata is constant). Fixed-length kstats containing long - * strings must explicitly change ks_data_size (after creation but before - * initialization) to reflect the correct amount of space required for the - * long strings and the kstat_named_t's. - */ -#define KSTAT_DATA_STRING 9 - -/* These types are obsolete */ - -#define KSTAT_DATA_LONGLONG KSTAT_DATA_INT64 -#define KSTAT_DATA_ULONGLONG KSTAT_DATA_UINT64 -#define KSTAT_DATA_FLOAT 5 -#define KSTAT_DATA_DOUBLE 6 - -#define KSTAT_NAMED_PTR(kptr) ((kstat_named_t *)(kptr)->ks_data) - -/* - * Retrieve the pointer of the string contained in the given named kstat. - */ -#define KSTAT_NAMED_STR_PTR(knptr) ((knptr)->value.str.addr.ptr) - -/* - * Retrieve the length of the buffer required to store the string in the given - * named kstat. - */ -#define KSTAT_NAMED_STR_BUFLEN(knptr) ((knptr)->value.str.len) - -/* - * Interrupt statistics. - * - * An interrupt is a hard interrupt (sourced from the hardware device - * itself), a soft interrupt (induced by the system via the use of - * some system interrupt source), a watchdog interrupt (induced by - * a periodic timer call), spurious (an interrupt entry point was - * entered but there was no interrupt condition to service), - * or multiple service (an interrupt condition was detected and - * serviced just prior to returning from any of the other types). - * - * Measurement of the spurious class of interrupts is useful for - * autovectored devices in order to pinpoint any interrupt latency - * problems in a particular system configuration. - * - * Devices that have more than one interrupt of the same - * type should use multiple structures. - */ - -#define KSTAT_INTR_HARD 0 -#define KSTAT_INTR_SOFT 1 -#define KSTAT_INTR_WATCHDOG 2 -#define KSTAT_INTR_SPURIOUS 3 -#define KSTAT_INTR_MULTSVC 4 - -#define KSTAT_NUM_INTRS 5 - -typedef struct kstat_intr { - uint_t intrs[KSTAT_NUM_INTRS]; /* interrupt counters */ -} kstat_intr_t; - -#define KSTAT_INTR_PTR(kptr) ((kstat_intr_t *)(kptr)->ks_data) - -/* - * I/O statistics. - */ - -typedef struct kstat_io { - - /* - * Basic counters. - * - * The counters should be updated at the end of service - * (e.g., just prior to calling biodone()). - */ - - u_longlong_t nread; /* number of bytes read */ - u_longlong_t nwritten; /* number of bytes written */ - uint_t reads; /* number of read operations */ - uint_t writes; /* number of write operations */ - - /* - * Accumulated time and queue length statistics. - * - * Accumulated time statistics are kept as a running sum - * of "active" time. Queue length statistics are kept as a - * running sum of the product of queue length and elapsed time - * at that length -- i.e., a Riemann sum for queue length - * integrated against time. (You can also think of the active time - * as a Riemann sum, for the boolean function (queue_length > 0) - * integrated against time, or you can think of it as the - * Lebesgue measure of the set on which queue_length > 0.) - * - * ^ - * | _________ - * 8 | i4 | - * | | | - * Queue 6 | | - * Length | _________ | | - * 4 | i2 |_______| | - * | | i3 | - * 2_______| | - * | i1 | - * |_______________________________| - * Time-> t1 t2 t3 t4 - * - * At each change of state (entry or exit from the queue), - * we add the elapsed time (since the previous state change) - * to the active time if the queue length was non-zero during - * that interval; and we add the product of the elapsed time - * times the queue length to the running length*time sum. - * - * This method is generalizable to measuring residency - * in any defined system: instead of queue lengths, think - * of "outstanding RPC calls to server X". - * - * A large number of I/O subsystems have at least two basic - * "lists" of transactions they manage: one for transactions - * that have been accepted for processing but for which processing - * has yet to begin, and one for transactions which are actively - * being processed (but not done). For this reason, two cumulative - * time statistics are defined here: wait (pre-service) time, - * and run (service) time. - * - * All times are 64-bit nanoseconds (hrtime_t), as returned by - * gethrtime(). - * - * The units of cumulative busy time are accumulated nanoseconds. - * The units of cumulative length*time products are elapsed time - * times queue length. - * - * Updates to the fields below are performed implicitly by calls to - * these five functions: - * - * kstat_waitq_enter() - * kstat_waitq_exit() - * kstat_runq_enter() - * kstat_runq_exit() - * - * kstat_waitq_to_runq() (see below) - * kstat_runq_back_to_waitq() (see below) - * - * Since kstat_waitq_exit() is typically followed immediately - * by kstat_runq_enter(), there is a single kstat_waitq_to_runq() - * function which performs both operations. This is a performance - * win since only one timestamp is required. - * - * In some instances, it may be necessary to move a request from - * the run queue back to the wait queue, e.g. for write throttling. - * For these situations, call kstat_runq_back_to_waitq(). - * - * These fields should never be updated by any other means. - */ - - hrtime_t wtime; /* cumulative wait (pre-service) time */ - hrtime_t wlentime; /* cumulative wait length*time product */ - hrtime_t wlastupdate; /* last time wait queue changed */ - hrtime_t rtime; /* cumulative run (service) time */ - hrtime_t rlentime; /* cumulative run length*time product */ - hrtime_t rlastupdate; /* last time run queue changed */ - - uint_t wcnt; /* count of elements in wait state */ - uint_t rcnt; /* count of elements in run state */ - -} kstat_io_t; - -#define KSTAT_IO_PTR(kptr) ((kstat_io_t *)(kptr)->ks_data) - -/* - * Event timer statistics - cumulative elapsed time and number of events. - * - * Updates to these fields are performed implicitly by calls to - * kstat_timer_start() and kstat_timer_stop(). - */ - -typedef struct kstat_timer { - char name[KSTAT_STRLEN]; /* event name */ - uchar_t resv; /* reserved */ - u_longlong_t num_events; /* number of events */ - hrtime_t elapsed_time; /* cumulative elapsed time */ - hrtime_t min_time; /* shortest event duration */ - hrtime_t max_time; /* longest event duration */ - hrtime_t start_time; /* previous event start time */ - hrtime_t stop_time; /* previous event stop time */ -} kstat_timer_t; - -#define KSTAT_TIMER_PTR(kptr) ((kstat_timer_t *)(kptr)->ks_data) - -#if defined(_KERNEL) - -#include <sys/t_lock.h> - -extern kid_t kstat_chain_id; /* bumped at each state change */ -extern void kstat_init(void); /* initialize kstat framework */ - -/* - * Adding and deleting kstats. - * - * The typical sequence to add a kstat is: - * - * ksp = kstat_create(module, instance, name, class, type, ndata, flags); - * if (ksp) { - * ... provider initialization, if necessary - * kstat_install(ksp); - * } - * - * There are three logically distinct steps here: - * - * Step 1: System Initialization (kstat_create) - * - * kstat_create() performs system initialization. kstat_create() - * allocates memory for the entire kstat (header plus data), initializes - * all header fields, initializes the data section to all zeroes, assigns - * a unique KID, and puts the kstat onto the system's kstat chain. - * The returned kstat is marked invalid (KSTAT_FLAG_INVALID is set), - * because the provider (caller) has not yet had a chance to initialize - * the data section. - * - * By default, kstats are exported to all zones on the system. A kstat may be - * created via kstat_create_zone() to specify a zone to which the statistics - * should be exported. kstat_zone_add() may be used to specify additional - * zones to which the statistics are to be exported. - * - * Step 2: Provider Initialization - * - * The provider performs any necessary initialization of the data section, - * e.g. setting the name fields in a KSTAT_TYPE_NAMED. Virtual kstats set - * the ks_data field at this time. The provider may also set the ks_update, - * ks_snapshot, ks_private, and ks_lock fields if necessary. - * - * Step 3: Installation (kstat_install) - * - * Once the kstat is completely initialized, kstat_install() clears the - * INVALID flag, thus making the kstat accessible to the outside world. - * kstat_install() also clears the DORMANT flag for persistent kstats. - * - * Removing a kstat from the system - * - * kstat_delete(ksp) removes ksp from the kstat chain and frees all - * associated system resources. NOTE: When you call kstat_delete(), - * you must NOT be holding that kstat's ks_lock. Otherwise, you may - * deadlock with a kstat reader. - * - * Persistent kstats - * - * From the provider's point of view, persistence is transparent. The only - * difference between ephemeral (normal) kstats and persistent kstats - * is that you pass KSTAT_FLAG_PERSISTENT to kstat_create(). Magically, - * this has the effect of making your data visible even when you're - * not home. Persistence is important to tools like iostat, which want - * to get a meaningful picture of disk activity. Without persistence, - * raw disk i/o statistics could never accumulate: they would come and - * go with each open/close of the raw device. - * - * The magic of persistence works by slightly altering the behavior of - * kstat_create() and kstat_delete(). The first call to kstat_create() - * creates a new kstat, as usual. However, kstat_delete() does not - * actually delete the kstat: it performs one final update of the data - * (i.e., calls the ks_update routine), marks the kstat as dormant, and - * sets the ks_lock, ks_update, ks_private, and ks_snapshot fields back - * to their default values (since they might otherwise point to garbage, - * e.g. if the provider is going away). kstat clients can still access - * the dormant kstat just like a live kstat; they just continue to see - * the final data values as long as the kstat remains dormant. - * All subsequent kstat_create() calls simply find the already-existing, - * dormant kstat and return a pointer to it, without altering any fields. - * The provider then performs its usual initialization sequence, and - * calls kstat_install(). kstat_install() uses the old data values to - * initialize the native data (i.e., ks_update is called with KSTAT_WRITE), - * thus making it seem like you were never gone. - */ - -extern kstat_t *kstat_create(const char *, int, const char *, const char *, - uchar_t, uint_t, uchar_t); -extern kstat_t *kstat_create_zone(const char *, int, const char *, - const char *, uchar_t, uint_t, uchar_t, zoneid_t); -extern void kstat_install(kstat_t *); -extern void kstat_delete(kstat_t *); -extern void kstat_named_setstr(kstat_named_t *knp, const char *src); -extern void kstat_set_string(char *, const char *); -extern void kstat_delete_byname(const char *, int, const char *); -extern void kstat_delete_byname_zone(const char *, int, const char *, zoneid_t); -extern void kstat_named_init(kstat_named_t *, const char *, uchar_t); -extern void kstat_timer_init(kstat_timer_t *, const char *); -extern void kstat_timer_start(kstat_timer_t *); -extern void kstat_timer_stop(kstat_timer_t *); - -extern void kstat_zone_add(kstat_t *, zoneid_t); -extern void kstat_zone_remove(kstat_t *, zoneid_t); -extern int kstat_zone_find(kstat_t *, zoneid_t); - -extern kstat_t *kstat_hold_bykid(kid_t kid, zoneid_t); -extern kstat_t *kstat_hold_byname(const char *, int, const char *, zoneid_t); -extern void kstat_rele(kstat_t *); - -#endif /* defined(_KERNEL) */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_KSTAT_H */ diff --git a/lib/libspl/include/sys/list.h b/lib/libspl/include/sys/list.h deleted file mode 100644 index cbbda85dabb5..000000000000 --- a/lib/libspl/include/sys/list.h +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_LIST_H -#define _SYS_LIST_H - -#include <sys/list_impl.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct list_node list_node_t; -typedef struct list list_t; - -void list_create(list_t *, size_t, size_t); -void list_destroy(list_t *); - -void list_insert_after(list_t *, void *, void *); -void list_insert_before(list_t *, void *, void *); -void list_insert_head(list_t *, void *); -void list_insert_tail(list_t *, void *); -void list_remove(list_t *, void *); -void *list_remove_head(list_t *); -void *list_remove_tail(list_t *); -void list_move_tail(list_t *, list_t *); - -void *list_head(list_t *); -void *list_tail(list_t *); -void *list_next(list_t *, void *); -void *list_prev(list_t *, void *); -int list_is_empty(list_t *); - -void list_link_init(list_node_t *); -void list_link_replace(list_node_t *, list_node_t *); - -int list_link_active(list_node_t *); - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_LIST_H */ diff --git a/lib/libspl/include/sys/list_impl.h b/lib/libspl/include/sys/list_impl.h deleted file mode 100644 index 10683adab325..000000000000 --- a/lib/libspl/include/sys/list_impl.h +++ /dev/null @@ -1,51 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_LIST_IMPL_H -#define _SYS_LIST_IMPL_H - -#include <sys/types.h> - -#ifdef __cplusplus -extern "C" { -#endif - -struct list_node { - struct list_node *next; - struct list_node *prev; -}; - -struct list { - size_t list_offset; - struct list_node list_head; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_LIST_IMPL_H */ diff --git a/lib/libspl/include/sys/mhd.h b/lib/libspl/include/sys/mhd.h deleted file mode 100644 index 82ec436750ef..000000000000 --- a/lib/libspl/include/sys/mhd.h +++ /dev/null @@ -1,160 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_MHD_H -#define _SYS_MHD_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Definitions for multi-host device I/O control commands - */ -#define MHIOC ('M'<<8) -#define MHIOCENFAILFAST (MHIOC|1) -#define MHIOCTKOWN (MHIOC|2) -#define MHIOCRELEASE (MHIOC|3) -#define MHIOCSTATUS (MHIOC|4) -#define MHIOCGRP_INKEYS (MHIOC|5) -#define MHIOCGRP_INRESV (MHIOC|6) -#define MHIOCGRP_REGISTER (MHIOC|7) -#define MHIOCGRP_RESERVE (MHIOC|8) -#define MHIOCGRP_PREEMPTANDABORT (MHIOC|9) -#define MHIOCGRP_PREEMPT (MHIOC|10) -#define MHIOCGRP_CLEAR (MHIOC|11) -#define MHIOCGRP_REGISTERANDIGNOREKEY (MHIOC|14) -#define MHIOCQRESERVE (MHIOC|12) -#define MHIOCREREGISTERDEVID (MHIOC|13) - -/* - * Following is the structure to specify the delay parameters in - * milliseconds, via the MHIOCTKOWN ioctl. - */ -struct mhioctkown { - int reinstate_resv_delay; - int min_ownership_delay; - int max_ownership_delay; -}; - -#define MHIOC_RESV_KEY_SIZE 8 -typedef struct mhioc_resv_key { - uchar_t key[MHIOC_RESV_KEY_SIZE]; -} mhioc_resv_key_t; - -typedef struct mhioc_key_list { - uint32_t listsize; - uint32_t listlen; - mhioc_resv_key_t *list; -} mhioc_key_list_t; - -typedef struct mhioc_inkeys { - uint32_t generation; - mhioc_key_list_t *li; -} mhioc_inkeys_t; - -#if defined(_SYSCALL32) -struct mhioc_key_list32 { - uint32_t listsize; - uint32_t listlen; - caddr32_t list; -} mhioc_key_list32_t; - -struct mhioc_inkeys32 { - uint32_t generation; - caddr32_t li; -} mhioc_inkeys32_t; -#endif - -typedef struct mhioc_resv_desc { - mhioc_resv_key_t key; - uint8_t type; - uint8_t scope; - uint32_t scope_specific_addr; -} mhioc_resv_desc_t; - -typedef struct mhioc_resv_desc_list { - uint32_t listsize; - uint32_t listlen; - mhioc_resv_desc_t *list; -} mhioc_resv_desc_list_t; - -typedef struct mhioc_inresvs { - uint32_t generation; - mhioc_resv_desc_list_t *li; -} mhioc_inresvs_t; - -#if defined(_SYSCALL32) -struct mhioc_resv_desc_list32 { - uint32_t listsize; - uint32_t listlen; - caddr32_t list; -} mhioc_resv_desc_list32_t; - -typedef struct mhioc_inresvs32 { - uint32_t generation; - caddr32_t li; -} mhioc_inresvs32_t; -#endif - -typedef struct mhioc_register { - mhioc_resv_key_t oldkey; - mhioc_resv_key_t newkey; - boolean_t aptpl; /* True if persistent across power failures */ -} mhioc_register_t; - -typedef struct mhioc_preemptandabort { - mhioc_resv_desc_t resvdesc; - mhioc_resv_key_t victim_key; -} mhioc_preemptandabort_t; - -typedef struct mhioc_registerandignorekey { - mhioc_resv_key_t newkey; - boolean_t aptpl; /* True if persistent across power failures */ -} mhioc_registerandignorekey_t; - -/* - * SCSI-3 PGR Reservation Type Codes. Codes with the _OBSOLETE suffix - * have been removed from the SCSI3 PGR standard. - */ -#define SCSI3_RESV_READSHARED_OBSOLETE 0 -#define SCSI3_RESV_WRITEEXCLUSIVE 1 -#define SCSI3_RESV_READEXCLUSIVE_OBSOLETE 2 -#define SCSI3_RESV_EXCLUSIVEACCESS 3 -#define SCSI3_RESV_SHAREDACCESS_OBSOLETE 4 -#define SCSI3_RESV_WRITEEXCLUSIVEREGISTRANTSONLY 5 -#define SCSI3_RESV_EXCLUSIVEACCESSREGISTRANTSONLY 6 - -#define SCSI3_SCOPE_LOGICALUNIT 0 -#define SCSI3_SCOPE_EXTENT_OBSOLETE 1 -#define SCSI3_SCOPE_ELEMENT 2 - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_MHD_H */ diff --git a/lib/libspl/include/sys/mkdev.h b/lib/libspl/include/sys/mkdev.h deleted file mode 100644 index f02823c68db0..000000000000 --- a/lib/libspl/include/sys/mkdev.h +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_MKDEV_H -#define _LIBSPL_SYS_MKDEV_H - -#endif diff --git a/lib/libspl/include/sys/mod.h b/lib/libspl/include/sys/mod.h deleted file mode 100644 index ad19b6607a42..000000000000 --- a/lib/libspl/include/sys/mod.h +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2012, 2018 by Delphix. All rights reserved. - * Copyright (c) 2012, Joyent, Inc. All rights reserved. - * Copyright (c) 2025, Rob Norris <robn@despairlabs.com> - */ - -#ifndef _SYS_MOD_H -#define _SYS_MOD_H - -#include <sys/tunables.h> - -#define ZFS_MODULE_PARAM(scope, prefix, name, type, perm, desc) \ - static const zfs_tunable_t _zfs_tunable_##prefix##name = { \ - .zt_name = #prefix#name, \ - .zt_varp = &prefix##name, \ - .zt_varsz = sizeof (prefix##name), \ - .zt_type = ZFS_TUNABLE_TYPE_##type, \ - .zt_perm = ZFS_TUNABLE_PERM_##perm, \ - .zt_desc = desc \ - }; \ - static const zfs_tunable_t * \ - __zfs_tunable_##prefix##name \ - __attribute__((__section__("zfs_tunables"))) \ - __attribute__((__used__)) \ - = &_zfs_tunable_##prefix##name; - -#define ZFS_MODULE_PARAM_ARGS void -#define ZFS_MODULE_PARAM_CALL(scope_prefix, name_prefix, name, setfunc, \ - getfunc, perm, desc) - -#define EXPORT_SYMBOL(x) - -#endif diff --git a/lib/libspl/include/sys/policy.h b/lib/libspl/include/sys/policy.h deleted file mode 100644 index 0d6016c1dd17..000000000000 --- a/lib/libspl/include/sys/policy.h +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 - */ - -#ifndef _LIBSYS_SYS_POLICY_H -#define _LIBSYS_SYS_POLICY_H - -#endif /* _LIBSYS_SYS_POLICY_H */ diff --git a/lib/libspl/include/sys/poll.h b/lib/libspl/include/sys/poll.h deleted file mode 100644 index 3e99db0bdbee..000000000000 --- a/lib/libspl/include/sys/poll.h +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2017 Zettabyte Software, LLC. All rights reserved. - * Use is subject to license terms. - */ - -/* - * Compiling against musl correctly points out that including sys/poll.h is - * disallowed by the Single UNIX Specification when building in userspace. We - * implement a dummy header to redirect the include to the proper header. - * However, glibc, klibc and uclibc break this shim by including sys/poll.h - * from poll.h, so we add explicit exceptions for them. - */ -#ifndef _LIBSPL_SYS_POLL_H -#define _LIBSPL_SYS_POLL_H -#if defined(__GLIBC__) || defined(__KLIBC__) || defined(__UCLIBC__) -#include_next <sys/poll.h> -#else -#include <poll.h> -#endif -#endif /* _LIBSPL_SYS_POLL_H */ diff --git a/lib/libspl/include/sys/priv.h b/lib/libspl/include/sys/priv.h deleted file mode 100644 index 30b88a6c47fc..000000000000 --- a/lib/libspl/include/sys/priv.h +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_PRIV_H -#define _LIBSPL_SYS_PRIV_H - -#endif diff --git a/lib/libspl/include/sys/processor.h b/lib/libspl/include/sys/processor.h deleted file mode 100644 index 9e1bd90992bd..000000000000 --- a/lib/libspl/include/sys/processor.h +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_PROCESSOR_H -#define _LIBSPL_SYS_PROCESSOR_H - -#define getcpuid() (-1) - -typedef int processorid_t; - -#endif diff --git a/lib/libspl/include/sys/simd.h b/lib/libspl/include/sys/simd.h deleted file mode 100644 index 4772a5416b2e..000000000000 --- a/lib/libspl/include/sys/simd.h +++ /dev/null @@ -1,625 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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) 2006 Sun Microsystems, Inc. All rights reserved. - * Copyright (c) 2022 Tino Reichardt <milky-zfs@mcmilk.de> - */ - -#ifndef _LIBSPL_SYS_SIMD_H -#define _LIBSPL_SYS_SIMD_H - -#include <sys/isa_defs.h> -#include <sys/types.h> - -/* including <sys/auxv.h> clashes with AT_UID and others */ -#if defined(__arm__) || defined(__aarch64__) || defined(__powerpc__) -#if defined(__FreeBSD__) -#define AT_HWCAP 25 -#define AT_HWCAP2 26 -extern int elf_aux_info(int aux, void *buf, int buflen); -static inline unsigned long getauxval(unsigned long key) -{ - unsigned long val = 0UL; - - if (elf_aux_info((int)key, &val, sizeof (val)) != 0) - return (0UL); - - return (val); -} -#elif defined(__linux__) -#define AT_HWCAP 16 -#define AT_HWCAP2 26 -extern unsigned long getauxval(unsigned long type); -#endif /* __linux__ */ -#endif /* arm || aarch64 || powerpc */ - -#if defined(__x86) -#include <cpuid.h> - -#define kfpu_allowed() 1 -#define kfpu_begin() do {} while (0) -#define kfpu_end() do {} while (0) -#define kfpu_init() 0 -#define kfpu_fini() ((void) 0) - -/* - * CPUID feature tests for user-space. - * - * x86 registers used implicitly by CPUID - */ -typedef enum cpuid_regs { - EAX = 0, - EBX, - ECX, - EDX, - CPUID_REG_CNT = 4 -} cpuid_regs_t; - -/* - * List of instruction sets identified by CPUID - */ -typedef enum cpuid_inst_sets { - SSE = 0, - SSE2, - SSE3, - SSSE3, - SSE4_1, - SSE4_2, - OSXSAVE, - AVX, - AVX2, - BMI1, - BMI2, - AVX512F, - AVX512CD, - AVX512DQ, - AVX512BW, - AVX512IFMA, - AVX512VBMI, - AVX512PF, - AVX512ER, - AVX512VL, - AES, - PCLMULQDQ, - MOVBE, - SHA_NI, - VAES, - VPCLMULQDQ -} cpuid_inst_sets_t; - -/* - * Instruction set descriptor. - */ -typedef struct cpuid_feature_desc { - uint32_t leaf; /* CPUID leaf */ - uint32_t subleaf; /* CPUID sub-leaf */ - uint32_t flag; /* bit mask of the feature */ - cpuid_regs_t reg; /* which CPUID return register to test */ -} cpuid_feature_desc_t; - -#define _AVX512F_BIT (1U << 16) -#define _AVX512CD_BIT (_AVX512F_BIT | (1U << 28)) -#define _AVX512DQ_BIT (_AVX512F_BIT | (1U << 17)) -#define _AVX512BW_BIT (_AVX512F_BIT | (1U << 30)) -#define _AVX512IFMA_BIT (_AVX512F_BIT | (1U << 21)) -#define _AVX512VBMI_BIT (1U << 1) /* AVX512F_BIT is on another leaf */ -#define _AVX512PF_BIT (_AVX512F_BIT | (1U << 26)) -#define _AVX512ER_BIT (_AVX512F_BIT | (1U << 27)) -#define _AVX512VL_BIT (1U << 31) /* if used also check other levels */ -#define _AES_BIT (1U << 25) -#define _PCLMULQDQ_BIT (1U << 1) -#define _MOVBE_BIT (1U << 22) -#define _VAES_BIT (1U << 9) -#define _VPCLMULQDQ_BIT (1U << 10) -#define _SHA_NI_BIT (1U << 29) - -/* - * Descriptions of supported instruction sets - */ -static const cpuid_feature_desc_t cpuid_features[] = { - [SSE] = {1U, 0U, 1U << 25, EDX }, - [SSE2] = {1U, 0U, 1U << 26, EDX }, - [SSE3] = {1U, 0U, 1U << 0, ECX }, - [SSSE3] = {1U, 0U, 1U << 9, ECX }, - [SSE4_1] = {1U, 0U, 1U << 19, ECX }, - [SSE4_2] = {1U, 0U, 1U << 20, ECX }, - [OSXSAVE] = {1U, 0U, 1U << 27, ECX }, - [AVX] = {1U, 0U, 1U << 28, ECX }, - [AVX2] = {7U, 0U, 1U << 5, EBX }, - [BMI1] = {7U, 0U, 1U << 3, EBX }, - [BMI2] = {7U, 0U, 1U << 8, EBX }, - [AVX512F] = {7U, 0U, _AVX512F_BIT, EBX }, - [AVX512CD] = {7U, 0U, _AVX512CD_BIT, EBX }, - [AVX512DQ] = {7U, 0U, _AVX512DQ_BIT, EBX }, - [AVX512BW] = {7U, 0U, _AVX512BW_BIT, EBX }, - [AVX512IFMA] = {7U, 0U, _AVX512IFMA_BIT, EBX }, - [AVX512VBMI] = {7U, 0U, _AVX512VBMI_BIT, ECX }, - [AVX512PF] = {7U, 0U, _AVX512PF_BIT, EBX }, - [AVX512ER] = {7U, 0U, _AVX512ER_BIT, EBX }, - [AVX512VL] = {7U, 0U, _AVX512ER_BIT, EBX }, - [AES] = {1U, 0U, _AES_BIT, ECX }, - [PCLMULQDQ] = {1U, 0U, _PCLMULQDQ_BIT, ECX }, - [MOVBE] = {1U, 0U, _MOVBE_BIT, ECX }, - [SHA_NI] = {7U, 0U, _SHA_NI_BIT, EBX }, - [VAES] = {7U, 0U, _VAES_BIT, ECX }, - [VPCLMULQDQ] = {7U, 0U, _VPCLMULQDQ_BIT, ECX }, -}; - -/* - * Check if OS supports AVX and AVX2 by checking XCR0 - * Only call this function if CPUID indicates that AVX feature is - * supported by the CPU, otherwise it might be an illegal instruction. - */ -static inline uint64_t -xgetbv(uint32_t index) -{ - uint32_t eax, edx; - /* xgetbv - instruction byte code */ - __asm__ __volatile__(".byte 0x0f; .byte 0x01; .byte 0xd0" - : "=a" (eax), "=d" (edx) - : "c" (index)); - - return ((((uint64_t)edx)<<32) | (uint64_t)eax); -} - -/* - * Check if CPU supports a feature - */ -static inline boolean_t -__cpuid_check_feature(const cpuid_feature_desc_t *desc) -{ - uint32_t r[CPUID_REG_CNT]; - - if (__get_cpuid_max(0, NULL) >= desc->leaf) { - /* - * __cpuid_count is needed to properly check - * for AVX2. It is a macro, so return parameters - * are passed by value. - */ - __cpuid_count(desc->leaf, desc->subleaf, - r[EAX], r[EBX], r[ECX], r[EDX]); - return ((r[desc->reg] & desc->flag) == desc->flag); - } - return (B_FALSE); -} - -#define CPUID_FEATURE_CHECK(name, id) \ -static inline boolean_t \ -__cpuid_has_ ## name(void) \ -{ \ - return (__cpuid_check_feature(&cpuid_features[id])); \ -} - -/* - * Define functions for user-space CPUID features testing - */ -CPUID_FEATURE_CHECK(sse, SSE); -CPUID_FEATURE_CHECK(sse2, SSE2); -CPUID_FEATURE_CHECK(sse3, SSE3); -CPUID_FEATURE_CHECK(ssse3, SSSE3); -CPUID_FEATURE_CHECK(sse4_1, SSE4_1); -CPUID_FEATURE_CHECK(sse4_2, SSE4_2); -CPUID_FEATURE_CHECK(avx, AVX); -CPUID_FEATURE_CHECK(avx2, AVX2); -CPUID_FEATURE_CHECK(osxsave, OSXSAVE); -CPUID_FEATURE_CHECK(bmi1, BMI1); -CPUID_FEATURE_CHECK(bmi2, BMI2); -CPUID_FEATURE_CHECK(avx512f, AVX512F); -CPUID_FEATURE_CHECK(avx512cd, AVX512CD); -CPUID_FEATURE_CHECK(avx512dq, AVX512DQ); -CPUID_FEATURE_CHECK(avx512bw, AVX512BW); -CPUID_FEATURE_CHECK(avx512ifma, AVX512IFMA); -CPUID_FEATURE_CHECK(avx512vbmi, AVX512VBMI); -CPUID_FEATURE_CHECK(avx512pf, AVX512PF); -CPUID_FEATURE_CHECK(avx512er, AVX512ER); -CPUID_FEATURE_CHECK(avx512vl, AVX512VL); -CPUID_FEATURE_CHECK(aes, AES); -CPUID_FEATURE_CHECK(pclmulqdq, PCLMULQDQ); -CPUID_FEATURE_CHECK(movbe, MOVBE); -CPUID_FEATURE_CHECK(shani, SHA_NI); -CPUID_FEATURE_CHECK(vaes, VAES); -CPUID_FEATURE_CHECK(vpclmulqdq, VPCLMULQDQ); - -/* - * Detect register set support - */ -static inline boolean_t -__simd_state_enabled(const uint64_t state) -{ - boolean_t has_osxsave; - uint64_t xcr0; - - has_osxsave = __cpuid_has_osxsave(); - if (!has_osxsave) - return (B_FALSE); - - xcr0 = xgetbv(0); - return ((xcr0 & state) == state); -} - -#define _XSTATE_SSE_AVX (0x2 | 0x4) -#define _XSTATE_AVX512 (0xE0 | _XSTATE_SSE_AVX) - -#define __ymm_enabled() __simd_state_enabled(_XSTATE_SSE_AVX) -#define __zmm_enabled() __simd_state_enabled(_XSTATE_AVX512) - -/* - * Check if SSE instruction set is available - */ -static inline boolean_t -zfs_sse_available(void) -{ - return (__cpuid_has_sse()); -} - -/* - * Check if SSE2 instruction set is available - */ -static inline boolean_t -zfs_sse2_available(void) -{ - return (__cpuid_has_sse2()); -} - -/* - * Check if SSE3 instruction set is available - */ -static inline boolean_t -zfs_sse3_available(void) -{ - return (__cpuid_has_sse3()); -} - -/* - * Check if SSSE3 instruction set is available - */ -static inline boolean_t -zfs_ssse3_available(void) -{ - return (__cpuid_has_ssse3()); -} - -/* - * Check if SSE4.1 instruction set is available - */ -static inline boolean_t -zfs_sse4_1_available(void) -{ - return (__cpuid_has_sse4_1()); -} - -/* - * Check if SSE4.2 instruction set is available - */ -static inline boolean_t -zfs_sse4_2_available(void) -{ - return (__cpuid_has_sse4_2()); -} - -/* - * Check if AVX instruction set is available - */ -static inline boolean_t -zfs_avx_available(void) -{ - return (__cpuid_has_avx() && __ymm_enabled()); -} - -/* - * Check if AVX2 instruction set is available - */ -static inline boolean_t -zfs_avx2_available(void) -{ - return (__cpuid_has_avx2() && __ymm_enabled()); -} - -/* - * Check if BMI1 instruction set is available - */ -static inline boolean_t -zfs_bmi1_available(void) -{ - return (__cpuid_has_bmi1()); -} - -/* - * Check if BMI2 instruction set is available - */ -static inline boolean_t -zfs_bmi2_available(void) -{ - return (__cpuid_has_bmi2()); -} - -/* - * Check if AES instruction set is available - */ -static inline boolean_t -zfs_aes_available(void) -{ - return (__cpuid_has_aes()); -} - -/* - * Check if PCLMULQDQ instruction set is available - */ -static inline boolean_t -zfs_pclmulqdq_available(void) -{ - return (__cpuid_has_pclmulqdq()); -} - -/* - * Check if MOVBE instruction is available - */ -static inline boolean_t -zfs_movbe_available(void) -{ - return (__cpuid_has_movbe()); -} - -/* - * Check if SHA_NI instruction is available - */ -static inline boolean_t -zfs_shani_available(void) -{ - return (__cpuid_has_shani()); -} - -/* - * Check if VAES instruction is available - */ -static inline boolean_t -zfs_vaes_available(void) -{ - return (__cpuid_has_vaes()); -} - -/* - * Check if VPCLMULQDQ instruction is available - */ -static inline boolean_t -zfs_vpclmulqdq_available(void) -{ - return (__cpuid_has_vpclmulqdq()); -} - -/* - * AVX-512 family of instruction sets: - * - * AVX512F Foundation - * AVX512CD Conflict Detection Instructions - * AVX512ER Exponential and Reciprocal Instructions - * AVX512PF Prefetch Instructions - * - * AVX512BW Byte and Word Instructions - * AVX512DQ Double-word and Quadword Instructions - * AVX512VL Vector Length Extensions - * - * AVX512IFMA Integer Fused Multiply Add (Not supported by kernel 4.4) - * AVX512VBMI Vector Byte Manipulation Instructions - */ - -/* - * Check if AVX512F instruction set is available - */ -static inline boolean_t -zfs_avx512f_available(void) -{ - return (__cpuid_has_avx512f() && __zmm_enabled()); -} - -/* - * Check if AVX512CD instruction set is available - */ -static inline boolean_t -zfs_avx512cd_available(void) -{ - return (__cpuid_has_avx512cd() && __zmm_enabled()); -} - -/* - * Check if AVX512ER instruction set is available - */ -static inline boolean_t -zfs_avx512er_available(void) -{ - return (__cpuid_has_avx512er() && __zmm_enabled()); -} - -/* - * Check if AVX512PF instruction set is available - */ -static inline boolean_t -zfs_avx512pf_available(void) -{ - return (__cpuid_has_avx512pf() && __zmm_enabled()); -} - -/* - * Check if AVX512BW instruction set is available - */ -static inline boolean_t -zfs_avx512bw_available(void) -{ - return (__cpuid_has_avx512bw() && __zmm_enabled()); -} - -/* - * Check if AVX512DQ instruction set is available - */ -static inline boolean_t -zfs_avx512dq_available(void) -{ - return (__cpuid_has_avx512dq() && __zmm_enabled()); -} - -/* - * Check if AVX512VL instruction set is available - */ -static inline boolean_t -zfs_avx512vl_available(void) -{ - return (__cpuid_has_avx512vl() && __zmm_enabled()); -} - -/* - * Check if AVX512IFMA instruction set is available - */ -static inline boolean_t -zfs_avx512ifma_available(void) -{ - return (__cpuid_has_avx512ifma() && __zmm_enabled()); -} - -/* - * Check if AVX512VBMI instruction set is available - */ -static inline boolean_t -zfs_avx512vbmi_available(void) -{ - return (__cpuid_has_avx512f() && __cpuid_has_avx512vbmi() && - __zmm_enabled()); -} - -#elif defined(__arm__) - -#define kfpu_allowed() 1 -#define kfpu_initialize(tsk) do {} while (0) -#define kfpu_begin() do {} while (0) -#define kfpu_end() do {} while (0) - -#define HWCAP_NEON 0x00001000 -#define HWCAP2_SHA2 0x00000008 - -/* - * Check if NEON is available - */ -static inline boolean_t -zfs_neon_available(void) -{ - unsigned long hwcap = getauxval(AT_HWCAP); - return (hwcap & HWCAP_NEON); -} - -/* - * Check if SHA2 is available - */ -static inline boolean_t -zfs_sha256_available(void) -{ - unsigned long hwcap = getauxval(AT_HWCAP); - return (hwcap & HWCAP2_SHA2); -} - -#elif defined(__aarch64__) - -#define kfpu_allowed() 1 -#define kfpu_initialize(tsk) do {} while (0) -#define kfpu_begin() do {} while (0) -#define kfpu_end() do {} while (0) - -#define HWCAP_FP 0x00000001 -#define HWCAP_SHA2 0x00000040 -#define HWCAP_SHA512 0x00200000 - -/* - * Check if NEON is available - */ -static inline boolean_t -zfs_neon_available(void) -{ - unsigned long hwcap = getauxval(AT_HWCAP); - return (hwcap & HWCAP_FP); -} - -/* - * Check if SHA2 is available - */ -static inline boolean_t -zfs_sha256_available(void) -{ - unsigned long hwcap = getauxval(AT_HWCAP); - return (hwcap & HWCAP_SHA2); -} - -/* - * Check if SHA512 is available - */ -static inline boolean_t -zfs_sha512_available(void) -{ - unsigned long hwcap = getauxval(AT_HWCAP); - return (hwcap & HWCAP_SHA512); -} - -#elif defined(__powerpc__) - -#define kfpu_allowed() 0 -#define kfpu_initialize(tsk) do {} while (0) -#define kfpu_begin() do {} while (0) -#define kfpu_end() do {} while (0) - -#define PPC_FEATURE_HAS_ALTIVEC 0x10000000 -#define PPC_FEATURE_HAS_VSX 0x00000080 -#define PPC_FEATURE2_ARCH_2_07 0x80000000 - -static inline boolean_t -zfs_altivec_available(void) -{ - unsigned long hwcap = getauxval(AT_HWCAP); - return (hwcap & PPC_FEATURE_HAS_ALTIVEC); -} - -static inline boolean_t -zfs_vsx_available(void) -{ - unsigned long hwcap = getauxval(AT_HWCAP); - return (hwcap & PPC_FEATURE_HAS_VSX); -} - -static inline boolean_t -zfs_isa207_available(void) -{ - unsigned long hwcap = getauxval(AT_HWCAP); - unsigned long hwcap2 = getauxval(AT_HWCAP2); - return ((hwcap & PPC_FEATURE_HAS_VSX) && - (hwcap2 & PPC_FEATURE2_ARCH_2_07)); -} - -#else - -#define kfpu_allowed() 0 -#define kfpu_initialize(tsk) do {} while (0) -#define kfpu_begin() do {} while (0) -#define kfpu_end() do {} while (0) - -#endif - -extern void simd_stat_init(void); -extern void simd_stat_fini(void); - -#endif /* _LIBSPL_SYS_SIMD_H */ diff --git a/lib/libspl/include/sys/stack.h b/lib/libspl/include/sys/stack.h deleted file mode 100644 index 80984086a145..000000000000 --- a/lib/libspl/include/sys/stack.h +++ /dev/null @@ -1,75 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 - */ -/* - * This header file distributed under the terms of the CDDL. - * Portions Copyright 2008 Sun Microsystems, Inc. All Rights reserved. - */ -#ifndef _SYS_STACK_H -#define _SYS_STACK_H - -#include <pthread.h> - -#define STACK_BIAS 0 - -#ifdef __USE_GNU - -static inline int -stack_getbounds(stack_t *sp) -{ - pthread_attr_t attr; - int rc; - - rc = pthread_getattr_np(pthread_self(), &attr); - if (rc) - return (rc); - - rc = pthread_attr_getstack(&attr, &sp->ss_sp, &sp->ss_size); - if (rc == 0) - sp->ss_flags = 0; - - pthread_attr_destroy(&attr); - - return (rc); -} - -static inline int -thr_stksegment(stack_t *sp) -{ - int rc; - - rc = stack_getbounds(sp); - if (rc) - return (rc); - - /* - * thr_stksegment() is expected to set sp.ss_sp to the high stack - * address, but the stack_getbounds() interface is expected to - * set sp.ss_sp to the low address. Adjust accordingly. - */ - sp->ss_sp = (void *)(((uintptr_t)sp->ss_sp) + sp->ss_size); - sp->ss_flags = 0; - - return (rc); -} - -#endif /* __USE_GNU */ -#endif /* _SYS_STACK_H */ diff --git a/lib/libspl/include/sys/stdtypes.h b/lib/libspl/include/sys/stdtypes.h deleted file mode 100644 index db5876e5bc2b..000000000000 --- a/lib/libspl/include/sys/stdtypes.h +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 - */ - -#ifndef __SYS_STDTYPES_H -#define __SYS_STDTYPES_H - -typedef enum { - B_FALSE = 0, - B_TRUE = 1 -} boolean_t; - -typedef unsigned char uchar_t; -typedef unsigned short ushort_t; -typedef unsigned int uint_t; -typedef unsigned long ulong_t; -typedef unsigned long long u_longlong_t; -typedef long long longlong_t; - -typedef longlong_t offset_t; -typedef u_longlong_t u_offset_t; -typedef u_longlong_t len_t; -typedef longlong_t diskaddr_t; - -typedef ulong_t pgcnt_t; /* number of pages */ -typedef long spgcnt_t; /* signed number of pages */ - -typedef short pri_t; -typedef ushort_t o_mode_t; /* old file attribute type */ - -typedef int major_t; -typedef int minor_t; - -typedef short index_t; - -#endif /* __SYS_STDTYPES_H */ diff --git a/lib/libspl/include/sys/string.h b/lib/libspl/include/sys/string.h deleted file mode 100644 index 3b2f5900276f..000000000000 --- a/lib/libspl/include/sys/string.h +++ /dev/null @@ -1 +0,0 @@ -#include <string.h> diff --git a/lib/libspl/include/sys/sunddi.h b/lib/libspl/include/sys/sunddi.h deleted file mode 100644 index 8489c7139bad..000000000000 --- a/lib/libspl/include/sys/sunddi.h +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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) 2008 by Sun Microsystems, Inc. - */ - -#ifndef _SYS_SUNDDI_H -#define _SYS_SUNDDI_H - -#endif /* _SYS_SUNDDI_H */ diff --git a/lib/libspl/include/sys/systeminfo.h b/lib/libspl/include/sys/systeminfo.h deleted file mode 100644 index 3ca1fa884994..000000000000 --- a/lib/libspl/include/sys/systeminfo.h +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_SYSTEMINFO_H -#define _LIBSPL_SYS_SYSTEMINFO_H - -#define HOSTID_MASK 0xFFFFFFFF -#define HW_INVALID_HOSTID 0xFFFFFFFF /* an invalid hostid */ -#define HW_HOSTID_LEN 11 /* minimum buffer size needed */ - /* to hold a decimal or hex */ - /* hostid string */ - -unsigned long get_system_hostid(void); - -#endif diff --git a/lib/libspl/include/sys/time.h b/lib/libspl/include/sys/time.h deleted file mode 100644 index 062c6ec979fc..000000000000 --- a/lib/libspl/include/sys/time.h +++ /dev/null @@ -1,117 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_TIME_H -#define _LIBSPL_SYS_TIME_H - -#include <time.h> -#include <sys/types.h> -#include_next <sys/time.h> - -#ifndef SEC -#define SEC 1 -#endif - -#ifndef MILLISEC -#define MILLISEC 1000 -#endif - -#ifndef MICROSEC -#define MICROSEC 1000000 -#endif - -#ifndef NANOSEC -#define NANOSEC 1000000000 -#endif - -#ifndef NSEC_PER_USEC -#define NSEC_PER_USEC 1000L -#endif - -#ifndef MSEC2NSEC -#define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC)) -#endif - -#ifndef NSEC2MSEC -#define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC)) -#endif - -#ifndef USEC2NSEC -#define USEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MICROSEC)) -#endif - -#ifndef NSEC2USEC -#define NSEC2USEC(n) ((n) / (NANOSEC / MICROSEC)) -#endif - -#ifndef NSEC2SEC -#define NSEC2SEC(n) ((n) / (NANOSEC / SEC)) -#endif - -#ifndef SEC2NSEC -#define SEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / SEC)) -#endif - -typedef long long hrtime_t; -typedef struct timespec timespec_t; -typedef struct timespec inode_timespec_t; - -static inline void -gethrestime(inode_timespec_t *ts) -{ - struct timeval tv; - (void) gettimeofday(&tv, NULL); - ts->tv_sec = tv.tv_sec; - ts->tv_nsec = tv.tv_usec * NSEC_PER_USEC; -} - -static inline uint64_t -gethrestime_sec(void) -{ - struct timeval tv; - (void) gettimeofday(&tv, NULL); - return (tv.tv_sec); -} - -static inline hrtime_t -getlrtime(void) -{ - struct timeval tv; - (void) gettimeofday(&tv, NULL); - return ((((uint64_t)tv.tv_sec) * NANOSEC) + - ((uint64_t)tv.tv_usec * NSEC_PER_USEC)); -} - -static inline hrtime_t -gethrtime(void) -{ - struct timespec ts; - (void) clock_gettime(CLOCK_MONOTONIC, &ts); - return ((((uint64_t)ts.tv_sec) * NANOSEC) + ts.tv_nsec); -} - -#endif /* _LIBSPL_SYS_TIME_H */ diff --git a/lib/libspl/include/sys/trace_spl.h b/lib/libspl/include/sys/trace_spl.h deleted file mode 100644 index b80d288f7332..000000000000 --- a/lib/libspl/include/sys/trace_spl.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Here to keep the libspl build happy */ - -#ifndef _LIBSPL_SPL_TRACE_H -#define _LIBSPL_SPL_TRACE_H - -/* - * The set-error SDT probe is extra static, in that we declare its fake - * function literally, rather than with the DTRACE_PROBE1() macro. This is - * necessary so that SET_ERROR() can evaluate to a value, which wouldn't - * be possible if it required multiple statements (to declare the function - * and then call it). - * - * SET_ERROR() uses the comma operator so that it can be used without much - * additional code. For example, "return (EINVAL);" becomes - * "return (SET_ERROR(EINVAL));". Note that the argument will be evaluated - * twice, so it should not have side effects (e.g. something like: - * "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice). - */ -#undef SET_ERROR -#define SET_ERROR(err) \ - (__set_error(__FILE__, __func__, __LINE__, err), err) - - -#endif diff --git a/lib/libspl/include/sys/trace_zfs.h b/lib/libspl/include/sys/trace_zfs.h deleted file mode 100644 index 87ed5ad3c3be..000000000000 --- a/lib/libspl/include/sys/trace_zfs.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Here to keep the libspl build happy */ - -#ifndef _LIBSPL_ZFS_TRACE_H -#define _LIBSPL_ZFS_TRACE_H - -/* - * The set-error SDT probe is extra static, in that we declare its fake - * function literally, rather than with the DTRACE_PROBE1() macro. This is - * necessary so that SET_ERROR() can evaluate to a value, which wouldn't - * be possible if it required multiple statements (to declare the function - * and then call it). - * - * SET_ERROR() uses the comma operator so that it can be used without much - * additional code. For example, "return (EINVAL);" becomes - * "return (SET_ERROR(EINVAL));". Note that the argument will be evaluated - * twice, so it should not have side effects (e.g. something like: - * "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice). - */ -#undef SET_ERROR -#define SET_ERROR(err) \ - (__set_error(__FILE__, __func__, __LINE__, err), err) - - -#endif diff --git a/lib/libspl/include/sys/tunables.h b/lib/libspl/include/sys/tunables.h deleted file mode 100644 index 5d9bb3d71a4a..000000000000 --- a/lib/libspl/include/sys/tunables.h +++ /dev/null @@ -1,60 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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) 2025, Rob Norris <robn@despairlabs.com> - */ - -#ifndef _SYS_TUNABLES_H -#define _SYS_TUNABLES_H - -typedef enum { - ZFS_TUNABLE_TYPE_INT, - ZFS_TUNABLE_TYPE_UINT, - ZFS_TUNABLE_TYPE_ULONG, - ZFS_TUNABLE_TYPE_U64, - ZFS_TUNABLE_TYPE_STRING, -} zfs_tunable_type_t; - -typedef enum { - ZFS_TUNABLE_PERM_ZMOD_RW, - ZFS_TUNABLE_PERM_ZMOD_RD, -} zfs_tunable_perm_t; - -typedef struct zfs_tunable { - const char *zt_name; - void *zt_varp; - size_t zt_varsz; - zfs_tunable_type_t zt_type; - zfs_tunable_perm_t zt_perm; - const char *zt_desc; -} zfs_tunable_t; - -int zfs_tunable_set(const zfs_tunable_t *tunable, const char *val); -int zfs_tunable_get(const zfs_tunable_t *tunable, char *val, size_t valsz); - -const zfs_tunable_t *zfs_tunable_lookup(const char *name); - -typedef int (*zfs_tunable_iter_t)(const zfs_tunable_t *tunable, void *arg); -void zfs_tunable_iter(zfs_tunable_iter_t cb, void *arg); - -#endif diff --git a/lib/libspl/include/sys/types.h b/lib/libspl/include/sys/types.h deleted file mode 100644 index f4bb85c7942e..000000000000 --- a/lib/libspl/include/sys/types.h +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_TYPES_H -#define _LIBSPL_SYS_TYPES_H - -#if defined(HAVE_MAKEDEV_IN_SYSMACROS) -#include <sys/sysmacros.h> -#elif defined(HAVE_MAKEDEV_IN_MKDEV) -#include <sys/mkdev.h> -#endif - -#include <sys/isa_defs.h> -#include <sys/feature_tests.h> -#include_next <sys/types.h> -#include <sys/types32.h> -#include <stdarg.h> -#include <sys/stdtypes.h> - -#ifndef HAVE_INTTYPES -#include <inttypes.h> -#endif /* HAVE_INTTYPES */ - -typedef uint_t zoneid_t; -typedef int projid_t; - -#include <sys/param.h> /* for NBBY */ - -#endif diff --git a/lib/libspl/include/sys/types32.h b/lib/libspl/include/sys/types32.h deleted file mode 100644 index 1bcae20187ad..000000000000 --- a/lib/libspl/include/sys/types32.h +++ /dev/null @@ -1,85 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_TYPES32_H -#define _SYS_TYPES32_H - -#include <sys/inttypes.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Interoperability types for programs. Used for: - * - * Crossing between 32-bit and 64-bit domains. - * - * On disk data formats such as filesystem meta data - * and disk label. - * - * Note: Applications should never include this - * header file. - */ -typedef uint32_t caddr32_t; -typedef int32_t daddr32_t; -typedef int32_t off32_t; -typedef uint32_t ino32_t; -typedef int32_t blkcnt32_t; -typedef uint32_t fsblkcnt32_t; -typedef uint32_t fsfilcnt32_t; -typedef int32_t id32_t; -typedef uint32_t major32_t; -typedef uint32_t minor32_t; -typedef int32_t key32_t; -typedef uint32_t mode32_t; -typedef uint32_t uid32_t; -typedef uint32_t gid32_t; -typedef uint32_t nlink32_t; -typedef uint32_t dev32_t; -typedef int32_t pid32_t; -typedef uint32_t size32_t; -typedef int32_t ssize32_t; -typedef int32_t time32_t; -typedef int32_t clock32_t; - -typedef struct timespec32 { - time32_t tv_sec; /* seconds */ - int32_t tv_nsec; /* and nanoseconds */ -} timespec32_t; - -typedef struct timespec32 timestruc32_t; - -typedef struct itimerspec32 { - struct timespec32 it_interval; - struct timespec32 it_value; -} itimerspec32_t; - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_TYPES32_H */ diff --git a/lib/libspl/include/sys/uio.h b/lib/libspl/include/sys/uio.h deleted file mode 100644 index 93aa4984d734..000000000000 --- a/lib/libspl/include/sys/uio.h +++ /dev/null @@ -1,138 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * University Copyright- Copyright (c) 1982, 1986, 1988 - * The Regents of the University of California - * All Rights Reserved - * - * University Acknowledgment- Portions of this document are derived from - * software developed by the University of California, Berkeley, and its - * contributors. - */ - -#ifndef _LIBSPL_SYS_UIO_H -#define _LIBSPL_SYS_UIO_H - -#include <sys/types.h> -#include_next <sys/uio.h> - -#ifdef __APPLE__ -#include <sys/_types/_iovec_t.h> -#endif - -#include <stdint.h> -typedef struct iovec iovec_t; - -#if defined(__linux__) || defined(__APPLE__) -typedef enum zfs_uio_rw { - UIO_READ = 0, - UIO_WRITE = 1, -} zfs_uio_rw_t; - -typedef enum zfs_uio_seg { - UIO_SYSSPACE = 0, -} zfs_uio_seg_t; - -#elif defined(__FreeBSD__) -typedef enum uio_seg zfs_uio_seg_t; -#endif - -typedef struct zfs_uio { - struct iovec *uio_iov; /* pointer to array of iovecs */ - int uio_iovcnt; /* number of iovecs */ - offset_t uio_loffset; /* file offset */ - zfs_uio_seg_t uio_segflg; /* address space (kernel or user) */ - uint16_t uio_fmode; /* file mode flags */ - uint16_t uio_extflg; /* extended flags */ - ssize_t uio_resid; /* residual count */ -} zfs_uio_t; - -#define zfs_uio_segflg(uio) (uio)->uio_segflg -#define zfs_uio_offset(uio) (uio)->uio_loffset -#define zfs_uio_resid(uio) (uio)->uio_resid -#define zfs_uio_iovcnt(uio) (uio)->uio_iovcnt -#define zfs_uio_iovlen(uio, idx) (uio)->uio_iov[(idx)].iov_len -#define zfs_uio_iovbase(uio, idx) (uio)->uio_iov[(idx)].iov_base - -static inline boolean_t -zfs_dio_page_aligned(void *buf) -{ - return ((((unsigned long)(buf) & (PAGESIZE - 1)) == 0) ? - B_TRUE : B_FALSE); -} - -static inline boolean_t -zfs_dio_offset_aligned(uint64_t offset, uint64_t blksz) -{ - return ((IS_P2ALIGNED(offset, blksz)) ? B_TRUE : B_FALSE); -} - -static inline boolean_t -zfs_dio_size_aligned(uint64_t size, uint64_t blksz) -{ - return (((size % blksz) == 0) ? B_TRUE : B_FALSE); -} - -static inline boolean_t -zfs_dio_aligned(uint64_t offset, uint64_t size, uint64_t blksz) -{ - return ((zfs_dio_offset_aligned(offset, blksz) && - zfs_dio_size_aligned(size, blksz)) ? B_TRUE : B_FALSE); -} - -static inline void -zfs_uio_iov_at_index(zfs_uio_t *uio, uint_t idx, void **base, uint64_t *len) -{ - *base = zfs_uio_iovbase(uio, idx); - *len = zfs_uio_iovlen(uio, idx); -} - -static inline void -zfs_uio_advance(zfs_uio_t *uio, ssize_t size) -{ - uio->uio_resid -= size; - uio->uio_loffset += size; -} - -static inline offset_t -zfs_uio_index_at_offset(zfs_uio_t *uio, offset_t off, uint_t *vec_idx) -{ - *vec_idx = 0; - while (*vec_idx < (uint_t)zfs_uio_iovcnt(uio) && - off >= (offset_t)zfs_uio_iovlen(uio, *vec_idx)) { - off -= zfs_uio_iovlen(uio, *vec_idx); - (*vec_idx)++; - } - - return (off); -} - -#endif /* _SYS_UIO_H */ diff --git a/lib/libspl/include/sys/vnode.h b/lib/libspl/include/sys/vnode.h deleted file mode 100644 index 49afe12c52b1..000000000000 --- a/lib/libspl/include/sys/vnode.h +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_VNODE_H -#define _LIBSPL_SYS_VNODE_H - -#endif /* _LIBSPL_SYS_VNODE_H */ diff --git a/lib/libspl/include/sys/wmsum.h b/lib/libspl/include/sys/wmsum.h deleted file mode 100644 index 36e37f9e17d4..000000000000 --- a/lib/libspl/include/sys/wmsum.h +++ /dev/null @@ -1,69 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * This file and its contents are supplied under the terms of the - * Common Development and Distribution License ("CDDL"), version 1.0. - * You may only use this file in accordance with the terms of version - * 1.0 of the CDDL. - * - * A full copy of the text of the CDDL should have accompanied this - * source. A copy of the CDDL is also available via the Internet at - * http://www.illumos.org/license/CDDL. - * - * CDDL HEADER END - */ - -/* - * wmsum counters are a reduced version of aggsum counters, optimized for - * write-mostly scenarios. They do not provide optimized read functions, - * but instead allow much cheaper add function. The primary usage is - * infrequently read statistic counters, not requiring exact precision. - * - * In user-space due to lack of better implementation mapped to aggsum. - */ - -#ifndef _SYS_WMSUM_H -#define _SYS_WMSUM_H - -#include <sys/aggsum.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define wmsum_t aggsum_t - -static inline void -wmsum_init(wmsum_t *ws, uint64_t value) -{ - - aggsum_init(ws, value); -} - -static inline void -wmsum_fini(wmsum_t *ws) -{ - - aggsum_fini(ws); -} - -static inline uint64_t -wmsum_value(wmsum_t *ws) -{ - - return (aggsum_value(ws)); -} - -static inline void -wmsum_add(wmsum_t *ws, int64_t delta) -{ - - aggsum_add(ws, delta); -} - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_WMSUM_H */ diff --git a/lib/libspl/include/sys/zone.h b/lib/libspl/include/sys/zone.h deleted file mode 100644 index f4037b4875a9..000000000000 --- a/lib/libspl/include/sys/zone.h +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_ZONE_H -#define _LIBSPL_SYS_ZONE_H - -#endif diff --git a/lib/libspl/include/umem.h b/lib/libspl/include/umem.h deleted file mode 100644 index 3e44610e4e21..000000000000 --- a/lib/libspl/include/umem.h +++ /dev/null @@ -1,231 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_UMEM_H -#define _LIBSPL_UMEM_H - -/* - * XXX: We should use the real portable umem library if it is detected - * at configure time. However, if the library is not available, we can - * use a trivial malloc based implementation. This obviously impacts - * performance, but unless you are using a full userspace build of zpool for - * something other than ztest, you are likely not going to notice or care. - * - * https://labs.omniti.com/trac/portableumem - */ -#include <sys/debug.h> - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void vmem_t; - -/* - * Flags for umem_alloc/umem_free - */ -#define UMEM_DEFAULT 0x0000 /* normal -- may fail */ -#define UMEM_NOFAIL 0x0100 /* Never fails */ - -/* - * Flags for umem_cache_create() - */ -#define UMC_NODEBUG 0x00020000 - -#define UMEM_CACHE_NAMELEN 31 - -typedef int umem_nofail_callback_t(void); -typedef int umem_constructor_t(void *, void *, int); -typedef void umem_destructor_t(void *, void *); -typedef void umem_reclaim_t(void *); - -typedef struct umem_cache { - char cache_name[UMEM_CACHE_NAMELEN + 1]; - size_t cache_bufsize; - size_t cache_align; - umem_constructor_t *cache_constructor; - umem_destructor_t *cache_destructor; - umem_reclaim_t *cache_reclaim; - void *cache_private; - void *cache_arena; - int cache_cflags; -} umem_cache_t; - -/* Prototypes for functions to provide defaults for umem envvars */ -const char *_umem_debug_init(void); -const char *_umem_options_init(void); -const char *_umem_logging_init(void); - -__attribute__((malloc, alloc_size(1))) -static inline void * -umem_alloc(size_t size, int flags) -{ - void *ptr = NULL; - - do { - ptr = malloc(size); - } while (ptr == NULL && (flags & UMEM_NOFAIL)); - - return (ptr); -} - -__attribute__((malloc, alloc_size(1))) -static inline void * -umem_alloc_aligned(size_t size, size_t align, int flags) -{ - void *ptr = NULL; - int rc; - - do { - rc = posix_memalign(&ptr, align, size); - } while (rc == ENOMEM && (flags & UMEM_NOFAIL)); - - if (rc == EINVAL) { - fprintf(stderr, "%s: invalid memory alignment (%zd)\n", - __func__, align); - if (flags & UMEM_NOFAIL) - abort(); - return (NULL); - } - - return (ptr); -} - -__attribute__((malloc, alloc_size(1))) -static inline void * -umem_zalloc(size_t size, int flags) -{ - void *ptr = NULL; - - ptr = umem_alloc(size, flags); - if (ptr) - memset(ptr, 0, size); - - return (ptr); -} - -static inline void -umem_free(const void *ptr, size_t size __maybe_unused) -{ - free((void *)ptr); -} - -/* - * umem_free_aligned was added for supporting portability - * with non-POSIX platforms that require a different free - * to be used with aligned allocations. - */ -static inline void -umem_free_aligned(void *ptr, size_t size __maybe_unused) -{ -#ifndef _WIN32 - free((void *)ptr); -#else - _aligned_free(ptr); -#endif -} - -static inline void -umem_nofail_callback(umem_nofail_callback_t *cb __maybe_unused) -{} - -static inline umem_cache_t * -umem_cache_create( - const char *name, size_t bufsize, size_t align, - umem_constructor_t *constructor, - umem_destructor_t *destructor, - umem_reclaim_t *reclaim, - void *priv, void *vmp, int cflags) -{ - umem_cache_t *cp; - - cp = (umem_cache_t *)umem_alloc(sizeof (umem_cache_t), UMEM_DEFAULT); - if (cp) { - strlcpy(cp->cache_name, name, UMEM_CACHE_NAMELEN); - cp->cache_bufsize = bufsize; - cp->cache_align = align; - cp->cache_constructor = constructor; - cp->cache_destructor = destructor; - cp->cache_reclaim = reclaim; - cp->cache_private = priv; - cp->cache_arena = vmp; - cp->cache_cflags = cflags; - } - - return (cp); -} - -static inline void -umem_cache_destroy(umem_cache_t *cp) -{ - umem_free(cp, sizeof (umem_cache_t)); -} - -__attribute__((malloc)) -static inline void * -umem_cache_alloc(umem_cache_t *cp, int flags) -{ - void *ptr = NULL; - - if (cp->cache_align != 0) - ptr = umem_alloc_aligned( - cp->cache_bufsize, cp->cache_align, flags); - else - ptr = umem_alloc(cp->cache_bufsize, flags); - - if (ptr && cp->cache_constructor) - cp->cache_constructor(ptr, cp->cache_private, UMEM_DEFAULT); - - return (ptr); -} - -static inline void -umem_cache_free(umem_cache_t *cp, void *ptr) -{ - if (cp->cache_destructor) - cp->cache_destructor(ptr, cp->cache_private); - - if (cp->cache_align != 0) - umem_free_aligned(ptr, cp->cache_bufsize); - else - umem_free(ptr, cp->cache_bufsize); -} - -static inline void -umem_cache_reap_now(umem_cache_t *cp __maybe_unused) -{ -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libspl/include/unistd.h b/lib/libspl/include/unistd.h deleted file mode 100644 index 6d755eb8ad91..000000000000 --- a/lib/libspl/include/unistd.h +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include_next <unistd.h> - -#ifndef _LIBSPL_UNISTD_H -#define _LIBSPL_UNISTD_H - -#include <sys/ioctl.h> - -#if !defined(HAVE_ISSETUGID) -#include <sys/types.h> -#define issetugid() (geteuid() == 0 || getegid() == 0) -#endif - -#endif /* _LIBSPL_UNISTD_H */ diff --git a/lib/libspl/include/zone.h b/lib/libspl/include/zone.h deleted file mode 100644 index f946c0f13f77..000000000000 --- a/lib/libspl/include/zone.h +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_ZONE_H -#define _LIBSPL_ZONE_H - -#include <sys/types.h> -#include <sys/zone.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __FreeBSD__ -#define GLOBAL_ZONEID 0 -#else -/* - * Hardcoded in the kernel's root user namespace. A "better" way to get - * this would be by using ioctl_ns(2), but this would need to be performed - * recursively on NS_GET_PARENT and then NS_GET_USERNS. Also, that's only - * supported since Linux 4.9. - */ -#define GLOBAL_ZONEID 4026531837U -#endif - -extern zoneid_t getzoneid(void); - -#ifdef __cplusplus -} -#endif - -#endif /* _LIBSPL_ZONE_H */ diff --git a/lib/libspl/libspl_impl.h b/lib/libspl/libspl_impl.h deleted file mode 100644 index 39392da09ef5..000000000000 --- a/lib/libspl/libspl_impl.h +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 - */ - - -extern ssize_t getexecname_impl(char *execname); diff --git a/lib/libspl/list.c b/lib/libspl/list.c deleted file mode 100644 index f95b358153de..000000000000 --- a/lib/libspl/list.c +++ /dev/null @@ -1,244 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * Generic doubly-linked list implementation - */ - -#include <sys/list.h> -#include <sys/list_impl.h> -#include <sys/types.h> -#include <sys/sysmacros.h> -#include <sys/debug.h> - -#define list_d2l(a, obj) ((list_node_t *)(((char *)obj) + (a)->list_offset)) -#define list_object(a, node) ((void *)(((char *)node) - (a)->list_offset)) -#define list_empty(a) ((a)->list_head.next == &(a)->list_head) - -#define list_insert_after_node(list, node, object) { \ - list_node_t *lnew = list_d2l(list, object); \ - lnew->prev = (node); \ - lnew->next = (node)->next; \ - (node)->next->prev = lnew; \ - (node)->next = lnew; \ -} - -#define list_insert_before_node(list, node, object) { \ - list_node_t *lnew = list_d2l(list, object); \ - lnew->next = (node); \ - lnew->prev = (node)->prev; \ - (node)->prev->next = lnew; \ - (node)->prev = lnew; \ -} - -#define list_remove_node(node) \ - (node)->prev->next = (node)->next; \ - (node)->next->prev = (node)->prev; \ - (node)->next = (node)->prev = NULL - -void -list_create(list_t *list, size_t size, size_t offset) -{ - ASSERT(list); - ASSERT(size > 0); - ASSERT(size >= offset + sizeof (list_node_t)); - - (void) size; - - list->list_offset = offset; - list->list_head.next = list->list_head.prev = &list->list_head; -} - -void -list_destroy(list_t *list) -{ - list_node_t *node = &list->list_head; - - ASSERT(list); - ASSERT(list->list_head.next == node); - ASSERT(list->list_head.prev == node); - - node->next = node->prev = NULL; -} - -void -list_insert_after(list_t *list, void *object, void *nobject) -{ - if (object == NULL) { - list_insert_head(list, nobject); - } else { - list_node_t *lold = list_d2l(list, object); - list_insert_after_node(list, lold, nobject); - } -} - -void -list_insert_before(list_t *list, void *object, void *nobject) -{ - if (object == NULL) { - list_insert_tail(list, nobject); - } else { - list_node_t *lold = list_d2l(list, object); - list_insert_before_node(list, lold, nobject); - } -} - -void -list_insert_head(list_t *list, void *object) -{ - list_node_t *lold = &list->list_head; - list_insert_after_node(list, lold, object); -} - -void -list_insert_tail(list_t *list, void *object) -{ - list_node_t *lold = &list->list_head; - list_insert_before_node(list, lold, object); -} - -void -list_remove(list_t *list, void *object) -{ - list_node_t *lold = list_d2l(list, object); - ASSERT(!list_empty(list)); - ASSERT(lold->next != NULL); - list_remove_node(lold); -} - -void * -list_remove_head(list_t *list) -{ - list_node_t *head = list->list_head.next; - if (head == &list->list_head) - return (NULL); - list_remove_node(head); - return (list_object(list, head)); -} - -void * -list_remove_tail(list_t *list) -{ - list_node_t *tail = list->list_head.prev; - if (tail == &list->list_head) - return (NULL); - list_remove_node(tail); - return (list_object(list, tail)); -} - -void * -list_head(list_t *list) -{ - if (list_empty(list)) - return (NULL); - return (list_object(list, list->list_head.next)); -} - -void * -list_tail(list_t *list) -{ - if (list_empty(list)) - return (NULL); - return (list_object(list, list->list_head.prev)); -} - -void * -list_next(list_t *list, void *object) -{ - list_node_t *node = list_d2l(list, object); - - if (node->next != &list->list_head) - return (list_object(list, node->next)); - - return (NULL); -} - -void * -list_prev(list_t *list, void *object) -{ - list_node_t *node = list_d2l(list, object); - - if (node->prev != &list->list_head) - return (list_object(list, node->prev)); - - return (NULL); -} - -/* - * Insert src list after dst list. Empty src list thereafter. - */ -void -list_move_tail(list_t *dst, list_t *src) -{ - list_node_t *dstnode = &dst->list_head; - list_node_t *srcnode = &src->list_head; - - ASSERT(dst->list_offset == src->list_offset); - - if (list_empty(src)) - return; - - dstnode->prev->next = srcnode->next; - srcnode->next->prev = dstnode->prev; - dstnode->prev = srcnode->prev; - srcnode->prev->next = dstnode; - - /* empty src list */ - srcnode->next = srcnode->prev = srcnode; -} - -void -list_link_replace(list_node_t *lold, list_node_t *lnew) -{ - ASSERT(list_link_active(lold)); - ASSERT(!list_link_active(lnew)); - - lnew->next = lold->next; - lnew->prev = lold->prev; - lold->prev->next = lnew; - lold->next->prev = lnew; - lold->next = lold->prev = NULL; -} - -void -list_link_init(list_node_t *ln) -{ - ln->next = NULL; - ln->prev = NULL; -} - -int -list_link_active(list_node_t *ln) -{ - EQUIV(ln->next == NULL, ln->prev == NULL); - return (ln->next != NULL); -} - -int -list_is_empty(list_t *list) -{ - return (list_empty(list)); -} diff --git a/lib/libspl/mkdirp.c b/lib/libspl/mkdirp.c deleted file mode 100644 index 80198dfbecba..000000000000 --- a/lib/libspl/mkdirp.c +++ /dev/null @@ -1,213 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - -/* - * Creates directory and it's parents if the parents do not - * exist yet. - * - * Returns -1 if fails for reasons other than non-existing - * parents. - * Does NOT simplify pathnames with . or .. in them. - */ - -#include <sys/types.h> -#include <libgen.h> -#include <stdlib.h> -#include <unistd.h> -#include <errno.h> -#include <string.h> -#include <sys/stat.h> - -static char *simplify(const char *str); - -int -mkdirp(const char *d, mode_t mode) -{ - char *endptr, *ptr, *slash, *str; - - str = simplify(d); - - /* If space couldn't be allocated for the simplified names, return. */ - - if (str == NULL) - return (-1); - - /* Try to make the directory */ - - if (mkdir(str, mode) == 0) { - free(str); - return (0); - } - if (errno != ENOENT) { - free(str); - return (-1); - } - endptr = strrchr(str, '\0'); - slash = strrchr(str, '/'); - - /* Search upward for the non-existing parent */ - - while (slash != NULL) { - - ptr = slash; - *ptr = '\0'; - - /* If reached an existing parent, break */ - - if (access(str, F_OK) == 0) - break; - - /* If non-existing parent */ - - else { - slash = strrchr(str, '/'); - - /* If under / or current directory, make it. */ - - if (slash == NULL || slash == str) { - if (mkdir(str, mode) != 0 && errno != EEXIST) { - free(str); - return (-1); - } - break; - } - } - } - - /* Create directories starting from upmost non-existing parent */ - - while ((ptr = strchr(str, '\0')) != endptr) { - *ptr = '/'; - if (mkdir(str, mode) != 0 && errno != EEXIST) { - /* - * If the mkdir fails because str already - * exists (EEXIST), then str has the form - * "existing-dir/..", and this is really - * ok. (Remember, this loop is creating the - * portion of the path that didn't exist) - */ - free(str); - return (-1); - } - } - free(str); - return (0); -} - -/* - * simplify - given a pathname, simplify that path by removing - * duplicate contiguous slashes. - * - * A simplified copy of the argument is returned to the - * caller, or NULL is returned on error. - * - * The caller should handle error reporting based upon the - * returned value, and should free the returned value, - * when appropriate. - */ - -static char * -simplify(const char *str) -{ - int i; - size_t mbPathlen; /* length of multi-byte path */ - size_t wcPathlen; /* length of wide-character path */ - wchar_t *wptr; /* scratch pointer */ - wchar_t *wcPath; /* wide-character version of the path */ - char *mbPath; /* The copy fo the path to be returned */ - - /* - * bail out if there is nothing there. - */ - - if (!str) { - errno = ENOENT; - return (NULL); - } - - /* - * Get a copy of the argument. - */ - - if ((mbPath = strdup(str)) == NULL) { - return (NULL); - } - - /* - * convert the multi-byte version of the path to a - * wide-character rendering, for doing our figuring. - */ - - mbPathlen = strlen(mbPath); - - if ((wcPath = calloc(mbPathlen+1, sizeof (wchar_t))) == NULL) { - free(mbPath); - return (NULL); - } - - if ((wcPathlen = mbstowcs(wcPath, mbPath, mbPathlen)) == (size_t)-1) { - free(mbPath); - free(wcPath); - return (NULL); - } - - /* - * remove duplicate slashes first ("//../" -> "/") - */ - - for (wptr = wcPath, i = 0; i < wcPathlen; i++) { - *wptr++ = wcPath[i]; - - if (wcPath[i] == '/') { - i++; - - while (wcPath[i] == '/') { - i++; - } - - i--; - } - } - - *wptr = '\0'; - - /* - * now convert back to the multi-byte format. - */ - - if (wcstombs(mbPath, wcPath, mbPathlen) == (size_t)-1) { - free(mbPath); - free(wcPath); - return (NULL); - } - - free(wcPath); - return (mbPath); -} diff --git a/lib/libspl/os/freebsd/getexecname.c b/lib/libspl/os/freebsd/getexecname.c deleted file mode 100644 index 49c0ce3a2432..000000000000 --- a/lib/libspl/os/freebsd/getexecname.c +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 - */ - -#include <stdint.h> -#include <limits.h> -#include <sys/param.h> -#include <sys/sysctl.h> -#include <sys/types.h> -#include "../../libspl_impl.h" - -__attribute__((visibility("hidden"))) ssize_t -getexecname_impl(char *execname) -{ - size_t len = PATH_MAX; - int name[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; - - if (sysctl(name, nitems(name), execname, &len, NULL, 0) != 0) - return (-1); - - return (len); -} diff --git a/lib/libspl/os/freebsd/gethostid.c b/lib/libspl/os/freebsd/gethostid.c deleted file mode 100644 index bd0f3ee5a075..000000000000 --- a/lib/libspl/os/freebsd/gethostid.c +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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) 2017, Lawrence Livermore National Security, LLC. - */ - -#include <fcntl.h> -#include <stdlib.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/systeminfo.h> - -unsigned long -get_system_hostid(void) -{ - return (gethostid()); -} diff --git a/lib/libspl/os/freebsd/getmntany.c b/lib/libspl/os/freebsd/getmntany.c deleted file mode 100644 index baff124b4a40..000000000000 --- a/lib/libspl/os/freebsd/getmntany.c +++ /dev/null @@ -1,65 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2005 Sun Microsystems, Inc. All rights reserved. - * Copyright 2006 Ricardo Correia. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - -#include <stdio.h> -#include <string.h> -#include <sys/errno.h> -#include <sys/mnttab.h> -#include <sys/types.h> -#include <sys/sysmacros.h> -#include <sys/stat.h> -#include <unistd.h> -#include <libzutil.h> - -int -getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf) -{ - struct statfs sfs; - - if (strlen(path) >= MAXPATHLEN) { - (void) fprintf(stderr, "invalid object; pathname too long\n"); - return (-1); - } - - if (stat64(path, statbuf) != 0) { - (void) fprintf(stderr, "cannot open '%s': %s\n", - path, zfs_strerror(errno)); - return (-1); - } - - if (statfs(path, &sfs) != 0) { - (void) fprintf(stderr, "%s: %s\n", path, - zfs_strerror(errno)); - return (-1); - } - statfs2mnttab(&sfs, (struct mnttab *)entry); - return (0); -} diff --git a/lib/libspl/os/freebsd/mnttab.c b/lib/libspl/os/freebsd/mnttab.c deleted file mode 100644 index 5287da132966..000000000000 --- a/lib/libspl/os/freebsd/mnttab.c +++ /dev/null @@ -1,235 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2006 Pawel Jakub Dawidek <pjd@FreeBSD.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * This file implements Solaris compatible getmntany() and hasmntopt() - * functions. - */ - -#include <sys/param.h> -#include <sys/mount.h> -#include <sys/mntent.h> -#include <sys/mnttab.h> - -#include <ctype.h> -#include <errno.h> -#include <pthread.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -static char * -mntopt(char **p) -{ - char *cp = *p; - char *retstr; - - while (*cp && isspace(*cp)) - cp++; - - retstr = cp; - while (*cp && *cp != ',') - cp++; - - if (*cp) { - *cp = '\0'; - cp++; - } - - *p = cp; - return (retstr); -} - -char * -hasmntopt(struct mnttab *mnt, const char *opt) -{ - char tmpopts[MNT_LINE_MAX]; - char *f, *opts = tmpopts; - - if (mnt->mnt_mntopts == NULL) - return (NULL); - (void) strlcpy(opts, mnt->mnt_mntopts, MNT_LINE_MAX); - f = mntopt(&opts); - for (; *f; f = mntopt(&opts)) { - if (strncmp(opt, f, strlen(opt)) == 0) - return (f - tmpopts + mnt->mnt_mntopts); - } - return (NULL); -} - -static void -optadd(char *mntopts, size_t size, const char *opt) -{ - - if (mntopts[0] != '\0') - strlcat(mntopts, ",", size); - strlcat(mntopts, opt, size); -} - -static __thread char gfstypename[MFSNAMELEN]; -static __thread char gmntfromname[MNAMELEN]; -static __thread char gmntonname[MNAMELEN]; -static __thread char gmntopts[MNTMAXSTR]; - -void -statfs2mnttab(struct statfs *sfs, struct mnttab *mp) -{ - long flags; - - strlcpy(gfstypename, sfs->f_fstypename, sizeof (gfstypename)); - mp->mnt_fstype = gfstypename; - - strlcpy(gmntfromname, sfs->f_mntfromname, sizeof (gmntfromname)); - mp->mnt_special = gmntfromname; - - strlcpy(gmntonname, sfs->f_mntonname, sizeof (gmntonname)); - mp->mnt_mountp = gmntonname; - - flags = sfs->f_flags; - gmntopts[0] = '\0'; -#define OPTADD(opt) optadd(gmntopts, sizeof (gmntopts), (opt)) - if (flags & MNT_RDONLY) - OPTADD(MNTOPT_RO); - else - OPTADD(MNTOPT_RW); - if (flags & MNT_NOSUID) - OPTADD(MNTOPT_NOSETUID); - else - OPTADD(MNTOPT_SETUID); - if (flags & MNT_UPDATE) - OPTADD(MNTOPT_REMOUNT); - if (flags & MNT_NOATIME) - OPTADD(MNTOPT_NOATIME); - else - OPTADD(MNTOPT_ATIME); - OPTADD(MNTOPT_NOXATTR); - if (flags & MNT_NOEXEC) - OPTADD(MNTOPT_NOEXEC); - else - OPTADD(MNTOPT_EXEC); -#undef OPTADD - mp->mnt_mntopts = gmntopts; -} - -static pthread_rwlock_t gsfs_lock = PTHREAD_RWLOCK_INITIALIZER; -static struct statfs *gsfs = NULL; -static int allfs = 0; - -static int -statfs_init(void) -{ - struct statfs *sfs; - int error; - - (void) pthread_rwlock_wrlock(&gsfs_lock); - - if (gsfs != NULL) { - free(gsfs); - gsfs = NULL; - } - allfs = getfsstat(NULL, 0, MNT_NOWAIT); - if (allfs == -1) - goto fail; - gsfs = malloc(sizeof (gsfs[0]) * allfs * 2); - if (gsfs == NULL) - goto fail; - allfs = getfsstat(gsfs, (long)(sizeof (gsfs[0]) * allfs * 2), - MNT_NOWAIT); - if (allfs == -1) - goto fail; - sfs = realloc(gsfs, allfs * sizeof (gsfs[0])); - if (sfs != NULL) - gsfs = sfs; - (void) pthread_rwlock_unlock(&gsfs_lock); - return (0); -fail: - error = errno; - if (gsfs != NULL) - free(gsfs); - gsfs = NULL; - allfs = 0; - (void) pthread_rwlock_unlock(&gsfs_lock); - return (error); -} - -int -getmntany(FILE *fd __unused, struct mnttab *mgetp, struct mnttab *mrefp) -{ - int i, error; - - error = statfs_init(); - if (error != 0) - return (error); - - (void) pthread_rwlock_rdlock(&gsfs_lock); - - for (i = 0; i < allfs; i++) { - if (mrefp->mnt_special != NULL && - strcmp(mrefp->mnt_special, gsfs[i].f_mntfromname) != 0) { - continue; - } - if (mrefp->mnt_mountp != NULL && - strcmp(mrefp->mnt_mountp, gsfs[i].f_mntonname) != 0) { - continue; - } - if (mrefp->mnt_fstype != NULL && - strcmp(mrefp->mnt_fstype, gsfs[i].f_fstypename) != 0) { - continue; - } - statfs2mnttab(&gsfs[i], mgetp); - (void) pthread_rwlock_unlock(&gsfs_lock); - return (0); - } - (void) pthread_rwlock_unlock(&gsfs_lock); - return (-1); -} - -int -getmntent(FILE *fp, struct mnttab *mp) -{ - int error, nfs; - - nfs = (int)lseek(fileno(fp), 0, SEEK_CUR); - if (nfs == -1) - return (errno); - /* If nfs is 0, we want to refresh out cache. */ - if (nfs == 0 || gsfs == NULL) { - error = statfs_init(); - if (error != 0) - return (error); - } - (void) pthread_rwlock_rdlock(&gsfs_lock); - if (nfs >= allfs) { - (void) pthread_rwlock_unlock(&gsfs_lock); - return (-1); - } - statfs2mnttab(&gsfs[nfs], mp); - (void) pthread_rwlock_unlock(&gsfs_lock); - if (lseek(fileno(fp), 1, SEEK_CUR) == -1) - return (errno); - return (0); -} diff --git a/lib/libspl/os/freebsd/zone.c b/lib/libspl/os/freebsd/zone.c deleted file mode 100644 index d6f698207cd1..000000000000 --- a/lib/libspl/os/freebsd/zone.c +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include <stdlib.h> -#include <assert.h> -#include <sys/types.h> -#include <sys/sysctl.h> -#include <zone.h> - -zoneid_t -getzoneid(void) -{ - size_t size; - int jailid; - - /* Information that we are in jail or not is enough for our needs. */ - size = sizeof (jailid); - if (sysctlbyname("security.jail.jailed", &jailid, &size, NULL, 0) == -1) - assert(!"No security.jail.jailed sysctl!"); - return ((zoneid_t)jailid); -} diff --git a/lib/libspl/os/linux/getexecname.c b/lib/libspl/os/linux/getexecname.c deleted file mode 100644 index dc4fe26ca550..000000000000 --- a/lib/libspl/os/linux/getexecname.c +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 - */ - -#include <limits.h> -#include <stdint.h> -#include <unistd.h> -#include "../../libspl_impl.h" - -__attribute__((visibility("hidden"))) ssize_t -getexecname_impl(char *execname) -{ - return (readlink("/proc/self/exe", execname, PATH_MAX)); -} diff --git a/lib/libspl/os/linux/gethostid.c b/lib/libspl/os/linux/gethostid.c deleted file mode 100644 index d39f3dda3b8d..000000000000 --- a/lib/libspl/os/linux/gethostid.c +++ /dev/null @@ -1,84 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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) 2017, Lawrence Livermore National Security, LLC. - */ - -#include <fcntl.h> -#include <stdlib.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/systeminfo.h> - -static unsigned long -get_spl_hostid(void) -{ - FILE *f; - unsigned long hostid; - char *env; - - /* - * Allow the hostid to be subverted for testing. - */ - env = getenv("ZFS_HOSTID"); - if (env) - return (strtoull(env, NULL, 0)); - - f = fopen("/proc/sys/kernel/spl/hostid", "re"); - if (!f) - return (0); - - if (fscanf(f, "%lx", &hostid) != 1) - hostid = 0; - - fclose(f); - - return (hostid); -} - -unsigned long -get_system_hostid(void) -{ - unsigned long hostid = get_spl_hostid(); - uint32_t system_hostid; - - /* - * We do not use gethostid(3) because it can return a bogus ID, - * depending on the libc and /etc/hostid presence, - * and the kernel and userspace must agree. - * See comments above hostid_read() in the SPL. - */ - if (hostid == 0) { - int fd = open("/etc/hostid", O_RDONLY | O_CLOEXEC); - if (fd >= 0) { - if (read(fd, &system_hostid, sizeof (system_hostid)) - != sizeof (system_hostid)) - hostid = 0; - else - hostid = system_hostid; - (void) close(fd); - } - } - - return (hostid & HOSTID_MASK); -} diff --git a/lib/libspl/os/linux/getmntany.c b/lib/libspl/os/linux/getmntany.c deleted file mode 100644 index ee1cdf59b9e5..000000000000 --- a/lib/libspl/os/linux/getmntany.c +++ /dev/null @@ -1,188 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 2005 Sun Microsystems, Inc. All rights reserved. - * Copyright 2006 Ricardo Correia. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - -#include <stdio.h> -#include <string.h> -#include <mntent.h> -#include <sys/errno.h> -#include <sys/mnttab.h> - -#include <sys/types.h> -#include <sys/sysmacros.h> -#include <sys/stat.h> -#include <unistd.h> -#include <libzutil.h> - -#define BUFSIZE (MNT_LINE_MAX + 2) - -static __thread char buf[BUFSIZE]; - -#define DIFF(xx) ( \ - (mrefp->xx != NULL) && \ - (mgetp->xx == NULL || strcmp(mrefp->xx, mgetp->xx) != 0)) - -int -getmntany(FILE *fp, struct mnttab *mgetp, struct mnttab *mrefp) -{ - int ret; - - while ( - ((ret = _sol_getmntent(fp, mgetp)) == 0) && ( - DIFF(mnt_special) || DIFF(mnt_mountp) || - DIFF(mnt_fstype) || DIFF(mnt_mntopts))) { } - - return (ret); -} - -int -_sol_getmntent(FILE *fp, struct mnttab *mgetp) -{ - struct mntent mntbuf; - struct mntent *ret; - - ret = getmntent_r(fp, &mntbuf, buf, BUFSIZE); - - if (ret != NULL) { - mgetp->mnt_special = mntbuf.mnt_fsname; - mgetp->mnt_mountp = mntbuf.mnt_dir; - mgetp->mnt_fstype = mntbuf.mnt_type; - mgetp->mnt_mntopts = mntbuf.mnt_opts; - return (0); - } - - if (feof(fp)) - return (-1); - - return (MNT_TOOLONG); -} - -static int -getextmntent_impl(FILE *fp, struct extmnttab *mp, uint64_t *mnt_id) -{ - int ret; - struct stat64 st; - - *mnt_id = 0; - ret = _sol_getmntent(fp, (struct mnttab *)mp); - if (ret == 0) { -#ifdef HAVE_STATX_MNT_ID - struct statx stx; - if (statx(AT_FDCWD, mp->mnt_mountp, - AT_STATX_SYNC_AS_STAT | AT_SYMLINK_NOFOLLOW, - STATX_MNT_ID, &stx) == 0 && (stx.stx_mask & STATX_MNT_ID)) - *mnt_id = stx.stx_mnt_id; -#endif - if (stat64(mp->mnt_mountp, &st) != 0) { - mp->mnt_major = 0; - mp->mnt_minor = 0; - return (ret); - } - mp->mnt_major = major(st.st_dev); - mp->mnt_minor = minor(st.st_dev); - } - - return (ret); -} - -int -getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf) -{ - struct stat64 st; - FILE *fp; - int match; - boolean_t have_mnt_id = B_FALSE; - uint64_t target_mnt_id = 0; - uint64_t entry_mnt_id; -#ifdef HAVE_STATX_MNT_ID - struct statx stx; -#endif - - if (strlen(path) >= MAXPATHLEN) { - (void) fprintf(stderr, "invalid object; pathname too long\n"); - return (-1); - } - - /* - * Search for the path in /proc/self/mounts. Rather than looking for the - * specific path, which can be fooled by non-standard paths (i.e. ".." - * or "//"), we stat() the path and search for the corresponding - * (major,minor) device pair. - */ - if (stat64(path, statbuf) != 0) { - (void) fprintf(stderr, "cannot open '%s': %s\n", - path, zfs_strerror(errno)); - return (-1); - } - -#ifdef HAVE_STATX_MNT_ID - if (statx(AT_FDCWD, path, AT_STATX_SYNC_AS_STAT | AT_SYMLINK_NOFOLLOW, - STATX_MNT_ID, &stx) == 0 && (stx.stx_mask & STATX_MNT_ID)) { - have_mnt_id = B_TRUE; - target_mnt_id = stx.stx_mnt_id; - } -#endif - - if ((fp = fopen(MNTTAB, "re")) == NULL) { - (void) fprintf(stderr, "cannot open %s\n", MNTTAB); - return (-1); - } - - /* - * Search for the given (major,minor) pair in the mount table. - */ - - match = 0; - while (getextmntent_impl(fp, entry, &entry_mnt_id) == 0) { - if (have_mnt_id) { - match = (entry_mnt_id == target_mnt_id); - } else { - match = makedev(entry->mnt_major, entry->mnt_minor) == - statbuf->st_dev; - } - if (match) - break; - } - (void) fclose(fp); - - if (!match) { - (void) fprintf(stderr, "cannot find mountpoint for '%s'\n", - path); - return (-1); - } - - if (stat64(entry->mnt_mountp, &st) != 0) { - entry->mnt_major = 0; - entry->mnt_minor = 0; - return (-1); - } - - return (0); -} diff --git a/lib/libspl/os/linux/zone.c b/lib/libspl/os/linux/zone.c deleted file mode 100644 index f1520676753e..000000000000 --- a/lib/libspl/os/linux/zone.c +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2006 Ricardo Correia. All rights reserved. - * Use is subject to license terms. - */ - -#include <unistd.h> -#include <stdio.h> -#include <errno.h> -#include <stdlib.h> -#include <limits.h> -#include <string.h> - -#include <zone.h> - -zoneid_t -getzoneid(void) -{ - char path[PATH_MAX]; - char buf[128] = { '\0' }; - char *cp; - - int c = snprintf(path, sizeof (path), "/proc/self/ns/user"); - /* This API doesn't have any error checking... */ - if (c < 0 || c >= sizeof (path)) - return (GLOBAL_ZONEID); - - ssize_t r = readlink(path, buf, sizeof (buf) - 1); - if (r < 0) - return (GLOBAL_ZONEID); - - cp = strchr(buf, '['); - if (cp == NULL) - return (GLOBAL_ZONEID); - cp++; - - unsigned long n = strtoul(cp, NULL, 10); - if (n == ULONG_MAX && errno == ERANGE) - return (GLOBAL_ZONEID); - zoneid_t z = (zoneid_t)n; - - return (z); -} diff --git a/lib/libspl/page.c b/lib/libspl/page.c deleted file mode 100644 index 6160a1de10cd..000000000000 --- a/lib/libspl/page.c +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.0 -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 https://opensource.org/licenses/CDDL-1.0. - * 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 - */ - -#include <unistd.h> -#include <sys/param.h> - -static size_t pagesize = 0; - -size_t -spl_pagesize(void) -{ - if (pagesize == 0) - pagesize = sysconf(_SC_PAGESIZE); - - return (pagesize); -} diff --git a/lib/libspl/strlcat.c b/lib/libspl/strlcat.c deleted file mode 100644 index 6e4c3280a83a..000000000000 --- a/lib/libspl/strlcat.c +++ /dev/null @@ -1,61 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -#ifndef HAVE_STRLCAT - -#include <string.h> -#include <sys/types.h> - -/* - * Appends src to the dstsize buffer at dst. The append will never - * overflow the destination buffer and the buffer will always be null - * terminated. Never reference beyond &dst[dstsize-1] when computing - * the length of the pre-existing string. - */ - -size_t -strlcat(char *dst, const char *src, size_t dstsize) -{ - char *df = dst; - size_t left = dstsize; - size_t l1; - size_t l2 = strlen(src); - size_t copied; - - while (left-- != 0 && *df != '\0') - df++; - l1 = df - dst; - if (dstsize == l1) - return (l1 + l2); - - copied = l1 + l2 >= dstsize ? dstsize - l1 - 1 : l2; - (void) memcpy(dst + l1, src, copied); - dst[l1+copied] = '\0'; - - return (l1 + l2); -} - -#endif diff --git a/lib/libspl/strlcpy.c b/lib/libspl/strlcpy.c deleted file mode 100644 index 49ffa2db67c5..000000000000 --- a/lib/libspl/strlcpy.c +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef HAVE_STRLCPY - -#include <string.h> -#include <sys/types.h> - -/* - * Copies src to the dstsize buffer at dst. The copy will never - * overflow the destination buffer and the buffer will always be null - * terminated. - */ - -size_t -strlcpy(char *dst, const char *src, size_t len) -{ - size_t slen = strlen(src); - size_t copied; - - if (len == 0) - return (slen); - - if (slen >= len) - copied = len - 1; - else - copied = slen; - (void) memcpy(dst, src, copied); - dst[copied] = '\0'; - return (slen); -} - -#endif /* HAVE_STRLCPY */ diff --git a/lib/libspl/timestamp.c b/lib/libspl/timestamp.c deleted file mode 100644 index 0b0838f4b442..000000000000 --- a/lib/libspl/timestamp.c +++ /dev/null @@ -1,107 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include <stdio.h> -#include <time.h> -#include <langinfo.h> -#include "statcommon.h" - -#ifndef _DATE_FMT -#ifdef D_T_FMT -#define _DATE_FMT D_T_FMT -#else /* D_T_FMT */ -#define _DATE_FMT "%+" -#endif /* !D_T_FMT */ -#endif /* _DATE_FMT */ - -/* - * Print timestamp as decimal reprentation of time_t value (-T u was specified) - * or in date(1) format (-T d was specified). - */ -void -print_timestamp(uint_t timestamp_fmt) -{ - time_t t = time(NULL); - static const char *fmt = NULL; - - /* We only need to retrieve this once per invocation */ - if (fmt == NULL) - fmt = nl_langinfo(_DATE_FMT); - - if (timestamp_fmt == UDATE) { - (void) printf("%lld\n", (longlong_t)t); - } else if (timestamp_fmt == DDATE) { - char dstr[64]; - struct tm tm; - int len; - - len = strftime(dstr, sizeof (dstr), fmt, localtime_r(&t, &tm)); - if (len > 0) - (void) printf("%s\n", dstr); - } -} - -/* - * Return timestamp as decimal reprentation (in string) of time_t - * value (-T u was specified) or in date(1) format (-T d was specified). - */ -void -get_timestamp(uint_t timestamp_fmt, char *buf, int len) -{ - time_t t = time(NULL); - static const char *fmt = NULL; - - /* We only need to retrieve this once per invocation */ - if (fmt == NULL) - fmt = nl_langinfo(_DATE_FMT); - - if (timestamp_fmt == UDATE) { - (void) snprintf(buf, len, "%lld", (longlong_t)t); - } else if (timestamp_fmt == DDATE) { - struct tm tm; - strftime(buf, len, fmt, localtime_r(&t, &tm)); - } -} - -/* - * Format the provided time stamp to human readable format - */ -void -format_timestamp(time_t t, char *buf, int len) -{ - struct tm tm; - static const char *fmt = NULL; - - if (t == 0) { - snprintf(buf, len, "-"); - return; - } - - /* We only need to retrieve this once per invocation */ - if (fmt == NULL) - fmt = nl_langinfo(_DATE_FMT); - strftime(buf, len, fmt, localtime_r(&t, &tm)); -} diff --git a/lib/libspl/tunables.c b/lib/libspl/tunables.c deleted file mode 100644 index 67dc9710dee8..000000000000 --- a/lib/libspl/tunables.c +++ /dev/null @@ -1,319 +0,0 @@ -// SPDX-License-Identifier: CDDL-1.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 https://opensource.org/licenses/CDDL-1.0. - * 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) 2025, Rob Norris <robn@despairlabs.com> - */ - -#include <stddef.h> -#include <string.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <limits.h> -#include <inttypes.h> -#include <sys/tunables.h> - -/* - * Userspace tunables. - * - * Tunables are external pointers to global variables that are wired up to the - * host environment in some way that allows the operator to directly change - * their values "under the hood". - * - * In userspace, the "host environment" is the program using libzpool.so. So - * that it can manipulate tunables if it wants, we provide an API to access - * them. - * - * Tunables are declared through the ZFS_MODULE_PARAM* macros, which associate - * a global variable with some metadata we can use to describe and access the - * tunable. This is done by creating a uniquely-named zfs_tunable_t. - * - * At runtime, we need a way to discover these zfs_tunable_t items. Since they - * are declared globally, all over the codebase, there's no central place to - * record or list them. So, we take advantage of the compiler's "linker set" - * feature. - * - * In the ZFS_MODULE_PARAM macro, after we create the zfs_tunable_t, we also - * create a zfs_tunable_t* pointing to it. That pointer is forced into the - * "zfs_tunables" ELF section in compiled object. At link time, the linker will - * collect all these pointers into one single big "zfs_tunable" section, and - * will generate two new symbols in the final object: __start_zfs_tunable and - * __stop_zfs_tunable. These point to the first and last item in that section, - * which allows us to access the pointers in that section like an array, and - * through those pointers access the tunable metadata, and from there the - * actual C variable that the tunable describes. - */ - -extern const zfs_tunable_t *__start_zfs_tunables; -extern const zfs_tunable_t *__stop_zfs_tunables; - -/* - * Because there are no tunables in libspl itself, the above symbols will not - * be generated, which will stop libspl being linked at all. To work around - * that, we force a symbol into that section, and then when iterating, skip - * any NULL pointers. - */ -static void *__zfs_tunable__placeholder - __attribute__((__section__("zfs_tunables"))) - __attribute__((__used__)) = NULL; - -/* - * Find the name tunable by walking through the linker set and comparing names, - * as described above. This is not particularly efficient but it's a fairly - * rare task, so it shouldn't be a big deal. - */ -const zfs_tunable_t * -zfs_tunable_lookup(const char *name) -{ - for (const zfs_tunable_t **ztp = &__start_zfs_tunables; - ztp != &__stop_zfs_tunables; ztp++) { - const zfs_tunable_t *zt = *ztp; - if (zt == NULL) - continue; - if (strcmp(name, zt->zt_name) == 0) - return (zt); - } - - return (NULL); -} - -/* - * Like zfs_tunable_lookup, but call the provided callback for each tunable. - */ -void -zfs_tunable_iter(zfs_tunable_iter_t cb, void *arg) -{ - for (const zfs_tunable_t **ztp = &__start_zfs_tunables; - ztp != &__stop_zfs_tunables; ztp++) { - const zfs_tunable_t *zt = *ztp; - if (zt == NULL) - continue; - if (cb(zt, arg)) - return; - } -} - -/* - * Parse a string into an int or uint. It's easier to have a pair of "generic" - * functions that clamp to a given min and max rather than have multiple - * functions for each width of type. - */ -static int -zfs_tunable_parse_int(const char *val, intmax_t *np, - intmax_t min, intmax_t max) -{ - intmax_t n; - char *end; - errno = 0; - n = strtoimax(val, &end, 0); - if (errno != 0) - return (errno); - if (*end != '\0') - return (EINVAL); - if (n < min || n > max) - return (ERANGE); - *np = n; - return (0); -} - -static int -zfs_tunable_parse_uint(const char *val, uintmax_t *np, - uintmax_t min, uintmax_t max) -{ - uintmax_t n; - char *end; - errno = 0; - n = strtoumax(val, &end, 0); - if (errno != 0) - return (errno); - if (*end != '\0') - return (EINVAL); - if (strchr(val, '-')) - return (ERANGE); - if (n < min || n > max) - return (ERANGE); - *np = n; - return (0); -} - -/* - * Set helpers for each tunable type. Parses the string, and if produces a - * valid value for the tunable, sets it. No effort is made to make sure the - * tunable is of the right type; that's done in zfs_tunable_set() below. - */ -static int -zfs_tunable_set_int(const zfs_tunable_t *zt, const char *val) -{ - intmax_t n; - int err = zfs_tunable_parse_int(val, &n, INT_MIN, INT_MAX); - if (err != 0) - return (err); - *(int *)zt->zt_varp = n; - return (0); -} - -static int -zfs_tunable_set_uint(const zfs_tunable_t *zt, const char *val) -{ - uintmax_t n; - int err = zfs_tunable_parse_uint(val, &n, 0, UINT_MAX); - if (err != 0) - return (err); - *(unsigned int *)zt->zt_varp = n; - return (0); -} - -static int -zfs_tunable_set_ulong(const zfs_tunable_t *zt, const char *val) -{ - uintmax_t n; - int err = zfs_tunable_parse_uint(val, &n, 0, ULONG_MAX); - if (err != 0) - return (err); - *(unsigned long *)zt->zt_varp = n; - return (0); -} - -static int -zfs_tunable_set_u64(const zfs_tunable_t *zt, const char *val) -{ - uintmax_t n; - int err = zfs_tunable_parse_uint(val, &n, 0, UINT64_MAX); - if (err != 0) - return (err); - *(uint64_t *)zt->zt_varp = n; - return (0); -} - -static int -zfs_tunable_set_string(const zfs_tunable_t *zt, const char *val) -{ - (void) zt, (void) val; - /* - * We can't currently handle strings. String tunables are pointers - * into read-only memory, so we can update the pointer, but not the - * contents. That would mean taking an allocation, but we don't have - * an obvious place to free it. - * - * For now, it's no big deal as there's only a couple of string - * tunables anyway. - */ - return (ENOTSUP); -} - -/* - * Get helpers for each tunable type. Converts the value to a string if - * necessary and writes it into the provided buffer. The type is assumed to - * be correct; zfs_tunable_get() below will call the correct function for the - * type. - */ -static int -zfs_tunable_get_int(const zfs_tunable_t *zt, char *val, size_t valsz) -{ - snprintf(val, valsz, "%d", *(int *)zt->zt_varp); - return (0); -} - -static int -zfs_tunable_get_uint(const zfs_tunable_t *zt, char *val, size_t valsz) -{ - snprintf(val, valsz, "%u", *(unsigned int *)zt->zt_varp); - return (0); -} - -static int -zfs_tunable_get_ulong(const zfs_tunable_t *zt, char *val, size_t valsz) -{ - snprintf(val, valsz, "%lu", *(unsigned long *)zt->zt_varp); - return (0); -} - -static int -zfs_tunable_get_u64(const zfs_tunable_t *zt, char *val, size_t valsz) -{ - snprintf(val, valsz, "%"PRIu64, *(uint64_t *)zt->zt_varp); - return (0); -} - -static int -zfs_tunable_get_string(const zfs_tunable_t *zt, char *val, size_t valsz) -{ - strlcpy(val, *(char **)zt->zt_varp, valsz); - return (0); -} - -/* The public set function. Delegates to the type-specific version. */ -int -zfs_tunable_set(const zfs_tunable_t *zt, const char *val) -{ - int err; - switch (zt->zt_type) { - case ZFS_TUNABLE_TYPE_INT: - err = zfs_tunable_set_int(zt, val); - break; - case ZFS_TUNABLE_TYPE_UINT: - err = zfs_tunable_set_uint(zt, val); - break; - case ZFS_TUNABLE_TYPE_ULONG: - err = zfs_tunable_set_ulong(zt, val); - break; - case ZFS_TUNABLE_TYPE_U64: - err = zfs_tunable_set_u64(zt, val); - break; - case ZFS_TUNABLE_TYPE_STRING: - err = zfs_tunable_set_string(zt, val); - break; - default: - err = EOPNOTSUPP; - break; - } - return (err); -} - -/* The public get function. Delegates to the type-specific version. */ -int -zfs_tunable_get(const zfs_tunable_t *zt, char *val, size_t valsz) -{ - int err; - switch (zt->zt_type) { - case ZFS_TUNABLE_TYPE_INT: - err = zfs_tunable_get_int(zt, val, valsz); - break; - case ZFS_TUNABLE_TYPE_UINT: - err = zfs_tunable_get_uint(zt, val, valsz); - break; - case ZFS_TUNABLE_TYPE_ULONG: - err = zfs_tunable_get_ulong(zt, val, valsz); - break; - case ZFS_TUNABLE_TYPE_U64: - err = zfs_tunable_get_u64(zt, val, valsz); - break; - case ZFS_TUNABLE_TYPE_STRING: - err = zfs_tunable_get_string(zt, val, valsz); - break; - default: - err = EOPNOTSUPP; - break; - } - return (err); -} |