aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2010-08-26 11:22:58 -0700
committerBrian Behlendorf <[email protected]>2010-08-31 13:41:27 -0700
commitc9c0d073da561bcbefbdf09c87fc75b227415619 (patch)
tree7daee55ae61526107f421de48171573fa5a15d28
parent40b84e7aec6392187722e61e5a4a853b530bf60f (diff)
Add build system
Add autoconf style build infrastructure to the ZFS tree. This includes autogen.sh, configure.ac, m4 macros, some scripts/*, and makefiles for all the core ZFS components.
-rw-r--r--ChangeLog576
-rw-r--r--META8
-rw-r--r--Makefile.am56
-rw-r--r--autogen.sh8
-rw-r--r--cmd/Makefile.am1
-rw-r--r--cmd/zdb/Makefile.am31
-rw-r--r--cmd/zfs/Makefile.am32
-rw-r--r--cmd/zinject/Makefile.am34
-rw-r--r--cmd/zpool/Makefile.am34
-rw-r--r--cmd/zpool_id/Makefile.am1
-rwxr-xr-xcmd/zpool_id/zpool_id60
-rw-r--r--cmd/zpool_layout/Makefile.am1
-rwxr-xr-xcmd/zpool_layout/zpool_layout127
-rw-r--r--cmd/ztest/Makefile.am34
-rw-r--r--config/Makefile.am1
-rw-r--r--config/Rules.am7
-rw-r--r--config/config.awk15
-rw-r--r--config/deb.am37
-rw-r--r--config/kernel-bdev-block-device-operations.m433
-rw-r--r--config/kernel-bdev-logical-size.m422
-rw-r--r--config/kernel-bio-empty-barrier.m420
-rw-r--r--config/kernel-bio-end-io-t-args.m429
-rw-r--r--config/kernel-bio-rw-syncio.m419
-rw-r--r--config/kernel-blk-end-request.m437
-rw-r--r--config/kernel-blk-fetch-request.m422
-rw-r--r--config/kernel-blk-requeue-request.m422
-rw-r--r--config/kernel-blk-rq-bytes.m438
-rw-r--r--config/kernel-blk-rq-pos.m418
-rw-r--r--config/kernel-blk-rq-sectors.m418
-rw-r--r--config/kernel-fmode-t.m418
-rw-r--r--config/kernel-get-disk-ro.m418
-rw-r--r--config/kernel-invalidate-bdev-args.m419
-rw-r--r--config/kernel-kobj-name-len.m421
-rw-r--r--config/kernel-open-bdev-exclusive.m412
-rw-r--r--config/kernel-rq-for-each_segment.m420
-rw-r--r--config/kernel-rq-is_sync.m418
-rw-r--r--config/kernel.m4390
-rw-r--r--config/rpm.am73
-rw-r--r--config/tgz.am30
-rw-r--r--config/user-arch.m419
-rw-r--r--config/user-frame-larger-than.m422
-rw-r--r--config/user-ioctl.m435
-rw-r--r--config/user-libblkid.m494
-rw-r--r--config/user-libshare.m48
-rw-r--r--config/user-libuuid.m418
-rw-r--r--config/user-nptl_guard_within_stack.m456
-rw-r--r--config/user-zlib.m421
-rw-r--r--config/user.m413
-rw-r--r--config/zfs-build.m4295
-rw-r--r--config/zfs-meta.m4131
-rw-r--r--configure.ac91
-rw-r--r--etc/Makefile.am3
-rw-r--r--etc/udev/rules.d/60-zpool.rules8
-rw-r--r--etc/zfs/zdev.conf9
-rw-r--r--etc/zfs/zdev.conf.dragon.example176
-rw-r--r--etc/zfs/zdev.conf.supermicro.example30
-rw-r--r--etc/zfs/zdev.conf.x4550.example66
-rw-r--r--lib/Makefile.am1
-rw-r--r--lib/libavl/Makefile.am14
-rw-r--r--lib/libefi/Makefile.am14
-rw-r--r--lib/libnvpair/Makefile.am19
-rw-r--r--lib/libunicode/Makefile.am15
-rw-r--r--lib/libuutil/Makefile.am27
-rw-r--r--lib/libzfs/Makefile.am39
-rw-r--r--lib/libzpool/Makefile.am168
-rw-r--r--lib/libzpool/include/Makefile.am1
-rw-r--r--man/Makefile.am1
-rw-r--r--man/man8/Makefile.am5
-rw-r--r--module/Makefile.in54
-rw-r--r--module/avl/Makefile.in8
-rw-r--r--module/nvpair/Makefile.in10
-rw-r--r--module/unicode/Makefile.in9
-rw-r--r--module/zcommon/Makefile.in18
-rw-r--r--module/zfs/Makefile.in89
-rw-r--r--patches/e2fsprogs-1.41.4-zfs-probe-uberblock.patch32
-rw-r--r--scripts/Makefile.am29
-rw-r--r--scripts/common.sh.in373
-rwxr-xr-xscripts/zconfig.sh572
-rwxr-xr-xscripts/zfs.sh74
-rw-r--r--scripts/zpool-config/dm0-raid0.sh60
-rw-r--r--scripts/zpool-config/dragon-raid0-1x70.sh21
-rw-r--r--scripts/zpool-config/dragon-raid10-35x2.sh21
-rw-r--r--scripts/zpool-config/dragon-raidz-7x10.sh21
-rw-r--r--scripts/zpool-config/dragon-raidz2-7x10.sh21
-rw-r--r--scripts/zpool-config/file-raid0.sh31
-rw-r--r--scripts/zpool-config/file-raid10.sh34
-rw-r--r--scripts/zpool-config/file-raidz.sh31
-rw-r--r--scripts/zpool-config/file-raidz2.sh31
-rw-r--r--scripts/zpool-config/hda-raid0.sh16
-rw-r--r--scripts/zpool-config/lo-raid0.sh39
-rw-r--r--scripts/zpool-config/lo-raid10.sh54
-rw-r--r--scripts/zpool-config/lo-raidz.sh39
-rw-r--r--scripts/zpool-config/lo-raidz2.sh39
-rw-r--r--scripts/zpool-config/md0-raid10.sh38
-rw-r--r--scripts/zpool-config/md0-raid5.sh38
-rw-r--r--scripts/zpool-config/ram0-raid0.sh16
-rw-r--r--scripts/zpool-config/sda-raid0.sh16
-rw-r--r--scripts/zpool-config/supermicro-raid0-1x16.sh21
-rw-r--r--scripts/zpool-config/supermicro-raid10-8x2.sh21
-rw-r--r--scripts/zpool-config/supermicro-raidz-4x4.sh21
-rw-r--r--scripts/zpool-config/supermicro-raidz2-4x4.sh21
-rw-r--r--scripts/zpool-config/x4550-raid0-1x48.sh21
-rw-r--r--scripts/zpool-config/x4550-raid10-24x2.sh21
-rw-r--r--scripts/zpool-config/x4550-raidz-8x6.sh21
-rw-r--r--scripts/zpool-config/x4550-raidz2-8x6.sh21
-rwxr-xr-xscripts/zpool-create.sh133
-rw-r--r--zfs-modules.spec.in280
-rw-r--r--zfs.spec.in79
108 files changed, 5853 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 000000000..e89461c44
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,576 @@
+2010-08-13 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.5.0
+
+ * : The ChangeLog is being retired. Please use the git commit
+ logs for a full records of changes: 'git log --no-merges'
+
+2010-05-21 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.4.9 - Use 'git log --no-merges' for full change log.
+
+ * : Build system improvements:
+ - Added support for the 'make -s' silent build option.
+ - Allow zfs_config.h to be included by dependent packages.
+ - Minor spec file updates.
+ - Minor build system message updates.
+
+ * : Topic branch cleanup. Several old branches were removed and
+ numerous hunks which were accidentaly commited to incorrect topic
+ branches in the past were relocated to the correct topic branch.
+
+ * *.c, *.h, *.sh, AUTHORS, COPYING, COPYRIGHT, DISCLAIMER, README:
+ Added standard header to source files which includes the copyright,
+ license, and author information. Additionally, updated the listed
+ top level files to the latest versions.
+
+ * cmd/zpool/zpool_vdev.c: Check all partitions with check_file()
+ even when no libblkid is found. This oversight would result in
+ ZFS not detecting existing filesystems on partitions.
+
+ * module/zfs/fm.c, module/zfs/zfs_fm, libzfs/libzfs_pool.c:
+ Added zevents which are similar to Solaris FMA support. The
+ existing FMA and sysevent call points in ZFS were unified in
+ to a single event type and used to create a user space visible
+ event notification system under Linux. The new 'zpool events'
+ command can be used to show all recent ZFS events.
+
+ * module/zfs/spa.c, module/zfs/zil.c: Suppress large memory
+ allocation warnings for two particular kmem_alloc()'s. For
+ now we can live with them as is but long term a way should be
+ found to perform small allocations or use the vmem based slab.
+
+ * module/zfs/zvol.c: Recreate volume and snapshot /dev links during
+ module load. Links in /dev for volumes/snapshots were only being
+ created at volume/snapshot creation time. Those links are now also
+ created dynamically at module load time based on the spa config.
+
+ * module/zfs/zvol.c, module/zfs/include/sys/blkdev.h: The handler
+ zvol_request() should use the unlocked version of blk_end_request()
+ to avoid a deadlock in the ZVOL.
+
+2010-03-11 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.4.8 - Use 'git log --no-merges' for full change log.
+
+ * : Build system improvements:
+ - Remove Module.markers and Module.symver{s} in clean target.
+ - Improved kernel source detection when none specified.
+ - Fix RPM definitions for the unknown distro/installation.
+ - Check for spl in ../spl if not found in install path.
+ - Include all headers regardless of depth in packages.
+ - Allow recursive configure/make.
+
+ * lib/libzpool/kernel.c: Fixed several zdb bugs when opening a pool
+ - zdb wasn't getting the correct device size when the vdev is a
+ block device. In Solaris, fstat64() returns the device size but
+ in Linux an ioctl() is needed.
+ - make sure that we don't try to open a block device in write mode
+ from userspace. This shouldn't happen, because zdb opens devices
+ in read-only mode, and ztest only uses files.
+
+ * lib/libspl/include/umem.h: Add umem_alloc_aligned() and honor
+ cache_align field for umem cache. Under linux we open block devices
+ with O_DIRECT which means we must provide aligned memory buffers.
+
+ * lib/libzpool/kernel.c: Fix some incorrect error handling. In
+ vn_open(), if fstat64() returned an error, the real errno was being
+ obscured by calling close().
+
+ * scripts/*: Fix scripts to work when invoked from other directories.
+
+ * module/zfs/arc.c: Fix struct ht_lock padding in arc.c.
+
+ * lib/libefi/include/sys/uuid.h: Fix duplicate uuid_t typedef.
+
+ * module/zfs/txg.c: Use CPU percentages for number of commit cb
+ threads. This doesn't change number of threads in the kernel, but it
+ reduces number of threads in ztest (important due to 32-bit address
+ limitations).
+
+ * cmd/ztest/ztest.c: Clean up emulation of kernel threads in
+ userspace. Updated to use pthread thread specific data rather than
+ keeping a global list. This also fixes at least one easily
+ reproducible crash in ztest
+
+ * META, config/kernel.m4: Add configure check for kernel build
+ options which are incompatible with the license. If your building
+ against a kernel deemed incompatible configure will fail and
+ suggest how you should rebuild your kernel.
+
+ * config/kernel-fmode-t.m4: Linux 2.6.28 compat, add a check for the
+ fmode_t type. This typedef first appears in 2.6.28 kernels as part
+ of some block device operation reworking.
+
+ * module/zfs/dmu_send.c: No inline to keep dmu_recv_stream() stack
+ frame less than 1024 bytes. Recent builds against 2.6.31 flagged
+ dmu_recv_stream() as stack heavy. Further analysis of this function
+ should be performed to further reduce its stack usage.
+
+ * scripts/common.sh: Split the udev rule from a specific configuration
+ by providing a generic 60-zpool.rules file which uses a small helper
+ util 'zpool_id' to parse a configuration file by default located in
+ /etc/zfs/zdev.conf. The helper script maps a by-path udev name to a
+ more friendly name of <channel><rank> for large configurations.
+
+ Additionally, when running zpool-create.sh in-tree it will no longer
+ use udev because we would have to copy certain helper scripts in to
+ the installed system. To avoid this the config file in simply
+ parsed and symlinks are created in your working tree. The script
+ will use udev if it as run as part of an installed zfs-test package.
+
+ * module/zfs/zvol.c: Use check_disk_change() instead of
+ revalidate_disk(). For 2.6.27 kernels are earlier revalidate_disk()
+ was not available. However, check_disk_change() has been available
+ for far longer and will properly inform the kernel of the volume
+ change for both older and newer kernels.
+
+ * module/zfs/dmu.c: Fixed incorrect ASSERT3S() added by ZVOL.
+
+ * module/zfs/vdev_raidz.c, module/zfs/zvol.c: Minor fixes for 32-bit.
+
+ * scripts/zfs-update.sh, man/man8/*: Added man pages based on the
+ latest documentation and modified zfs-update.sh script to update them.
+
+ * .gitignore: Updated .gitignore rules to exclude build products.
+
+2009-11-24 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.4.7 - Use 'git log --no-merges' for full change log.
+
+ * module/zcommon/include/sys/fs/zfs.h, module/zfs/include/sys/blkdev.h,
+ module/zfs/include/sys/dmu.h, module/zfs/dmu.c,
+ module/zfs/include/sys/zvol.h, module/zfs/zvol.c,
+ module/zfs/zfs_ioctl.c:
+ Added the ZVOL block device, with the addition of the ZVOL real ZFS
+ based block devices are available and can be compared head to head
+ with Linux's MD and LVM block drivers. The Linux ZVOL has not yet
+ had any performance work done but from a user perspective it should
+ be functionally complete and behave like any other Linux block device.
+ The ZVOL has so far been tested using zconfig.sh on the following
+ x86_64 based platforms: FC11, CHAOS4, RHEL5, RHEL6, and SLES11.
+ However, more testing is required to ensure everything is working
+ as designed.
+
+ * scripts/udev-rules/99-zpool.rules.promise,
+ scripts/zpool-config/promise-raid0-1x16.sh,
+ scripts/zpool-config/promise-raid10-8x2.sh,
+ scripts/zpool-config/promise-raidz-2x8.sh,
+ scripts/zpool-config/promise-raidz2-2x8.sh:
+ Additional test configurations for a small 16 drive JBOD.
+
+ * module/zfs/arc.c: Linux 2.6.31 compat, mutexes can now exceed 64
+ bytes depending on the the kernel build options. To account for
+ this increase the pad size to 256 bytes.
+
+ * module/zfs/vdev_disk.c: Linux 2.6.31 compat, to get the hard
+ sector size use bdev_logical_block_size() this function replaces
+ bdev_hardsect_size().
+
+ * module/zfs/zfs_rlock.c: Prevent gcc uninit compiler warning in
+ zfs_range_unlock_reader().
+
+ * Makefile.am: Ensure *.order and *.markers build products are
+ removed by distclean rule.
+
+2009-11-02 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.4.6 - Use 'git log --no-merges' for full change log.
+
+ * Rebased to ZFS b121 from OpenSolaris.
+
+ * module/zfs/vdev_disk.c: Finally a feature complete implementation:
+ - Handle dynamic bio merge_bdev limitations when constructing the
+ bio set associated with a dio. This previously prevented us from
+ layering cleanly on the md and dm virtual devices.
+ - Removed hard coded 512 byte sector size.
+ - Correctly determine the device size when using a partition.
+ - Hold and extra dio reference when submitting bio's using
+ bio_submit() to prevent a completion race.
+
+ * lib/libefi/*: Added fully function libefi library from Solaris.
+ This allows us to properly create and access GPT style partition
+ tables which are used when a whole device is added to a zpool.
+
+ * cmd/zpool/zpool_vdev.c: Fully integrated zpool with Linux package
+ libblkid. This allows zpool to identify existing devices of
+ various types to prevent devices from accidentally being used. When
+ given a whole device with a GPT partition table all partitions will
+ be checked for existing filesystems. At the moment MBR style
+ partition tables cannot be check and the force option must be used.
+
+ * cmd/zpool/zpool_vdev.c: Solaris devid support has been removed in
+ favor of Linux's udev. This means that a zpool device will always be
+ opened using the path provided at configuration time. This may
+ initially seem limiting but it has certain advantages:
+ - When creating a zpool where the physical location of the device
+ is NOT import simply create the pool using the /dev/disk/by-id paths.
+ This will ensure that regardless of physical location the device
+ will be properly located.
+ - When creating a zpool where the physical location of the device
+ is important use the /dev/disk/by-path paths. This will ensure that
+ devices are never accidentally detected and used in an incorrect
+ location which would compromise the redundancy of the system.
+ - Ever better you can create use your own udev rules file to setup
+ any mapping and naming convention you desire. One example of a
+ custom rule is to map physical device locations using grid with
+ numbers are letter for coordinates. Each letter might represent
+ a specific bus/channel and each number a specific device. For large
+ configurations this provides an easy way to identify devices.
+
+ * module/zpios/zpios.c: Update to use kobject_set_name() for
+ increased portability.
+
+ * modules/*/*: Update module init/exit access points to use
+ spl_module_{init,exit}() macro API. This ensures the cwd is
+ immediately set to '/' and may be leveraged latter for any
+ additional module setup/cleanup which is required.
+
+ * cmd/ztest/ztest.c: Check ftrucate() return code to prevent
+ warnings when --fortify-source options is used in rpm builds.
+
+ * config/Rules.am: Set DEBUG/NDEBUG globally when building user
+ space components.
+
+ * scripts/zconfig.sh: Initial hook for running additional sanity
+ tests are part of 'make check'. Currently, there are only two
+ tests which do some basic configuration checking but they should
+ be extended as much as possible to prevent regressions. Tests
+ should also all be written so they run entirely in-tree.
+
+ * scripts/zpios-sanity.sh: Initial hook for validating real IO
+ using all block devices and all raid configurations. Supported
+ device types include scsi, ide, md, dm, ram, loop, and file.
+ Supported raid types include raid0, raid10, raidz, and raidz2.
+
+ * scripts/zpool-config/*: Update dragon and x4550 configs to use
+ custom udev rules file with <A-Z><1-N> naming convention. Add
+ configs for md, dm, and ram block devices to verify functionality.
+
+ * zfs-test.spec.in: Added zfs-test package which extends the existing
+ in-tree test infrastructure such that it can be run as part of an
+ installed package. This simplifies the testing of tagged releases.
+
+ * zfs-modules.spec.in: Various spec file tweaks for the supported
+ distros: RHEL5, RHEL6, SLES10, SLES11, Chaos4, Fedora 11.
+
+2009-08-04 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.4.5 - Use 'git log --no-merges' for full change log.
+
+ * FC11 and SLES11 support: This includes all compatibility changes
+ to support 2.6.29 based kernels and the required build system
+ improvements.
+ * lib/libspl/asm-generic/atomic.c: Generic user space atomic support.
+ * module/zpios/zpios.c: Register a basic compat ioctl handler for
+ 32-bit user vs 64-bit kernel compatibility. This is the default
+ build environment for all 64-bit SLES systems. Additionally
+ replace the use of 'struct timespec' which uses longs internally
+ and is therefore different sizes on 32-bit vs 64-bit objects with
+ 'struct zpios_timespec_t'.a
+ * config/kernel.m4: Check arch/default path when detecting kernel
+ objects under SLES. We still preferentially use arch/arch if
+ available but if that fails it is acceptable to use default.
+ * config/kernel.m4: Remove LINUXINCLUDE from autoconf wrapper.
+ This breaks the 2.6.28+ kernels build system, all kernel build systems
+ at least post 2.6.16 will set this properly so we should not.
+ * lib/libspl/include/assert.h: Add ASSERTV macro to simplify removing
+ variables (the V in ASSERTV) which are only used in ASSERT().
+ Also revert all previously modified ASSERT()s to their original
+ definitions and use the ASSERTV macro to handle unused variables.
+ * module/zpios/zpios.c: Use spl device interfaces for portability.
+ * scripts/common.sh: The losetup -f option is unavailable for
+ SLES10 use the unused_loop_device() common function. Additionally
+ LOSETUP is now used to portably reference the losetup binary.
+ * module/zfs/vdev_disk.c: Unused destroy_dirty_buffers arg removed.
+ * module/zfs/vdev_disk.c: BIO_RW_SYNC renamed to BIO_RW_SYNCIO.
+ * module/zfs/vdev_disk.c: open/close_bdev_excl() renamed to
+ open/close_bdev_exclusive().
+ * module/zfs/vdev_disk.c: Empty write barriers are supported as of
+ linux 2.6.24 and are now used to implement DKIOCFLUSHWRITECACHE.
+ * module/zfs/vdev_disk.c: The bi_end_io API changes make partial
+ IO's impossible handle this case cleanly.
+ * module/zfs/vdev_disk.c: BIO_RW_FAILFAST replaced with
+ BIO_RW_FAILFAST_{DEV|_TRANSPORT|_DRIVER}, use the legacy
+ BIO_RW_FAILFAST flag if it exists for now.
+ * module/zfs/dmu_objset.c, module/zfs/spa_history.c: Excessively
+ large stack frames (>2048) were detected in dmu_objset_snapshot()
+ and spa_history_log() and were reduced by allocating from the heap.
+
+ * Rebased to ZFS b117 from OpenSolaris:
+ * module/zfs/dmu.c: Update zerocopy patch to be consistent with
+ new flags arg passed to dmu_read().
+ * module/zpios/zpios.c: Update zpios to be aware of the new flags
+ argument available in dmu_read(). Additionally add a zpios command
+ line flag to set the DMU_READ_NO_PREFETCH flag for a test.
+ * module/zfs/include/sys/zfs_context.h: Wrap new sysevent includes
+ until sysevent or something like it is implemented.
+ * module/zfs/zfs_ioctl.c: Wrap all the ACL interfaces with HAVE_ZPL.
+ They are integrated with the vfs layer which is not yet supported.
+ * module/zcommon/zfs_prop.c: Export new quota related symbols.
+ * lib/libzfs/libzfs_util.c: Increase buffer size for nvlist which
+ is needed for large configurations.
+
+ * Bug fixes:
+ * lib/libspl/include/sys/zfs_debug.h: Removed duplicate file.
+ * lib/libspl/include/sys/isa_defs.h: Fixed missing macro definitions
+ for little endian and big endian.
+ * cmd/zpios/zpios_main.c: Pretty-up the zpios 'make check' output.
+ * module/zfs/vdev_disk.c: Honor spa_mode() when opening block devs.
+ * module/zfs/vdev_disk.c: Initial error handling added to
+ vdev_disk_io_done() to revalidate the media on EIO.
+ * lib/libzfs/libzfs_util.c: Fix an accidentally introduced formatting
+ issue in zfs_nicenum() output.
+
+2009-07-02 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.4.4 - Use 'git log --no-merges' for full change log.
+
+ * : Generic distro friendly build system / packaging improvements
+ for RPM based distros including CHAOS, RHEL, Fedora, and SLES.
+
+ These changes bring the zfs-0.4.4 tree in to compliance with
+ the spl-0.4.4 packaging changes. The bottom line is 2 source
+ rpms and 4 binary rpms will now be generated when creating
+ packages there will be:
+
+ zfs-<version>.src.rpm
+ - Fully rebuildable source rpm for libzfs and utils.
+ zfs-modules-<version>.src.rpm
+ - Fully rebuildable source rpm for kernel modules.
+
+ zfs-<version>.<arch>.rpm
+ - Binary rpm for libzfs and utils. The utils in this package are
+ compatible with all zfs-module rpms of the same version.
+ zfs-devel-<version>.<arch>.rpm
+ - Binary rpm containing headers for building against libzfs libraries.
+
+ zfs-modules-<verion>-<kernel>.arch.rpm
+ - Binary rpm containing the kernel modules for a specific kernel build.
+ The package name contains the kernel version and you should have one
+ of these packages installed to match every kernel on your system.
+ zfs-modules-devel-<verion>-<kernel>.arch.rpm
+ - Binary rpm containing development header and module symbols needed
+ for building additional kernel modules which are dependent on the
+ zfs module stack.
+
+ * : SLES9/10 distro support added: Several significant updates to
+ the build system were required to support this including:
+
+ - Autoconf macros updated to be aware of the standard install
+ locations for SLES kernel sources and build objects. Additionally
+ changes were made to support multiple names for Module{s}.symvers.
+ - By default on SLES all user space builds are 32-bit even on
+ 64-bit arches. This means we need to be careful to pass -m64 in
+ the autoconf checks which probe the kernel. Additionally,
+ ioctl_compat handles still need to be added so 32-bit user
+ binarys can perform ioctls with the 64-bit kernel.
+
+ * : Powerpc64 support added:
+
+ - 64-bit user space atomic support for power64 was obtained from
+ an old version of OpenSolaris which offered minimal powerpc support.
+ The atomic support is not 100% fully implemented but it's a good
+ first step towards cleanly supporting the architecture.
+ - Added powerpc ISA type.
+ - Explicitly use signed char for portability. On x86/x86_64
+ systems the default char type is signed, on ppc/ppc64 systems
+ the default char type is unsigned.
+ - Core target arch support for conditional compilation of SUBDIRs.
+ Required by libspl for its arch specific atomic implementations.
+
+ * COPYRIGHT: Readded accidentally dropped COPYRIGHT, it just
+ references the OPENSOLARIS.LICENSE which was still in the project.
+
+ * module/zfs/dmu_tx.c: Add EXPORT_SYMBOL(dmu_tx_callback_register).
+
+ * config/user-zlib.m4: Add basic zlib autoconf check for user space.
+
+2009-03-20 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.4.3 - Use 'git log --no-merges' for full change log.
+
+ * : Rebased to ZFS b108 from OpenSolaris
+
+ * configure.ac, *Makefile.am: Build system update. This includes
+ resolving various build issues and adding support for the remaining
+ common build targets. Available targets now include:
+
+ - make all # Build everything
+ - make install # Install everything
+ - make clean # Clean up build products
+ - make distclean # Clean up everything
+ - make dist # Create package tarball
+ - make srpm # Create package source RPM
+ - make rpm # Create package binary RPMs
+ - make tags # Create ctags and etags for everything
+
+ Extra care was taken to ensure that the source RPMs are fully
+ rebuildable against Fedora/RHEL/Chaos kernels. To build binary
+ RPMs from the source RPM for your system simply run:
+
+ rpmbuild --rebuild zfs-x.y.z-1.src.rpm
+
+ This will produce two binary RPMs with correct 'requires'
+ dependencies for your kernel. One will contain all zfs modules
+ and support utilities, the other is a devel package for compiling
+ additional kernel modules which are dependent on the zfs.
+
+ zfs-x.y.z-1_<kernel version>.x86_64.rpm
+ zfs-devel-x.y.2-1_<kernel version>.x86_64.rpm
+
+ * config/kernel.m4, config/Rules.am: Removed the build options
+ -Wno-unused -Wno-missing -Wno-unused -Wno-parentheses and
+ -Wno-unknown-pragmas. All upstream warnings which were being
+ suppressed by these options are now handled in the matching
+ gcc-* topic branch.
+
+ * zpios: Various zpios and test infrastructure improvements.
+
+ * feature-commit-cb: New feature commit callbacks.
+
+ * : Various bug fixes which are more clearly detailed in the
+ git commit logs. For a detailed summary of changes post version
+ 0.4.2, check out the 'top' topic branch and view the commit logs.
+
+ git checkout top
+ git log --no-merges -53
+
+2009-02-05 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.4.2
+
+ * lib/libzfs/libzfs_util.c: Remove mknod() this is now handled by
+ by the SPL with an upcall even without GPL-only symbols.
+
+ * module/zfs/vdev_diskc: Updated linux vdev_disk interfaces to issue
+ multiple bios if needed due to the maximum request size being smaller
+ than the request size passed down from the spa.
+
+ * scripts/zpool-config/lo-*: Add loopback based test configs.
+
+2009-01-21 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.4.1
+
+ * : Rebased to ZFS b105 from OpenSolaris
+
+ * : Restructured project and build system to more closely
+ mirror the code organization used in OpenSolaris. This
+ allows us minimize the changes to upstream source needed,
+ and allows concurrent user+kernel space builds of all components.
+
+2008-11-19 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.4.0
+
+ * : ZFS project migrated from Subversion which leveraged a
+ quilt based patch stack to Git and a TopGit managed patch
+ stack. The new method treats all patches as Git branches
+ which can be more easily shared for distributed development.
+ Consult the top level GIT file for detailed information on
+ how to properly develop for this package using Git+TopGit.
+
+2008-11-12 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.3.4
+
+ * zfs-07-create-dev-zfs.patch:
+ Ricardo M. Correia <[email protected]>
+ - Make libzfs create /dev/zfs if it doesn't exist.
+
+ * zfs-05-check-zvol-size.patch:
+ Ricardo M. Correia <[email protected]>
+ - Properly check zvol size under Linux.
+
+ * zfs-04-no-openat-fdopendir.patch:
+ Ricardo M. Correia <[email protected]>
+ - Do not use openat() and fdopendir() since they are not available
+ on older systems.
+
+ * zfs-03-fix-bio-sync.patch:
+ Ricardo M. Correia <[email protected]>
+ - Fix memory corruption in RHEL4 due to synchronous IO becoming
+ asynchronous.
+
+2008-11-06 Brian Behlendorf <[email protected]>
+
+ * zfs-02-zpios-fix-stuck-thread-memleak.patch:
+ Ricardo M. Correia <[email protected]>
+ - Fix stuck threads and memory leaks when errors occur while writing.
+
+ * zfs-01-zpios-arg-corruption.patch:
+ Ricardo M. Correia <[email protected]>
+ - Fix zpios cmd line argument corruption problem.
+
+ * zfs-00-minor-fixes.patch:
+ Ricardo M. Correia <[email protected]>
+ - Minor build system improvements
+ - Minor script improvements
+ - Create a full copy and not a link tree with quilt
+ - ZPIOS_MAJOR changed from 231 to 232
+ - BIO_RW_BARRIER flag removed from IO request
+
+2008-06-30 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.3.3
+
+ * : Minor script updates and tweaks to be compatible with
+ the latest version of the SPL.
+
+2008-06-13 Brian Behlendorf <[email protected]>
+
+ * vdev_disk.diff: Replace vdev_disk implementation which was
+ based on the kmalloc'ed logical address space with a version
+ which works with vmalloc'ed memory in the virtual address space.
+ This was done to support the new SPL slab implementation which
+ is based on virtual addresses to avoid the need for contigeously
+ allocated memory.
+
+2008-06-05 Brian Behlendorf <[email protected]>
+
+ * arc-vm-integration.diff: Reduce maximum default arc memory
+ usage to 1/4 of total system memory. Because all the bulk data
+ is still allocated on the slab memory fragmentation is a serious
+ concern. To address this in the short term we simply need to
+ leave lots of free memory.
+
+ * fix-stack.diff: First step towards reducing stack usage so
+ we can run the full ZFS stack using a stock kernel.
+
+2008-06-04 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.3.2
+
+ * : Extensive improvements to the build system to detect kernel
+ API changes so we can flexibly build with a wider range of kernel
+ versions. The code has now been testing with the 2.6.18-32chaos
+ and 2.6.25.3-18.fc9 kernels, however we should also be compatible
+ with other kernels in the range of 2.6.18-2.6.25. The only
+ remaining issue preventing us from running with a stock
+ kernel is ZFS stack usage.
+
+2008-05-21 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.3.1
+
+ * : License headers including URCL added for release.
+
+2008-05-21 Brian Behlendorf <[email protected]>
+
+ * : Tag zfs-0.3.0
+
+ * configure.ac: Improved autotools support and configurable debug.
+
+2008-05-15 Brian Behlendorf <[email protected]>
+
+ * : Updating original ZFS sources to build 89 which
+ includes the new write throttling changes plus support
+ for using ZFS as your root device. Neither of which
+ will work exactly right without some more work but this
+ gets us much closers to the latest source.
+
+
+2008-02-28 Brian Behlendorf <[email protected]>
+
+ * : First attempt based on SPL module and zfs-lustre sources
diff --git a/META b/META
new file mode 100644
index 000000000..1e1c6fba9
--- /dev/null
+++ b/META
@@ -0,0 +1,8 @@
+Meta: 1
+Name: zfs
+Branch: 1.0
+Version: 0.5.0
+Release: 1
+Release-Tags: relext
+License: CDDL
+Author: Sun Microsystems/Oracle, Lawrence Livermore National Laboratory
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 000000000..3689d1f8f
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,56 @@
+include $(top_srcdir)/config/rpm.am
+include ${top_srcdir}/config/deb.am
+include ${top_srcdir}/config/tgz.am
+
+if CONFIG_USER
+USER_DIR = config etc man scripts lib cmd
+endif
+if CONFIG_KERNEL
+KERNEL_DIR = module
+endif
+SUBDIRS = $(USER_DIR) $(KERNEL_DIR)
+
+AUTOMAKE_OPTIONS = foreign dist-zip
+EXTRA_DIST = autogen.sh zfs.spec.in zfs-modules.spec.in
+EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am
+EXTRA_DIST += META DISCLAIMER COPYRIGHT GIT README.markdown
+EXTRA_DIST += OPENSOLARIS.LICENSE ZFS.RELEASE
+
+noinst_HEADERS = zfs_config.h
+
+distclean-local::
+ -$(RM) -R autom4te*.cache
+ -find . \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \
+ -o -name .pc -o -name .hg -o -name .git \) -prune -o \
+ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
+ -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
+ -o -name '.*.rej' -o -name 'aclocal.m4' -o -size 0 \
+ -o -name '*%' -o -name '.*.cmd' -o -name 'core' \
+ -o -name 'Makefile' -o -name 'Module.symvers' \
+ -o -name '*.order' -o -name '*.markers' \
+ -o -name '.script-config' \) \
+ -type f -print | xargs $(RM)
+
+if CONFIG_KERNEL
+install-data-local:
+ destname=zfs-$(ZFS_META_VERSION)/$(LINUX_VERSION); \
+ instdest=$(DESTDIR)/usr/src/$$destname; \
+ echo "${ZFS_META_VERSION}" >$$instdest/zfs.release; \
+ for instfile in $(noinst_HEADERS) module/$(LINUX_SYMBOLS); do \
+ $(INSTALL) -D $$instfile $$instdest/$$instfile; \
+ done
+endif
+
+ctags:
+ $(RM) $(top_srcdir)/tags
+ find $(top_srcdir) -name .git -prune -o -name '*.[hc]' | xargs ctags
+
+etags:
+ $(RM) $(top_srcdir)/TAGS
+ find $(top_srcdir) -name .pc -prune -o -name '*.[hc]' | xargs etags -a
+
+tags: ctags etags
+
+pkg: @DEFAULT_PACKAGE@
+pkg-modules: @DEFAULT_PACKAGE@-modules
+pkg-utils: @DEFAULT_PACKAGE@-utils
diff --git a/autogen.sh b/autogen.sh
new file mode 100644
index 000000000..728000ae4
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+aclocal -I config &&
+libtoolize --automake --copy
+autoheader &&
+automake --add-missing --include-deps --copy
+autoconf
+rm -rf autom4te.cache aclocal.m4
diff --git a/cmd/Makefile.am b/cmd/Makefile.am
new file mode 100644
index 000000000..954f8565c
--- /dev/null
+++ b/cmd/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = zfs zpool zpool_id zpool_layout zdb zinject ztest
diff --git a/cmd/zdb/Makefile.am b/cmd/zdb/Makefile.am
new file mode 100644
index 000000000..6f0b0cb87
--- /dev/null
+++ b/cmd/zdb/Makefile.am
@@ -0,0 +1,31 @@
+include $(top_srcdir)/config/Rules.am
+
+DEFAULT_INCLUDES += \
+ -I${top_srcdir}/lib/libspl/include \
+ -I${top_srcdir}/lib/libefi/include \
+ -I${top_srcdir}/lib/libzpool/include \
+ -I${top_srcdir}/lib/libnvpair/include \
+ -I${top_srcdir}/lib/libzfs/include \
+ -I${top_srcdir}/module/zfs/include \
+ -I${top_srcdir}/module/zcommon/include \
+ -I${top_srcdir}/module/nvpair/include \
+ -I${top_srcdir}/module/avl/include \
+ -I${top_srcdir}/module/unicode/include
+
+sbin_PROGRAMS = zdb
+
+zdb_SOURCES = \
+ ${top_srcdir}/cmd/zdb/zdb.c \
+ ${top_srcdir}/cmd/zdb/zdb_il.c
+
+zdb_LDADD = \
+ $(top_builddir)/lib/libspl/libspl.la \
+ $(top_builddir)/lib/libavl/libavl.la \
+ $(top_builddir)/lib/libefi/libefi.la \
+ $(top_builddir)/lib/libnvpair/libnvpair.la \
+ $(top_builddir)/lib/libunicode/libunicode.la \
+ $(top_builddir)/lib/libuutil/libuutil.la \
+ $(top_builddir)/lib/libzpool/libzpool.la \
+ $(top_builddir)/lib/libzfs/libzfs.la
+
+zdb_LDFLAGS = -pthread -lm $(ZLIB) -lrt $(LIBUUID) $(LIBBLKID)
diff --git a/cmd/zfs/Makefile.am b/cmd/zfs/Makefile.am
new file mode 100644
index 000000000..4d66e37a2
--- /dev/null
+++ b/cmd/zfs/Makefile.am
@@ -0,0 +1,32 @@
+include $(top_srcdir)/config/Rules.am
+
+DEFAULT_INCLUDES += \
+ -I${top_srcdir}/lib/libspl/include \
+ -I${top_srcdir}/lib/libefi/include \
+ -I${top_srcdir}/lib/libuutil/include \
+ -I${top_srcdir}/lib/libzfs/include \
+ -I${top_srcdir}/lib/libnvpair/include \
+ -I${top_srcdir}/module/zcommon/include \
+ -I${top_srcdir}/module/nvpair/include \
+ -I${top_srcdir}/module/avl/include \
+ -I${top_srcdir}/module/unicode/include
+
+sbin_PROGRAMS = zfs
+
+zfs_SOURCES = \
+ ${top_srcdir}/cmd/zfs/zfs_iter.c \
+ ${top_srcdir}/cmd/zfs/zfs_iter.h \
+ ${top_srcdir}/cmd/zfs/zfs_main.c \
+ ${top_srcdir}/cmd/zfs/zfs_util.h
+
+zfs_LDADD = \
+ $(top_builddir)/lib/libspl/libspl.la \
+ $(top_builddir)/lib/libavl/libavl.la \
+ $(top_builddir)/lib/libefi/libefi.la \
+ $(top_builddir)/lib/libnvpair/libnvpair.la \
+ $(top_builddir)/lib/libunicode/libunicode.la \
+ $(top_builddir)/lib/libuutil/libuutil.la \
+ $(top_builddir)/lib/libzpool/libzpool.la \
+ $(top_builddir)/lib/libzfs/libzfs.la
+
+zfs_LDFLAGS = -pthread -lm $(ZLIB) -lrt $(LIBUUID) $(LIBBLKID)
diff --git a/cmd/zinject/Makefile.am b/cmd/zinject/Makefile.am
new file mode 100644
index 000000000..7166ed9b4
--- /dev/null
+++ b/cmd/zinject/Makefile.am
@@ -0,0 +1,34 @@
+include $(top_srcdir)/config/Rules.am
+
+DEFAULT_INCLUDES += \
+ -I${top_srcdir}/lib/libspl/include \
+ -I${top_srcdir}/lib/libefi/include \
+ -I${top_srcdir}/lib/libzpool/include \
+ -I${top_srcdir}/lib/libuutil/include \
+ -I${top_srcdir}/lib/libzfs/include \
+ -I${top_srcdir}/lib/libnvpair/include \
+ -I${top_srcdir}/module/zfs \
+ -I${top_srcdir}/module/zfs/include \
+ -I${top_srcdir}/module/zcommon/include \
+ -I${top_srcdir}/module/nvpair/include \
+ -I${top_srcdir}/module/avl/include \
+ -I${top_srcdir}/module/unicode/include
+
+sbin_PROGRAMS = zinject
+
+zinject_SOURCES = \
+ ${top_srcdir}/cmd/zinject/translate.c \
+ ${top_srcdir}/cmd/zinject/zinject.c \
+ ${top_srcdir}/cmd/zinject/zinject.h
+
+zinject_LDADD = \
+ $(top_builddir)/lib/libspl/libspl.la \
+ $(top_builddir)/lib/libavl/libavl.la \
+ $(top_builddir)/lib/libefi/libefi.la \
+ $(top_builddir)/lib/libnvpair/libnvpair.la \
+ $(top_builddir)/lib/libunicode/libunicode.la \
+ $(top_builddir)/lib/libuutil/libuutil.la \
+ $(top_builddir)/lib/libzpool/libzpool.la \
+ $(top_builddir)/lib/libzfs/libzfs.la
+
+zinject_LDFLAGS = -pthread -lm $(ZLIB) -lrt $(LIBUUID) $(LIBBLKID)
diff --git a/cmd/zpool/Makefile.am b/cmd/zpool/Makefile.am
new file mode 100644
index 000000000..ec9757bd6
--- /dev/null
+++ b/cmd/zpool/Makefile.am
@@ -0,0 +1,34 @@
+include $(top_srcdir)/config/Rules.am
+
+DEFAULT_INCLUDES += \
+ -I${top_srcdir}/lib/libspl/include \
+ -I${top_srcdir}/lib/libefi/include \
+ -I${top_srcdir}/lib/libuutil/include \
+ -I${top_srcdir}/lib/libzfs/include \
+ -I${top_srcdir}/lib/libnvpair/include \
+ -I${top_srcdir}/module/zcommon/include \
+ -I${top_srcdir}/module/zfs/include \
+ -I${top_srcdir}/module/nvpair/include \
+ -I${top_srcdir}/module/avl/include \
+ -I${top_srcdir}/module/unicode/include
+
+sbin_PROGRAMS = zpool
+
+zpool_SOURCES = \
+ ${top_srcdir}/cmd/zpool/zpool_iter.c \
+ ${top_srcdir}/cmd/zpool/zpool_main.c \
+ ${top_srcdir}/cmd/zpool/zpool_util.c \
+ ${top_srcdir}/cmd/zpool/zpool_util.h \
+ ${top_srcdir}/cmd/zpool/zpool_vdev.c
+
+zpool_LDADD = \
+ $(top_builddir)/lib/libspl/libspl.la \
+ $(top_builddir)/lib/libavl/libavl.la \
+ $(top_builddir)/lib/libefi/libefi.la \
+ $(top_builddir)/lib/libnvpair/libnvpair.la \
+ $(top_builddir)/lib/libunicode/libunicode.la \
+ $(top_builddir)/lib/libuutil/libuutil.la \
+ $(top_builddir)/lib/libzpool/libzpool.la \
+ $(top_builddir)/lib/libzfs/libzfs.la
+
+zpool_LDFLAGS = -pthread -lm $(ZLIB) -lrt $(LIBUUID) $(LIBBLKID)
diff --git a/cmd/zpool_id/Makefile.am b/cmd/zpool_id/Makefile.am
new file mode 100644
index 000000000..023e1ab59
--- /dev/null
+++ b/cmd/zpool_id/Makefile.am
@@ -0,0 +1 @@
+dist_bin_SCRIPTS = zpool_id
diff --git a/cmd/zpool_id/zpool_id b/cmd/zpool_id/zpool_id
new file mode 100755
index 000000000..c3637847a
--- /dev/null
+++ b/cmd/zpool_id/zpool_id
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+CONFIG=${CONFIG:-/etc/zfs/zdev.conf}
+PATH_ID=${PATH_ID:-/lib/udev/path_id}
+AWK=${AWK:-/bin/awk}
+
+die() {
+ echo "Error: $*"
+ exit 1
+}
+
+usage() {
+ cat << EOF
+Usage: zpool_id [h] [-c configfile] <devpath>
+ -c Alternate config file [default /etc/zfs/zdev.conf]
+ -d Use path_id from device as the mapping key
+ -h Show this message
+EOF
+ exit 1
+}
+
+while getopts 'c:d:h' OPTION; do
+ case ${OPTION} in
+ c)
+ CONFIG=${OPTARG}
+ ;;
+ d)
+ DEVICE=${OPTARG}
+ ;;
+ h)
+ usage
+ ;;
+ esac
+done
+
+# Check that a device was requested
+[ -z ${DEVICE} ] && usage
+
+# Check for the existence of a configuration file
+[ ! -f ${CONFIG} ] && die "Missing config file: ${CONFIG}"
+
+# Use udev's path_id to generate a unique persistent key
+eval `${PATH_ID} ${DEVICE}`
+[ -z ${ID_PATH} ] && die "Missing ID_PATH for ${DEVICE}"
+
+# Use the persistent key to lookup the zpool device id in the
+# configuration file which is of the format <device id> <key>.
+# Lines starting with #'s are treated as comments and ignored.
+# Exact matches are required, wild cards are not supported,
+# and only the first match is returned.
+ID_ZPOOL=`${AWK} "/${ID_PATH}\>/ && !/^#/ { print \\$1; exit }" ${CONFIG}`
+[ -z ${ID_ZPOOL} ] && die "Missing ID_ZPOOL for ID_PATH: ${ID_PATH}"
+
+if [ ${ID_ZPOOL} ]; then
+ echo "ID_PATH=${ID_PATH}"
+ echo "ID_ZPOOL=${ID_ZPOOL}"
+ echo "ID_ZPOOL_PATH=disk/zpool/${ID_ZPOOL}"
+fi
+
+exit 0
diff --git a/cmd/zpool_layout/Makefile.am b/cmd/zpool_layout/Makefile.am
new file mode 100644
index 000000000..b17e6a362
--- /dev/null
+++ b/cmd/zpool_layout/Makefile.am
@@ -0,0 +1 @@
+dist_bin_SCRIPTS = zpool_layout
diff --git a/cmd/zpool_layout/zpool_layout b/cmd/zpool_layout/zpool_layout
new file mode 100755
index 000000000..19cd12807
--- /dev/null
+++ b/cmd/zpool_layout/zpool_layout
@@ -0,0 +1,127 @@
+#!/bin/bash
+#
+# Set BUSES and PORTS to match the topology of your system. As each
+# port is enumerated it will be assigned the next channel name. The
+# current script enumerates each port on a bus before moving on to
+# enumerate the next bus.
+#
+# Every distribution, version of udev, and type of attached storage
+# seems to result in slightly different formatting of the by-path
+# name. For this reason you may need to adjust the parsing below
+# to suit your needs. This is one of the reasons to use a custom
+# /etc/zfs/zdev.conf file, it allows the by-path naming convertion
+# to change and still keep the simple <channel><rank> naming.
+#
+CONFIG=${CONFIG:-/etc/zfs/zdev.conf}
+BUSES=( 01 02 03 )
+PORTS=( 4 0 )
+CHANNELS=( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z )
+TRIGGER=
+
+usage() {
+ cat << EOF
+Usage: zpool_layout [-th] [-c file] [-b buses] [-p ports] [-n channels]
+ -c Alternate config file [default=/etc/zfs/zdev.conf]
+ -b Enumerate buses [default="01 02 03"]
+ -p Enumerate ports [default="4 0"]
+ -n Channel names [default="A..Z"]
+ -t Trigger and wait for udev to settle [default=no]
+ -h Show this message
+EOF
+ exit 0
+}
+
+while getopts 'c:b:p:n:th' OPTION; do
+ case ${OPTION} in
+ c)
+ CONFIG=${OPTARG}
+ ;;
+ b)
+ BUSES=(${OPTARG})
+ ;;
+ p)
+ PORTS=(${OPTARG})
+ ;;
+ n)
+ CHANNELS=(${OPTARG})
+ ;;
+ t)
+ TRIGGER=1
+ ;;
+ h)
+ usage
+ ;;
+ esac
+done
+
+# Save stdout as fd #8, then redirect stdout to the config file.
+exec 8>&1
+exec >${CONFIG}
+pushd /dev/disk/by-path >/dev/null
+
+# Generate comment header.
+echo "#"
+echo "# Custom /dev/disk/by-path to /dev/disk/zpool mapping, "
+echo "# based of the following physical cable layout."
+echo "#"
+
+# Generate host port layout table for comment header.
+echo "# ------------------ Host Port Layout ---------------------"
+echo -n "# "
+for (( i=0; i<${#BUSES[*]}; i++ )); do
+ printf "%-8d" ${BUSES[$i]}
+done
+echo
+
+for (( i=0, k=0; i<${#PORTS[*]}; i++ )); do
+ printf "# Port %-2d " ${PORTS[$i]}
+
+ for (( j=0; j<${#BUSES[*]}; j++, k++ )); do
+ let k=$j*${#PORTS[*]}+$i
+ printf "%-8s" ${CHANNELS[$k]}
+ done
+ echo
+done
+echo "#"
+
+# Generate channel/disk layout table for comment header.
+echo "# ----------------- Channel/Disk Layout -------------------"
+echo "# Channel Disks"
+for (( i=0, k=0; i<${#BUSES[*]}; i++ )); do
+ for (( j=0; j<${#PORTS[*]}; j++, k++ )); do
+ printf "# %-9s" ${CHANNELS[$k]}
+ ls *:${BUSES[$i]}:*:${PORTS[$j]}* 2>/dev/null | \
+ cut -f7 -d'-' | sort -u -n | tr '\n' ','
+ echo
+ done
+done
+echo "#"
+
+# Generate mapping from <channel><rank> to by-path name.
+TMP_FILE=`mktemp`
+AWK=${AWK:-/bin/awk}
+
+for (( i=0, k=0; i<${#BUSES[*]}; i++ )); do
+ for (( j=0; j<${#PORTS[*]}; j++, k++ )); do
+ ls *:${BUSES[$i]}:*:${PORTS[$j]}* 2>/dev/null | \
+ grep -v part | sort -n -k7 -t'-'>${TMP_FILE}
+
+ echo
+ echo -n "# Channel ${CHANNELS[$k]}, "
+ echo "Bus ${BUSES[$i]}, Port ${PORTS[$j]}"
+ ${AWK} -F '-' -v ch="${CHANNELS[$k]}" \
+ '{print ch$7 "\t" $0 }' ${TMP_FILE}
+ done
+done
+
+# Restore stdout from fd #8 and close fd #8.
+exec 1>&8 8>&-
+rm -f ${TMP_FILE}
+popd >/dev/null
+
+if [ ${TRIGGER} ]; then
+ udevadm trigger
+ udevadm settle
+fi
+
+exit 0
diff --git a/cmd/ztest/Makefile.am b/cmd/ztest/Makefile.am
new file mode 100644
index 000000000..804efccca
--- /dev/null
+++ b/cmd/ztest/Makefile.am
@@ -0,0 +1,34 @@
+include $(top_srcdir)/config/Rules.am
+
+AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
+
+DEFAULT_INCLUDES += \
+ -I${top_srcdir}/lib/libspl/include \
+ -I${top_srcdir}/lib/libefi/include \
+ -I${top_srcdir}/lib/libzpool/include \
+ -I${top_srcdir}/lib/libuutil/include \
+ -I${top_srcdir}/lib/libzfs/include \
+ -I${top_srcdir}/lib/libnvpair/include \
+ -I${top_srcdir}/module/zfs \
+ -I${top_srcdir}/module/zfs/include \
+ -I${top_srcdir}/module/zcommon/include \
+ -I${top_srcdir}/module/nvpair/include \
+ -I${top_srcdir}/module/avl/include \
+ -I${top_srcdir}/module/unicode/include
+
+sbin_PROGRAMS = ztest
+
+ztest_SOURCES = \
+ ${top_srcdir}/cmd/ztest/ztest.c
+
+ztest_LDADD = \
+ $(top_builddir)/lib/libspl/libspl.la \
+ $(top_builddir)/lib/libavl/libavl.la \
+ $(top_builddir)/lib/libefi/libefi.la \
+ $(top_builddir)/lib/libnvpair/libnvpair.la \
+ $(top_builddir)/lib/libunicode/libunicode.la \
+ $(top_builddir)/lib/libuutil/libuutil.la \
+ $(top_builddir)/lib/libzpool/libzpool.la \
+ $(top_builddir)/lib/libzfs/libzfs.la
+
+ztest_LDFLAGS = -pthread -lm $(ZLIB) -lrt -ldl $(LIBUUID) $(LIBBLKID)
diff --git a/config/Makefile.am b/config/Makefile.am
new file mode 100644
index 000000000..b412e6bdc
--- /dev/null
+++ b/config/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = *.m4 Rules.am
diff --git a/config/Rules.am b/config/Rules.am
new file mode 100644
index 000000000..b22b724a6
--- /dev/null
+++ b/config/Rules.am
@@ -0,0 +1,7 @@
+DEFAULT_INCLUDES = -include ${top_srcdir}/zfs_config.h
+
+AM_LIBTOOLFLAGS = --silent
+AM_CFLAGS = -Wall -Wstrict-prototypes -fno-strict-aliasing ${DEBUG_CFLAGS}
+AM_CFLAGS += -D_GNU_SOURCE -D__EXTENSIONS__ -D_REENTRANT
+AM_CFLAGS += -D_POSIX_PTHREAD_SEMANTICS -D_FILE_OFFSET_BITS=64
+AM_CFLAGS += -D_LARGEFILE64_SOURCE -DTEXT_DOMAIN=\"zfs-linux-user\"
diff --git a/config/config.awk b/config/config.awk
new file mode 100644
index 000000000..cc4b7cc26
--- /dev/null
+++ b/config/config.awk
@@ -0,0 +1,15 @@
+# Remove default preprocessor define's from config.h
+# PACKAGE
+# PACKAGE_BUGREPORT
+# PACKAGE_NAME
+# PACKAGE_STRING
+# PACKAGE_TARNAME
+# PACKAGE_VERSION
+# STDC_HEADERS
+# VERSION
+
+BEGIN { RS = "" ; FS = "\n" } \
+ !/.#define PACKAGE./ && \
+ !/.#define VERSION./ && \
+ !/.#define STDC_HEADERS./ \
+ { print $0"\n" }
diff --git a/config/deb.am b/config/deb.am
new file mode 100644
index 000000000..f836a3cf1
--- /dev/null
+++ b/config/deb.am
@@ -0,0 +1,37 @@
+deb-local:
+ @(if test "${HAVE_DPKGBUILD}" = "no"; then \
+ echo -e "\n" \
+ "*** Required util ${DPKGBUILD} missing. Please install the\n" \
+ "*** package for your distribution which provides ${DPKGBUILD},\n" \
+ "*** re-run configure, and try again.\n"; \
+ exit 1; \
+ fi; \
+ if test "${HAVE_ALIEN}" = "no"; then \
+ echo -e "\n" \
+ "*** Required util ${ALIEN} missing. Please install the\n" \
+ "*** package for your distribution which provides ${ALIEN},\n" \
+ "*** re-run configure, and try again.\n"; \
+ exit 1; \
+ fi)
+
+deb-modules: deb-local rpm-modules
+ name=${PACKAGE}-modules; \
+ version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
+ release=`echo ${LINUX_VERSION} | $(SED) -e "s/-/_/g"`; \
+ arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch}`; \
+ pkg1=$${name}-$${version}_$${release}.$${arch}.rpm; \
+ pkg2=$${name}-devel-$${version}_$${release}.$${arch}.rpm; \
+ fakeroot $(ALIEN) --scripts --to-deb $$pkg1 $$pkg2; \
+ $(RM) $$pkg1 $$pkg2
+
+deb-utils: deb-local rpm-utils
+ name=${PACKAGE}; \
+ version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
+ arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch}`; \
+ pkg1=$${name}-$${version}.$${arch}.rpm; \
+ pkg2=$${name}-devel-$${version}.$${arch}.rpm; \
+ pkg3=$${name}-test-$${version}.$${arch}.rpm; \
+ fakeroot $(ALIEN) --scripts --to-deb $$pkg1 $$pkg2 $$pkg3; \
+ $(RM) $$pkg1 $$pkg2 $$pkg3
+
+deb: deb-modules deb-utils
diff --git a/config/kernel-bdev-block-device-operations.m4 b/config/kernel-bdev-block-device-operations.m4
new file mode 100644
index 000000000..daf14f0f9
--- /dev/null
+++ b/config/kernel-bdev-block-device-operations.m4
@@ -0,0 +1,33 @@
+dnl #
+dnl # 2.6.x API change
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_BDEV_BLOCK_DEVICE_OPERATIONS], [
+ AC_MSG_CHECKING([block device operation prototypes])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/blkdev.h>
+ ],[
+ int (*blk_open) (struct block_device *, fmode_t) = NULL;
+ int (*blk_release) (struct gendisk *, fmode_t) = NULL;
+ int (*blk_ioctl) (struct block_device *, fmode_t,
+ unsigned, unsigned long) = NULL;
+ int (*blk_compat_ioctl) (struct block_device *, fmode_t,
+ unsigned, unsigned long) = NULL;
+ struct block_device_operations blk_ops = {
+ .open = blk_open,
+ .release = blk_release,
+ .ioctl = blk_ioctl,
+ .compat_ioctl = blk_compat_ioctl,
+ };
+
+ blk_ops.open(NULL, 0);
+ blk_ops.release(NULL, 0);
+ blk_ops.ioctl(NULL, 0, 0, 0);
+ blk_ops.compat_ioctl(NULL, 0, 0, 0);
+ ],[
+ AC_MSG_RESULT(struct block_device)
+ AC_DEFINE(HAVE_BDEV_BLOCK_DEVICE_OPERATIONS, 1,
+ [struct block_device_operations use bdevs])
+ ],[
+ AC_MSG_RESULT(struct inode)
+ ])
+])
diff --git a/config/kernel-bdev-logical-size.m4 b/config/kernel-bdev-logical-size.m4
new file mode 100644
index 000000000..1e199663b
--- /dev/null
+++ b/config/kernel-bdev-logical-size.m4
@@ -0,0 +1,22 @@
+dnl #
+dnl # 2.6.30 API change
+dnl # bdev_hardsect_size() replaced with bdev_logical_block_size(). While
+dnl # it has been true for a while that there was no strict 1:1 mapping
+dnl # between physical sector size and logical block size this change makes
+dnl # it explicit.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_BDEV_LOGICAL_BLOCK_SIZE], [
+ AC_MSG_CHECKING([whether bdev_logical_block_size() is available])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/blkdev.h>
+ ],[
+ struct block_device *bdev = NULL;
+ bdev_logical_block_size(bdev);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BDEV_LOGICAL_BLOCK_SIZE, 1,
+ [bdev_logical_block_size() is available])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/config/kernel-bio-empty-barrier.m4 b/config/kernel-bio-empty-barrier.m4
new file mode 100644
index 000000000..99549fe24
--- /dev/null
+++ b/config/kernel-bio-empty-barrier.m4
@@ -0,0 +1,20 @@
+dnl #
+dnl # 2.6.24 API change
+dnl # Empty write barriers are now supported and we should use them.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_BIO_EMPTY_BARRIER], [
+ AC_MSG_CHECKING([whether bio_empty_barrier() is defined])
+ EXTRA_KCFLAGS="-Werror"
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/bio.h>
+ ],[
+ struct bio bio;
+ (void)bio_empty_barrier(&bio);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BIO_EMPTY_BARRIER, 1,
+ [bio_empy_barrier() is defined])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/config/kernel-bio-end-io-t-args.m4 b/config/kernel-bio-end-io-t-args.m4
new file mode 100644
index 000000000..ea69bdba5
--- /dev/null
+++ b/config/kernel-bio-end-io-t-args.m4
@@ -0,0 +1,29 @@
+dnl #
+dnl # 2.6.24 API change
+dnl # Size argument dropped from bio_endio and bi_end_io, because the
+dnl # bi_end_io is only called once now when the request is complete.
+dnl # There is no longer any need for a size argument. This also means
+dnl # that partial IO's are no longer possibe and the end_io callback
+dnl # should not check bi->bi_size. Finally, the return type was updated
+dnl # to void.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_BIO_END_IO_T_ARGS], [
+ AC_MSG_CHECKING([whether bio_end_io_t wants 2 args])
+ tmp_flags="$EXTRA_KCFLAGS"
+ EXTRA_KCFLAGS="-Werror"
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/bio.h>
+ ],[
+ void (*wanted_end_io)(struct bio *, int) = NULL;
+ bio_end_io_t *local_end_io;
+
+ local_end_io = wanted_end_io;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_2ARGS_BIO_END_IO_T, 1,
+ [bio_end_io_t wants 2 args])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+ EXTRA_KCFLAGS="$tmp_flags"
+])
diff --git a/config/kernel-bio-rw-syncio.m4 b/config/kernel-bio-rw-syncio.m4
new file mode 100644
index 000000000..2c80f5c0e
--- /dev/null
+++ b/config/kernel-bio-rw-syncio.m4
@@ -0,0 +1,19 @@
+dnl #
+dnl # 2.6.29 API change
+dnl # BIO_RW_SYNC renamed to BIO_RW_SYNCIO
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_BIO_RW_SYNCIO], [
+ AC_MSG_CHECKING([whether BIO_RW_SYNCIO is defined])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/bio.h>
+ ],[
+ int flags;
+ flags = BIO_RW_SYNCIO;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BIO_RW_SYNCIO, 1,
+ [BIO_RW_SYNCIO is defined])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/config/kernel-blk-end-request.m4 b/config/kernel-blk-end-request.m4
new file mode 100644
index 000000000..20ad1a926
--- /dev/null
+++ b/config/kernel-blk-end-request.m4
@@ -0,0 +1,37 @@
+dnl #
+dnl # 2.6.31 API change
+dnl # In 2.6.29 kernels blk_end_request() was a GPL-only symbol, this was
+dnl # changed in 2.6.31 so it may be used by non-GPL modules.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_BLK_END_REQUEST], [
+ AC_MSG_CHECKING([whether blk_end_request() is available])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/blkdev.h>
+ ],[
+ struct request *req = NULL;
+ (void) blk_end_request(req, 0, 0);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BLK_END_REQUEST, 1,
+ [blk_end_request() is available])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
+ AC_MSG_CHECKING([whether blk_end_request() is GPL-only])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/module.h>
+ #include <linux/blkdev.h>
+
+ MODULE_LICENSE("CDDL");
+ ],[
+ struct request *req = NULL;
+ (void) blk_end_request(req, 0, 0);
+ ],[
+ AC_MSG_RESULT(no)
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BLK_END_REQUEST_GPL_ONLY, 1,
+ [blk_end_request() is GPL-only])
+ ])
+])
diff --git a/config/kernel-blk-fetch-request.m4 b/config/kernel-blk-fetch-request.m4
new file mode 100644
index 000000000..34a5d2fa8
--- /dev/null
+++ b/config/kernel-blk-fetch-request.m4
@@ -0,0 +1,22 @@
+dnl #
+dnl # 2.6.31 API change
+dnl # Request queue peek/retrieval interface cleanup, the blk_fetch_request()
+dnl # function replaces the elv_next_request() and blk_fetch_request()
+dnl # functions. The updated blk_fetch_request() function returns the
+dnl # next available request and removed it from the request queue.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_BLK_FETCH_REQUEST], [
+ AC_MSG_CHECKING([whether blk_fetch_request() is available])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/blkdev.h>
+ ],[
+ struct request_queue *q = NULL;
+ (void) blk_fetch_request(q);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BLK_FETCH_REQUEST, 1,
+ [blk_fetch_request() is available])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/config/kernel-blk-requeue-request.m4 b/config/kernel-blk-requeue-request.m4
new file mode 100644
index 000000000..f676f85cb
--- /dev/null
+++ b/config/kernel-blk-requeue-request.m4
@@ -0,0 +1,22 @@
+dnl #
+dnl # 2.6.31 API change
+dnl # Request queue peek/retrieval interface cleanup, the
+dnl # elv_requeue_request() function has been replaced with the
+dnl # blk_requeue_request() function.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_BLK_REQUEUE_REQUEST], [
+ AC_MSG_CHECKING([whether blk_requeue_request() is available])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/blkdev.h>
+ ],[
+ struct request_queue *q = NULL;
+ struct request *req = NULL;
+ blk_requeue_request(q, req);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BLK_REQUEUE_REQUEST, 1,
+ [blk_requeue_request() is available])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/config/kernel-blk-rq-bytes.m4 b/config/kernel-blk-rq-bytes.m4
new file mode 100644
index 000000000..da83405cb
--- /dev/null
+++ b/config/kernel-blk-rq-bytes.m4
@@ -0,0 +1,38 @@
+dnl #
+dnl # 2.6.29 API change
+dnl # In the 2.6.29 kernel blk_rq_bytes() was available as a GPL-only symbol.
+dnl # So we need to check the symbol license as well. As of 2.6.31 the
+dnl blk_rq_bytes() helper was changed to a static inline which we can use.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_BLK_RQ_BYTES], [
+ AC_MSG_CHECKING([whether blk_rq_bytes() is available])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/blkdev.h>
+ ],[
+ struct request *req = NULL;
+ (void) blk_rq_bytes(req);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BLK_RQ_BYTES, 1,
+ [blk_rq_bytes() is available])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
+ AC_MSG_CHECKING([whether blk_rq_bytes() is GPL-only])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/module.h>
+ #include <linux/blkdev.h>
+
+ MODULE_LICENSE("CDDL");
+ ],[
+ struct request *req = NULL;
+ (void) blk_rq_bytes(req);
+ ],[
+ AC_MSG_RESULT(no)
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BLK_RQ_BYTES_GPL_ONLY, 1,
+ [blk_rq_bytes() is GPL-only])
+ ])
+])
diff --git a/config/kernel-blk-rq-pos.m4 b/config/kernel-blk-rq-pos.m4
new file mode 100644
index 000000000..aaa464665
--- /dev/null
+++ b/config/kernel-blk-rq-pos.m4
@@ -0,0 +1,18 @@
+dnl #
+dnl # 2.6.31 API change
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_BLK_RQ_POS], [
+ AC_MSG_CHECKING([whether blk_rq_pos() is available])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/blkdev.h>
+ ],[
+ struct request *req = NULL;
+ (void) blk_rq_pos(req);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BLK_RQ_POS, 1,
+ [blk_rq_pos() is available])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/config/kernel-blk-rq-sectors.m4 b/config/kernel-blk-rq-sectors.m4
new file mode 100644
index 000000000..db8c43938
--- /dev/null
+++ b/config/kernel-blk-rq-sectors.m4
@@ -0,0 +1,18 @@
+dnl #
+dnl # 2.6.31 API change
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_BLK_RQ_SECTORS], [
+ AC_MSG_CHECKING([whether blk_rq_sectors() is available])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/blkdev.h>
+ ],[
+ struct request *req = NULL;
+ (void) blk_rq_sectors(req);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BLK_RQ_SECTORS, 1,
+ [blk_rq_sectors() is available])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/config/kernel-fmode-t.m4 b/config/kernel-fmode-t.m4
new file mode 100644
index 000000000..cf25d8127
--- /dev/null
+++ b/config/kernel-fmode-t.m4
@@ -0,0 +1,18 @@
+dnl #
+dnl # 2.6.28 API change,
+dnl # check if fmode_t typedef is defined
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_TYPE_FMODE_T],
+ [AC_MSG_CHECKING([whether kernel defines fmode_t])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/types.h>
+ ],[
+ fmode_t *ptr;
+ ],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_FMODE_T, 1,
+ [kernel defines fmode_t])
+ ],[
+ AC_MSG_RESULT([no])
+ ])
+])
diff --git a/config/kernel-get-disk-ro.m4 b/config/kernel-get-disk-ro.m4
new file mode 100644
index 000000000..365afdbc6
--- /dev/null
+++ b/config/kernel-get-disk-ro.m4
@@ -0,0 +1,18 @@
+dnl #
+dnl # 2.6.x API change
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_GET_DISK_RO], [
+ AC_MSG_CHECKING([whether get_disk_ro() is available])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/blkdev.h>
+ ],[
+ struct gendisk *disk = NULL;
+ (void) get_disk_ro(disk);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_GET_DISK_RO, 1,
+ [blk_disk_ro() is available])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/config/kernel-invalidate-bdev-args.m4 b/config/kernel-invalidate-bdev-args.m4
new file mode 100644
index 000000000..c768f6275
--- /dev/null
+++ b/config/kernel-invalidate-bdev-args.m4
@@ -0,0 +1,19 @@
+dnl #
+dnl # 2.6.22 API change
+dnl # Unused destroy_dirty_buffers arg removed from prototype.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_INVALIDATE_BDEV_ARGS], [
+ AC_MSG_CHECKING([whether invalidate_bdev() wants 1 arg])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/buffer_head.h>
+ ],[
+ struct block_device *bdev;
+ invalidate_bdev(bdev);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_1ARG_INVALIDATE_BDEV, 1,
+ [invalidate_bdev() wants 1 arg])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/config/kernel-kobj-name-len.m4 b/config/kernel-kobj-name-len.m4
new file mode 100644
index 000000000..5363a41ca
--- /dev/null
+++ b/config/kernel-kobj-name-len.m4
@@ -0,0 +1,21 @@
+dnl #
+dnl # 2.6.27 API change,
+dnl # kobject KOBJ_NAME_LEN static limit removed. All users of this
+dnl # constant were removed prior to 2.6.27, but to be on the safe
+dnl # side this check ensures the constant is undefined.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_KOBJ_NAME_LEN], [
+ AC_MSG_CHECKING([whether kernel defines KOBJ_NAME_LEN])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/kobject.h>
+ ],[
+ int val;
+ val = KOBJ_NAME_LEN;
+ ],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_KOBJ_NAME_LEN, 1,
+ [kernel defines KOBJ_NAME_LEN])
+ ],[
+ AC_MSG_RESULT([no])
+ ])
+])
diff --git a/config/kernel-open-bdev-exclusive.m4 b/config/kernel-open-bdev-exclusive.m4
new file mode 100644
index 000000000..734b2134c
--- /dev/null
+++ b/config/kernel-open-bdev-exclusive.m4
@@ -0,0 +1,12 @@
+dnl #
+dnl # 2.6.28 API change
+dnl # open/close_bdev_excl() renamed to open/close_bdev_exclusive()
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE], [
+ ZFS_CHECK_SYMBOL_EXPORT(
+ [open_bdev_exclusive],
+ [fs/block_dev.c],
+ [AC_DEFINE(HAVE_OPEN_BDEV_EXCLUSIVE, 1,
+ [open_bdev_exclusive() is available])],
+ [])
+])
diff --git a/config/kernel-rq-for-each_segment.m4 b/config/kernel-rq-for-each_segment.m4
new file mode 100644
index 000000000..15f030f35
--- /dev/null
+++ b/config/kernel-rq-for-each_segment.m4
@@ -0,0 +1,20 @@
+dnl #
+dnl # 2.6.x API change
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_RQ_FOR_EACH_SEGMENT], [
+ AC_MSG_CHECKING([whether rq_for_each_segment() is available])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/blkdev.h>
+ ],[
+ struct bio_vec *bv;
+ struct req_iterator iter;
+ struct request *req = NULL;
+ rq_for_each_segment(bv, req, iter) { }
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_RQ_FOR_EACH_SEGMENT, 1,
+ [rq_for_each_segment() is available])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/config/kernel-rq-is_sync.m4 b/config/kernel-rq-is_sync.m4
new file mode 100644
index 000000000..40d0de80c
--- /dev/null
+++ b/config/kernel-rq-is_sync.m4
@@ -0,0 +1,18 @@
+dnl #
+dnl # 2.6.x API change
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_RQ_IS_SYNC], [
+ AC_MSG_CHECKING([whether rq_is_sync() is available])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/blkdev.h>
+ ],[
+ struct request *req = NULL;
+ (void) rq_is_sync(req);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_RQ_IS_SYNC, 1,
+ [rq_is_sync() is available])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/config/kernel.m4 b/config/kernel.m4
new file mode 100644
index 000000000..4c06981dc
--- /dev/null
+++ b/config/kernel.m4
@@ -0,0 +1,390 @@
+dnl #
+dnl # Default ZFS kernel configuration
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
+ ZFS_AC_KERNEL
+ ZFS_AC_SPL
+ ZFS_AC_KERNEL_CONFIG
+ ZFS_AC_KERNEL_BDEV_BLOCK_DEVICE_OPERATIONS
+ ZFS_AC_KERNEL_TYPE_FMODE_T
+ ZFS_AC_KERNEL_KOBJ_NAME_LEN
+ ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE
+ ZFS_AC_KERNEL_INVALIDATE_BDEV_ARGS
+ ZFS_AC_KERNEL_BDEV_LOGICAL_BLOCK_SIZE
+ ZFS_AC_KERNEL_BIO_EMPTY_BARRIER
+ ZFS_AC_KERNEL_BIO_END_IO_T_ARGS
+ ZFS_AC_KERNEL_BIO_RW_SYNCIO
+ ZFS_AC_KERNEL_BLK_END_REQUEST
+ ZFS_AC_KERNEL_BLK_FETCH_REQUEST
+ ZFS_AC_KERNEL_BLK_REQUEUE_REQUEST
+ ZFS_AC_KERNEL_BLK_RQ_BYTES
+ ZFS_AC_KERNEL_BLK_RQ_POS
+ ZFS_AC_KERNEL_BLK_RQ_SECTORS
+ ZFS_AC_KERNEL_GET_DISK_RO
+ ZFS_AC_KERNEL_RQ_IS_SYNC
+ ZFS_AC_KERNEL_RQ_FOR_EACH_SEGMENT
+
+ dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
+ dnl # compiler options are added by the kernel build system.
+ KERNELCPPFLAGS="$KERNELCPPFLAGS -DHAVE_SPL -D_KERNEL"
+ KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\""
+ KERNELCPPFLAGS="$KERNELCPPFLAGS -I$SPL"
+ KERNELCPPFLAGS="$KERNELCPPFLAGS -I$SPL/include"
+ KERNELCPPFLAGS="$KERNELCPPFLAGS -include $SPL/spl_config.h"
+ KERNELCPPFLAGS="$KERNELCPPFLAGS -include $TOPDIR/zfs_config.h"
+
+ if test "$LINUX_OBJ" != "$LINUX"; then
+ KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
+ fi
+
+ AC_SUBST(KERNELMAKE_PARAMS)
+ AC_SUBST(KERNELCPPFLAGS)
+])
+
+dnl #
+dnl # Detect name used for Module.symvers file in kernel
+dnl #
+AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [
+ modpost=$LINUX/scripts/Makefile.modpost
+ AC_MSG_CHECKING([kernel file name for module symbols])
+ if test -f "$modpost"; then
+ if grep -q Modules.symvers $modpost; then
+ LINUX_SYMBOLS=Modules.symvers
+ else
+ LINUX_SYMBOLS=Module.symvers
+ fi
+ else
+ LINUX_SYMBOLS=NONE
+ fi
+ AC_MSG_RESULT($LINUX_SYMBOLS)
+ AC_SUBST(LINUX_SYMBOLS)
+])
+
+dnl #
+dnl # Detect the kernel to be built against
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL], [
+ AC_ARG_WITH([linux],
+ AS_HELP_STRING([--with-linux=PATH],
+ [Path to kernel source]),
+ [kernelsrc="$withval"])
+
+ AC_ARG_WITH(linux-obj,
+ AS_HELP_STRING([--with-linux-obj=PATH],
+ [Path to kernel build objects]),
+ [kernelbuild="$withval"])
+
+ AC_MSG_CHECKING([kernel source directory])
+ if test -z "$kernelsrc"; then
+ headersdir="/lib/modules/$(uname -r)/build"
+ if test -e "$headersdir"; then
+ sourcelink=$(readlink -f "$headersdir")
+ else
+ sourcelink=$(ls -1d /usr/src/kernels/* \
+ /usr/src/linux-* \
+ 2>/dev/null | grep -v obj | tail -1)
+ fi
+
+ if test -n "$sourcelink" && test -e ${sourcelink}; then
+ kernelsrc=`readlink -f ${sourcelink}`
+ else
+ AC_MSG_RESULT([Not found])
+ AC_MSG_ERROR([
+ *** Please make sure the kernel devel package for your distribution
+ *** is installed then try again. If that fails you can specify the
+ *** location of the kernel source with the '--with-linux=PATH' option.])
+ fi
+ else
+ if test "$kernelsrc" = "NONE"; then
+ kernsrcver=NONE
+ fi
+ fi
+
+ AC_MSG_RESULT([$kernelsrc])
+ AC_MSG_CHECKING([kernel build directory])
+ if test -z "$kernelbuild"; then
+ if test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
+ kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
+ elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
+ kernelbuild=${kernelsrc}-obj/${target_cpu}/default
+ elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
+ kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
+ else
+ kernelbuild=${kernelsrc}
+ fi
+ fi
+ AC_MSG_RESULT([$kernelbuild])
+
+ AC_MSG_CHECKING([kernel source version])
+ utsrelease1=$kernelbuild/include/linux/version.h
+ utsrelease2=$kernelbuild/include/linux/utsrelease.h
+ utsrelease3=$kernelbuild/include/generated/utsrelease.h
+ if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
+ utsrelease=linux/version.h
+ elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
+ utsrelease=linux/utsrelease.h
+ elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
+ utsrelease=generated/utsrelease.h
+ fi
+
+ if test "$utsrelease"; then
+ kernsrcver=`(echo "#include <$utsrelease>";
+ echo "kernsrcver=UTS_RELEASE") |
+ cpp -I $kernelbuild/include |
+ grep "^kernsrcver=" | cut -d \" -f 2`
+
+ if test -z "$kernsrcver"; then
+ AC_MSG_RESULT([Not found])
+ AC_MSG_ERROR([*** Cannot determine kernel version.])
+ fi
+ else
+ AC_MSG_RESULT([Not found])
+ AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
+ fi
+
+ AC_MSG_RESULT([$kernsrcver])
+
+ LINUX=${kernelsrc}
+ LINUX_OBJ=${kernelbuild}
+ LINUX_VERSION=${kernsrcver}
+
+ AC_SUBST(LINUX)
+ AC_SUBST(LINUX_OBJ)
+ AC_SUBST(LINUX_VERSION)
+
+ ZFS_AC_MODULE_SYMVERS
+])
+
+dnl #
+dnl # Detect name used for the additional SPL Module.symvers file. If one
+dnl # does not exist this is likely because the SPL has been configured
+dnl # but not built. To allow recursive builds a good guess is made as to
+dnl # what this file will be named based on what it is named in the kernel
+dnl # build products. This file will first be used at link time so if
+dnl # the guess is wrong the build will fail then. This unfortunately
+dnl # means the ZFS package does not contain a reliable mechanism to
+dnl # detect symbols exported by the SPL at configure time.
+dnl #
+AC_DEFUN([ZFS_AC_SPL_MODULE_SYMVERS], [
+ AC_MSG_CHECKING([spl file name for module symbols])
+ if test -r $SPL_OBJ/Module.symvers; then
+ SPL_SYMBOLS=Module.symvers
+ elif test -r $SPL_OBJ/Modules.symvers; then
+ SPL_SYMBOLS=Modules.symvers
+ else
+ SPL_SYMBOLS=$LINUX_SYMBOLS
+ fi
+
+ AC_MSG_RESULT([$SPL_SYMBOLS])
+ AC_SUBST(SPL_SYMBOLS)
+])
+
+dnl #
+dnl # Detect the SPL module to be built against
+dnl #
+AC_DEFUN([ZFS_AC_SPL], [
+ AC_ARG_WITH([spl],
+ AS_HELP_STRING([--with-spl=PATH],
+ [Path to spl source]),
+ [splsrc="$withval"])
+
+ AC_ARG_WITH([spl-obj],
+ AS_HELP_STRING([--with-spl-obj=PATH],
+ [Path to spl build objects]),
+ [splbuild="$withval"])
+
+
+ AC_MSG_CHECKING([spl source directory])
+ if test -z "$splsrc"; then
+ sourcelink=`ls -1d /usr/src/spl-*/${LINUX_VERSION} \
+ 2>/dev/null | tail -1`
+
+ if test -z "$sourcelink" || test ! -e $sourcelink; then
+ sourcelink=../spl
+ fi
+
+ if test -e $sourcelink; then
+ splsrc=`readlink -f ${sourcelink}`
+ else
+ AC_MSG_RESULT([Not found])
+ AC_MSG_ERROR([
+ *** Please make sure the spl devel package for your distribution
+ *** is installed then try again. If that fails you can specify the
+ *** location of the spl source with the '--with-spl=PATH' option.])
+ fi
+ else
+ if test "$splsrc" = "NONE"; then
+ splbuild=NONE
+ splsrcver=NONE
+ fi
+ fi
+
+ AC_MSG_RESULT([$splsrc])
+ AC_MSG_CHECKING([spl build directory])
+ if test -z "$splbuild"; then
+ if test -d ${splsrc}/module; then
+ splbuild=${splsrc}/module
+ else
+ splbuild=${splsrc}
+ fi
+ fi
+ AC_MSG_RESULT([$splbuild])
+
+ AC_MSG_CHECKING([spl source version])
+ if test -r $splsrc/spl_config.h &&
+ fgrep -q SPL_META_VERSION $splsrc/spl_config.h; then
+
+ splsrcver=`(echo "#include <spl_config.h>";
+ echo "splsrcver=SPL_META_VERSION") |
+ cpp -I $splsrc |
+ grep "^splsrcver=" | cut -d \" -f 2`
+ fi
+
+ if test -z "$splsrcver"; then
+ AC_MSG_RESULT([Not found])
+ AC_MSG_ERROR([
+ *** Cannot determine the version of the spl source.
+ *** Please prepare the spl source before running this script])
+ fi
+
+ AC_MSG_RESULT([$splsrcver])
+
+ SPL=${splsrc}
+ SPL_OBJ=${splbuild}
+ SPL_VERSION=${splsrcver}
+
+ AC_SUBST(SPL)
+ AC_SUBST(SPL_OBJ)
+ AC_SUBST(SPL_VERSION)
+
+ ZFS_AC_SPL_MODULE_SYMVERS
+])
+
+dnl #
+dnl # There are certain kernel build options which when enabled are
+dnl # completely incompatible with non GPL kernel modules. It is best
+dnl # to detect these at configure time and fail with a clear error
+dnl # rather than build everything and fail during linking.
+dnl #
+dnl # CONFIG_DEBUG_LOCK_ALLOC - Maps mutex_lock() to mutex_lock_nested()
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_CONFIG], [
+
+ if test "$ZFS_META_LICENSE" = CDDL; then
+ ZFS_LINUX_CONFIG([DEBUG_LOCK_ALLOC],
+ AC_MSG_ERROR([
+ *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is
+ *** incompatible with the CDDL license. You must rebuild
+ *** your kernel without this option.]), [])
+ fi
+
+ if test "$ZFS_META_LICENSE" = GPL; then
+ AC_DEFINE([HAVE_GPL_ONLY_SYMBOLS], [1],
+ [Define to 1 if licensed under the GPL])
+ fi
+])
+
+dnl #
+dnl # ZFS_LINUX_CONFTEST
+dnl #
+AC_DEFUN([ZFS_LINUX_CONFTEST], [
+cat confdefs.h - <<_ACEOF >conftest.c
+$1
+_ACEOF
+])
+
+dnl #
+dnl # ZFS_LANG_PROGRAM(C)([PROLOGUE], [BODY])
+dnl #
+m4_define([ZFS_LANG_PROGRAM], [
+$1
+int
+main (void)
+{
+dnl Do *not* indent the following line: there may be CPP directives.
+dnl Don't move the `;' right after for the same reason.
+$2
+ ;
+ return 0;
+}
+])
+
+dnl #
+dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
+dnl #
+AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
+ m4_ifvaln([$1], [ZFS_LINUX_CONFTEST([$1])])
+ rm -Rf build && mkdir -p build
+ echo "obj-m := conftest.o" >build/Makefile
+ AS_IF(
+ [AC_TRY_COMMAND(cp conftest.c build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
+ [$4],
+ [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
+ )
+ rm -Rf build
+])
+
+dnl #
+dnl # ZFS_LINUX_TRY_COMPILE like AC_TRY_COMPILE
+dnl #
+AC_DEFUN([ZFS_LINUX_TRY_COMPILE],
+ [ZFS_LINUX_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
+ [modules],
+ [test -s build/conftest.o],
+ [$3], [$4])
+])
+
+dnl #
+dnl # ZFS_LINUX_CONFIG
+dnl #
+AC_DEFUN([ZFS_LINUX_CONFIG],
+ [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
+ ZFS_LINUX_TRY_COMPILE([
+ #ifndef AUTOCONF_INCLUDED
+ #include <linux/config.h>
+ #endif
+ ],[
+ #ifndef CONFIG_$1
+ #error CONFIG_$1 not #defined
+ #endif
+ ],[
+ AC_MSG_RESULT([yes])
+ $2
+ ],[
+ AC_MSG_RESULT([no])
+ $3
+ ])
+])
+
+dnl #
+dnl # ZFS_CHECK_SYMBOL_EXPORT
+dnl # check symbol exported or not
+dnl #
+AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT],
+ [AC_MSG_CHECKING([whether symbol $1 is exported])
+ grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
+ $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
+ rc=$?
+ if test $rc -ne 0; then
+ export=0
+ for file in $2; do
+ grep -q -E "EXPORT_SYMBOL.*($1)" "$LINUX/$file" 2>/dev/null
+ rc=$?
+ if test $rc -eq 0; then
+ export=1
+ break;
+ fi
+ done
+ if test $export -eq 0; then
+ AC_MSG_RESULT([no])
+ $4
+ else
+ AC_MSG_RESULT([yes])
+ $3
+ fi
+ else
+ AC_MSG_RESULT([yes])
+ $3
+ fi
+])
diff --git a/config/rpm.am b/config/rpm.am
new file mode 100644
index 000000000..c352fc582
--- /dev/null
+++ b/config/rpm.am
@@ -0,0 +1,73 @@
+srpm-modules:
+ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" srpm-common
+
+srpm-utils:
+ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" srpm-common
+
+srpm: srpm-modules srpm-utils
+
+rpm-modules: srpm-modules
+ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" rpm-common
+
+rpm-utils: srpm-utils
+ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" rpm-common
+
+rpm-modules: srpm-modules
+
+rpm: rpm-modules rpm-utils
+
+rpm-local:
+ @(if test "${HAVE_RPMBUILD}" = "no"; then \
+ echo -e "\n" \
+ "*** Required util ${RPMBUILD} missing. Please install the\n" \
+ "*** package for your distribution which provides ${RPMBUILD},\n" \
+ "*** re-run configure, and try again.\n"; \
+ exit 1; \
+ fi; \
+ mkdir -p $(rpmbuild)/TMP && \
+ mkdir -p $(rpmbuild)/BUILD && \
+ mkdir -p $(rpmbuild)/RPMS && \
+ mkdir -p $(rpmbuild)/SRPMS && \
+ mkdir -p $(rpmbuild)/SPECS && \
+ cp $(rpmspec) $(rpmbuild)/SPECS && \
+ mkdir -p $(rpmbuild)/SOURCES && \
+ cp $(distdir).tar.gz $(rpmbuild)/SOURCES)
+
+srpm-common: dist
+ rpmpkg=$(pkg)-$(ZFS_META_VERSION)-$(ZFS_META_RELEASE).src.rpm; \
+ rpmspec=$(pkg).spec; \
+ rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ rpmbuild="$$rpmbuild" \
+ rpmspec="$$rpmspec" \
+ rpm-local || exit 1; \
+ $(RPMBUILD) \
+ --define "_tmppath $$rpmbuild/TMP" \
+ --define "_topdir $$rpmbuild" \
+ --define "build_src_rpm 1" \
+ --define "dist %{nil}" \
+ --nodeps -bs $$rpmbuild/SPECS/$$rpmspec || exit 1; \
+ cp $$rpmbuild/SRPMS/$$rpmpkg . || exit 1; \
+ $(RM) -R $$rpmbuild
+
+rpm-common:
+ rpmpkg=$(pkg)-$(ZFS_META_VERSION)-$(ZFS_META_RELEASE).src.rpm; \
+ rpmspec=$(pkg).spec; \
+ rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ rpmbuild="$$rpmbuild" \
+ rpmspec="$$rpmspec" \
+ rpm-local || exit 1; \
+ $(RPMBUILD) \
+ --define "_tmppath $$rpmbuild/TMP" \
+ --define "_topdir $$rpmbuild" \
+ --define "dist %{nil}" \
+ --define "require_kdir $(LINUX)" \
+ --define "require_kobj $(LINUX_OBJ)" \
+ --define "require_kver $(LINUX_VERSION)" \
+ --define "require_spldir $(SPL)" \
+ --define "require_splobj $(SPL_OBJ)" \
+ --define "require_splver $(SPL_VERSION)" \
+ --nodeps --rebuild $$rpmpkg || exit 1; \
+ cp $$rpmbuild/RPMS/*/* . || exit 1; \
+ $(RM) -R $$rpmbuild
diff --git a/config/tgz.am b/config/tgz.am
new file mode 100644
index 000000000..625d7a370
--- /dev/null
+++ b/config/tgz.am
@@ -0,0 +1,30 @@
+tgz-local:
+ @(if test "${HAVE_ALIEN}" = "no"; then \
+ echo -e "\n" \
+ "*** Required util ${ALIEN} missing. Please install the\n" \
+ "*** package for your distribution which provides ${ALIEN},\n" \
+ "*** re-run configure, and try again.\n"; \
+ exit 1; \
+ fi)
+
+tgz-modules: tgz-local rpm-modules
+ name=${PACKAGE}-modules; \
+ version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
+ release=`echo ${LINUX_VERSION} | $(SED) -e "s/-/_/g"`; \
+ arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch}`; \
+ pkg1=$${name}-$${version}_$${release}.$${arch}.rpm; \
+ pkg2=$${name}-devel-$${version}_$${release}.$${arch}.rpm; \
+ fakeroot $(ALIEN) --scripts --to-tgz $$pkg1 $$pkg2; \
+ $(RM) $$pkg1 $$pkg2
+
+tgz-utils: tgz-local rpm-utils
+ name=${PACKAGE}; \
+ version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
+ arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch}`; \
+ pkg1=$${name}-$${version}.$${arch}.rpm; \
+ pkg2=$${name}-devel-$${version}.$${arch}.rpm; \
+ pkg3=$${name}-test-$${version}.$${arch}.rpm; \
+ fakeroot $(ALIEN) --scripts --to-tgz $$pkg1 $$pkg2 $$pkg3; \
+ $(RM) $$pkg1 $$pkg2 $$pkg3
+
+tgz: tgz-modules tgz-utils
diff --git a/config/user-arch.m4 b/config/user-arch.m4
new file mode 100644
index 000000000..fcc566fc5
--- /dev/null
+++ b/config/user-arch.m4
@@ -0,0 +1,19 @@
+dnl #
+dnl # Set the target arch for libspl atomic implementation
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_USER_ARCH], [
+ AC_MSG_CHECKING(for target asm dir)
+ TARGET_ARCH=`echo ${target_cpu} | sed -e s/i.86/i386/`
+
+ case $TARGET_ARCH in
+ i386|x86_64)
+ TARGET_ASM_DIR=asm-${TARGET_ARCH}
+ ;;
+ *)
+ TARGET_ASM_DIR=asm-generic
+ ;;
+ esac
+
+ AC_SUBST([TARGET_ASM_DIR])
+ AC_MSG_RESULT([$TARGET_ASM_DIR])
+])
diff --git a/config/user-frame-larger-than.m4 b/config/user-frame-larger-than.m4
new file mode 100644
index 000000000..3384f50e4
--- /dev/null
+++ b/config/user-frame-larger-than.m4
@@ -0,0 +1,22 @@
+dnl #
+dnl # Check if gcc supports -Wframe-larger-than=<size> option.
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN], [
+ AC_MSG_CHECKING([for -Wframe-larger-than=<size> support])
+
+ saved_flags="$CFLAGS"
+ CFLAGS="$CFLAGS -Wframe-larger-than=1024"
+
+ AC_RUN_IFELSE(AC_LANG_PROGRAM( [], []),
+ [
+ FRAME_LARGER_THAN=-Wframe-larger-than=1024
+ AC_MSG_RESULT([yes])
+ ],
+ [
+ FRAME_LARGER_THAN=
+ AC_MSG_RESULT([no])
+ ])
+
+ CFLAGS="$saved_flags"
+ AC_SUBST([FRAME_LARGER_THAN])
+])
diff --git a/config/user-ioctl.m4 b/config/user-ioctl.m4
new file mode 100644
index 000000000..53fb118fc
--- /dev/null
+++ b/config/user-ioctl.m4
@@ -0,0 +1,35 @@
+dnl #
+dnl # Check for ioctl()
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_USER_IOCTL], [
+ AC_MSG_CHECKING(for ioctl())
+ AC_EGREP_HEADER(ioctl, unistd.h, is_unistd=yes, is_unistd=no)
+ AC_EGREP_HEADER(ioctl, sys/ioctl.h, is_sys_ioctl=yes, is_sys_ioctl=no)
+ AC_EGREP_HEADER(ioctl, stropts.h, is_stropts=yes, is_stropts=no)
+
+ if test $is_unistd = yes; then
+ result=unistd.h
+ AC_DEFINE([HAVE_IOCTL_IN_UNISTD_H], 1,
+ [Define to 1 if ioctl() defined in <unistd.h>])
+ else
+
+ if test $is_sys_ioctl = yes; then
+ result=sys/ioctl.h
+ AC_DEFINE([HAVE_IOCTL_IN_SYS_IOCTL_H], 1,
+ [Define to 1 if ioctl() defined in <sys/ioctl.h>])
+ elif test $is_stropts = yes; then
+ AC_DEFINE([HAVE_IOCTL_IN_STROPTS_H], 1,
+ result=stropts.h
+ [Define to 1 if ioctl() defined in <stropts.h>])
+ else
+ result=no
+ fi
+ fi
+
+ if test $result = no; then
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([*** Cannot locate ioctl() definition])
+ else
+ AC_MSG_RESULT(yes)
+ fi
+])
diff --git a/config/user-libblkid.m4 b/config/user-libblkid.m4
new file mode 100644
index 000000000..8934d0ab8
--- /dev/null
+++ b/config/user-libblkid.m4
@@ -0,0 +1,94 @@
+dnl #
+dnl # Check for ZFS support in libblkid. This test needs to check
+dnl # more than if the library exists because we expect there are
+dnl # at least 3 flavors of the library out in the wild:
+dnl #
+dnl # 1) blkid which has no ZFS support
+dnl # 2) blkid with ZFS support and a flawed method of probing
+dnl # 3) blkid with ZFS support and a working method of probing
+dnl #
+dnl # To handle this the check first validates that there is a version
+dnl # of the library installed. If there is it creates a simulated
+dnl # ZFS filesystem and then links a small test app which attempts
+dnl # to detect the simualated filesystem type. If it correctly
+dnl # identifies the filesystem as ZFS we can safely assume case 3).
+dnl # Otherwise we disable blkid support and resort to manual probing.
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_USER_LIBBLKID], [
+ AC_ARG_WITH([blkid],
+ [AS_HELP_STRING([--with-blkid],
+ [support blkid caching @<:@default=check@:>@])],
+ [],
+ [with_blkid=check])
+
+ LIBBLKID=
+ AS_IF([test "x$with_blkid" != xno],
+ [
+ AC_CHECK_LIB([blkid], [blkid_get_cache],
+ [
+ AC_MSG_CHECKING([for blkid zfs support])
+
+ ZFS_DEV=`mktemp`
+ dd if=/dev/zero of=$ZFS_DEV bs=1024k count=8 \
+ >/dev/null 2>/dev/null
+ echo -en "\x0c\xb1\xba\0\0\0\0\0" | \
+ dd of=$ZFS_DEV bs=1k count=8 \
+ seek=132 conv=notrunc &>/dev/null \
+ >/dev/null 2>/dev/null
+
+ saved_LDFLAGS="$LDFLAGS"
+ LDFLAGS="-lblkid"
+
+ AC_RUN_IFELSE(AC_LANG_PROGRAM(
+ [
+ #include <stdio.h>
+ #include <blkid/blkid.h>
+ ],
+ [
+ blkid_cache cache;
+ char *value;
+
+ if (blkid_get_cache(&cache, NULL) < 0)
+ return 1;
+
+ value = blkid_get_tag_value(cache, "TYPE",
+ "$ZFS_DEV");
+ if (!value) {
+ blkid_put_cache(cache);
+ return 2;
+ }
+
+ if (strcmp(value, "zfs")) {
+ free(value);
+ blkid_put_cache(cache);
+ return 3;
+ }
+
+ free(value);
+ blkid_put_cache(cache);
+ ]),
+ [
+ rm -f $ZFS_DEV
+ AC_MSG_RESULT([yes])
+ AC_SUBST([LIBBLKID], ["-lblkid"])
+ AC_DEFINE([HAVE_LIBBLKID], 1,
+ [Define if you have libblkid])
+ ],
+ [
+ rm -f $ZFS_DEV
+ AC_MSG_RESULT([no])
+ AS_IF([test "x$with_blkid" != xcheck],
+ [AC_MSG_FAILURE(
+ [--with-blkid given but unavailable])])
+ ])
+
+ LDFLAGS="$saved_LDFLAGS"
+ ],
+ [
+ AS_IF([test "x$with_blkid" != xcheck],
+ [AC_MSG_FAILURE(
+ [--with-blkid given but unavailable])])
+ ]
+ [])
+ ])
+])
diff --git a/config/user-libshare.m4 b/config/user-libshare.m4
new file mode 100644
index 000000000..3b92bbaa5
--- /dev/null
+++ b/config/user-libshare.m4
@@ -0,0 +1,8 @@
+dnl #
+dnl # Check for libshare
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_USER_LIBSHARE], [
+ AC_CHECK_LIB([share], [sa_init],
+ [AC_DEFINE([HAVE_LIBSHARE], 1,
+ [Define to 1 if 'libshare' library available])])
+])
diff --git a/config/user-libuuid.m4 b/config/user-libuuid.m4
new file mode 100644
index 000000000..aba375a22
--- /dev/null
+++ b/config/user-libuuid.m4
@@ -0,0 +1,18 @@
+dnl #
+dnl # Check for libuuid
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_USER_LIBUUID], [
+ LIBUUID=
+
+ AC_CHECK_HEADER([uuid/uuid.h], [], [AC_MSG_FAILURE([
+ *** uuid/uuid.h missing, libuuid-devel package required])])
+
+ AC_CHECK_LIB([uuid], [uuid_generate], [], [AC_MSG_FAILURE([
+ *** uuid_generate() missing, libuuid-devel package required])])
+
+ AC_CHECK_LIB([uuid], [uuid_is_null], [], [AC_MSG_FAILURE([
+ *** uuid_is_null() missing, libuuid-devel package required])])
+
+ AC_SUBST([LIBUUID], ["-luuid"])
+ AC_DEFINE([HAVE_LIBUUID], 1, [Define if you have libuuid])
+])
diff --git a/config/user-nptl_guard_within_stack.m4 b/config/user-nptl_guard_within_stack.m4
new file mode 100644
index 000000000..d094da733
--- /dev/null
+++ b/config/user-nptl_guard_within_stack.m4
@@ -0,0 +1,56 @@
+dnl #
+dnl # Check if the glibc NPTL threading implementation includes the guard area
+dnl # within the stack size allocation, rather than allocating extra space at
+dnl # the end of the stack, as POSIX.1 requires.
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_USER_STACK_GUARD], [
+
+ AC_MSG_CHECKING([whether pthread stack includes guard])
+
+ saved_CFLAGS="$CFLAGS"
+ CFLAGS="-fstack-check"
+ saved_LDFLAGS="$LDFLAGS"
+ LDFLAGS="-lpthread"
+
+ AC_RUN_IFELSE(AC_LANG_PROGRAM(
+ [
+ #include <pthread.h>
+ #include <sys/resource.h>
+ #include <unistd.h>
+ #include <bits/local_lim.h>
+
+ #define PAGESIZE (sysconf(_SC_PAGESIZE))
+ #define STACK_SIZE 8192
+ #define BUFSIZE 4096
+
+ void * func(void *arg)
+ {
+ char buf[[[BUFSIZE]]];
+ }
+ ],
+ [
+ pthread_t tid;
+ pthread_attr_t attr;
+ struct rlimit l;
+
+ l.rlim_cur = 0;
+ l.rlim_max = 0;
+ setrlimit(RLIMIT_CORE, &l);
+ pthread_attr_init(&attr);
+ pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + STACK_SIZE);
+ pthread_attr_setguardsize(&attr, PAGESIZE);
+ pthread_create(&tid, &attr, func, NULL);
+ pthread_join(tid, NULL);
+ ]),
+ [
+ AC_MSG_RESULT([no])
+ ],
+ [
+ AC_DEFINE([NPTL_GUARD_WITHIN_STACK], 1,
+ [Define to 1 if NPTL threading implementation includes
+ guard area in stack allocation])
+ AC_MSG_RESULT([yes])
+ ])
+ CFLAGS="$saved_CFLAGS"
+ LDFLAGS="$saved_LDFLAGS"
+])
diff --git a/config/user-zlib.m4 b/config/user-zlib.m4
new file mode 100644
index 000000000..a48361662
--- /dev/null
+++ b/config/user-zlib.m4
@@ -0,0 +1,21 @@
+dnl #
+dnl # Check for zlib
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_USER_ZLIB], [
+ ZLIB=
+
+ AC_CHECK_HEADER([zlib.h], [], [AC_MSG_FAILURE([
+ *** zlib.h missing, zlib-devel package required])])
+
+ AC_CHECK_LIB([z], [compress2], [], [AC_MSG_FAILURE([
+ *** compress2() missing, zlib-devel package required])])
+
+ AC_CHECK_LIB([z], [uncompress], [], [AC_MSG_FAILURE([
+ *** uncompress() missing, zlib-devel package required])])
+
+ AC_CHECK_LIB([z], [crc32], [], [AC_MSG_FAILURE([
+ *** crc32() missing, zlib-devel package required])])
+
+ AC_SUBST([ZLIB], ["-lz"])
+ AC_DEFINE([HAVE_ZLIB], 1, [Define if you have zlib])
+])
diff --git a/config/user.m4 b/config/user.m4
new file mode 100644
index 000000000..bc68808f8
--- /dev/null
+++ b/config/user.m4
@@ -0,0 +1,13 @@
+dnl #
+dnl # Default ZFS user configuration
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_USER], [
+ ZFS_AC_CONFIG_USER_ARCH
+ ZFS_AC_CONFIG_USER_LIBSHARE
+ ZFS_AC_CONFIG_USER_IOCTL
+ ZFS_AC_CONFIG_USER_ZLIB
+ ZFS_AC_CONFIG_USER_LIBUUID
+ ZFS_AC_CONFIG_USER_LIBBLKID
+ ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN
+ ZFS_AC_CONFIG_USER_STACK_GUARD
+])
diff --git a/config/zfs-build.m4 b/config/zfs-build.m4
new file mode 100644
index 000000000..b88003585
--- /dev/null
+++ b/config/zfs-build.m4
@@ -0,0 +1,295 @@
+AC_DEFUN([ZFS_AC_LICENSE], [
+ AC_MSG_CHECKING([zfs author])
+ AC_MSG_RESULT([$ZFS_META_AUTHOR])
+
+ AC_MSG_CHECKING([zfs license])
+ AC_MSG_RESULT([$ZFS_META_LICENSE])
+])
+
+AC_DEFUN([ZFS_AC_DEBUG], [
+ AC_MSG_CHECKING([whether debugging is enabled])
+ AC_ARG_ENABLE([debug],
+ [AS_HELP_STRING([--enable-debug],
+ [Enable generic debug support @<:@default=no@:>@])],
+ [],
+ [enable_debug=no])
+
+ AS_IF([test "x$enable_debug" = xyes],
+ [
+ KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
+ HOSTCFLAGS="${HOSTCFLAGS} -DDEBUG -Werror"
+ DEBUG_CFLAGS="-DDEBUG -Werror"
+ DEBUG_STACKFLAGS="-fstack-check"
+ ],
+ [
+ KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG "
+ HOSTCFLAGS="${HOSTCFLAGS} -DNDEBUG "
+ DEBUG_CFLAGS="-DNDEBUG"
+ DEBUG_STACKFLAGS=""
+ ])
+
+ AC_SUBST(DEBUG_CFLAGS)
+ AC_SUBST(DEBUG_STACKFLAGS)
+ AC_MSG_RESULT([$enable_debug])
+])
+
+AC_DEFUN([ZFS_AC_CONFIG_SCRIPT], [
+ cat >.script-config <<EOF
+KERNELSRC=${LINUX}
+KERNELBUILD=${LINUX_OBJ}
+KERNELSRCVER=${LINUX_VERSION}
+KERNELMOD=/lib/modules/\${KERNELSRCVER}/kernel
+
+SPLSRC=${SPL}
+SPLBUILD=${SPL_OBJ}
+SPLSRCVER=${SPL_VERSION}
+
+TOPDIR=${TOPDIR}
+BUILDDIR=${BUILDDIR}
+LIBDIR=${LIBDIR}
+CMDDIR=${CMDDIR}
+MODDIR=${MODDIR}
+SCRIPTDIR=${SCRIPTDIR}
+ETCDIR=\${TOPDIR}/etc
+DEVDIR=\${TOPDIR}/dev
+ZPOOLDIR=\${TOPDIR}/scripts/zpool-config
+
+ZDB=\${CMDDIR}/zdb/zdb
+ZFS=\${CMDDIR}/zfs/zfs
+ZINJECT=\${CMDDIR}/zinject/zinject
+ZPOOL=\${CMDDIR}/zpool/zpool
+ZPOOL_ID=\${CMDDIR}/zpool_id/zpool_id
+ZTEST=\${CMDDIR}/ztest/ztest
+
+COMMON_SH=\${SCRIPTDIR}/common.sh
+ZFS_SH=\${SCRIPTDIR}/zfs.sh
+ZPOOL_CREATE_SH=\${SCRIPTDIR}/zpool-create.sh
+
+INTREE=1
+LDMOD=/sbin/insmod
+
+KERNEL_MODULES=( \\
+ \${KERNELMOD}/lib/zlib_deflate/zlib_deflate.ko \\
+)
+
+SPL_MODULES=( \\
+ \${SPLBUILD}/spl/spl.ko \\
+ \${SPLBUILD}/splat/splat.ko \\
+)
+
+ZFS_MODULES=( \\
+ \${MODDIR}/avl/zavl.ko \\
+ \${MODDIR}/nvpair/znvpair.ko \\
+ \${MODDIR}/unicode/zunicode.ko \\
+ \${MODDIR}/zcommon/zcommon.ko \\
+ \${MODDIR}/zfs/zfs.ko \\
+)
+
+MODULES=( \\
+ \${KERNEL_MODULES[[*]]} \\
+ \${SPL_MODULES[[*]]} \\
+ \${ZFS_MODULES[[*]]} \\
+)
+EOF
+])
+
+AC_DEFUN([ZFS_AC_CONFIG], [
+ TOPDIR=`readlink -f ${srcdir}`
+ BUILDDIR=$TOPDIR
+ LIBDIR=$TOPDIR/lib
+ CMDDIR=$TOPDIR/cmd
+ MODDIR=$TOPDIR/module
+ SCRIPTDIR=$TOPDIR/scripts
+ TARGET_ASM_DIR=asm-generic
+
+ AC_SUBST(TOPDIR)
+ AC_SUBST(BUILDDIR)
+ AC_SUBST(LIBDIR)
+ AC_SUBST(CMDDIR)
+ AC_SUBST(MODDIR)
+ AC_SUBST(SCRIPTDIR)
+ AC_SUBST(TARGET_ASM_DIR)
+
+ ZFS_CONFIG=all
+ AC_ARG_WITH([config],
+ AS_HELP_STRING([--with-config=CONFIG],
+ [Config file 'kernel|user|all|srpm']),
+ [ZFS_CONFIG="$withval"])
+
+ AC_MSG_CHECKING([zfs config])
+ AC_MSG_RESULT([$ZFS_CONFIG]);
+ AC_SUBST(ZFS_CONFIG)
+
+ case "$ZFS_CONFIG" in
+ kernel) ZFS_AC_CONFIG_KERNEL ;;
+ user) ZFS_AC_CONFIG_USER ;;
+ all) ZFS_AC_CONFIG_KERNEL
+ ZFS_AC_CONFIG_USER ;;
+ srpm) ;;
+ *)
+ AC_MSG_RESULT([Error!])
+ AC_MSG_ERROR([Bad value "$ZFS_CONFIG" for --with-config,
+ user kernel|user|all|srpm]) ;;
+ esac
+
+ AM_CONDITIONAL([CONFIG_USER],
+ [test "$ZFS_CONFIG" = user] ||
+ [test "$ZFS_CONFIG" = all])
+ AM_CONDITIONAL([CONFIG_KERNEL],
+ [test "$ZFS_CONFIG" = kernel] ||
+ [test "$ZFS_CONFIG" = all])
+
+ ZFS_AC_CONFIG_SCRIPT
+])
+
+dnl #
+dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
+dnl # are missing it is non-fatal but you will not be able to build
+dnl # RPM packages and will be warned if you try too.
+dnl #
+AC_DEFUN([ZFS_AC_RPM], [
+ RPM=rpm
+ RPMBUILD=rpmbuild
+
+ AC_MSG_CHECKING([whether $RPM is available])
+ AS_IF([tmp=$($RPM --version 2>/dev/null)], [
+ RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
+ HAVE_RPM=yes
+ AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
+ ],[
+ HAVE_RPM=no
+ AC_MSG_RESULT([$HAVE_RPM])
+ ])
+
+ AC_MSG_CHECKING([whether $RPMBUILD is available])
+ AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
+ RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
+ HAVE_RPMBUILD=yes
+ AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
+ ],[
+ HAVE_RPMBUILD=no
+ AC_MSG_RESULT([$HAVE_RPMBUILD])
+ ])
+
+ AC_SUBST(HAVE_RPM)
+ AC_SUBST(RPM)
+ AC_SUBST(RPM_VERSION)
+
+ AC_SUBST(HAVE_RPMBUILD)
+ AC_SUBST(RPMBUILD)
+ AC_SUBST(RPMBUILD_VERSION)
+])
+
+dnl #
+dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
+dnl # tools are missing it is non-fatal but you will not be able to build
+dnl # DEB packages and will be warned if you try too.
+dnl #
+AC_DEFUN([ZFS_AC_DPKG], [
+ DPKG=dpkg
+ DPKGBUILD=dpkg-buildpackage
+
+ AC_MSG_CHECKING([whether $DPKG is available])
+ AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
+ DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
+ HAVE_DPKG=yes
+ AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
+ ],[
+ HAVE_DPKG=no
+ AC_MSG_RESULT([$HAVE_DPKG])
+ ])
+
+ AC_MSG_CHECKING([whether $DPKGBUILD is available])
+ AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
+ DPKGBUILD_VERSION=$(echo $tmp | \
+ $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
+ HAVE_DPKGBUILD=yes
+ AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
+ ],[
+ HAVE_DPKGBUILD=no
+ AC_MSG_RESULT([$HAVE_DPKGBUILD])
+ ])
+
+ AC_SUBST(HAVE_DPKG)
+ AC_SUBST(DPKG)
+ AC_SUBST(DPKG_VERSION)
+
+ AC_SUBST(HAVE_DPKGBUILD)
+ AC_SUBST(DPKGBUILD)
+ AC_SUBST(DPKGBUILD_VERSION)
+])
+
+dnl #
+dnl # Until native packaging for various different packing systems
+dnl # can be added the least we can do is attempt to use alien to
+dnl # convert the RPM packages to the needed package type. This is
+dnl # a hack but so far it has worked reasonable well.
+dnl #
+AC_DEFUN([ZFS_AC_ALIEN], [
+ ALIEN=alien
+
+ AC_MSG_CHECKING([whether $ALIEN is available])
+ AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
+ ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
+ HAVE_ALIEN=yes
+ AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
+ ],[
+ HAVE_ALIEN=no
+ AC_MSG_RESULT([$HAVE_ALIEN])
+ ])
+
+ AC_SUBST(HAVE_ALIEN)
+ AC_SUBST(ALIEN)
+ AC_SUBST(ALIEN_VERSION)
+])
+
+dnl #
+dnl # Using the VENDOR tag from config.guess set the default
+dnl # package type for 'make pkg': (rpm | deb | tgz)
+dnl #
+AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [
+ AC_MSG_CHECKING([linux distribution])
+ if test -f /etc/redhat-release ; then
+ VENDOR=redhat ;
+ elif test -f /etc/fedora-release ; then
+ VENDOR=fedora ;
+ elif test -f /etc/debian_version ; then
+ VENDOR=debian ;
+ elif test -f /etc/lsb-release ; then
+ VENDOR=ubuntu ;
+ elif test -f /etc/SuSE-release ; then
+ VENDOR=sles ;
+ elif test -f /etc/slackware-version ; then
+ VENDOR=slackware ;
+ elif test -f /etc/gentoo-release ; then
+ VENDOR=gentoo ;
+ else
+ VENDOR= ;
+ fi
+ AC_MSG_RESULT([$VENDOR])
+ AC_SUBST(VENDOR)
+
+ AC_MSG_CHECKING([default package type])
+ case "$VENDOR" in
+ fedora) DEFAULT_PACKAGE=rpm ;;
+ redhat) DEFAULT_PACKAGE=rpm ;;
+ sles) DEFAULT_PACKAGE=rpm ;;
+ ubuntu) DEFAULT_PACKAGE=deb ;;
+ debian) DEFAULT_PACKAGE=deb ;;
+ slackware) DEFAULT_PACKAGE=tgz ;;
+ *) DEFAULT_PACKAGE=rpm ;;
+ esac
+
+ AC_MSG_RESULT([$DEFAULT_PACKAGE])
+ AC_SUBST(DEFAULT_PACKAGE)
+])
+
+dnl #
+dnl # Default ZFS package configuration
+dnl #
+AC_DEFUN([ZFS_AC_PACKAGE], [
+ ZFS_AC_RPM
+ ZFS_AC_DPKG
+ ZFS_AC_ALIEN
+ ZFS_AC_DEFAULT_PACKAGE
+])
diff --git a/config/zfs-meta.m4 b/config/zfs-meta.m4
new file mode 100644
index 000000000..8b3689af7
--- /dev/null
+++ b/config/zfs-meta.m4
@@ -0,0 +1,131 @@
+dnl #
+dnl # ZFS_AC_META
+dnl # Read metadata from the META file.
+dnl #
+dnl # AUTHOR:
+dnl # Chris Dunlap <[email protected]>
+dnl #
+AC_DEFUN([ZFS_AC_META], [
+
+ AH_BOTTOM([
+#undef PACKAGE
+#undef PACKAGE_BUGREPORT
+#undef PACKAGE_NAME
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+#undef PACKAGE_VERSION
+#undef STDC_HEADERS
+#undef VERSION])
+
+ AC_MSG_CHECKING([metadata])
+
+ META="$srcdir/META"
+ _zfs_ac_meta_got_file=no
+ if test -f "$META"; then
+ _zfs_ac_meta_got_file=yes
+
+ ZFS_META_NAME=_ZFS_AC_META_GETVAL([(?:NAME|PROJECT|PACKAGE)]);
+ if test -n "$ZFS_META_NAME"; then
+ AC_DEFINE_UNQUOTED([ZFS_META_NAME], ["$ZFS_META_NAME"],
+ [Define the project name.]
+ )
+ AC_SUBST([ZFS_META_NAME])
+ fi
+
+ ZFS_META_VERSION=_ZFS_AC_META_GETVAL([VERSION]);
+ if test -n "$ZFS_META_VERSION"; then
+ AC_DEFINE_UNQUOTED([ZFS_META_VERSION], ["$ZFS_META_VERSION"],
+ [Define the project version.]
+ )
+ AC_SUBST([ZFS_META_VERSION])
+ fi
+
+ ZFS_META_RELEASE=_ZFS_AC_META_GETVAL([RELEASE]);
+ if test -n "$ZFS_META_RELEASE"; then
+ AC_DEFINE_UNQUOTED([ZFS_META_RELEASE], ["$ZFS_META_RELEASE"],
+ [Define the project release.]
+ )
+ AC_SUBST([ZFS_META_RELEASE])
+ fi
+
+ ZFS_META_LICENSE=_ZFS_AC_META_GETVAL([LICENSE]);
+ if test -n "$ZFS_META_LICENSE"; then
+ AC_DEFINE_UNQUOTED([ZFS_META_LICENSE], ["$ZFS_META_LICENSE"],
+ [Define the project license.]
+ )
+ AC_SUBST([ZFS_META_LICENSE])
+ fi
+
+ if test -n "$ZFS_META_NAME" -a -n "$ZFS_META_VERSION"; then
+ ZFS_META_ALIAS="$ZFS_META_NAME-$ZFS_META_VERSION"
+ test -n "$ZFS_META_RELEASE" &&
+ ZFS_META_ALIAS="$ZFS_META_ALIAS-$ZFS_META_RELEASE"
+ AC_DEFINE_UNQUOTED([ZFS_META_ALIAS],
+ ["$ZFS_META_ALIAS"],
+ [Define the project alias string.]
+ )
+ AC_SUBST([ZFS_META_ALIAS])
+ fi
+
+ ZFS_META_DATA=_ZFS_AC_META_GETVAL([DATE]);
+ if test -n "$ZFS_META_DATA"; then
+ AC_DEFINE_UNQUOTED([ZFS_META_DATA], ["$ZFS_META_DATA"],
+ [Define the project release date.]
+ )
+ AC_SUBST([ZFS_META_DATA])
+ fi
+
+ ZFS_META_AUTHOR=_ZFS_AC_META_GETVAL([AUTHOR]);
+ if test -n "$ZFS_META_AUTHOR"; then
+ AC_DEFINE_UNQUOTED([ZFS_META_AUTHOR], ["$ZFS_META_AUTHOR"],
+ [Define the project author.]
+ )
+ AC_SUBST([ZFS_META_AUTHOR])
+ fi
+
+ m4_pattern_allow([^LT_(CURRENT|REVISION|AGE)$])
+ ZFS_META_LT_CURRENT=_ZFS_AC_META_GETVAL([LT_CURRENT]);
+ ZFS_META_LT_REVISION=_ZFS_AC_META_GETVAL([LT_REVISION]);
+ ZFS_META_LT_AGE=_ZFS_AC_META_GETVAL([LT_AGE]);
+ if test -n "$ZFS_META_LT_CURRENT" \
+ -o -n "$ZFS_META_LT_REVISION" \
+ -o -n "$ZFS_META_LT_AGE"; then
+ test -n "$ZFS_META_LT_CURRENT" || ZFS_META_LT_CURRENT="0"
+ test -n "$ZFS_META_LT_REVISION" || ZFS_META_LT_REVISION="0"
+ test -n "$ZFS_META_LT_AGE" || ZFS_META_LT_AGE="0"
+ AC_DEFINE_UNQUOTED([ZFS_META_LT_CURRENT],
+ ["$ZFS_META_LT_CURRENT"],
+ [Define the libtool library 'current'
+ version information.]
+ )
+ AC_DEFINE_UNQUOTED([ZFS_META_LT_REVISION],
+ ["$ZFS_META_LT_REVISION"],
+ [Define the libtool library 'revision'
+ version information.]
+ )
+ AC_DEFINE_UNQUOTED([ZFS_META_LT_AGE], ["$ZFS_META_LT_AGE"],
+ [Define the libtool library 'age'
+ version information.]
+ )
+ AC_SUBST([ZFS_META_LT_CURRENT])
+ AC_SUBST([ZFS_META_LT_REVISION])
+ AC_SUBST([ZFS_META_LT_AGE])
+ fi
+ fi
+
+ AC_MSG_RESULT([$_zfs_ac_meta_got_file])
+ ]
+)
+
+AC_DEFUN([_ZFS_AC_META_GETVAL],
+ [`perl -n\
+ -e "BEGIN { \\$key=shift @ARGV; }"\
+ -e "next unless s/^\s*\\$key@<:@:=@:>@//i;"\
+ -e "s/^((?:@<:@^'\"#@:>@*(?:(@<:@'\"@:>@)@<:@^\2@:>@*\2)*)*)#.*/\\@S|@1/;"\
+ -e "s/^\s+//;"\
+ -e "s/\s+$//;"\
+ -e "s/^(@<:@'\"@:>@)(.*)\1/\\@S|@2/;"\
+ -e "\\$val=\\$_;"\
+ -e "END { print \\$val if defined \\$val; }"\
+ '$1' $META`]dnl
+)
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 000000000..728a2dd7c
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,91 @@
+/*
+ * This file is part of the ZFS Linux port.
+ *
+ * Copyright (c) 2009 Lawrence Livermore National Security, LLC.
+ * Produced at Lawrence Livermore National Laboratory
+ * Written by:
+ * Brian Behlendorf <[email protected]>,
+ * Herb Wartens <[email protected]>,
+ * Jim Garlick <[email protected]>
+ * LLNL-CODE-403049
+ *
+ * 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 http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+AC_INIT
+AC_LANG(C)
+ZFS_AC_META
+AC_CONFIG_AUX_DIR([config])
+AC_CANONICAL_SYSTEM
+AM_MAINTAINER_MODE
+AM_SILENT_RULES
+AM_INIT_AUTOMAKE([$ZFS_META_NAME], [$ZFS_META_VERSION])
+AC_CONFIG_HEADERS([zfs_config.h], [
+ (mv zfs_config.h zfs_config.h.tmp &&
+ awk -f config/config.awk zfs_config.h.tmp >zfs_config.h &&
+ rm zfs_config.h.tmp) || exit 1])
+
+AC_PROG_INSTALL
+AC_PROG_CC
+AC_PROG_LIBTOOL
+AM_PROG_AS
+
+ZFS_AC_LICENSE
+ZFS_AC_PACKAGE
+ZFS_AC_CONFIG
+ZFS_AC_DEBUG
+
+AC_CONFIG_FILES([
+ Makefile
+ config/Makefile
+ etc/Makefile
+ man/Makefile
+ man/man8/Makefile
+ lib/Makefile
+ lib/libavl/Makefile
+ lib/libefi/Makefile
+ lib/libnvpair/Makefile
+ lib/libunicode/Makefile
+ lib/libuutil/Makefile
+ lib/libzpool/Makefile
+ lib/libzpool/include/Makefile
+ lib/libzfs/Makefile
+ cmd/Makefile
+ cmd/zdb/Makefile
+ cmd/zfs/Makefile
+ cmd/zinject/Makefile
+ cmd/zpool/Makefile
+ cmd/zpool_id/Makefile
+ cmd/zpool_layout/Makefile
+ cmd/ztest/Makefile
+ module/Makefile
+ module/avl/Makefile
+ module/nvpair/Makefile
+ module/unicode/Makefile
+ module/zcommon/Makefile
+ module/zfs/Makefile
+ scripts/Makefile
+ scripts/common.sh
+ zfs.spec
+ zfs-modules.spec
+])
+
+AC_OUTPUT
diff --git a/etc/Makefile.am b/etc/Makefile.am
new file mode 100644
index 000000000..1bc847d1a
--- /dev/null
+++ b/etc/Makefile.am
@@ -0,0 +1,3 @@
+sysconfdir = /etc
+nobase_dist_sysconf_DATA = zfs/*
+nobase_dist_sysconf_DATA += udev/rules.d/*
diff --git a/etc/udev/rules.d/60-zpool.rules b/etc/udev/rules.d/60-zpool.rules
new file mode 100644
index 000000000..0f4a356dd
--- /dev/null
+++ b/etc/udev/rules.d/60-zpool.rules
@@ -0,0 +1,8 @@
+#
+# /etc/udev/rules.d/99-zpool.rules
+#
+
+ENV{DEVTYPE}=="disk", IMPORT{program}="/usr/bin/zpool_id -d %p"
+
+KERNEL=="*[!0-9]", ENV{SUBSYSTEM}=="block", ENV{ID_ZPOOL}=="?*", SYMLINK+="$env{ID_ZPOOL_PATH}"
+KERNEL=="*[0-9]", ENV{SUBSYSTEM}=="block", ENV{ID_ZPOOL}=="?*", SYMLINK+="$env{ID_ZPOOL_PATH}-part%n"
diff --git a/etc/zfs/zdev.conf b/etc/zfs/zdev.conf
new file mode 100644
index 000000000..236c342b3
--- /dev/null
+++ b/etc/zfs/zdev.conf
@@ -0,0 +1,9 @@
+#
+# Custom by-path mapping for large JBOD configurations
+#
+# Example Config: Desktop
+#
+
+#<ID> <by-path name>
+#disk1 pci-0000:61:06.1-scsi-0:0:0:0
+#disk2 pci-0000:61:06.1-scsi-0:0:0:1
diff --git a/etc/zfs/zdev.conf.dragon.example b/etc/zfs/zdev.conf.dragon.example
new file mode 100644
index 000000000..23ef7f09d
--- /dev/null
+++ b/etc/zfs/zdev.conf.dragon.example
@@ -0,0 +1,176 @@
+#
+# Custom by-path mapping for large JBOD configurations
+#
+# Example Config:
+# Quarter scale dragon drawer based SSU for RHEL6
+#
+
+# Channel A: PCI Bus 3, Enclosure 0x50001ff10e991000
+a1 pci-0000:03:00.0-sas-0x50001ff10e991000-34
+a2 pci-0000:03:00.0-sas-0x50001ff10e991000-35
+a3 pci-0000:03:00.0-sas-0x50001ff10e991000-39
+a4 pci-0000:03:00.0-sas-0x50001ff10e991000-40
+a5 pci-0000:03:00.0-sas-0x50001ff10e991000-44
+a6 pci-0000:03:00.0-sas-0x50001ff10e991000-45
+a7 pci-0000:03:00.0-sas-0x50001ff10e991000-48
+a8 pci-0000:03:00.0-sas-0x50001ff10e991000-49
+a9 pci-0000:03:00.0-sas-0x50001ff10e991000-50
+a10 pci-0000:03:00.0-sas-0x50001ff10e991000-53
+a11 pci-0000:03:00.0-sas-0x50001ff10e991000-54
+a12 pci-0000:03:00.0-sas-0x50001ff10e991000-55
+a13 pci-0000:03:00.0-sas-0x50001ff10e991000-58
+a14 pci-0000:03:00.0-sas-0x50001ff10e991000-59
+a15 pci-0000:03:00.0-sas-0x50001ff10e991000-60
+
+# Channel B: PCI Bus 3, Enclosure 0x50001ff10e9d1000
+b1 pci-0000:03:00.0-sas-0x50001ff10e9d1000-34
+b2 pci-0000:03:00.0-sas-0x50001ff10e9d1000-35
+b3 pci-0000:03:00.0-sas-0x50001ff10e9d1000-39
+b4 pci-0000:03:00.0-sas-0x50001ff10e9d1000-40
+b5 pci-0000:03:00.0-sas-0x50001ff10e9d1000-44
+b6 pci-0000:03:00.0-sas-0x50001ff10e9d1000-45
+b7 pci-0000:03:00.0-sas-0x50001ff10e9d1000-48
+b8 pci-0000:03:00.0-sas-0x50001ff10e9d1000-49
+b9 pci-0000:03:00.0-sas-0x50001ff10e9d1000-50
+b10 pci-0000:03:00.0-sas-0x50001ff10e9d1000-53
+b11 pci-0000:03:00.0-sas-0x50001ff10e9d1000-54
+b12 pci-0000:03:00.0-sas-0x50001ff10e9d1000-55
+b13 pci-0000:03:00.0-sas-0x50001ff10e9d1000-58
+b14 pci-0000:03:00.0-sas-0x50001ff10e9d1000-59
+b15 pci-0000:03:00.0-sas-0x50001ff10e9d1000-60
+
+# Channel C: PCI Bus 4, Enclosure 0x50001ff10e991000
+c1 pci-0000:04:00.0-sas-0x50001ff10e991000-31
+c2 pci-0000:04:00.0-sas-0x50001ff10e991000-32
+c3 pci-0000:04:00.0-sas-0x50001ff10e991000-33
+c4 pci-0000:04:00.0-sas-0x50001ff10e991000-36
+c5 pci-0000:04:00.0-sas-0x50001ff10e991000-37
+c6 pci-0000:04:00.0-sas-0x50001ff10e991000-38
+c7 pci-0000:04:00.0-sas-0x50001ff10e991000-41
+c8 pci-0000:04:00.0-sas-0x50001ff10e991000-42
+c9 pci-0000:04:00.0-sas-0x50001ff10e991000-43
+c10 pci-0000:04:00.0-sas-0x50001ff10e991000-46
+c11 pci-0000:04:00.0-sas-0x50001ff10e991000-47
+c12 pci-0000:04:00.0-sas-0x50001ff10e991000-51
+c13 pci-0000:04:00.0-sas-0x50001ff10e991000-52
+c14 pci-0000:04:00.0-sas-0x50001ff10e991000-56
+c15 pci-0000:04:00.0-sas-0x50001ff10e991000-57
+
+# Channel D: PCI Bus 4, Enclosure 0x50001ff10e9d1000
+d1 pci-0000:04:00.0-sas-0x50001ff10e9d1000-31
+d2 pci-0000:04:00.0-sas-0x50001ff10e9d1000-32
+d3 pci-0000:04:00.0-sas-0x50001ff10e9d1000-33
+d4 pci-0000:04:00.0-sas-0x50001ff10e9d1000-36
+d5 pci-0000:04:00.0-sas-0x50001ff10e9d1000-37
+d6 pci-0000:04:00.0-sas-0x50001ff10e9d1000-38
+d7 pci-0000:04:00.0-sas-0x50001ff10e9d1000-41
+d8 pci-0000:04:00.0-sas-0x50001ff10e9d1000-42
+d9 pci-0000:04:00.0-sas-0x50001ff10e9d1000-43
+d10 pci-0000:04:00.0-sas-0x50001ff10e9d1000-46
+d11 pci-0000:04:00.0-sas-0x50001ff10e9d1000-47
+d12 pci-0000:04:00.0-sas-0x50001ff10e9d1000-51
+d13 pci-0000:04:00.0-sas-0x50001ff10e9d1000-52
+d14 pci-0000:04:00.0-sas-0x50001ff10e9d1000-56
+d15 pci-0000:04:00.0-sas-0x50001ff10e9d1000-57
+
+# Channel E: PCI Bus 84, Enclosure 0x50001ff10e991000
+e1 pci-0000:84:00.0-sas-0x50001ff10e991000-3
+e2 pci-0000:84:00.0-sas-0x50001ff10e991000-4
+e3 pci-0000:84:00.0-sas-0x50001ff10e991000-5
+e4 pci-0000:84:00.0-sas-0x50001ff10e991000-8
+e5 pci-0000:84:00.0-sas-0x50001ff10e991000-9
+e6 pci-0000:84:00.0-sas-0x50001ff10e991000-10
+e7 pci-0000:84:00.0-sas-0x50001ff10e991000-13
+e8 pci-0000:84:00.0-sas-0x50001ff10e991000-14
+e9 pci-0000:84:00.0-sas-0x50001ff10e991000-15
+e10 pci-0000:84:00.0-sas-0x50001ff10e991000-19
+e11 pci-0000:84:00.0-sas-0x50001ff10e991000-20
+e12 pci-0000:84:00.0-sas-0x50001ff10e991000-24
+e13 pci-0000:84:00.0-sas-0x50001ff10e991000-25
+e14 pci-0000:84:00.0-sas-0x50001ff10e991000-29
+e15 pci-0000:84:00.0-sas-0x50001ff10e991000-30
+
+# Channel F: PCI Bus 84, Enclosure 0x50001ff10e9d1000
+f1 pci-0000:84:00.0-sas-0x50001ff10e9d1000-3
+f2 pci-0000:84:00.0-sas-0x50001ff10e9d1000-4
+f3 pci-0000:84:00.0-sas-0x50001ff10e9d1000-5
+f4 pci-0000:84:00.0-sas-0x50001ff10e9d1000-8
+f5 pci-0000:84:00.0-sas-0x50001ff10e9d1000-9
+f6 pci-0000:84:00.0-sas-0x50001ff10e9d1000-10
+f7 pci-0000:84:00.0-sas-0x50001ff10e9d1000-13
+f8 pci-0000:84:00.0-sas-0x50001ff10e9d1000-14
+f9 pci-0000:84:00.0-sas-0x50001ff10e9d1000-15
+f10 pci-0000:84:00.0-sas-0x50001ff10e9d1000-19
+f11 pci-0000:84:00.0-sas-0x50001ff10e9d1000-20
+f12 pci-0000:84:00.0-sas-0x50001ff10e9d1000-24
+f13 pci-0000:84:00.0-sas-0x50001ff10e9d1000-25
+f14 pci-0000:84:00.0-sas-0x50001ff10e9d1000-29
+f15 pci-0000:84:00.0-sas-0x50001ff10e9d1000-30
+
+# Channel G: PCI Bus 85, Enclosure 0x50001ff10e991000
+g1 pci-0000:85:00.0-sas-0x50001ff10e991000-1
+g2 pci-0000:85:00.0-sas-0x50001ff10e991000-2
+g3 pci-0000:85:00.0-sas-0x50001ff10e991000-6
+g4 pci-0000:85:00.0-sas-0x50001ff10e991000-7
+g5 pci-0000:85:00.0-sas-0x50001ff10e991000-11
+g6 pci-0000:85:00.0-sas-0x50001ff10e991000-12
+g7 pci-0000:85:00.0-sas-0x50001ff10e991000-16
+g8 pci-0000:85:00.0-sas-0x50001ff10e991000-17
+g9 pci-0000:85:00.0-sas-0x50001ff10e991000-18
+g10 pci-0000:85:00.0-sas-0x50001ff10e991000-21
+g11 pci-0000:85:00.0-sas-0x50001ff10e991000-22
+g12 pci-0000:85:00.0-sas-0x50001ff10e991000-23
+g13 pci-0000:85:00.0-sas-0x50001ff10e991000-26
+g14 pci-0000:85:00.0-sas-0x50001ff10e991000-27
+g15 pci-0000:85:00.0-sas-0x50001ff10e991000-28
+
+# Channel H: PCI Bus 85, Enclosure 0x50001ff10e9d1000
+h1 pci-0000:85:00.0-sas-0x50001ff10e9d1000-1
+h2 pci-0000:85:00.0-sas-0x50001ff10e9d1000-2
+h3 pci-0000:85:00.0-sas-0x50001ff10e9d1000-6
+h4 pci-0000:85:00.0-sas-0x50001ff10e9d1000-7
+h5 pci-0000:85:00.0-sas-0x50001ff10e9d1000-11
+h6 pci-0000:85:00.0-sas-0x50001ff10e9d1000-12
+h7 pci-0000:85:00.0-sas-0x50001ff10e9d1000-16
+h8 pci-0000:85:00.0-sas-0x50001ff10e9d1000-17
+h9 pci-0000:85:00.0-sas-0x50001ff10e9d1000-18
+h10 pci-0000:85:00.0-sas-0x50001ff10e9d1000-21
+h11 pci-0000:85:00.0-sas-0x50001ff10e9d1000-22
+h12 pci-0000:85:00.0-sas-0x50001ff10e9d1000-23
+h13 pci-0000:85:00.0-sas-0x50001ff10e9d1000-26
+h14 pci-0000:85:00.0-sas-0x50001ff10e9d1000-27
+h15 pci-0000:85:00.0-sas-0x50001ff10e9d1000-28
+
+# Channel I: PCI Bus 83, Enclosure 0x5000155359b8e33f
+i1 pci-0000:83:00.0-sas-0x5000155359b8e33f-0
+i2 pci-0000:83:00.0-sas-0x5000155359b8e33f-1
+i3 pci-0000:83:00.0-sas-0x5000155359b8e33f-2
+i4 pci-0000:83:00.0-sas-0x5000155359b8e33f-3
+i5 pci-0000:83:00.0-sas-0x5000155359b8e33f-4
+i6 pci-0000:83:00.0-sas-0x5000155359b8e33f-5
+i7 pci-0000:83:00.0-sas-0x5000155359b8e33f-6
+i8 pci-0000:83:00.0-sas-0x5000155359b8e33f-7
+i9 pci-0000:83:00.0-sas-0x5000155359b8e33f-8
+i10 pci-0000:83:00.0-sas-0x5000155359b8e33f-9
+i11 pci-0000:83:00.0-sas-0x5000155359b8e33f-10
+i12 pci-0000:83:00.0-sas-0x5000155359b8e33f-11
+i13 pci-0000:83:00.0-sas-0x5000155359b8e33f-12
+i14 pci-0000:83:00.0-sas-0x5000155359b8e33f-13
+i15 pci-0000:83:00.0-sas-0x5000155359b8e33f-14
+
+# Channel J: PCI Bus 83, Enclosure 0x5000155359dba33f
+j1 pci-0000:83:00.0-sas-0x5000155359dba33f-0
+j2 pci-0000:83:00.0-sas-0x5000155359dba33f-1
+j3 pci-0000:83:00.0-sas-0x5000155359dba33f-2
+j4 pci-0000:83:00.0-sas-0x5000155359dba33f-3
+j5 pci-0000:83:00.0-sas-0x5000155359dba33f-4
+j6 pci-0000:83:00.0-sas-0x5000155359dba33f-5
+j7 pci-0000:83:00.0-sas-0x5000155359dba33f-6
+j8 pci-0000:83:00.0-sas-0x5000155359dba33f-7
+j9 pci-0000:83:00.0-sas-0x5000155359dba33f-8
+j10 pci-0000:83:00.0-sas-0x5000155359dba33f-9
+j11 pci-0000:83:00.0-sas-0x5000155359dba33f-10
+j12 pci-0000:83:00.0-sas-0x5000155359dba33f-11
+j13 pci-0000:83:00.0-sas-0x5000155359dba33f-12
+j14 pci-0000:83:00.0-sas-0x5000155359dba33f-13
+j15 pci-0000:83:00.0-sas-0x5000155359dba33f-14
diff --git a/etc/zfs/zdev.conf.supermicro.example b/etc/zfs/zdev.conf.supermicro.example
new file mode 100644
index 000000000..f20dcc081
--- /dev/null
+++ b/etc/zfs/zdev.conf.supermicro.example
@@ -0,0 +1,30 @@
+#
+# Custom by-path mapping for large JBOD configurations
+#
+# Example Config:
+# Single Supermicro JBOD for RHEL6
+#
+
+# Channel A: PCI Bus 7, Enclosure 0x500304800027367f
+a1 pci-0000:07:00.0-sas-0x500304800027367f-0
+a2 pci-0000:07:00.0-sas-0x500304800027367f-1
+a3 pci-0000:07:00.0-sas-0x500304800027367f-2
+a4 pci-0000:07:00.0-sas-0x500304800027367f-3
+
+# Channel B: PCI Bus 7, Enclosure 0x500304800027367f
+b1 pci-0000:07:00.0-sas-0x500304800027367f-4
+b2 pci-0000:07:00.0-sas-0x500304800027367f-5
+b3 pci-0000:07:00.0-sas-0x500304800027367f-6
+b4 pci-0000:07:00.0-sas-0x500304800027367f-7
+
+# Channel C: PCI Bus 7, Enclosure 0x500304800027367f
+c1 pci-0000:07:00.0-sas-0x500304800027367f-8
+c2 pci-0000:07:00.0-sas-0x500304800027367f-9
+c3 pci-0000:07:00.0-sas-0x500304800027367f-10
+c4 pci-0000:07:00.0-sas-0x500304800027367f-11
+
+# Channel D: PCI Bus 7, Enclosure 0x500304800027367f
+d1 pci-0000:07:00.0-sas-0x500304800027367f-12
+d2 pci-0000:07:00.0-sas-0x500304800027367f-13
+d3 pci-0000:07:00.0-sas-0x500304800027367f-14
+d4 pci-0000:07:00.0-sas-0x500304800027367f-15
diff --git a/etc/zfs/zdev.conf.x4550.example b/etc/zfs/zdev.conf.x4550.example
new file mode 100644
index 000000000..9c611ed45
--- /dev/null
+++ b/etc/zfs/zdev.conf.x4550.example
@@ -0,0 +1,66 @@
+#
+# Custom by-path mapping for large JBOD configurations
+#
+# Example Config:
+# Sun x4550 for RHEL5
+#
+
+# Channel A: PCI Bus 2
+a1 pci-0000:02:00.0-sas-0x50062b0000000001:1:0-0xd6807184d601e192:0
+a2 pci-0000:02:00.0-sas-0x50062b0000000002:1:1-0xd4905378e6e3d592:1
+a3 pci-0000:02:00.0-sas-0x50062b0000000003:1:2-0xd3827673d806d392:2
+a4 pci-0000:02:00.0-sas-0x50062b0000000004:1:3-0xd6805385d6e3e192:3
+a5 pci-0000:02:00.0-sas-0x50062b0000000005:1:4-0xd680655bd6f5b792:4
+a6 pci-0000:02:00.0-sas-0x50062b0000000006:1:5-0x7a967598ec06d091:5
+a7 pci-0000:02:00.0-sas-0x50062b0000000007:1:6-0xd3826c60d8fcbf92:6
+a8 pci-0000:02:00.0-sas-0x50062b0000000008:1:7-0xd6805271d6e2cd92:7
+
+# Channel B: PCI Bus 3
+b1 pci-0000:03:00.0-sas-0x50062b0000000002:1:0-0xd680685fd6f8bb92:0
+b2 pci-0000:03:00.0-sas-0x50062b0000000003:1:1-0xd58c706de200cb92:1
+b3 pci-0000:03:00.0-sas-0x50062b0000000004:1:2-0xd5897480df04de92:2
+b4 pci-0000:03:00.0-sas-0x50062b0000000005:1:3-0xd6805764d6e7c092:3
+b5 pci-0000:03:00.0-sas-0x50062b0000000006:1:4-0xd6806a6dd6fac992:4
+b6 pci-0000:03:00.0-sas-0x50062b0000000007:1:5-0xd58c6b84e2fbe192:5
+b7 pci-0000:03:00.0-sas-0x50062b0000000008:1:6-0xd58a576ee0e7cb92:6
+b8 pci-0000:03:00.0-sas-0x50062b0000000009:1:7-0xd5877871dd08cf92:7
+
+# Channel C: PCI Bus 4
+c1 pci-0000:04:00.0-sas-0x50062b0000000003:1:0-0xd6806678d6f6d492:0
+c2 pci-0000:04:00.0-sas-0x50062b0000000004:1:1-0xd680696fd6f9cb92:1
+c3 pci-0000:04:00.0-sas-0x50062b0000000005:1:2-0xd3827182d801e292:2
+c4 pci-0000:04:00.0-sas-0x50062b0000000006:1:3-0xd680666fd6f6cb92:3
+c5 pci-0000:04:00.0-sas-0x50062b0000000007:1:4-0xd6806970d6f9cc92:4
+c6 pci-0000:04:00.0-sas-0x50062b0000000008:1:5-0xd6806b62d6fbbe92:5
+c7 pci-0000:04:00.0-sas-0x50062b0000000009:1:6-0xd58a5760e0e7bd92:6
+c8 pci-0000:04:00.0-sas-0x50062b000000000a:1:7-0xd680717fd601dc92:7
+
+# Channel D: PCI Bus 41
+d1 pci-0000:41:00.0-sas-0x50062b0000000004:1:0-0xd6806572d6f5ce92:0
+d2 pci-0000:41:00.0-sas-0x50062b0000000005:1:1-0xd6806983d6f9df92:1
+d3 pci-0000:41:00.0-sas-0x50062b0000000006:1:2-0xd3826c69d8fcc892:2
+d4 pci-0000:41:00.0-sas-0x50062b0000000007:1:3-0xd680725fd602bc92:3
+d5 pci-0000:41:00.0-sas-0x50062b0000000008:1:4-0xd6806971d6f9cd92:4
+d6 pci-0000:41:00.0-sas-0x50062b0000000009:1:5-0xd680726dd602ca92:5
+d7 pci-0000:41:00.0-sas-0x50062b000000000a:1:6-0xd3827772d807d292:6
+d8 pci-0000:41:00.0-sas-0x50062b000000000b:1:7-0xd4955584ebe5e192:7
+
+# Channel E: PCI Bus 42
+e1 pci-0000:42:00.0-sas-0x50062b0000000005:1:0-0xd4925676e8e6d392:0
+e2 pci-0000:42:00.0-sas-0x50062b0000000006:1:1-0xd6806b6ed6fbca92:1
+e3 pci-0000:42:00.0-sas-0x50062b0000000007:1:2-0xd382765fd806bf92:2
+e4 pci-0000:42:00.0-sas-0x50062b0000000008:1:3-0xd587786cdd08ca92:3
+e5 pci-0000:42:00.0-sas-0x50062b0000000009:1:4-0xd66f4e5bc5deb792:4
+e6 pci-0000:42:00.0-sas-0x50062b000000000a:1:5-0xd6806879d6f8d592:5
+e7 pci-0000:42:00.0-sas-0x50062b000000000b:1:6-0xd5885175dee1d292:6
+e8 pci-0000:42:00.0-sas-0x50062b000000000c:1:7-0xd588515fdee1bc92:7
+
+# Channel F: PCI Bus 43
+f1 pci-0000:43:00.0-sas-0x50062b0000000006:1:0-0xd66d6978c3f9d492:0
+f2 pci-0000:43:00.0-sas-0x50062b0000000007:1:1-0xd6806a5cd6fab892:1
+f3 pci-0000:43:00.0-sas-0x50062b0000000008:1:2-0xd6806563d6f5bf92:2
+f4 pci-0000:43:00.0-sas-0x50062b0000000009:1:3-0xd6805664d6e6c092:3
+f5 pci-0000:43:00.0-sas-0x50062b000000000a:1:4-0xd58c707ee200dc92:4
+f6 pci-0000:43:00.0-sas-0x50062b000000000b:1:5-0xd5885781dee7de92:5
+f7 pci-0000:43:00.0-sas-0x50062b000000000c:1:6-0xd3827481d804e192:6
+f8 pci-0000:43:00.0-sas-0x50062b000000000d:1:7-0xd6806863d6f8bf92:7
diff --git a/lib/Makefile.am b/lib/Makefile.am
new file mode 100644
index 000000000..2de022787
--- /dev/null
+++ b/lib/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = libavl libefi libnvpair libunicode libuutil libzfs libzpool
diff --git a/lib/libavl/Makefile.am b/lib/libavl/Makefile.am
new file mode 100644
index 000000000..50185e281
--- /dev/null
+++ b/lib/libavl/Makefile.am
@@ -0,0 +1,14 @@
+include $(top_srcdir)/config/Rules.am
+
+AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
+
+DEFAULT_INCLUDES += \
+ -I${top_srcdir}/module/avl/include \
+ -I${top_srcdir}/lib/libspl/include
+
+lib_LTLIBRARIES = libavl.la
+
+libavl_la_SOURCES = \
+ ${top_srcdir}/module/avl/avl.c \
+ ${top_srcdir}/module/avl/include/sys/avl.h \
+ ${top_srcdir}/module/avl/include/sys/avl_impl.h
diff --git a/lib/libefi/Makefile.am b/lib/libefi/Makefile.am
new file mode 100644
index 000000000..431179340
--- /dev/null
+++ b/lib/libefi/Makefile.am
@@ -0,0 +1,14 @@
+include $(top_srcdir)/config/Rules.am
+
+AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
+
+DEFAULT_INCLUDES += \
+ -I${top_srcdir}/lib/libefi/include \
+ -I${top_srcdir}/lib/libspl/include
+
+lib_LTLIBRARIES = libefi.la
+
+libefi_la_SOURCES = \
+ ${top_srcdir}/lib/libefi/rdwr_efi.c \
+ ${top_srcdir}/lib/libefi/include/sys/efi_partition.h \
+ ${top_srcdir}/lib/libefi/include/sys/uuid.h
diff --git a/lib/libnvpair/Makefile.am b/lib/libnvpair/Makefile.am
new file mode 100644
index 000000000..9cac22c53
--- /dev/null
+++ b/lib/libnvpair/Makefile.am
@@ -0,0 +1,19 @@
+include $(top_srcdir)/config/Rules.am
+
+AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
+
+DEFAULT_INCLUDES += \
+ -I${top_srcdir}/module/nvpair/include \
+ -I${top_srcdir}/lib/libnvpair/include \
+ -I${top_srcdir}/lib/libspl/include
+
+lib_LTLIBRARIES = libnvpair.la
+
+libnvpair_la_SOURCES = \
+ ${top_srcdir}/lib/libnvpair/libnvpair.c \
+ ${top_srcdir}/lib/libnvpair/nvpair_alloc_system.c \
+ ${top_srcdir}/lib/libnvpair/include/libnvpair.h \
+ ${top_srcdir}/module/nvpair/nvpair_alloc_fixed.c \
+ ${top_srcdir}/module/nvpair/nvpair.c \
+ ${top_srcdir}/module/nvpair/include/sys/nvpair.h \
+ ${top_srcdir}/module/nvpair/include/sys/nvpair_impl.h
diff --git a/lib/libunicode/Makefile.am b/lib/libunicode/Makefile.am
new file mode 100644
index 000000000..9d5785595
--- /dev/null
+++ b/lib/libunicode/Makefile.am
@@ -0,0 +1,15 @@
+include $(top_srcdir)/config/Rules.am
+
+AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
+
+DEFAULT_INCLUDES += \
+ -I${top_srcdir}/module/unicode/include \
+ -I${top_srcdir}/lib/libspl/include
+
+lib_LTLIBRARIES = libunicode.la
+
+libunicode_la_SOURCES = \
+ ${top_srcdir}/module/unicode/u8_textprep.c \
+ ${top_srcdir}/module/unicode/uconv.c \
+ ${top_srcdir}/module/unicode/include/sys/u8_textprep.h \
+ ${top_srcdir}/module/unicode/include/sys/u8_textprep_data.h
diff --git a/lib/libuutil/Makefile.am b/lib/libuutil/Makefile.am
new file mode 100644
index 000000000..6edca7313
--- /dev/null
+++ b/lib/libuutil/Makefile.am
@@ -0,0 +1,27 @@
+include $(top_srcdir)/config/Rules.am
+
+AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
+
+DEFAULT_INCLUDES += \
+ -I${top_srcdir}/lib/libuutil/include \
+ -I${top_srcdir}/lib/libspl/include \
+ -I${top_srcdir}/module/avl/include
+
+lib_LTLIBRARIES = libuutil.la
+
+libuutil_la_LIBADD = ${top_srcdir}/lib/libavl/libavl.la
+
+libuutil_la_SOURCES = \
+ ${top_srcdir}/lib/libuutil/uu_alloc.c \
+ ${top_srcdir}/lib/libuutil/uu_avl.c \
+ ${top_srcdir}/lib/libuutil/uu_dprintf.c \
+ ${top_srcdir}/lib/libuutil/uu_ident.c \
+ ${top_srcdir}/lib/libuutil/uu_list.c \
+ ${top_srcdir}/lib/libuutil/uu_misc.c \
+ ${top_srcdir}/lib/libuutil/uu_open.c \
+ ${top_srcdir}/lib/libuutil/uu_pname.c \
+ ${top_srcdir}/lib/libuutil/uu_string.c \
+ ${top_srcdir}/lib/libuutil/uu_strtoint.c \
+ ${top_srcdir}/lib/libuutil/include/libuutil.h \
+ ${top_srcdir}/lib/libuutil/include/libuutil_common.h \
+ ${top_srcdir}/lib/libuutil/include/libuutil_impl.h
diff --git a/lib/libzfs/Makefile.am b/lib/libzfs/Makefile.am
new file mode 100644
index 000000000..071362a86
--- /dev/null
+++ b/lib/libzfs/Makefile.am
@@ -0,0 +1,39 @@
+include $(top_srcdir)/config/Rules.am
+
+DEFAULT_INCLUDES += \
+ -I${top_srcdir}/lib/libzfs/include \
+ -I${top_srcdir}/lib/libzpool/include \
+ -I${top_srcdir}/lib/libspl/include \
+ -I${top_srcdir}/lib/libnvpair/include \
+ -I${top_srcdir}/lib/libuutil/include \
+ -I${top_srcdir}/lib/libefi/include \
+ -I${top_srcdir}/module/zfs \
+ -I${top_srcdir}/module/zfs/include \
+ -I${top_srcdir}/module/zcommon/include \
+ -I${top_srcdir}/module/nvpair/include \
+ -I${top_srcdir}/module/avl/include \
+ -I${top_srcdir}/module/unicode/include
+
+lib_LTLIBRARIES = libzfs.la
+
+libzfs_la_LDFLAGS = -lm
+
+libzfs_la_LIBADD = \
+ ${top_srcdir}/lib/libefi/libefi.la \
+ ${top_srcdir}/lib/libuutil/libuutil.la
+
+libzfs_la_SOURCES = \
+ ${top_srcdir}/lib/libzfs/libzfs_changelist.c \
+ ${top_srcdir}/lib/libzfs/libzfs_config.c \
+ ${top_srcdir}/lib/libzfs/libzfs_dataset.c \
+ ${top_srcdir}/lib/libzfs/libzfs_diff.c \
+ ${top_srcdir}/lib/libzfs/libzfs_fru.c \
+ ${top_srcdir}/lib/libzfs/libzfs_graph.c \
+ ${top_srcdir}/lib/libzfs/libzfs_import.c \
+ ${top_srcdir}/lib/libzfs/libzfs_mount.c \
+ ${top_srcdir}/lib/libzfs/libzfs_pool.c \
+ ${top_srcdir}/lib/libzfs/libzfs_sendrecv.c \
+ ${top_srcdir}/lib/libzfs/libzfs_status.c \
+ ${top_srcdir}/lib/libzfs/libzfs_util.c \
+ ${top_srcdir}/lib/libzfs/include/libzfs.h \
+ ${top_srcdir}/lib/libzfs/include/libzfs_impl.h
diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am
new file mode 100644
index 000000000..4e2f31f75
--- /dev/null
+++ b/lib/libzpool/Makefile.am
@@ -0,0 +1,168 @@
+include $(top_srcdir)/config/Rules.am
+
+AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
+
+SUBDIRS = include
+DEFAULT_INCLUDES += \
+ -I${top_srcdir}/lib/libzpool/include \
+ -I${top_srcdir}/lib/libspl/include \
+ -I${top_srcdir}/lib/libnvpair/include \
+ -I${top_srcdir}/module/zcommon/include \
+ -I${top_srcdir}/module/nvpair/include \
+ -I${top_srcdir}/module/avl/include \
+ -I${top_srcdir}/module/unicode/include \
+ -I${top_srcdir}/module/zfs/include
+
+lib_LTLIBRARIES = libzpool.la
+
+libzpool_la_LIBADD = \
+ ${top_srcdir}/lib/libunicode/libunicode.la \
+ ${top_srcdir}/lib/libavl/libavl.la \
+ ${top_srcdir}/lib/libspl/libspl.la
+
+libzpool_la_SOURCES = \
+ ${top_srcdir}/lib/libzpool/kernel.c \
+ ${top_srcdir}/lib/libzpool/taskq.c \
+ ${top_srcdir}/lib/libzpool/util.c \
+ ${top_srcdir}/module/zcommon/zfs_comutil.c \
+ ${top_srcdir}/module/zcommon/zfs_deleg.c \
+ ${top_srcdir}/module/zcommon/zfs_fletcher.c \
+ ${top_srcdir}/module/zcommon/zfs_namecheck.c \
+ ${top_srcdir}/module/zcommon/zfs_prop.c \
+ ${top_srcdir}/module/zcommon/zpool_prop.c \
+ ${top_srcdir}/module/zcommon/zprop_common.c \
+ ${top_srcdir}/module/zcommon/include/sys/fs \
+ ${top_srcdir}/module/zcommon/include/sys/fs/zfs.h \
+ ${top_srcdir}/module/zcommon/include/zfs_comutil.h \
+ ${top_srcdir}/module/zcommon/include/zfs_deleg.h \
+ ${top_srcdir}/module/zcommon/include/zfs_fletcher.h \
+ ${top_srcdir}/module/zcommon/include/zfs_namecheck.h \
+ ${top_srcdir}/module/zcommon/include/zfs_prop.h \
+ ${top_srcdir}/module/zfs/arc.c \
+ ${top_srcdir}/module/zfs/bplist.c \
+ ${top_srcdir}/module/zfs/bpobj.c \
+ ${top_srcdir}/module/zfs/dbuf.c \
+ ${top_srcdir}/module/zfs/ddt.c \
+ ${top_srcdir}/module/zfs/ddt_zap.c \
+ ${top_srcdir}/module/zfs/dmu.c \
+ ${top_srcdir}/module/zfs/dmu_diff.c \
+ ${top_srcdir}/module/zfs/dmu_object.c \
+ ${top_srcdir}/module/zfs/dmu_objset.c \
+ ${top_srcdir}/module/zfs/dmu_send.c \
+ ${top_srcdir}/module/zfs/dmu_traverse.c \
+ ${top_srcdir}/module/zfs/dmu_tx.c \
+ ${top_srcdir}/module/zfs/dmu_zfetch.c \
+ ${top_srcdir}/module/zfs/dnode.c \
+ ${top_srcdir}/module/zfs/dnode_sync.c \
+ ${top_srcdir}/module/zfs/dsl_dataset.c \
+ ${top_srcdir}/module/zfs/dsl_deadlist.c \
+ ${top_srcdir}/module/zfs/dsl_deleg.c \
+ ${top_srcdir}/module/zfs/dsl_dir.c \
+ ${top_srcdir}/module/zfs/dsl_pool.c \
+ ${top_srcdir}/module/zfs/dsl_prop.c \
+ ${top_srcdir}/module/zfs/dsl_scan.c \
+ ${top_srcdir}/module/zfs/dsl_synctask.c \
+ ${top_srcdir}/module/zfs/fm.c \
+ ${top_srcdir}/module/zfs/gzip.c \
+ ${top_srcdir}/module/zfs/lzjb.c \
+ ${top_srcdir}/module/zfs/metaslab.c \
+ ${top_srcdir}/module/zfs/refcount.c \
+ ${top_srcdir}/module/zfs/rrwlock.c \
+ ${top_srcdir}/module/zfs/sa.c \
+ ${top_srcdir}/module/zfs/sha256.c \
+ ${top_srcdir}/module/zfs/spa.c \
+ ${top_srcdir}/module/zfs/spa_boot.c \
+ ${top_srcdir}/module/zfs/spa_config.c \
+ ${top_srcdir}/module/zfs/spa_errlog.c \
+ ${top_srcdir}/module/zfs/spa_history.c \
+ ${top_srcdir}/module/zfs/spa_misc.c \
+ ${top_srcdir}/module/zfs/space_map.c \
+ ${top_srcdir}/module/zfs/txg.c \
+ ${top_srcdir}/module/zfs/uberblock.c \
+ ${top_srcdir}/module/zfs/unique.c \
+ ${top_srcdir}/module/zfs/vdev.c \
+ ${top_srcdir}/module/zfs/vdev_cache.c \
+ ${top_srcdir}/module/zfs/vdev_file.c \
+ ${top_srcdir}/module/zfs/vdev_label.c \
+ ${top_srcdir}/module/zfs/vdev_mirror.c \
+ ${top_srcdir}/module/zfs/vdev_missing.c \
+ ${top_srcdir}/module/zfs/vdev_queue.c \
+ ${top_srcdir}/module/zfs/vdev_raidz.c \
+ ${top_srcdir}/module/zfs/vdev_root.c \
+ ${top_srcdir}/module/zfs/zap.c \
+ ${top_srcdir}/module/zfs/zap_leaf.c \
+ ${top_srcdir}/module/zfs/zap_micro.c \
+ ${top_srcdir}/module/zfs/zfs_byteswap.c \
+ ${top_srcdir}/module/zfs/zfs_debug.c \
+ ${top_srcdir}/module/zfs/zfs_fm.c \
+ ${top_srcdir}/module/zfs/zfs_fuid.c \
+ ${top_srcdir}/module/zfs/zfs_onexit.c \
+ ${top_srcdir}/module/zfs/zfs_sa.c \
+ ${top_srcdir}/module/zfs/zfs_znode.c \
+ ${top_srcdir}/module/zfs/zil.c \
+ ${top_srcdir}/module/zfs/zio.c \
+ ${top_srcdir}/module/zfs/zio_checksum.c \
+ ${top_srcdir}/module/zfs/zio_compress.c \
+ ${top_srcdir}/module/zfs/zio_inject.c \
+ ${top_srcdir}/module/zfs/zle.c \
+ ${top_srcdir}/module/zfs/zrlock.c \
+ ${top_srcdir}/module/zfs/include/sys/arc.h \
+ ${top_srcdir}/module/zfs/include/sys/bplist.h \
+ ${top_srcdir}/module/zfs/include/sys/dbuf.h \
+ ${top_srcdir}/module/zfs/include/sys/dmu.h \
+ ${top_srcdir}/module/zfs/include/sys/dmu_impl.h \
+ ${top_srcdir}/module/zfs/include/sys/dmu_objset.h \
+ ${top_srcdir}/module/zfs/include/sys/dmu_traverse.h \
+ ${top_srcdir}/module/zfs/include/sys/dmu_tx.h \
+ ${top_srcdir}/module/zfs/include/sys/dmu_zfetch.h \
+ ${top_srcdir}/module/zfs/include/sys/dnode.h \
+ ${top_srcdir}/module/zfs/include/sys/dsl_dataset.h \
+ ${top_srcdir}/module/zfs/include/sys/dsl_deleg.h \
+ ${top_srcdir}/module/zfs/include/sys/dsl_dir.h \
+ ${top_srcdir}/module/zfs/include/sys/dsl_pool.h \
+ ${top_srcdir}/module/zfs/include/sys/dsl_prop.h \
+ ${top_srcdir}/module/zfs/include/sys/dsl_synctask.h \
+ ${top_srcdir}/module/zfs/include/sys/metaslab.h \
+ ${top_srcdir}/module/zfs/include/sys/metaslab_impl.h \
+ ${top_srcdir}/module/zfs/include/sys/refcount.h \
+ ${top_srcdir}/module/zfs/include/sys/rrwlock.h \
+ ${top_srcdir}/module/zfs/include/sys/spa_boot.h \
+ ${top_srcdir}/module/zfs/include/sys/space_map.h \
+ ${top_srcdir}/module/zfs/include/sys/spa.h \
+ ${top_srcdir}/module/zfs/include/sys/spa_impl.h \
+ ${top_srcdir}/module/zfs/include/sys/txg.h \
+ ${top_srcdir}/module/zfs/include/sys/txg_impl.h \
+ ${top_srcdir}/module/zfs/include/sys/uberblock.h \
+ ${top_srcdir}/module/zfs/include/sys/uberblock_impl.h \
+ ${top_srcdir}/module/zfs/include/sys/unique.h \
+ ${top_srcdir}/module/zfs/include/sys/vdev_file.h \
+ ${top_srcdir}/module/zfs/include/sys/vdev.h \
+ ${top_srcdir}/module/zfs/include/sys/vdev_impl.h \
+ ${top_srcdir}/module/zfs/include/sys/zap.h \
+ ${top_srcdir}/module/zfs/include/sys/zap_impl.h \
+ ${top_srcdir}/module/zfs/include/sys/zap_leaf.h \
+ ${top_srcdir}/module/zfs/include/sys/zfs_acl.h \
+ ${top_srcdir}/module/zfs/include/sys/zfs_context.h \
+ ${top_srcdir}/module/zfs/include/sys/zfs_ctldir.h \
+ ${top_srcdir}/module/zfs/include/sys/zfs_debug.h \
+ ${top_srcdir}/module/zfs/include/sys/zfs_dir.h \
+ ${top_srcdir}/module/zfs/include/sys/zfs_fuid.h \
+ ${top_srcdir}/module/zfs/include/sys/zfs_ioctl.h \
+ ${top_srcdir}/module/zfs/include/sys/zfs_onexit.h \
+ ${top_srcdir}/module/zfs/include/sys/zfs_rlock.h \
+ ${top_srcdir}/module/zfs/include/sys/zfs_stat.h \
+ ${top_srcdir}/module/zfs/include/sys/zfs_vfsops.h \
+ ${top_srcdir}/module/zfs/include/sys/zfs_znode.h \
+ ${top_srcdir}/module/zfs/include/sys/zfs_zrlock.h \
+ ${top_srcdir}/module/zfs/include/sys/zil.h \
+ ${top_srcdir}/module/zfs/include/sys/zil_impl.h \
+ ${top_srcdir}/module/zfs/include/sys/zio_checksum.h \
+ ${top_srcdir}/module/zfs/include/sys/zio_compress.h \
+ ${top_srcdir}/module/zfs/include/sys/zio.h \
+ ${top_srcdir}/module/zfs/include/sys/zio_impl.h \
+ ${top_srcdir}/module/zfs/include/sys/zvol.h \
+ ${top_srcdir}/module/zfs/include/sys/fm/protocol.h \
+ ${top_srcdir}/module/zfs/include/sys/fm/util.h \
+ ${top_srcdir}/module/zfs/include/sys/fm/fs/zfs.h
+
+libzpool_la_LDFLAGS = -pthread
diff --git a/lib/libzpool/include/Makefile.am b/lib/libzpool/include/Makefile.am
new file mode 100644
index 000000000..2d7d45358
--- /dev/null
+++ b/lib/libzpool/include/Makefile.am
@@ -0,0 +1 @@
+nobase_pkginclude_HEADERS = sys/*.h
diff --git a/man/Makefile.am b/man/Makefile.am
new file mode 100644
index 000000000..1602da107
--- /dev/null
+++ b/man/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = man8
diff --git a/man/man8/Makefile.am b/man/man8/Makefile.am
new file mode 100644
index 000000000..8f0227f88
--- /dev/null
+++ b/man/man8/Makefile.am
@@ -0,0 +1,5 @@
+man_MANS = zdb.8 zfs.8 zpool.8
+EXTRA_DIST = $(man_MANS)
+
+install-data-local:
+ $(INSTALL) -d -m 0755 "$(DESTDIR)$(mandir)/man8"
diff --git a/module/Makefile.in b/module/Makefile.in
new file mode 100644
index 000000000..489119ab3
--- /dev/null
+++ b/module/Makefile.in
@@ -0,0 +1,54 @@
+subdir-m += avl
+subdir-m += nvpair
+subdir-m += unicode
+subdir-m += zcommon
+subdir-m += zfs
+
+modules:
+ # Make the exported SPL symbols available to these modules.
+ cp @SPL_OBJ@/@SPL_SYMBOLS@ .
+ $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@
+
+clean:
+ $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@
+ if [ -f @SPL_SYMBOLS@ ]; then $(RM) @SPL_SYMBOLS@; fi
+ if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi
+ if [ -f Module.markers ]; then $(RM) Module.markers; fi
+
+modules_install:
+ # Install the kernel modules
+ $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` \
+ INSTALL_MOD_PATH=$(DESTDIR) \
+ INSTALL_MOD_DIR=addon/zfs $@
+ find ${DESTDIR}/lib/modules/ -name 'modules.*' | xargs ${RM}
+ sysmap=${DESTDIR}/boot/System.map-@LINUX_VERSION@; \
+ if [ -f $$sysmap ]; then \
+ depmod -ae -F $$sysmap @LINUX_VERSION@; \
+ fi
+ # Install the required headers in to the kernel source
+ destname=zfs-@ZFS_META_VERSION@/@LINUX_VERSION@; \
+ instdest=$(DESTDIR)/usr/src/$$destname; \
+ (find . -mindepth 3 -name '*.h' | xargs -Ihdr sh -c \
+ "DEST=hdr && install -D hdr $$instdest/\$${DEST#*/*/*/}") || exit 1
+
+modules_uninstall:
+ # Uninstall the kernel modules
+ $(RM) -R ${DESTDIR}/lib/modules/@LINUX_VERSION@/addon/zfs
+ # Uninstall the required headers from the kernel source
+ destname=zfs-@ZFS_META_VERSION@/@LINUX_VERSION@; \
+ instdest=$(DESTDIR)/usr/src/$$destname; \
+ $(RM) -R $$instdest
+
+distdir:
+ distfiles=`find . -name '*.c' -o -name '*.h'`; \
+ for distfile in $$distfiles; do \
+ distpath=`dirname $$distdir/$$distfile`; \
+ (/bin/mkdir -p $$distpath && \
+ /bin/cp $$distfile $$distdir/$$distfile) || exit 1; \
+ done
+
+distclean maintainer-clean: clean
+install: modules_install
+uninstall: modules_uninstall
+all: modules
+check:
diff --git a/module/avl/Makefile.in b/module/avl/Makefile.in
new file mode 100644
index 000000000..941de20f4
--- /dev/null
+++ b/module/avl/Makefile.in
@@ -0,0 +1,8 @@
+MODULE := zavl
+
+EXTRA_CFLAGS = -I@MODDIR@/avl/include
+EXTRA_CFLAGS += @KERNELCPPFLAGS@
+
+obj-m := ${MODULE}.o
+
+${MODULE}-objs += avl.o
diff --git a/module/nvpair/Makefile.in b/module/nvpair/Makefile.in
new file mode 100644
index 000000000..3f643e724
--- /dev/null
+++ b/module/nvpair/Makefile.in
@@ -0,0 +1,10 @@
+MODULE := znvpair
+
+EXTRA_CFLAGS = -I@MODDIR@/nvpair/include
+EXTRA_CFLAGS += @KERNELCPPFLAGS@
+
+obj-m := ${MODULE}.o
+
+${MODULE}-objs += nvpair.o
+${MODULE}-objs += nvpair_alloc_spl.o
+${MODULE}-objs += nvpair_alloc_fixed.o
diff --git a/module/unicode/Makefile.in b/module/unicode/Makefile.in
new file mode 100644
index 000000000..1a78fe0b5
--- /dev/null
+++ b/module/unicode/Makefile.in
@@ -0,0 +1,9 @@
+MODULE := zunicode
+
+EXTRA_CFLAGS = -I@MODDIR@/unicode/include
+EXTRA_CFLAGS += @KERNELCPPFLAGS@
+
+obj-m := ${MODULE}.o
+
+${MODULE}-objs += u8_textprep.o
+${MODULE}-objs += uconv.o
diff --git a/module/zcommon/Makefile.in b/module/zcommon/Makefile.in
new file mode 100644
index 000000000..def2b7d97
--- /dev/null
+++ b/module/zcommon/Makefile.in
@@ -0,0 +1,18 @@
+MODULE := zcommon
+
+EXTRA_CFLAGS = -I@MODDIR@/avl/include
+EXTRA_CFLAGS += -I@MODDIR@/nvpair/include
+EXTRA_CFLAGS += -I@MODDIR@/unicode/include
+EXTRA_CFLAGS += -I@MODDIR@/zcommon/include
+EXTRA_CFLAGS += -I@MODDIR@/zfs/include
+EXTRA_CFLAGS += @KERNELCPPFLAGS@
+
+obj-m := ${MODULE}.o
+
+${MODULE}-objs += zfs_deleg.o
+${MODULE}-objs += zfs_prop.o
+${MODULE}-objs += zprop_common.o
+${MODULE}-objs += zfs_namecheck.o
+${MODULE}-objs += zfs_comutil.o
+${MODULE}-objs += zfs_fletcher.o
+${MODULE}-objs += zpool_prop.o
diff --git a/module/zfs/Makefile.in b/module/zfs/Makefile.in
new file mode 100644
index 000000000..b9effcbf1
--- /dev/null
+++ b/module/zfs/Makefile.in
@@ -0,0 +1,89 @@
+MODULE := zfs
+
+EXTRA_CFLAGS = -I@MODDIR@/zfs/include
+EXTRA_CFLAGS += -I@MODDIR@/zcommon/include
+EXTRA_CFLAGS += -I@MODDIR@/avl/include
+EXTRA_CFLAGS += -I@MODDIR@/nvpair/include
+EXTRA_CFLAGS += -I@MODDIR@/unicode/include
+EXTRA_CFLAGS += @KERNELCPPFLAGS@
+
+obj-m := ${MODULE}.o
+
+${MODULE}-objs += arc.o
+${MODULE}-objs += bplist.o
+${MODULE}-objs += bpobj.o
+${MODULE}-objs += dbuf.o
+${MODULE}-objs += ddt.o
+${MODULE}-objs += ddt_zap.o
+${MODULE}-objs += dmu.o
+${MODULE}-objs += dmu_diff.o
+${MODULE}-objs += dmu_object.o
+${MODULE}-objs += dmu_objset.o
+${MODULE}-objs += dmu_send.o
+${MODULE}-objs += dmu_traverse.o
+${MODULE}-objs += dmu_tx.o
+${MODULE}-objs += dmu_zfetch.o
+${MODULE}-objs += dnode.o
+${MODULE}-objs += dnode_sync.o
+${MODULE}-objs += dsl_dataset.o
+${MODULE}-objs += dsl_deadlist.o
+${MODULE}-objs += dsl_deleg.o
+${MODULE}-objs += dsl_dir.o
+${MODULE}-objs += dsl_pool.o
+${MODULE}-objs += dsl_prop.o
+${MODULE}-objs += dsl_scan.o
+${MODULE}-objs += dsl_synctask.o
+${MODULE}-objs += fm.o
+${MODULE}-objs += gzip.o
+${MODULE}-objs += lzjb.o
+${MODULE}-objs += metaslab.o
+${MODULE}-objs += refcount.o
+${MODULE}-objs += rrwlock.o
+${MODULE}-objs += sa.o
+${MODULE}-objs += sha256.o
+${MODULE}-objs += spa.o
+${MODULE}-objs += spa_boot.o
+${MODULE}-objs += spa_config.o
+${MODULE}-objs += spa_errlog.o
+${MODULE}-objs += spa_history.o
+${MODULE}-objs += spa_misc.o
+${MODULE}-objs += space_map.o
+${MODULE}-objs += txg.o
+${MODULE}-objs += uberblock.o
+${MODULE}-objs += unique.o
+${MODULE}-objs += vdev.o
+${MODULE}-objs += vdev_cache.o
+${MODULE}-objs += vdev_file.o
+${MODULE}-objs += vdev_label.o
+${MODULE}-objs += vdev_mirror.o
+${MODULE}-objs += vdev_missing.o
+${MODULE}-objs += vdev_queue.o
+${MODULE}-objs += vdev_raidz.o
+${MODULE}-objs += vdev_root.o
+${MODULE}-objs += zap.o
+${MODULE}-objs += zap_leaf.o
+${MODULE}-objs += zap_micro.o
+${MODULE}-objs += zfs_acl.o
+${MODULE}-objs += zfs_byteswap.o
+${MODULE}-objs += zfs_ctldir.o
+${MODULE}-objs += zfs_debug.o
+${MODULE}-objs += zfs_dir.o
+${MODULE}-objs += zfs_fm.o
+${MODULE}-objs += zfs_fuid.o
+${MODULE}-objs += zfs_ioctl.o
+${MODULE}-objs += zfs_log.o
+${MODULE}-objs += zfs_onexit.o
+${MODULE}-objs += zfs_replay.o
+${MODULE}-objs += zfs_rlock.o
+${MODULE}-objs += zfs_sa.o
+${MODULE}-objs += zfs_vfsops.o
+${MODULE}-objs += zfs_vnops.o
+${MODULE}-objs += zfs_znode.o
+${MODULE}-objs += zil.o
+${MODULE}-objs += zio.o
+${MODULE}-objs += zio_checksum.o
+${MODULE}-objs += zio_compress.o
+${MODULE}-objs += zio_inject.o
+${MODULE}-objs += zle.o
+${MODULE}-objs += zrlock.o
+${MODULE}-objs += zvol.o
diff --git a/patches/e2fsprogs-1.41.4-zfs-probe-uberblock.patch b/patches/e2fsprogs-1.41.4-zfs-probe-uberblock.patch
new file mode 100644
index 000000000..bf50df431
--- /dev/null
+++ b/patches/e2fsprogs-1.41.4-zfs-probe-uberblock.patch
@@ -0,0 +1,32 @@
+Detect a ZFS filesystem by looking for valid uberblocks.
+
+This support will appear in an upstream version of e2fsprogs. For the
+moment however you will still need to locally patch you e2fsprogs packages.
+This patch applies cleanly to fc11's e2fsprogs-*-1.41.4-10 and should
+apply easily enough to the e2fsprogs from other distros.
+
+--- e2fsprogs.orig/lib/blkid/probe.c 2009-01-20 09:06:31.000000000 -0800
++++ e2fsprogs/lib/blkid/probe.c 2009-10-06 10:16:37.000000000 -0700
+@@ -1359,10 +1361,18 @@
+ { "iso9660", 32, 1, 5, "CD001", probe_iso9660 },
+ { "iso9660", 32, 9, 5, "CDROM", probe_iso9660 },
+ { "jfs", 32, 0, 4, "JFS1", probe_jfs },
+- { "zfs", 8, 0, 8, "\0\0\x02\xf5\xb0\x07\xb1\x0c", probe_zfs },
+- { "zfs", 8, 0, 8, "\x0c\xb1\x07\xb0\xf5\x02\0\0", probe_zfs },
+- { "zfs", 264, 0, 8, "\0\0\x02\xf5\xb0\x07\xb1\x0c", probe_zfs },
+- { "zfs", 264, 0, 8, "\x0c\xb1\x07\xb0\xf5\x02\0\0", probe_zfs },
++ { "zfs", 128, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs },
++ { "zfs", 132, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs },
++ { "zfs", 136, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs },
++ { "zfs", 128, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs },
++ { "zfs", 132, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs },
++ { "zfs", 136, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs },
++ { "zfs", 384, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs },
++ { "zfs", 388, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs },
++ { "zfs", 392, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs },
++ { "zfs", 384, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs },
++ { "zfs", 388, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs },
++ { "zfs", 392, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs },
+ { "hfsplus", 1, 0, 2, "BD", probe_hfsplus },
+ { "hfsplus", 1, 0, 2, "H+", probe_hfsplus },
+ { "hfsplus", 1, 0, 2, "HX", probe_hfsplus },
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
new file mode 100644
index 000000000..a1dfc3871
--- /dev/null
+++ b/scripts/Makefile.am
@@ -0,0 +1,29 @@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+nobase_pkglibexec_SCRIPTS = common.sh
+nobase_pkglibexec_SCRIPTS += zconfig.sh
+nobase_pkglibexec_SCRIPTS += zfs.sh
+nobase_pkglibexec_SCRIPTS += zpool-create.sh
+nobase_pkglibexec_SCRIPTS += zpool-config/*
+EXTRA_DIST = zfs-update.sh $(nobase_pkglibexec_SCRIPTS)
+
+ZFS=${top_srcdir}/scripts/zfs.sh
+ZCONFIG=${top_srcdir}/scripts/zconfig.sh
+ZTEST=${top_builddir}/cmd/ztest/ztest
+
+check:
+ @echo
+ @echo -n "===================================="
+ @echo -n " ZTEST "
+ @echo "===================================="
+ @echo
+ @$(ZFS)
+ @$(ZTEST) -V
+ @$(ZFS) -u
+ @echo
+ @echo
+ @echo -n "==================================="
+ @echo -n " ZCONFIG "
+ @echo "==================================="
+ @echo
+ @$(ZCONFIG)
+ @echo
diff --git a/scripts/common.sh.in b/scripts/common.sh.in
new file mode 100644
index 000000000..00418696c
--- /dev/null
+++ b/scripts/common.sh.in
@@ -0,0 +1,373 @@
+#!/bin/bash
+#
+# Common support functions for testing scripts. If a .script-config
+# files is available it will be sourced so in-tree kernel modules and
+# utilities will be used. If no .script-config can be found then the
+# installed kernel modules and utilities will be used.
+
+basedir="$(dirname $0)"
+
+SCRIPT_CONFIG=.script-config
+if [ -f "${basedir}/../${SCRIPT_CONFIG}" ]; then
+. "${basedir}/../${SCRIPT_CONFIG}"
+else
+MODULES=(zlib_deflate spl splat zavl znvpair zunicode zcommon zfs)
+fi
+
+PROG="<define PROG>"
+CLEANUP=
+VERBOSE=
+VERBOSE_FLAG=
+FORCE=
+FORCE_FLAG=
+DUMP_LOG=
+ERROR=
+RAID0S=()
+RAID10S=()
+RAIDZS=()
+RAIDZ2S=()
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libexecdir=@libexecdir@
+pkglibexecdir=${libexecdir}/@PACKAGE@
+bindir=@bindir@
+sbindir=@sbindir@
+
+ETCDIR=${ETCDIR:-/etc}
+DEVDIR=${DEVDIR:-/dev/disk/zpool}
+ZPOOLDIR=${ZPOOLDIR:-${pkglibexecdir}/zpool-config}
+
+ZDB=${ZDB:-${sbindir}/zdb}
+ZFS=${ZFS:-${sbindir}/zfs}
+ZINJECT=${ZINJECT:-${sbindir}/zinject}
+ZPOOL=${ZPOOL:-${sbindir}/zpool}
+ZPOOL_ID=${ZPOOL_ID:-${bindir}/zpool_id}
+ZTEST=${ZTEST:-${sbindir}/ztest}
+
+COMMON_SH=${COMMON_SH:-${pkglibexecdir}/common.sh}
+ZFS_SH=${ZFS_SH:-${pkglibexecdir}/zfs.sh}
+ZPOOL_CREATE_SH=${ZPOOL_CREATE_SH:-${pkglibexecdir}/zpool-create.sh}
+
+LDMOD=${LDMOD:-/sbin/modprobe}
+LSMOD=${LSMOD:-/sbin/lsmod}
+RMMOD=${RMMOD:-/sbin/rmmod}
+INFOMOD=${INFOMOD:-/sbin/modinfo}
+LOSETUP=${LOSETUP:-/sbin/losetup}
+SYSCTL=${SYSCTL:-/sbin/sysctl}
+UDEVADM=${UDEVADM:-/sbin/udevadm}
+AWK=${AWK:-/usr/bin/awk}
+
+die() {
+ echo -e "${PROG}: $1" >&2
+ exit 1
+}
+
+msg() {
+ if [ ${VERBOSE} ]; then
+ echo "$@"
+ fi
+}
+
+pass() {
+ echo "PASS"
+}
+
+fail() {
+ echo "FAIL ($1)"
+ exit $1
+}
+
+spl_dump_log() {
+ ${SYSCTL} -w kernel.spl.debug.dump=1 &>/dev/null
+ local NAME=`dmesg | tail -n 1 | cut -f5 -d' '`
+ ${SPLBUILD}/cmd/spl ${NAME} >${NAME}.log
+ echo
+ echo "Dumped debug log: ${NAME}.log"
+ tail -n1 ${NAME}.log
+ echo
+ return 0
+}
+
+check_modules() {
+ local LOADED_MODULES=()
+ local MISSING_MODULES=()
+
+ for MOD in ${MODULES[*]}; do
+ local NAME=`basename $MOD .ko`
+
+ if ${LSMOD} | egrep -q "^${NAME}"; then
+ LOADED_MODULES=(${NAME} ${LOADED_MODULES[*]})
+ fi
+
+ if [ ${INFOMOD} ${MOD} 2>/dev/null ]; then
+ MISSING_MODULES=("\t${MOD}\n" ${MISSING_MODULES[*]})
+ fi
+ done
+
+ if [ ${#LOADED_MODULES[*]} -gt 0 ]; then
+ ERROR="Unload these modules with '${PROG} -u':\n"
+ ERROR="${ERROR}${LOADED_MODULES[*]}"
+ return 1
+ fi
+
+ if [ ${#MISSING_MODULES[*]} -gt 0 ]; then
+ ERROR="The following modules can not be found,"
+ ERROR="${ERROR} ensure your source trees are built:\n"
+ ERROR="${ERROR}${MISSING_MODULES[*]}"
+ return 1
+ fi
+
+ return 0
+}
+
+load_module() {
+ local NAME=`basename $1 .ko`
+
+ if [ ${VERBOSE} ]; then
+ echo "Loading ${NAME} ($@)"
+ fi
+
+ ${LDMOD} $* || ERROR="Failed to load $1" return 1
+
+ return 0
+}
+
+load_modules() {
+ mkdir -p /etc/zfs
+
+ for MOD in ${MODULES[*]}; do
+ local NAME=`basename ${MOD} .ko`
+ local VALUE=
+
+ for OPT in "$@"; do
+ OPT_NAME=`echo ${OPT} | cut -f1 -d'='`
+
+ if [ ${NAME} = "${OPT_NAME}" ]; then
+ VALUE=`echo ${OPT} | cut -f2- -d'='`
+ fi
+ done
+
+ load_module ${MOD} ${VALUE} || return 1
+ done
+
+ if [ ${VERBOSE} ]; then
+ echo "Successfully loaded ZFS module stack"
+ fi
+
+ return 0
+}
+
+unload_module() {
+ local NAME=`basename $1 .ko`
+
+ if [ ${VERBOSE} ]; then
+ echo "Unloading ${NAME} ($@)"
+ fi
+
+ ${RMMOD} ${NAME} || ERROR="Failed to unload ${NAME}" return 1
+
+ return 0
+}
+
+unload_modules() {
+ local MODULES_REVERSE=( $(echo ${MODULES[@]} |
+ ${AWK} '{for (i=NF;i>=1;i--) printf $i" "} END{print ""}') )
+
+ for MOD in ${MODULES_REVERSE[*]}; do
+ local NAME=`basename ${MOD} .ko`
+ local USE_COUNT=`${LSMOD} |
+ egrep "^${NAME} "| ${AWK} '{print $3}'`
+
+ if [ "${USE_COUNT}" = 0 ] ; then
+
+ if [ "${DUMP_LOG}" -a ${NAME} = "spl" ]; then
+ spl_dump_log
+ fi
+
+ unload_module ${MOD} || return 1
+ fi
+ done
+
+ if [ ${VERBOSE} ]; then
+ echo "Successfully unloaded ZFS module stack"
+ fi
+
+ return 0
+}
+
+unused_loop_device() {
+ for DEVICE in `ls -1 /dev/loop*`; do
+ ${LOSETUP} ${DEVICE} &>/dev/null
+ if [ $? -ne 0 ]; then
+ echo ${DEVICE}
+ return
+ fi
+ done
+
+ die "Error: Unable to find unused loopback device"
+}
+
+#
+# This can be slightly dangerous because the loop devices we are
+# cleanup up may not be ours. However, if the devices are currently
+# in use we will not be able to remove them, and we only remove
+# devices which include 'zpool' in the name. So any damage we might
+# do should be limited to other zfs related testing.
+#
+cleanup_loop_devices() {
+ local TMP_FILE=`mktemp`
+
+ ${LOSETUP} -a | tr -d '()' >${TMP_FILE}
+ ${AWK} -F":" -v losetup="$LOSETUP" \
+ '/zpool/ { system("losetup -d "$1) }' ${TMP_FILE}
+ ${AWK} -F" " '/zpool/ { system("rm -f "$3) }' ${TMP_FILE}
+
+ rm -f ${TMP_FILE}
+}
+
+#
+# The following udev helper functions assume that the provided
+# udev rules file will create a /dev/disk/zpool/<CHANNEL><RANK>
+# disk mapping. In this mapping each CHANNEL is represented by
+# the letters a-z, and the RANK is represented by the numbers
+# 1-n. A CHANNEL should identify a group of RANKS which are all
+# attached to a single controller, each RANK represents a disk.
+# This provides a simply mechanism to locate a specific drive
+# given a known hardware configuration.
+#
+udev_setup() {
+ local SRC_PATH=$1
+
+ # When running in tree manually contruct symlinks in tree to
+ # the proper devices. Symlinks are installed for all entires
+ # in the config file regardless of if that device actually
+ # exists. When installed as a package udev can be relied on for
+ # this and it will only create links for devices which exist.
+ if [ ${INTREE} ]; then
+ PWD=`pwd`
+ mkdir -p ${DEVDIR}/
+ cd ${DEVDIR}/
+ ${AWK} '!/^#/ && /./ { system( \
+ "ln -f -s /dev/disk/by-path/"$2" "$1";" \
+ "ln -f -s /dev/disk/by-path/"$2"-part1 "$1"p1;" \
+ "ln -f -s /dev/disk/by-path/"$2"-part9 "$1"p9;" \
+ ) }' $SRC_PATH
+ cd ${PWD}
+ else
+ DST_FILE=`basename ${SRC_PATH} | cut -f1-2 -d'.'`
+ DST_PATH=/etc/zfs/${DST_FILE}
+
+ if [ -e ${DST_PATH} ]; then
+ die "Error: Config ${DST_PATH} already exists"
+ fi
+
+ cp ${SRC_PATH} ${DST_PATH}
+
+ if [ -f ${UDEVADM} ]; then
+ ${UDEVADM} trigger
+ ${UDEVADM} settle
+ else
+ /sbin/udevtrigger
+ /sbin/udevsettle
+ fi
+ fi
+
+ return 0
+}
+
+udev_cleanup() {
+ local SRC_PATH=$1
+
+ if [ ${INTREE} ]; then
+ PWD=`pwd`
+ cd ${DEVDIR}/
+ ${AWK} '!/^#/ && /./ { system( \
+ "rm -f "$1" "$1"p1 "$1"p9") }' $SRC_PATH
+ cd ${PWD}
+ fi
+
+ return 0
+}
+
+udev_cr2d() {
+ local CHANNEL=`echo "obase=16; $1+96" | bc`
+ local RANK=$2
+
+ printf "\x${CHANNEL}${RANK}"
+}
+
+udev_raid0_setup() {
+ local RANKS=$1
+ local CHANNELS=$2
+ local IDX=0
+
+ RAID0S=()
+ for RANK in `seq 1 ${RANKS}`; do
+ for CHANNEL in `seq 1 ${CHANNELS}`; do
+ DISK=`udev_cr2d ${CHANNEL} ${RANK}`
+ RAID0S[${IDX}]="${DEVDIR}/${DISK}"
+ let IDX=IDX+1
+ done
+ done
+
+ return 0
+}
+
+udev_raid10_setup() {
+ local RANKS=$1
+ local CHANNELS=$2
+ local IDX=0
+
+ RAID10S=()
+ for RANK in `seq 1 ${RANKS}`; do
+ for CHANNEL1 in `seq 1 2 ${CHANNELS}`; do
+ let CHANNEL2=CHANNEL1+1
+ DISK1=`udev_cr2d ${CHANNEL1} ${RANK}`
+ DISK2=`udev_cr2d ${CHANNEL2} ${RANK}`
+ GROUP="${DEVDIR}/${DISK1} ${DEVDIR}/${DISK2}"
+ RAID10S[${IDX}]="mirror ${GROUP}"
+ let IDX=IDX+1
+ done
+ done
+
+ return 0
+}
+
+udev_raidz_setup() {
+ local RANKS=$1
+ local CHANNELS=$2
+
+ RAIDZS=()
+ for RANK in `seq 1 ${RANKS}`; do
+ RAIDZ=("raidz")
+
+ for CHANNEL in `seq 1 ${CHANNELS}`; do
+ DISK=`udev_cr2d ${CHANNEL} ${RANK}`
+ RAIDZ[${CHANNEL}]="${DEVDIR}/${DISK}"
+ done
+
+ RAIDZS[${RANK}]="${RAIDZ[*]}"
+ done
+
+ return 0
+}
+
+udev_raidz2_setup() {
+ local RANKS=$1
+ local CHANNELS=$2
+
+ RAIDZ2S=()
+ for RANK in `seq 1 ${RANKS}`; do
+ RAIDZ2=("raidz2")
+
+ for CHANNEL in `seq 1 ${CHANNELS}`; do
+ DISK=`udev_cr2d ${CHANNEL} ${RANK}`
+ RAIDZ2[${CHANNEL}]="${DEVDIR}/${DISK}"
+ done
+
+ RAIDZ2S[${RANK}]="${RAIDZ2[*]}"
+ done
+
+ return 0
+}
diff --git a/scripts/zconfig.sh b/scripts/zconfig.sh
new file mode 100755
index 000000000..98f00fa0e
--- /dev/null
+++ b/scripts/zconfig.sh
@@ -0,0 +1,572 @@
+#!/bin/bash
+#
+# ZFS/ZPOOL configuration test script.
+
+basedir="$(dirname $0)"
+
+SCRIPT_COMMON=common.sh
+if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then
+. "${basedir}/${SCRIPT_COMMON}"
+else
+echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
+fi
+
+PROG=zconfig.sh
+
+usage() {
+cat << EOF
+USAGE:
+$0 [hvc]
+
+DESCRIPTION:
+ ZFS/ZPOOL configuration tests
+
+OPTIONS:
+ -h Show this message
+ -v Verbose
+ -c Cleanup lo+file devices at start
+
+EOF
+}
+
+while getopts 'hvc?' OPTION; do
+ case $OPTION in
+ h)
+ usage
+ exit 1
+ ;;
+ v)
+ VERBOSE=1
+ ;;
+ c)
+ CLEANUP=1
+ ;;
+ ?)
+ usage
+ exit
+ ;;
+ esac
+done
+
+if [ $(id -u) != 0 ]; then
+ die "Must run as root"
+fi
+
+# Perform pre-cleanup is requested
+if [ ${CLEANUP} ]; then
+ cleanup_loop_devices
+ rm -f /tmp/zpool.cache.*
+fi
+
+zconfig_partition() {
+ local DEVICE=$1
+ local START=$2
+ local END=$3
+ local TMP_FILE=`mktemp`
+
+ /sbin/sfdisk -q ${DEVICE} << EOF &>${TMP_FILE} || fail 4
+${START},${END}
+;
+;
+;
+EOF
+
+ rm ${TMP_FILE}
+}
+
+# Validate persistent zpool.cache configuration.
+zconfig_test1() {
+ local POOL_NAME=test1
+ local TMP_FILE1=`mktemp`
+ local TMP_FILE2=`mktemp`
+ local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
+
+ echo -n "test 1 - persistent zpool.cache: "
+
+ # Create a pool save its status for comparison.
+ ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2
+ ${ZPOOL} status ${POOL_NAME} >${TMP_FILE1} || fail 3
+
+ # Unload/load the module stack and verify the pool persists.
+ ${ZFS_SH} -u || fail 4
+ ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 5
+ ${ZPOOL} status ${POOL_NAME} >${TMP_FILE2} || fail 6
+ cmp ${TMP_FILE1} ${TMP_FILE2} || fail 7
+
+ # Cleanup the test pool and temporary files
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 -d || fail 8
+ rm -f ${TMP_FILE1} ${TMP_FILE2} ${TMP_CACHE} || fail 9
+ ${ZFS_SH} -u || fail 10
+
+ pass
+}
+zconfig_test1
+
+# Validate ZFS disk scanning and import w/out zpool.cache configuration.
+zconfig_test2() {
+ local POOL_NAME=test2
+ local TMP_FILE1=`mktemp`
+ local TMP_FILE2=`mktemp`
+ local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
+
+ echo -n "test 2 - scan disks for pools to import: "
+
+ # Create a pool save its status for comparison.
+ ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2
+ ${ZPOOL} status ${POOL_NAME} >${TMP_FILE1} || fail 3
+
+ # Unload the module stack, remove the cache file, load the module
+ # stack and attempt to probe the disks to import the pool. As
+ # a cross check verify the old pool state against the imported.
+ ${ZFS_SH} -u || fail 4
+ rm -f ${TMP_CACHE} || fail 5
+ ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 6
+ ${ZPOOL} import | grep ${POOL_NAME} >/dev/null || fail 7
+ ${ZPOOL} import ${POOL_NAME} || fail 8
+ ${ZPOOL} status ${POOL_NAME} >${TMP_FILE2} || fail 9
+ cmp ${TMP_FILE1} ${TMP_FILE2} || fail 10
+
+ # Cleanup the test pool and temporary files
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 -d || fail 11
+ rm -f ${TMP_FILE1} ${TMP_FILE2} || fail 12
+ ${ZFS_SH} -u || fail 13
+
+ pass
+}
+zconfig_test2
+
+zconfig_zvol_device_stat() {
+ local EXPECT=$1
+ local POOL_NAME=/dev/$2
+ local ZVOL_NAME=/dev/$3
+ local SNAP_NAME=/dev/$4
+ local CLONE_NAME=/dev/$5
+ local COUNT=0
+
+ # Briefly delay for udev
+ sleep 1
+
+ # Pool exists
+ stat ${POOL_NAME} &>/dev/null && let COUNT=$COUNT+1
+
+ # Volume and partitions
+ stat ${ZVOL_NAME} &>/dev/null && let COUNT=$COUNT+1
+ stat ${ZVOL_NAME}1 &>/dev/null && let COUNT=$COUNT+1
+ stat ${ZVOL_NAME}2 &>/dev/null && let COUNT=$COUNT+1
+
+ # Snapshot with partitions
+ stat ${SNAP_NAME} &>/dev/null && let COUNT=$COUNT+1
+ stat ${SNAP_NAME}1 &>/dev/null && let COUNT=$COUNT+1
+ stat ${SNAP_NAME}2 &>/dev/null && let COUNT=$COUNT+1
+
+ # Clone with partitions
+ stat ${CLONE_NAME} &>/dev/null && let COUNT=$COUNT+1
+ stat ${CLONE_NAME}1 &>/dev/null && let COUNT=$COUNT+1
+ stat ${CLONE_NAME}2 &>/dev/null && let COUNT=$COUNT+1
+
+ if [ $EXPECT -ne $COUNT ]; then
+ return 1
+ fi
+
+ return 0
+}
+
+# zpool import/export device check
+# (1 volume, 2 partitions, 1 snapshot, 1 clone)
+zconfig_test3() {
+ local POOL_NAME=tank
+ local ZVOL_NAME=volume
+ local SNAP_NAME=snap
+ local CLONE_NAME=clone
+ local FULL_ZVOL_NAME=${POOL_NAME}/${ZVOL_NAME}
+ local FULL_SNAP_NAME=${POOL_NAME}/${ZVOL_NAME}@${SNAP_NAME}
+ local FULL_CLONE_NAME=${POOL_NAME}/${CLONE_NAME}
+ local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
+
+ echo -n "test 3 - zpool import/export device: "
+
+ # Create a pool, volume, partition, snapshot, and clone.
+ ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2
+ ${ZFS} create -V 100M ${FULL_ZVOL_NAME} || fail 3
+ zconfig_partition /dev/${FULL_ZVOL_NAME} 0 64 || fail 4
+ ${ZFS} snapshot ${FULL_SNAP_NAME} || fail 5
+ ${ZFS} clone ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 6
+
+ # Verify the devices were created
+ zconfig_zvol_device_stat 10 ${POOL_NAME} ${FULL_ZVOL_NAME} \
+ ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 7
+
+ # Export the pool
+ ${ZPOOL} export ${POOL_NAME} || fail 8
+
+ # verify the devices were removed
+ zconfig_zvol_device_stat 0 ${POOL_NAME} ${FULL_ZVOL_NAME} \
+ ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 9
+
+ # Import the pool, wait 1 second for udev
+ ${ZPOOL} import ${POOL_NAME} || fail 10
+
+ # Verify the devices were created
+ zconfig_zvol_device_stat 10 ${POOL_NAME} ${FULL_ZVOL_NAME} \
+ ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 11
+
+ # Destroy the pool and consequently the devices
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 -d || fail 12
+
+ # verify the devices were removed
+ zconfig_zvol_device_stat 0 ${POOL_NAME} ${FULL_ZVOL_NAME} \
+ ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 13
+
+ ${ZFS_SH} -u || fail 14
+ rm -f ${TMP_CACHE} || fail 15
+
+ pass
+}
+zconfig_test3
+
+# zpool insmod/rmmod device check (1 volume, 1 snapshot, 1 clone)
+zconfig_test4() {
+ POOL_NAME=tank
+ ZVOL_NAME=volume
+ SNAP_NAME=snap
+ CLONE_NAME=clone
+ FULL_ZVOL_NAME=${POOL_NAME}/${ZVOL_NAME}
+ FULL_SNAP_NAME=${POOL_NAME}/${ZVOL_NAME}@${SNAP_NAME}
+ FULL_CLONE_NAME=${POOL_NAME}/${CLONE_NAME}
+ TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
+
+ echo -n "test 4 - zpool insmod/rmmod device: "
+
+ # Create a pool, volume, snapshot, and clone
+ ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2
+ ${ZFS} create -V 100M ${FULL_ZVOL_NAME} || fail 3
+ zconfig_partition /dev/${FULL_ZVOL_NAME} 0 64 || fail 4
+ ${ZFS} snapshot ${FULL_SNAP_NAME} || fail 5
+ ${ZFS} clone ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 6
+
+ # Verify the devices were created
+ zconfig_zvol_device_stat 10 ${POOL_NAME} ${FULL_ZVOL_NAME} \
+ ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 7
+
+ # Unload the modules
+ ${ZFS_SH} -u || fail 8
+
+ # Verify the devices were removed
+ zconfig_zvol_device_stat 0 ${POOL_NAME} ${FULL_ZVOL_NAME} \
+ ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 9
+
+ # Load the modules, wait 1 second for udev
+ ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 10
+
+ # Verify the devices were created
+ zconfig_zvol_device_stat 10 ${POOL_NAME} ${FULL_ZVOL_NAME} \
+ ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 11
+
+ # Destroy the pool and consequently the devices
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 -d || fail 12
+
+ # Verify the devices were removed
+ zconfig_zvol_device_stat 0 ${POOL_NAME} ${FULL_ZVOL_NAME} \
+ ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 13
+
+ ${ZFS_SH} -u || fail 14
+ rm -f ${TMP_CACHE} || fail 15
+
+ pass
+}
+zconfig_test4
+
+# ZVOL volume sanity check
+zconfig_test5() {
+ local POOL_NAME=tank
+ local ZVOL_NAME=fish
+ local FULL_NAME=${POOL_NAME}/${ZVOL_NAME}
+ local SRC_DIR=/bin/
+ local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
+
+ echo -n "test 5 - zvol+ext3 volume: "
+
+ # Create a pool and volume.
+ ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2
+ ${ZFS} create -V 400M ${FULL_NAME} || fail 3
+
+ # Partition the volume, for a 400M volume there will be
+ # 812 cylinders, 16 heads, and 63 sectors per track.
+ zconfig_partition /dev/${FULL_NAME} 0 812
+
+ # Format the partition with ext3.
+ /sbin/mkfs.ext3 -q /dev/${FULL_NAME}1 || fail 5
+
+ # Mount the ext3 filesystem and copy some data to it.
+ mkdir -p /tmp/${ZVOL_NAME}1 || fail 6
+ mount /dev/${FULL_NAME}1 /tmp/${ZVOL_NAME}1 || fail 7
+ cp -RL ${SRC_DIR} /tmp/${ZVOL_NAME}1 || fail 8
+ sync
+
+ # Verify the copied files match the original files.
+ diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}1${SRC_DIR} &>/dev/null || fail 9
+
+ # Remove the files, umount, destroy the volume and pool.
+ rm -Rf /tmp/${ZVOL_NAME}1${SRC_DIR}* || fail 10
+ umount /tmp/${ZVOL_NAME}1 || fail 11
+ rmdir /tmp/${ZVOL_NAME}1 || fail 12
+
+ ${ZFS} destroy ${FULL_NAME} || fail 13
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 -d || fail 14
+ ${ZFS_SH} -u || fail 15
+ rm -f ${TMP_CACHE} || fail 16
+
+ pass
+}
+zconfig_test5
+
+# ZVOL snapshot sanity check
+zconfig_test6() {
+ local POOL_NAME=tank
+ local ZVOL_NAME=fish
+ local SNAP_NAME=pristine
+ local FULL_ZVOL_NAME=${POOL_NAME}/${ZVOL_NAME}
+ local FULL_SNAP_NAME=${POOL_NAME}/${ZVOL_NAME}@${SNAP_NAME}
+ local SRC_DIR=/bin/
+ local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
+
+ echo -n "test 6 - zvol+ext2 snapshot: "
+
+ # Create a pool and volume.
+ ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2
+ ${ZFS} create -V 400M ${FULL_ZVOL_NAME} || fail 3
+
+ # Partition the volume, for a 400M volume there will be
+ # 812 cylinders, 16 heads, and 63 sectors per track.
+ zconfig_partition /dev/${FULL_ZVOL_NAME} 0 812
+
+ # Format the partition with ext2 (no journal).
+ /sbin/mkfs.ext2 -q /dev/${FULL_ZVOL_NAME}1 || fail 5
+
+ # Mount the ext3 filesystem and copy some data to it.
+ mkdir -p /tmp/${ZVOL_NAME}1 || fail 6
+ mount /dev/${FULL_ZVOL_NAME}1 /tmp/${ZVOL_NAME}1 || fail 7
+
+ # Snapshot the pristine ext2 filesystem and mount it read-only.
+ ${ZFS} snapshot ${FULL_SNAP_NAME} && sleep 1 || fail 8
+ mkdir -p /tmp/${SNAP_NAME}1 || fail 9
+ mount /dev/${FULL_SNAP_NAME}1 /tmp/${SNAP_NAME}1 &>/dev/null || fail 10
+
+ # Copy to original volume
+ cp -RL ${SRC_DIR} /tmp/${ZVOL_NAME}1 || fail 11
+ sync
+
+ # Verify the copied files match the original files,
+ # and the copied files do NOT appear in the snapshot.
+ diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}1${SRC_DIR} &>/dev/null || fail 12
+ diff -ur ${SRC_DIR} /tmp/${SNAP_NAME}1${SRC_DIR} &>/dev/null && fail 13
+
+ # umount, destroy the snapshot, volume, and pool.
+ umount /tmp/${SNAP_NAME}1 || fail 14
+ rmdir /tmp/${SNAP_NAME}1 || fail 15
+ ${ZFS} destroy ${FULL_SNAP_NAME} || fail 16
+
+ umount /tmp/${ZVOL_NAME}1 || fail 17
+ rmdir /tmp/${ZVOL_NAME}1 || fail 18
+ ${ZFS} destroy ${FULL_ZVOL_NAME} || fail 19
+
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 -d || fail 20
+ ${ZFS_SH} -u || fail 21
+ rm -f ${TMP_CACHE} || fail 22
+
+ pass
+}
+zconfig_test6
+
+# ZVOL clone sanity check
+zconfig_test7() {
+ local POOL_NAME=tank
+ local ZVOL_NAME=fish
+ local SNAP_NAME=pristine
+ local CLONE_NAME=clone
+ local FULL_ZVOL_NAME=${POOL_NAME}/${ZVOL_NAME}
+ local FULL_SNAP_NAME=${POOL_NAME}/${ZVOL_NAME}@${SNAP_NAME}
+ local FULL_CLONE_NAME=${POOL_NAME}/${CLONE_NAME}
+ local SRC_DIR=/bin/
+ local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
+
+ echo -n "test 7 - zvol+ext2 clone: "
+
+ # Create a pool and volume.
+ ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2
+ ${ZFS} create -V 400M ${FULL_ZVOL_NAME} || fail 3
+
+ # Partition the volume, for a 400M volume there will be
+ # 812 cylinders, 16 heads, and 63 sectors per track.
+ zconfig_partition /dev/${FULL_ZVOL_NAME} 0 812
+
+ # Format the partition with ext2 (no journal).
+ /sbin/mkfs.ext2 -q /dev/${FULL_ZVOL_NAME}1 || fail 5
+
+ # Mount the ext3 filesystem and copy some data to it.
+ mkdir -p /tmp/${ZVOL_NAME}1 || fail 6
+ mount /dev/${FULL_ZVOL_NAME}1 /tmp/${ZVOL_NAME}1 || fail 7
+
+ # Snapshot the pristine ext2 filesystem and mount it read-only.
+ ${ZFS} snapshot ${FULL_SNAP_NAME} && sleep 1 || fail 8
+ mkdir -p /tmp/${SNAP_NAME}1 || fail 9
+ mount /dev/${FULL_SNAP_NAME}1 /tmp/${SNAP_NAME}1 &>/dev/null || fail 10
+
+ # Copy to original volume.
+ cp -RL ${SRC_DIR} /tmp/${ZVOL_NAME}1 || fail 11
+ sync
+
+ # Verify the copied files match the original files,
+ # and the copied files do NOT appear in the snapshot.
+ diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}1${SRC_DIR} &>/dev/null || fail 12
+ diff -ur ${SRC_DIR} /tmp/${SNAP_NAME}1${SRC_DIR} &>/dev/null && fail 13
+
+ # Clone from the original pristine snapshot
+ ${ZFS} clone ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} && sleep 1 || fail 14
+ mkdir -p /tmp/${CLONE_NAME}1 || fail 15
+ mount /dev/${FULL_CLONE_NAME}1 /tmp/${CLONE_NAME}1 || fail 16
+
+ # Verify the clone matches the pristine snapshot,
+ # and the files copied to the original volume are NOT there.
+ diff -ur /tmp/${SNAP_NAME}1 /tmp/${CLONE_NAME}1 &>/dev/null || fail 17
+ diff -ur /tmp/${ZVOL_NAME}1 /tmp/${CLONE_NAME}1 &>/dev/null && fail 18
+
+ # Copy to cloned volume.
+ cp -RL ${SRC_DIR} /tmp/${CLONE_NAME}1 || fail 19
+ sync
+
+ # Verify the clone matches the modified original volume.
+ diff -ur /tmp/${ZVOL_NAME}1 /tmp/${CLONE_NAME}1 &>/dev/null || fail 20
+
+ # umount, destroy the snapshot, volume, and pool.
+ umount /tmp/${CLONE_NAME}1 || fail 21
+ rmdir /tmp/${CLONE_NAME}1 || fail 22
+ ${ZFS} destroy ${FULL_CLONE_NAME} || fail 23
+
+ umount /tmp/${SNAP_NAME}1 || fail 24
+ rmdir /tmp/${SNAP_NAME}1 || fail 25
+ ${ZFS} destroy ${FULL_SNAP_NAME} || fail 26
+
+ umount /tmp/${ZVOL_NAME}1 || fail 27
+ rmdir /tmp/${ZVOL_NAME}1 || fail 28
+ ${ZFS} destroy ${FULL_ZVOL_NAME} || fail 29
+
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 -d || fail 30
+ ${ZFS_SH} -u || fail 31
+ rm -f ${TMP_CACHE} || fail 32
+
+ pass
+}
+zconfig_test7
+
+# Send/Receive sanity check
+test_8() {
+ local POOL_NAME1=tank1
+ local POOL_NAME2=tank2
+ local ZVOL_NAME=fish
+ local SNAP_NAME=snap
+ local FULL_ZVOL_NAME1=${POOL_NAME1}/${ZVOL_NAME}
+ local FULL_ZVOL_NAME2=${POOL_NAME2}/${ZVOL_NAME}
+ local FULL_SNAP_NAME1=${POOL_NAME1}/${ZVOL_NAME}@${SNAP_NAME}
+ local FULL_SNAP_NAME2=${POOL_NAME2}/${ZVOL_NAME}@${SNAP_NAME}
+ local SRC_DIR=/bin/
+ local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
+
+ # Create two pools and a volume
+ ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME1} -c lo-raidz2 || fail 2
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME2} -c lo-raidz2 || fail 3
+ ${ZFS} create -V 400M ${FULL_ZVOL_NAME1} || fail 4
+
+ # Partition the volume, for a 400M volume there will be
+ # 812 cylinders, 16 heads, and 63 sectors per track.
+ zconfig_partition /dev/${FULL_ZVOL_NAME1} 0 812
+
+ # Format the partition with ext2.
+ /sbin/mkfs.ext2 -q /dev/${FULL_ZVOL_NAME1}1 || fail 5
+
+ # Mount the ext3 filesystem and copy some data to it.
+ mkdir -p /tmp/${FULL_ZVOL_NAME1}1 || fail 6
+ mount /dev/${FULL_ZVOL_NAME1}1 /tmp/${FULL_ZVOL_NAME1}1 || fail 7
+ cp -RL ${SRC_DIR} /tmp/${FULL_ZVOL_NAME1}1 || fail 8
+ sync || fail 9
+
+ # Snapshot the ext3 filesystem so it may be sent.
+ ${ZFS} snapshot ${FULL_SNAP_NAME1} && sleep 1 || fail 11
+
+ # Send/receive the snapshot from POOL_NAME1 to POOL_NAME2
+ (${ZFS} send ${FULL_SNAP_NAME1} | \
+ ${ZFS} receive ${FULL_ZVOL_NAME2}) && sleep 1 || fail 12
+
+ # Mount the sent ext3 filesystem.
+ mkdir -p /tmp/${FULL_ZVOL_NAME2}1 || fail 13
+ mount /dev/${FULL_ZVOL_NAME2}1 /tmp/${FULL_ZVOL_NAME2}1 || fail 14
+
+ # Verify the contents of the volumes match
+ diff -ur /tmp/${FULL_ZVOL_NAME1}1 /tmp/${FULL_ZVOL_NAME2}1 \
+ &>/dev/null || fail 15
+
+ # Umount, destroy the volume and pool.
+ umount /tmp/${FULL_ZVOL_NAME1}1 || fail 16
+ umount /tmp/${FULL_ZVOL_NAME2}1 || fail 17
+ rmdir /tmp/${FULL_ZVOL_NAME1}1 || fail 18
+ rmdir /tmp/${FULL_ZVOL_NAME2}1 || fail 19
+ rmdir /tmp/${POOL_NAME1} || fail 20
+ rmdir /tmp/${POOL_NAME2} || fail 21
+
+ ${ZFS} destroy ${FULL_SNAP_NAME1} || fail 22
+ ${ZFS} destroy ${FULL_SNAP_NAME2} || fail 23
+ ${ZFS} destroy ${FULL_ZVOL_NAME1} || fail 24
+ ${ZFS} destroy ${FULL_ZVOL_NAME2} || fail 25
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME1} -c lo-raidz2 -d || fail 26
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME2} -c lo-raidz2 -d || fail 27
+ ${ZFS_SH} -u || fail 28
+ rm -f ${TMP_CACHE} || fail 29
+
+ pass
+}
+run_test 8 "zfs send/receive"
+
+# zpool event sanity check
+test_9() {
+ local POOL_NAME=tank
+ local ZVOL_NAME=fish
+ local FULL_NAME=${POOL_NAME}/${ZVOL_NAME}
+ local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
+ local TMP_EVENTS=`mktemp -p /tmp zpool.events.XXXXXXXX`
+
+ # Create a pool and volume.
+ ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2
+ ${ZFS} create -V 400M ${FULL_NAME} || fail 3
+
+ # Dump the events, there should be at least 5 lines.
+ ${ZPOOL} events >${TMP_EVENTS} || fail 4
+ EVENTS=`wc -l ${TMP_EVENTS} | cut -f1 -d' '`
+ [ $EVENTS -lt 5 ] && fail 5
+
+ # Clear the events and ensure there are none.
+ ${ZPOOL} events -c >/dev/null || fail 6
+ ${ZPOOL} events >${TMP_EVENTS} || fail 7
+ EVENTS=`wc -l ${TMP_EVENTS} | cut -f1 -d' '`
+ [ $EVENTS -gt 1 ] && fail 8
+
+ ${ZFS} destroy ${FULL_NAME} || fail 9
+ ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 -d || fail 10
+ ${ZFS_SH} -u || fail 11
+ rm -f ${TMP_CACHE} || fail 12
+ rm -f ${TMP_EVENTS} || fail 13
+
+ pass
+}
+run_test 9 "zpool events"
+
+exit 0
+
diff --git a/scripts/zfs.sh b/scripts/zfs.sh
new file mode 100755
index 000000000..523fbfcc0
--- /dev/null
+++ b/scripts/zfs.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+#
+# A simple script to simply the loading/unloading the ZFS module stack.
+
+basedir="$(dirname $0)"
+
+SCRIPT_COMMON=common.sh
+if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then
+. "${basedir}/${SCRIPT_COMMON}"
+else
+echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
+fi
+
+PROG=zfs.sh
+UNLOAD=
+
+usage() {
+cat << EOF
+USAGE:
+$0 [hvud] [module-options]
+
+DESCRIPTION:
+ Load/unload the ZFS module stack.
+
+OPTIONS:
+ -h Show this message
+ -v Verbose
+ -u Unload modules
+ -d Save debug log on unload
+
+MODULE-OPTIONS:
+ Must be of the from module="options", for example:
+
+$0 zfs="zfs_prefetch_disable=1"
+$0 zfs="zfs_prefetch_disable=1 zfs_mdcomp_disable=1"
+$0 spl="spl_debug_mask=0"
+
+EOF
+}
+
+while getopts 'hvud' OPTION; do
+ case $OPTION in
+ h)
+ usage
+ exit 1
+ ;;
+ v)
+ VERBOSE=1
+ ;;
+ u)
+ UNLOAD=1
+ ;;
+ d)
+ DUMP_LOG=1
+ ;;
+ ?)
+ usage
+ exit
+ ;;
+ esac
+done
+
+if [ $(id -u) != 0 ]; then
+ die "Must run as root"
+fi
+
+if [ ${UNLOAD} ]; then
+ unload_modules
+else
+ check_modules || die "${ERROR}"
+ load_modules "$@"
+fi
+
+exit 0
diff --git a/scripts/zpool-config/dm0-raid0.sh b/scripts/zpool-config/dm0-raid0.sh
new file mode 100644
index 000000000..89f66e73a
--- /dev/null
+++ b/scripts/zpool-config/dm0-raid0.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+#
+# Four disk Raid-0 DM in a single Raid-0 Configuration
+#
+
+PVCREATE=${PVCREATE:-/sbin/pvcreate}
+PVREMOVE=${PVREMOVE:-/sbin/pvremove}
+PVDEVICES=${PVDEVICES:-"/dev/sd[abcd]"}
+
+VGCREATE=${VGCREATE:-/sbin/vgcreate}
+VGREMOVE=${VGREMOVE:-/sbin/vgremove}
+VGNAME=${VGNAME:-"vg_tank"}
+
+LVCREATE=${LVCREATE:-/sbin/lvcreate}
+LVREMOVE=${LVREMOVE:-/sbin/lvremove}
+LVNAME=${LVNAME:-"lv_tank"}
+LVSTRIPES=${LVSTRIPES:-4}
+LVSIZE=${LVSIZE:-32G}
+
+DEVICES="/dev/${VGNAME}/${LVNAME}"
+
+zpool_dm_destroy() {
+ msg ${LVREMOVE} -f ${VGNAME}/${LVNAME}
+ ${LVREMOVE} -f ${VGNAME}/${LVNAME} >/dev/null
+
+ msg ${VGREMOVE} -f ${VGNAME}
+ ${VGREMOVE} -f ${VGNAME} >/dev/null
+
+ msg ${PVREMOVE} ${PVDEVICES}
+ ${PVREMOVE} ${PVDEVICES} >/dev/null
+}
+
+zpool_create() {
+ # Remove EFI labels which cause pvcreate failure
+ for DEVICE in ${PVDEVICES}; do
+ dd if=/dev/urandom of=${DEVICE} bs=1k count=32 &>/dev/null
+ done
+
+ msg ${PVCREATE} -f ${PVDEVICES}
+ ${PVCREATE} -f ${PVDEVICES} >/dev/null || exit 1
+
+ msg ${VGCREATE} ${VGNAME} ${PVDEVICES}
+ ${VGCREATE} ${VGNAME} ${PVDEVICES} >/dev/null || exit 2
+
+ msg ${LVCREATE} --size=${LVSIZE} --stripes=${LVSTRIPES} \
+ --name=${LVNAME} ${VGNAME}
+ ${LVCREATE} --size=${LVSIZE} --stripes=${LVSTRIPES} \
+ --name=${LVNAME} ${VGNAME} >/dev/null || exit 3
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} \
+ ${DEVICES} || (zpool_dm_destroy && exit 4)
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+
+ zpool_dm_destroy
+}
diff --git a/scripts/zpool-config/dragon-raid0-1x70.sh b/scripts/zpool-config/dragon-raid0-1x70.sh
new file mode 100644
index 000000000..dda995700
--- /dev/null
+++ b/scripts/zpool-config/dragon-raid0-1x70.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Dragon (White Box) Raid-0 Configuration (1x70)
+#
+
+RANKS=7
+CHANNELS=10
+
+zpool_create() {
+ udev_setup ${ETCDIR}/zfs/zdev.conf.dragon.example
+ udev_raid0_setup ${RANKS} ${CHANNELS}
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID0S[*]}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID0S[*]} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+ udev_cleanup ${ETCDIR}/zfs/zdev.conf.dragon.example
+}
diff --git a/scripts/zpool-config/dragon-raid10-35x2.sh b/scripts/zpool-config/dragon-raid10-35x2.sh
new file mode 100644
index 000000000..37f2a539a
--- /dev/null
+++ b/scripts/zpool-config/dragon-raid10-35x2.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Dragon (White Box) Raid-10 Configuration (35x2(1+1))
+#
+
+RANKS=7
+CHANNELS=10
+
+zpool_create() {
+ udev_setup ${ETCDIR}/zfs/zdev.conf.dragon.example
+ udev_raid10_setup ${RANKS} ${CHANNELS}
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID10S[*]}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID10S[*]} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+ udev_cleanup ${ETCDIR}/zfs/zdev.conf.dragon.example
+}
diff --git a/scripts/zpool-config/dragon-raidz-7x10.sh b/scripts/zpool-config/dragon-raidz-7x10.sh
new file mode 100644
index 000000000..9857cf1c0
--- /dev/null
+++ b/scripts/zpool-config/dragon-raidz-7x10.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Dragon (White Box) Raid-Z Configuration (7x10(9+1))
+#
+
+RANKS=7
+CHANNELS=10
+
+zpool_create() {
+ udev_setup ${ETCDIR}/zfs/zdev.conf.dragon.example
+ udev_raidz_setup ${RANKS} ${CHANNELS}
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZS[*]}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZS[*]} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+ udev_cleanup ${ETCDIR}/zfs/zdev.conf.dragon.example
+}
diff --git a/scripts/zpool-config/dragon-raidz2-7x10.sh b/scripts/zpool-config/dragon-raidz2-7x10.sh
new file mode 100644
index 000000000..0dd07a19b
--- /dev/null
+++ b/scripts/zpool-config/dragon-raidz2-7x10.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Dragon (White Box) Raid-Z2 Configuration (7x10(8+2))
+#
+
+RANKS=7
+CHANNELS=10
+
+zpool_create() {
+ udev_setup ${ETCDIR}/zfs/zdev.conf.dragon.example
+ udev_raidz2_setup ${RANKS} ${CHANNELS}
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZ2S[*]}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZ2S[*]} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+ udev_cleanup ${ETCDIR}/zfs/zdev.conf.dragon.example
+}
diff --git a/scripts/zpool-config/file-raid0.sh b/scripts/zpool-config/file-raid0.sh
new file mode 100644
index 000000000..5ec80b05c
--- /dev/null
+++ b/scripts/zpool-config/file-raid0.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# 4 File Raid-0 Configuration
+#
+
+FILES="/tmp/zpool-vdev0 \
+ /tmp/zpool-vdev1 \
+ /tmp/zpool-vdev2 \
+ /tmp/zpool-vdev3"
+
+zpool_create() {
+ for FILE in ${FILES}; do
+ msg "Creating ${FILE}"
+ rm -f ${FILE} || exit 1
+ dd if=/dev/zero of=${FILE} bs=1024k count=0 seek=256 \
+ &>/dev/null || die "Error $? creating ${FILE}"
+ done
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${FILES}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${FILES} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+
+ for FILE in ${FILES}; do
+ msg "Removing ${FILE}"
+ rm -f ${FILE} || exit 1
+ done
+}
diff --git a/scripts/zpool-config/file-raid10.sh b/scripts/zpool-config/file-raid10.sh
new file mode 100644
index 000000000..ae7f0ae07
--- /dev/null
+++ b/scripts/zpool-config/file-raid10.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+#
+# 4 File Raid-10 Configuration
+#
+
+FILES_M1="/tmp/zpool-vdev0 \
+ /tmp/zpool-vdev1"
+FILES_M2="/tmp/zpool-vdev2 \
+ /tmp/zpool-vdev3"
+FILES="${FILES_M1} ${FILES_M2}"
+
+zpool_create() {
+ for FILE in ${FILES}; do
+ msg "Creating ${FILE}"
+ rm -f ${FILE} || exit 1
+ dd if=/dev/zero of=${FILE} bs=1024k count=0 seek=256 \
+ &>/dev/null || die "Error $? creating ${FILE}"
+ done
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} \
+ mirror ${FILES_M1} mirror ${FILES_M2}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} \
+ mirror ${FILES_M1} mirror ${FILES_M2} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+
+ for FILE in ${FILES}; do
+ msg "Removing ${FILE}"
+ rm -f ${FILE} || exit 1
+ done
+}
diff --git a/scripts/zpool-config/file-raidz.sh b/scripts/zpool-config/file-raidz.sh
new file mode 100644
index 000000000..5b6c3ea2c
--- /dev/null
+++ b/scripts/zpool-config/file-raidz.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# 4 File Raid-Z Configuration
+#
+
+FILES="/tmp/zpool-vdev0 \
+ /tmp/zpool-vdev1 \
+ /tmp/zpool-vdev2 \
+ /tmp/zpool-vdev3"
+
+zpool_create() {
+ for FILE in ${FILES}; do
+ msg "Creating ${FILE}"
+ rm -f ${FILE} || exit 1
+ dd if=/dev/zero of=${FILE} bs=1024k count=0 seek=256 \
+ &>/dev/null || die "Error $? creating ${FILE}"
+ done
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz ${FILES}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz ${FILES} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+
+ for FILE in ${FILES}; do
+ msg "Removing ${FILE}"
+ rm -f ${FILE} || exit 1
+ done
+}
diff --git a/scripts/zpool-config/file-raidz2.sh b/scripts/zpool-config/file-raidz2.sh
new file mode 100644
index 000000000..bc0e5ec8a
--- /dev/null
+++ b/scripts/zpool-config/file-raidz2.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# 4 File Raid-Z2 Configuration
+#
+
+FILES="/tmp/zpool-vdev0 \
+ /tmp/zpool-vdev1 \
+ /tmp/zpool-vdev2 \
+ /tmp/zpool-vdev3"
+
+zpool_create() {
+ for FILE in ${FILES}; do
+ msg "Creating ${FILE}"
+ rm -f ${FILE} || exit 1
+ dd if=/dev/zero of=${FILE} bs=1024k count=0 seek=256 \
+ &>/dev/null || die "Error $? creating ${FILE}"
+ done
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz2 ${FILES}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz2 ${FILES} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+
+ for FILE in ${FILES}; do
+ msg "Removing ${FILE}"
+ rm -f ${FILE} || exit 1
+ done
+}
diff --git a/scripts/zpool-config/hda-raid0.sh b/scripts/zpool-config/hda-raid0.sh
new file mode 100644
index 000000000..fb743fae5
--- /dev/null
+++ b/scripts/zpool-config/hda-raid0.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# Single disk /dev/hda Raid-0 Configuration
+#
+
+DEVICES="/dev/hda"
+
+zpool_create() {
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME} || exit 1
+}
diff --git a/scripts/zpool-config/lo-raid0.sh b/scripts/zpool-config/lo-raid0.sh
new file mode 100644
index 000000000..321d9b1f7
--- /dev/null
+++ b/scripts/zpool-config/lo-raid0.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+# 4 Device Loopback Raid-0 Configuration
+#
+
+FILES="/tmp/zpool-vdev0 \
+ /tmp/zpool-vdev1 \
+ /tmp/zpool-vdev2 \
+ /tmp/zpool-vdev3"
+DEVICES=""
+
+zpool_create() {
+ for FILE in ${FILES}; do
+ DEVICE=`unused_loop_device`
+ msg "Creating ${FILE} using loopback device ${DEVICE}"
+ rm -f ${FILE} || exit 1
+ dd if=/dev/zero of=${FILE} bs=1024k count=0 seek=256 \
+ &>/dev/null || die "Error $? creating ${FILE}"
+ ${LOSETUP} ${DEVICE} ${FILE} ||
+ die "Error $? creating ${FILE} -> ${DEVICE} loopback"
+ DEVICES="${DEVICES} ${DEVICE}"
+ done
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+
+ for FILE in ${FILES}; do
+ DEVICE=`${LOSETUP} -a | grep ${FILE} | head -n1|cut -f1 -d:`
+ msg "Removing ${FILE} using loopback device ${DEVICE}"
+ ${LOSETUP} -d ${DEVICE} ||
+ die "Error $? destroying ${FILE} -> ${DEVICE} loopback"
+ rm -f ${FILE} || exit 1
+ done
+}
diff --git a/scripts/zpool-config/lo-raid10.sh b/scripts/zpool-config/lo-raid10.sh
new file mode 100644
index 000000000..f9c47cd1e
--- /dev/null
+++ b/scripts/zpool-config/lo-raid10.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+#
+# 4 Device Loopback Raid-0 Configuration
+#
+
+FILES_M1="/tmp/zpool-vdev0 \
+ /tmp/zpool-vdev1"
+FILES_M2="/tmp/zpool-vdev2 \
+ /tmp/zpool-vdev3"
+FILES="${FILES_M1} ${FILES_M2}"
+DEVICES_M1=""
+DEVICES_M2=""
+
+zpool_create() {
+ for FILE in ${FILES_M1}; do
+ DEVICE=`unused_loop_device`
+ msg "Creating ${FILE} using loopback device ${DEVICE}"
+ rm -f ${FILE} || exit 1
+ dd if=/dev/zero of=${FILE} bs=1024k count=0 seek=256 \
+ &>/dev/null || die "Error $? creating ${FILE}"
+ ${LOSETUP} ${DEVICE} ${FILE} ||
+ die "Error $? creating ${FILE} -> ${DEVICE} loopback"
+ DEVICES_M1="${DEVICES_M1} ${DEVICE}"
+ done
+
+ for FILE in ${FILES_M2}; do
+ DEVICE=`unused_loop_device`
+ msg "Creating ${FILE} using loopback device ${DEVICE}"
+ rm -f ${FILE} || exit 1
+ dd if=/dev/zero of=${FILE} bs=1024k count=0 seek=256 \
+ &>/dev/null || die "Error $? creating ${FILE}"
+ ${LOSETUP} ${DEVICE} ${FILE} ||
+ die "Error $? creating ${FILE} -> ${DEVICE} loopback"
+ DEVICES_M2="${DEVICES_M2} ${DEVICE}"
+ done
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} \
+ mirror ${DEVICES_M1} mirror ${DEVICES_M2}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} \
+ mirror ${DEVICES_M1} mirror ${DEVICES_M2}
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+
+ for FILE in ${FILES}; do
+ DEVICE=`${LOSETUP} -a | grep ${FILE} | head -n1|cut -f1 -d:`
+ msg "Removing ${FILE} using loopback device ${DEVICE}"
+ ${LOSETUP} -d ${DEVICE} ||
+ die "Error $? destroying ${FILE} -> ${DEVICE} loopback"
+ rm -f ${FILE} || exit 1
+ done
+}
diff --git a/scripts/zpool-config/lo-raidz.sh b/scripts/zpool-config/lo-raidz.sh
new file mode 100644
index 000000000..509f6ee1d
--- /dev/null
+++ b/scripts/zpool-config/lo-raidz.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+# 4 Device Loopback Raid-0 Configuration
+#
+
+FILES="/tmp/zpool-vdev0 \
+ /tmp/zpool-vdev1 \
+ /tmp/zpool-vdev2 \
+ /tmp/zpool-vdev3"
+DEVICES=""
+
+zpool_create() {
+ for FILE in ${FILES}; do
+ DEVICE=`unused_loop_device`
+ msg "Creating ${FILE} using loopback device ${DEVICE}"
+ rm -f ${FILE} || exit 1
+ dd if=/dev/zero of=${FILE} bs=1024k count=0 seek=256 \
+ &>/dev/null || die "Error $? creating ${FILE}"
+ ${LOSETUP} ${DEVICE} ${FILE} ||
+ die "Error $? creating ${FILE} -> ${DEVICE} loopback"
+ DEVICES="${DEVICES} ${DEVICE}"
+ done
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz ${DEVICES}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz ${DEVICES} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+
+ for FILE in ${FILES}; do
+ DEVICE=`${LOSETUP} -a | grep ${FILE} | head -n1|cut -f1 -d:`
+ msg "Removing ${FILE} using loopback device ${DEVICE}"
+ ${LOSETUP} -d ${DEVICE} ||
+ die "Error $? destroying ${FILE} -> ${DEVICE} loopback"
+ rm -f ${FILE} || exit 1
+ done
+}
diff --git a/scripts/zpool-config/lo-raidz2.sh b/scripts/zpool-config/lo-raidz2.sh
new file mode 100644
index 000000000..6e61293c0
--- /dev/null
+++ b/scripts/zpool-config/lo-raidz2.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+# 4 Device Loopback Raid-0 Configuration
+#
+
+FILES="/tmp/zpool-vdev0 \
+ /tmp/zpool-vdev1 \
+ /tmp/zpool-vdev2 \
+ /tmp/zpool-vdev3"
+DEVICES=""
+
+zpool_create() {
+ for FILE in ${FILES}; do
+ DEVICE=`unused_loop_device`
+ msg "Creating ${FILE} using loopback device ${DEVICE}"
+ rm -f ${FILE} || exit 1
+ dd if=/dev/zero of=${FILE} bs=1024k count=0 seek=256 \
+ &>/dev/null || die "Error $? creating ${FILE}"
+ ${LOSETUP} ${DEVICE} ${FILE} ||
+ die "Error $? creating ${FILE} -> ${DEVICE} loopback"
+ DEVICES="${DEVICES} ${DEVICE}"
+ done
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz2 ${DEVICES}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz2 ${DEVICES} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+
+ for FILE in ${FILES}; do
+ DEVICE=`${LOSETUP} -a | grep ${FILE} | head -n1|cut -f1 -d:`
+ msg "Removing ${FILE} using loopback device ${DEVICE}"
+ ${LOSETUP} -d ${DEVICE} ||
+ die "Error $? destroying ${FILE} -> ${DEVICE} loopback"
+ rm -f ${FILE} || exit 1
+ done
+}
diff --git a/scripts/zpool-config/md0-raid10.sh b/scripts/zpool-config/md0-raid10.sh
new file mode 100644
index 000000000..ccc717015
--- /dev/null
+++ b/scripts/zpool-config/md0-raid10.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+#
+# Four disk Raid-10 in a single Raid-0 Configuration
+#
+
+MDADM=${MDADM:-/sbin/mdadm}
+MDDEVICES=${MDDEVICES:-"/dev/sd[abcd]"}
+MDCOUNT=${MDCOUNT:-4}
+MDRAID=${MDRAID:-10}
+
+DEVICES="/dev/md0"
+
+zpool_md_destroy() {
+ msg ${MDADM} --manage --stop ${DEVICES}
+ ${MDADM} --manage --stop ${DEVICES} &>/dev/null
+
+ msg ${MDADM} --zero-superblock ${MDDEVICES}
+ ${MDADM} --zero-superblock ${MDDEVICES} >/dev/null
+}
+
+zpool_create() {
+ msg ${MDADM} --create ${DEVICES} --level=${MDRAID} \
+ --raid-devices=${MDCOUNT} ${MDDEVICES}
+ ${MDADM} --create ${DEVICES} --level=${MDRAID} \
+ --raid-devices=${MDCOUNT} ${MDDEVICES} \
+ &>/dev/null || (zpool_md_destroy && exit 1)
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} \
+ ${DEVICES} || (zpool_md_destroy && exit 2)
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+
+ zpool_md_destroy
+}
diff --git a/scripts/zpool-config/md0-raid5.sh b/scripts/zpool-config/md0-raid5.sh
new file mode 100644
index 000000000..b5b22fe7a
--- /dev/null
+++ b/scripts/zpool-config/md0-raid5.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+#
+# Four disk Raid-5 in a single Raid-0 Configuration
+#
+
+MDADM=${MDADM:-/sbin/mdadm}
+MDDEVICES=${MDDEVICES:-"/dev/sd[abcd]"}
+MDCOUNT=${MDCOUNT:-4}
+MDRAID=${MDRAID:-5}
+
+DEVICES="/dev/md0"
+
+zpool_md_destroy() {
+ msg ${MDADM} --manage --stop ${DEVICES}
+ ${MDADM} --manage --stop ${DEVICES} &>/dev/null
+
+ msg ${MDADM} --zero-superblock ${MDDEVICES}
+ ${MDADM} --zero-superblock ${MDDEVICES} >/dev/null
+}
+
+zpool_create() {
+ msg ${MDADM} --create ${DEVICES} --level=${MDRAID} \
+ --raid-devices=${MDCOUNT} ${MDDEVICES}
+ ${MDADM} --create ${DEVICES} --level=${MDRAID} \
+ --raid-devices=${MDCOUNT} ${MDDEVICES} \
+ &>/dev/null || (zpool_md_destroy && exit 1)
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} \
+ ${DEVICES} || (zpool_md_destroy && exit 2)
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+
+ zpool_md_destroy
+}
diff --git a/scripts/zpool-config/ram0-raid0.sh b/scripts/zpool-config/ram0-raid0.sh
new file mode 100644
index 000000000..b1939bfaa
--- /dev/null
+++ b/scripts/zpool-config/ram0-raid0.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# Single ram disk /dev/ram0 Raid-0 Configuration
+#
+
+DEVICES="/dev/ram0"
+
+zpool_create() {
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME} || exit 1
+}
diff --git a/scripts/zpool-config/sda-raid0.sh b/scripts/zpool-config/sda-raid0.sh
new file mode 100644
index 000000000..b11092466
--- /dev/null
+++ b/scripts/zpool-config/sda-raid0.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# Single disk /dev/sda Raid-0 Configuration
+#
+
+DEVICES="/dev/sda"
+
+zpool_create() {
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME} || exit 1
+}
diff --git a/scripts/zpool-config/supermicro-raid0-1x16.sh b/scripts/zpool-config/supermicro-raid0-1x16.sh
new file mode 100644
index 000000000..efe48459d
--- /dev/null
+++ b/scripts/zpool-config/supermicro-raid0-1x16.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Supermicro (White Box) Raid-0 Configuration (1x16)
+#
+
+RANKS=4
+CHANNELS=4
+
+zpool_create() {
+ udev_setup ${ETCDIR}/zfs/zdev.conf.supermicro.example
+ udev_raid0_setup ${RANKS} ${CHANNELS}
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID0S[*]}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID0S[*]} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+ udev_cleanup ${ETCDIR}/zfs/zdev.conf.supermicro.example
+}
diff --git a/scripts/zpool-config/supermicro-raid10-8x2.sh b/scripts/zpool-config/supermicro-raid10-8x2.sh
new file mode 100644
index 000000000..a6e6be6c0
--- /dev/null
+++ b/scripts/zpool-config/supermicro-raid10-8x2.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Supermicro (White Box) Raid-10 Configuration (8x2(1+1))
+#
+
+RANKS=4
+CHANNELS=4
+
+zpool_create() {
+ udev_setup ${ETCDIR}/zfs/zdev.conf.supermicro.example
+ udev_raid10_setup ${RANKS} ${CHANNELS}
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID10S[*]}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID10S[*]} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+ udev_cleanup ${ETCDIR}/zfs/zdev.conf.supermicro.example
+}
diff --git a/scripts/zpool-config/supermicro-raidz-4x4.sh b/scripts/zpool-config/supermicro-raidz-4x4.sh
new file mode 100644
index 000000000..9ed2780e9
--- /dev/null
+++ b/scripts/zpool-config/supermicro-raidz-4x4.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Supermicro (White Box) Raid-Z Configuration (4x4(3+1))
+#
+
+RANKS=4
+CHANNELS=4
+
+zpool_create() {
+ udev_setup ${ETCDIR}/zfs/zdev.conf.supermicro.example
+ udev_raidz_setup ${RANKS} ${CHANNELS}
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZS[*]}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZS[*]} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+ udev_cleanup ${ETCDIR}/zfs/zdev.conf.supermicro.example
+}
diff --git a/scripts/zpool-config/supermicro-raidz2-4x4.sh b/scripts/zpool-config/supermicro-raidz2-4x4.sh
new file mode 100644
index 000000000..ed3eedfdf
--- /dev/null
+++ b/scripts/zpool-config/supermicro-raidz2-4x4.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Supermicro (White Box) Raid-Z2 Configuration (4x4(2+2))
+#
+
+RANKS=4
+CHANNELS=4
+
+zpool_create() {
+ udev_setup ${ETCDIR}/zfs/zdev.conf.supermicro.example
+ udev_raidz2_setup ${RANKS} ${CHANNELS}
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZ2S[*]}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZ2S[*]} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+ udev_cleanup ${ETCDIR}/zfs/zdev.conf.supermicro.example
+}
diff --git a/scripts/zpool-config/x4550-raid0-1x48.sh b/scripts/zpool-config/x4550-raid0-1x48.sh
new file mode 100644
index 000000000..16156aa09
--- /dev/null
+++ b/scripts/zpool-config/x4550-raid0-1x48.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Sun Fire x4550 (Thumper/Thor) Raid-0 Configuration (1x48)
+#
+
+RANKS=8
+CHANNELS=6
+
+zpool_create() {
+ udev_setup ${ETCDIR}/zfs/zdev.conf.x4550.example
+ udev_raid0_setup ${RANKS} ${CHANNELS}
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID0S[*]}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID0S[*]} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+ udev_cleanup ${ETCDIR}/zfs/zdev.conf.x4550.example
+}
diff --git a/scripts/zpool-config/x4550-raid10-24x2.sh b/scripts/zpool-config/x4550-raid10-24x2.sh
new file mode 100644
index 000000000..ec91f43e6
--- /dev/null
+++ b/scripts/zpool-config/x4550-raid10-24x2.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Sun Fire x4550 (Thumper/Thor) Raid-10 Configuration (24x2(1+1))
+#
+
+RANKS=8
+CHANNELS=6
+
+zpool_create() {
+ udev_setup ${ETCDIR}/zfs/zdev.conf.x4550.example
+ udev_raid10_setup ${RANKS} ${CHANNELS}
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID10S[*]}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAID10S[*]} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+ udev_cleanup ${ETCDIR}/zfs/zdev.conf.x4550.example
+}
diff --git a/scripts/zpool-config/x4550-raidz-8x6.sh b/scripts/zpool-config/x4550-raidz-8x6.sh
new file mode 100644
index 000000000..ed31a80e6
--- /dev/null
+++ b/scripts/zpool-config/x4550-raidz-8x6.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Sun Fire x4550 (Thumper/Thor) Raid-Z Configuration (8x6(5+1))
+#
+
+RANKS=8
+CHANNELS=6
+
+zpool_create() {
+ udev_setup ${ETCDIR}/zfs/zdev.conf.x4550.example
+ udev_raidz_setup ${RANKS} ${CHANNELS}
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZS[*]}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZS[*]} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+ udev_cleanup ${ETCDIR}/zfs/zdev.conf.x4550.example
+}
diff --git a/scripts/zpool-config/x4550-raidz2-8x6.sh b/scripts/zpool-config/x4550-raidz2-8x6.sh
new file mode 100644
index 000000000..45ccd7474
--- /dev/null
+++ b/scripts/zpool-config/x4550-raidz2-8x6.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Sun Fire x4550 (Thumper/Thor) Raid-Z Configuration (8x6(4+2))
+#
+
+RANKS=8
+CHANNELS=6
+
+zpool_create() {
+ udev_setup ${ETCDIR}/zfs/zdev.conf.x4550.example
+ udev_raidz2_setup ${RANKS} ${CHANNELS}
+
+ msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZ2S[*]}
+ ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${RAIDZ2S[*]} || exit 1
+}
+
+zpool_destroy() {
+ msg ${ZPOOL} destroy ${ZPOOL_NAME}
+ ${ZPOOL} destroy ${ZPOOL_NAME}
+ udev_cleanup ${ETCDIR}/zfs/zdev.conf.x4550.example
+}
diff --git a/scripts/zpool-create.sh b/scripts/zpool-create.sh
new file mode 100755
index 000000000..d6b301e32
--- /dev/null
+++ b/scripts/zpool-create.sh
@@ -0,0 +1,133 @@
+#!/bin/bash
+
+basedir="$(dirname $0)"
+
+SCRIPT_COMMON=common.sh
+if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then
+. "${basedir}/${SCRIPT_COMMON}"
+else
+echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
+fi
+
+PROG=zpool-create.sh
+
+usage() {
+cat << EOF
+USAGE:
+$0 [hvcp]
+
+DESCRIPTION:
+ Create one of several predefined zpool configurations.
+
+OPTIONS:
+ -h Show this message
+ -v Verbose
+ -f Force everything
+ -c Configuration for zpool
+ -p Name for zpool
+ -d Destroy zpool (default create)
+ -l Additional zpool options
+ -s Additional zfs options
+
+EOF
+}
+
+check_config() {
+
+ if [ ! -f ${ZPOOL_CONFIG} ]; then
+ local NAME=`basename ${ZPOOL_CONFIG} .sh`
+ ERROR="Unknown config '${NAME}', available configs are:\n"
+
+ for CFG in `ls ${ZPOOLDIR}/ | grep ".sh"`; do
+ local NAME=`basename ${CFG} .sh`
+ ERROR="${ERROR}${NAME}\n"
+ done
+
+ return 1
+ fi
+
+ return 0
+}
+
+ZPOOL_CONFIG=unknown
+ZPOOL_NAME=tank
+ZPOOL_DESTROY=
+ZPOOL_OPTIONS=""
+ZFS_OPTIONS=""
+
+while getopts 'hvfc:p:dl:s:' OPTION; do
+ case $OPTION in
+ h)
+ usage
+ exit 1
+ ;;
+ v)
+ VERBOSE=1
+ VERBOSE_FLAG="-v"
+ ;;
+ f)
+ FORCE=1
+ FORCE_FLAG="-f"
+ ;;
+ c)
+ ZPOOL_CONFIG=${ZPOOLDIR}/${OPTARG}.sh
+ ;;
+ p)
+ ZPOOL_NAME=${OPTARG}
+ ;;
+ d)
+ ZPOOL_DESTROY=1
+ ;;
+ l)
+ ZPOOL_OPTIONS=${OPTARG}
+ ;;
+ s)
+ ZFS_OPTIONS=${OPTARG}
+ ;;
+ ?)
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+if [ $(id -u) != 0 ]; then
+ die "Must run as root"
+fi
+
+check_config || die "${ERROR}"
+. ${ZPOOL_CONFIG}
+
+if [ ${ZPOOL_DESTROY} ]; then
+ zpool_destroy
+else
+ zpool_create
+
+ if [ "${ZPOOL_OPTIONS}" ]; then
+ if [ ${VERBOSE} ]; then
+ echo
+ echo "${ZPOOL} ${ZPOOL_OPTIONS} ${ZPOOL_NAME}"
+ fi
+ ${ZPOOL} ${ZPOOL_OPTIONS} ${ZPOOL_NAME} || exit 1
+ fi
+
+ if [ "${ZFS_OPTIONS}" ]; then
+ if [ ${VERBOSE} ]; then
+ echo
+ echo "${ZFS} ${ZFS_OPTIONS} ${ZPOOL_NAME}"
+ fi
+ ${ZFS} ${ZFS_OPTIONS} ${ZPOOL_NAME} || exit 1
+ fi
+
+ if [ ${VERBOSE} ]; then
+ echo
+ echo "zpool list"
+ ${ZPOOL} list || exit 1
+
+ echo
+ echo "zpool status ${ZPOOL_NAME}"
+ ${ZPOOL} status ${ZPOOL_NAME} || exit 1
+ fi
+fi
+
+exit 0
diff --git a/zfs-modules.spec.in b/zfs-modules.spec.in
new file mode 100644
index 000000000..93129b3d7
--- /dev/null
+++ b/zfs-modules.spec.in
@@ -0,0 +1,280 @@
+# The following block is used to allow the source RPM to be rebuilt
+# against specific kernels. It is preferable that rpmbuild define the
+# require_kver, require_kdir, require_obj constants for us, but if it does not
+# not we attempt to determine the correct values based on your distro.
+
+# kdir: Full path to the kernel source headers
+# kobj: Full path to the kernel build objects
+# kver: Kernel version
+# kpkg: Kernel package name
+# kdevpkg: Kernel devel package name
+# kverpkg: Kernel package version
+
+%if %{defined require_kver}
+%define kver %{require_kver}
+%endif
+
+%if %{defined require_kdir}
+%define kdir %{require_kdir}
+%endif
+
+%if %{defined require_kobj}
+%define kobj %{require_kobj}
+%endif
+
+# SLES:
+%if %{defined suse_version}
+ %if %{undefined kver}
+ %ifarch ppc64
+ %define kverextra ppc64
+ %else
+ %define kverextra default
+ %endif
+
+ %if %{suse_version} >= 1100
+ %define klnk %{_usrsrc}/linux-obj/%{_target_cpu}/%{kverextra}
+ %define krelease %{klnk}/include/config/kernel.release
+ %else
+ %define klnk %{_usrsrc}/linux-obj/%{_target_cpu}/%{kverextra}
+ %define krelease %{klnk}/.kernelrelease
+ %endif
+
+ %define kver %((echo X; %{__cat} %{krelease} 2>/dev/null)|tail -1)
+ %endif
+
+ %if %{undefined kverextra}
+ %define kverextra %(echo %{kver} | cut -f3 -d'-')
+ %endif
+
+ %define kpkg kernel-%{kverextra}
+ %define kdevpkg kernel-source
+ %define kverpkg %(echo %{kver} | %{__sed} -e 's/-%{kverextra}//g')
+
+ # The kernel and rpm versions do not strictly match under SLES11
+ # e.g. kernel version 2.6.27.19-5 != rpm version 2.6.27.19-5.1
+ %if %{suse_version} >= 1100
+ %define koppkg >=
+ %else
+ %define koppkg =
+ %endif
+
+ %if %{undefined kdir}
+ %define kdir %{_usrsrc}/linux-%{kverpkg}
+ %endif
+ %if %{undefined kobj}
+ %define kobj %{kdir}-obj/%{_target_cpu}/%{kverextra}
+ %endif
+%else
+
+# CHAOS 4.x/5.x:
+%if %{defined ch4} || %{defined ch5}
+ %if %{undefined kver}
+ %define klnk %{_usrsrc}/kernels/*/include/config
+ %define kver %((echo X; %{__cat} %{klnk}/kernel.release
+ 2>/dev/null) | tail -1)
+ %endif
+ %define kpkg chaos-kernel
+ %define kdevpkg chaos-kernel-devel
+ %define kverpkg %{kver}
+ %define koppkg =
+ %if %{undefined kdir}
+ %define kdir %{_usrsrc}/kernels/%{kver}
+ %endif
+ %if %{undefined kobj}
+ %define kobj %{kdir}
+ %endif
+%else
+
+# RHEL 5.x/6.x:
+%if %{defined el5} || %{defined el6}
+ %if %{undefined kver}
+ %define klnk %{_usrsrc}/kernels/*/include/config
+ %define kver %((echo X; %{__cat} %{klnk}/kernel.release
+ 2>/dev/null) | tail -1)
+ %endif
+ %define kpkg kernel
+ %define kdevpkg kernel-devel
+ %if %{defined el6}
+ %define kverpkg %(echo %{kver} | %{__sed} -e 's/.%{_target_cpu}//g')
+ %else
+ %define kverpkg %{kver}
+ %endif
+ %define koppkg =
+ %if %{undefined kdir}
+ %define kdir %{_usrsrc}/kernels/%{kver}-%{_target_cpu}
+ %endif
+ %if %{undefined kobj}
+ %define kobj %{kdir}
+ %endif
+%else
+
+# Fedora:
+%if %{defined fedora}
+ %if %{undefined kver}
+ %define klnk %{_usrsrc}/kernels/*/include/config
+ %define kver %((echo X; %{__cat} %{klnk}/kernel.release
+ 2>/dev/null) | tail -1)
+ %endif
+ %define kpkg kernel
+ %define kdevpkg kernel-devel
+ %define kverpkg %(echo %{kver} | %{__sed} -e 's/.%{_target_cpu}//g')
+ %define koppkg =
+ %if %{undefined kdir}
+ %define kdir %{_usrsrc}/kernels/%{kver}
+ %endif
+ %if %{undefined kobj}
+ %define kobj %{kdir}
+ %endif
+%else
+
+# Unsupported distro:
+ %if %{undefined kver}
+ %define kver %(uname -r)
+ %endif
+ %define kverpkg %{kver}
+ %if %{undefined kdir}
+ %define kdir /lib/modules/%{kver}/build
+ %endif
+ %if %{undefined kobj}
+ %define kobj %{kdir}
+ %endif
+
+%endif
+%endif
+%endif
+%endif
+
+# spldir: Full path to the spl source headers
+# splobj: Full path to the spl build objects
+# splver: Spl version
+# splpkg: Spl package name
+# spldevpkg: Spl devel package name
+# splverpkg: Spl package version
+
+%if %{defined require_splver}
+%define splver %{require_splver}
+%endif
+
+%if %{defined require_spldir}
+%define spldir %{require_spldir}
+%endif
+
+%if %{defined require_splobj}
+%define splobj %{require_splobj}
+%endif
+
+%if %{undefined splver}
+ %define spllnk %{_usrsrc}/spl-*/%{kver}
+ %define splver %((echo X; %{__cat} %{spllnk}/spl.release
+ 2>/dev/null) | tail -1)
+%endif
+%define splpkg spl-modules
+%define spldevpkg spl-modules-devel
+%define splverpkg %{splver}
+%if %{undefined spldir}
+ %define spldir %{_usrsrc}/spl-%{splver}/%{kver}
+%endif
+%if %{undefined splobj}
+ %define splobj %{spldir}/module
+%endif
+
+
+# Distro agnostic:
+%define name @PACKAGE@-modules
+%define version @VERSION@
+%define debug_package %{nil}
+
+# The kernel version should only be appended to a binary RPM. When
+# building a source RPM it must be kernel version agnostic. This means
+# the source RPM must never specify a required kernel version, but the
+# final RPM should be keyed to the kernel version it was built against.
+%if %{defined build_src_rpm}
+%define release @ZFS_META_RELEASE@
+%if %{defined kpkg}
+%define krequires %{kpkg}
+%endif
+%define splrequires %{splpkg}
+%else
+%define relext %(echo %{kverpkg} | %{__sed} -e 's/-/_/g')
+%define release @ZFS_META_RELEASE@_%{relext}
+%if %{defined kpkg}
+%define krequires %{kpkg} %{koppkg} %{kverpkg}
+%endif
+%define splrequires %{splpkg} = %{splverpkg}
+%endif
+
+Summary: ZFS File System
+Group: Utilities/System
+Name: %{name}
+Version: %{version}
+Release: %{release}
+License: @LICENSE@
+URL: git://eris.llnl.gov/zfs.git
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id} -un)
+Source: @PACKAGE@-%{version}.tar.gz
+%if %{defined krequires}
+Requires: %{krequires}
+%endif
+%if %{defined kdevpkg}
+BuildRequires: %{kdevpkg}
+%endif
+Requires: %{splrequires}
+BuildRequires: %{spldevpkg}
+
+%description
+The %{name} package contains kernel modules and support utilities for
+the %{name} file system.
+
+%package devel
+Summary: ZFS File System Headers and Symbols
+Group: Development/Libraries
+%if %{defined krequires}
+Requires: %{krequires}
+%endif
+Requires: %{splrequires}
+%if %{defined kdevpkg}
+BuildRequires: %{kdevpkg}
+%endif
+BuildRequires: %{spldevpkg}
+
+%description devel
+The %{name}-devel package contains the kernel header files and
+Module.symvers symbols needed for building additional modules
+which use %{name}.
+
+%prep
+%setup -n @PACKAGE@-%{version}
+%build
+%configure --with-linux=%{kdir} --with-linux-obj=%{kobj} \
+ --with-spl=%{spldir} --with-spl-obj=%{splobj} \
+ --with-config=kernel
+make
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make DESTDIR=$RPM_BUILD_ROOT install
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-, root, root)
+/lib/modules/*
+
+%files devel
+%defattr(-,root,root)
+%{_prefix}/src/*
+
+%post
+if [ -f /boot/System.map-%{kver} ]; then
+ depmod -ae -F /boot/System.map-%{kver} %{kver} || exit 0
+else
+ depmod -ae %{kver} || exit 0
+fi
+
+%postun
+if [ -f /boot/System.map-%{kver} ]; then
+ depmod -ae -F /boot/System.map-%{kver} %{kver} || exit 0
+else
+ depmod -ae %{kver} || exit 0
+fi
diff --git a/zfs.spec.in b/zfs.spec.in
new file mode 100644
index 000000000..17e0131ad
--- /dev/null
+++ b/zfs.spec.in
@@ -0,0 +1,79 @@
+%define name @PACKAGE@
+%define version @VERSION@
+%define release @ZFS_META_RELEASE@
+%define debug_package %{nil}
+
+Summary: ZFS Library and Utils
+Group: Utilities/System
+Name: %{name}
+Version: %{version}
+Release: %{release}
+License: CDDL
+URL: git://eris.llnl.gov/zfs.git
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id} -un)
+Source: %{name}-%{version}.tar.gz
+Requires: zlib e2fsprogs
+BuildRequires: zlib-devel e2fsprogs-devel
+
+%description
+The %{name} package contains the libzfs library and support utilities
+for the zfs file system.
+
+%package devel
+Summary: ZFS File System User Headers
+Group: Development/Libraries
+%if %{defined ch5} || %{defined el6} || %{defined fc12}
+Requires: zlib libuuid libblkid
+BuildRequires: zlib-devel libuuid-devel libblkid-devel
+%else
+Requires: zlib e2fsprogs
+BuildRequires: zlib-devel e2fsprogs-devel
+%endif
+
+%description devel
+The %{name}-devel package contains the header files needed for building
+additional applications against the %{name} libraries.
+
+%package test
+Summary: ZFS File System Test Infrastructure
+Group: Utilities/System
+
+%description test
+The %{name}-test package contains a test infrastructure for zpios which
+can be used to simplfy the benchmarking of various hardware and software
+configurations. The test infrastructure additionally integrates with
+various system profiling tools to facilitate an in depth analysis.
+
+%prep
+%setup
+%build
+%configure --with-config=user --without-blkid
+make
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make DESTDIR=$RPM_BUILD_ROOT install
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-, root, root)
+%doc AUTHORS ChangeLog COPYING COPYRIGHT DISCLAIMER
+%doc GIT OPENSOLARIS.LICENSE README.markdown ZFS.RELEASE
+%{_sbindir}/*
+%{_bindir}/*
+%{_libdir}/*
+%{_mandir}/man8/*
+%{_sysconfdir}/*
+
+%files devel
+%defattr(-,root,root)
+%{_includedir}/*
+
+%files test
+%defattr(-,root,root)
+%{_libexecdir}/@PACKAGE@/*
+
+%post
+%postun