forked from openzfs/zfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
661 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
# shellcheck disable=SC2154 | ||
# | ||
# Helper to mount and unmount snapshots when asked to by kernel. | ||
# | ||
# Mostly used in macOS. | ||
# | ||
set -ef | ||
|
||
[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc" | ||
. "${ZED_ZEDLET_DIR}/zed-functions.sh" | ||
|
||
[ -n "${ZEVENT_SNAPSHOT_NAME}" ] || exit 1 | ||
[ -n "${ZEVENT_SUBCLASS}" ] || exit 2 | ||
|
||
if [ "${ZEVENT_SUBCLASS}" = "snapshot_mount" ]; then | ||
action="mount" | ||
elif [ "${ZEVENT_SUBCLASS}" = "snapshot_unmount" ]; then | ||
action="unmount" | ||
else | ||
zed_log_err "unsupported event class \"${ZEVENT_SUBCLASS}\"" | ||
exit 3 | ||
fi | ||
|
||
zed_exit_if_ignoring_this_event | ||
zed_check_cmd "${ZFS}" || exit 4 | ||
|
||
"${ZFS}" "${action}" "${ZEVENT_SNAPSHOT_NAME}" | ||
|
||
finished |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
snapshot_mount.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/sh | ||
# shellcheck disable=SC2154 | ||
# | ||
# Log the zevent via syslog. | ||
# | ||
|
||
# Given POOL and DATASET name for ZVOL | ||
# DEVICE_NAME for /dev/disk* | ||
# RAW_DEVICE_NAME for /dev/rdisk* | ||
# Create symlink in | ||
# /var/run/zfs/zvol/dsk/POOL/DATASET -> /dev/disk* | ||
# /var/run/zfs/zvol/rdsk/POOL/DATASET -> /dev/rdisk* | ||
|
||
ZVOL_ROOT="/var/run/zfs/zvol" | ||
|
||
mkdir -p "$(dirname "${ZVOL_ROOT}/rdsk/${ZEVENT_POOL}/${ZEVENT_VOLUME}")" "$(dirname "${ZVOL_ROOT}/dsk/${ZEVENT_POOL}/${ZEVENT_VOLUME}")" | ||
|
||
# Remove them if they already exist. (ln -f is not portable) | ||
rm -f "${ZVOL_ROOT}/rdsk/${ZEVENT_POOL}/${ZEVENT_VOLUME}" "${ZVOL_ROOT}/dsk/${ZEVENT_POOL}/${ZEVENT_VOLUME}" | ||
|
||
ln -s "/dev/${ZEVENT_DEVICE_NAME}" "${ZVOL_ROOT}/dsk/${ZEVENT_POOL}/${ZEVENT_VOLUME}" | ||
ln -s "/dev/${ZEVENT_RAW_NAME}" "${ZVOL_ROOT}/rdsk/${ZEVENT_POOL}/${ZEVENT_VOLUME}" | ||
|
||
logger -t "${ZED_SYSLOG_TAG:=zed}" -p "${ZED_SYSLOG_PRIORITY:=daemon.notice}" \ | ||
eid="${ZEVENT_EID}" class="${ZEVENT_SUBCLASS}" \ | ||
"${ZEVENT_POOL:+pool=$ZEVENT_POOL}/${ZEVENT_VOLUME} symlinked ${ZEVENT_DEVICE_NAME}" | ||
|
||
echo 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/sh | ||
# shellcheck disable=SC2154 | ||
# | ||
# Log the zevent via syslog. | ||
# | ||
|
||
# Given POOL and DATASET name for ZVOL | ||
# DEVICE_NAME for /dev/disk* | ||
# RAW_DEVICE_NAME for /dev/rdisk* | ||
# Create symlink in | ||
# /var/run/zfs/zvol/dsk/POOL/DATASET -> /dev/disk* | ||
# /var/run/zfs/zvol/rdsk/POOL/DATASET -> /dev/rdisk* | ||
|
||
ZVOL_ROOT="/var/run/zfs/zvol" | ||
|
||
rm -f "${ZVOL_ROOT}/rdsk/${ZEVENT_POOL}/${ZEVENT_VOLUME}" "${ZVOL_ROOT}/dsk/${ZEVENT_POOL}/${ZEVENT_VOLUME}" | ||
rmdir "$(dirname "${ZVOL_ROOT}/rdsk/${ZEVENT_POOL}/${ZEVENT_VOLUME}")" "$(dirname "${ZVOL_ROOT}/dsk/${ZEVENT_POOL}/${ZEVENT_VOLUME}")" | ||
|
||
logger -t "${ZED_SYSLOG_TAG:=zed}" -p "${ZED_SYSLOG_PRIORITY:=daemon.notice}" \ | ||
eid="${ZEVENT_EID}" class="${ZEVENT_SUBCLASS}" \ | ||
"${ZEVENT_POOL:+pool=$ZEVENT_POOL}/${ZEVENT_VOLUME} removed symlink" | ||
|
||
echo 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
#exit code 1 means no zfs file systems mounted | ||
|
||
echo "Mounted ZFS file system(s) check" | ||
myvar="$(2>/dev/null /usr/bin/lsvfs zfs | /usr/bin/tail -1 | /usr/bin/awk '{print $2}')" | ||
[ ! -z "${myvar##*[!0-9]*}" ] || exit 1 | ||
[ $myvar -ne 0 ] && exit 0 | ||
sysctl -n kstat.zfs.darwin.ldi.handle_count || exit 1 | ||
if [ x"$(sysctl -n kstat.zfs.darwin.ldi.handle_count)" != x"0" ]; then exit 0; fi | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
#exit code 1 means ZEVO is neither installed nor just uninstalled without reboot | ||
|
||
echo "ZEVO files check" | ||
ls /System/Library/Extensions/ZFSDriver.kext/ &>/dev/null && exit 0 | ||
ls /System/Library/Extensions/ZFSFilesystem.kext/ &>/dev/null && exit 0 | ||
ls /Library/LaunchDaemons/com.getgreenbytes* &>/dev/null && exit 0 | ||
|
||
echo "ZEVO launchctl check" | ||
/bin/launchctl list | grep greenbytes &>/dev/null | ||
[ $? -eq 0 ] && exit 0 | ||
|
||
echo "ZEVO kextstat check" | ||
/usr/sbin/kextstat | grep greenbytes &>/dev/null | ||
[ $? -eq 0 ] && exit 0 | ||
|
||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
# | ||
# Expected to be run from the root of the source tree, as root; | ||
# ./scripts/load_macos.sh | ||
# | ||
# Copies compiled zfs.kext to /tmp/ and prepares the requirements | ||
# for load. | ||
# | ||
|
||
rsync -ar module/os/macos/zfs.kext/ /tmp/zfs.kext/ | ||
|
||
chown -R root:wheel /tmp/zfs.kext | ||
|
||
kextload -v /tmp/zfs.kext || kextutil /tmp/zfs.kext | ||
|
||
# log stream --source --predicate 'sender == "zfs"' --style compact |
Oops, something went wrong.