2018-04-06 21:11:09 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Track changes to enumerated pools for use in early-boot
|
|
|
|
set -ef
|
|
|
|
|
|
|
|
FSLIST_DIR="@sysconfdir@/zfs/zfs-list.cache"
|
|
|
|
FSLIST_TMP="@runstatedir@/zfs-list.cache.new"
|
|
|
|
FSLIST="${FSLIST_DIR}/${ZEVENT_POOL}"
|
|
|
|
|
|
|
|
# If the pool specific cache file is not writeable, abort
|
|
|
|
[ -w "${FSLIST}" ] || exit 0
|
|
|
|
|
|
|
|
[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
|
|
|
|
. "${ZED_ZEDLET_DIR}/zed-functions.sh"
|
|
|
|
|
2020-12-18 17:34:10 +00:00
|
|
|
[ "$ZEVENT_SUBCLASS" != "history_event" ] && exit 0
|
2021-04-23 20:41:47 +00:00
|
|
|
zed_check_cmd "${ZFS}" sort diff
|
2018-04-06 21:11:09 +00:00
|
|
|
|
|
|
|
# If we are acting on a snapshot, we have nothing to do
|
2021-04-23 20:41:47 +00:00
|
|
|
[ "${ZEVENT_HISTORY_DSNAME%@*}" = "${ZEVENT_HISTORY_DSNAME}" ] || exit 0
|
2018-04-06 21:11:09 +00:00
|
|
|
|
|
|
|
# We obtain a lock on zfs-list to avoid any simultaneous writes.
|
|
|
|
# If we run into trouble, log and drop the lock
|
|
|
|
abort_alter() {
|
|
|
|
zed_log_msg "Error updating zfs-list.cache!"
|
|
|
|
zed_unlock zfs-list
|
|
|
|
}
|
|
|
|
|
|
|
|
finished() {
|
|
|
|
zed_unlock zfs-list
|
|
|
|
trap - EXIT
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
case "${ZEVENT_HISTORY_INTERNAL_NAME}" in
|
|
|
|
create|"finish receiving"|import|destroy|rename)
|
|
|
|
;;
|
|
|
|
|
|
|
|
export)
|
|
|
|
zed_lock zfs-list
|
|
|
|
trap abort_alter EXIT
|
|
|
|
echo > "${FSLIST}"
|
|
|
|
finished
|
|
|
|
;;
|
|
|
|
|
|
|
|
set|inherit)
|
2018-05-11 19:44:14 +00:00
|
|
|
# Only act if one of the tracked properties is altered.
|
|
|
|
case "${ZEVENT_HISTORY_INTERNAL_STR%%=*}" in
|
2020-02-12 17:01:15 +00:00
|
|
|
canmount|mountpoint|atime|relatime|devices|exec|readonly| \
|
|
|
|
setuid|nbmand|encroot|keylocation|org.openzfs.systemd:requires| \
|
|
|
|
org.openzfs.systemd:requires-mounts-for| \
|
|
|
|
org.openzfs.systemd:before|org.openzfs.systemd:after| \
|
|
|
|
org.openzfs.systemd:wanted-by|org.openzfs.systemd:required-by| \
|
|
|
|
org.openzfs.systemd:nofail|org.openzfs.systemd:ignore \
|
|
|
|
) ;;
|
2018-04-06 21:11:09 +00:00
|
|
|
*) exit 0 ;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
# Ignore all other events.
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
zed_lock zfs-list
|
|
|
|
trap abort_alter EXIT
|
|
|
|
|
2020-02-12 17:01:15 +00:00
|
|
|
PROPS="name,mountpoint,canmount,atime,relatime,devices,exec\
|
|
|
|
,readonly,setuid,nbmand,encroot,keylocation\
|
|
|
|
,org.openzfs.systemd:requires,org.openzfs.systemd:requires-mounts-for\
|
|
|
|
,org.openzfs.systemd:before,org.openzfs.systemd:after\
|
|
|
|
,org.openzfs.systemd:wanted-by,org.openzfs.systemd:required-by\
|
|
|
|
,org.openzfs.systemd:nofail,org.openzfs.systemd:ignore"
|
2018-05-11 19:44:14 +00:00
|
|
|
|
|
|
|
"${ZFS}" list -H -t filesystem -o $PROPS -r "${ZEVENT_POOL}" > "${FSLIST_TMP}"
|
2018-04-06 21:11:09 +00:00
|
|
|
|
|
|
|
# Sort the output so that it is stable
|
|
|
|
sort "${FSLIST_TMP}" -o "${FSLIST_TMP}"
|
|
|
|
|
|
|
|
# Don't modify the file if it hasn't changed
|
|
|
|
diff -q "${FSLIST_TMP}" "${FSLIST}" || mv "${FSLIST_TMP}" "${FSLIST}"
|
|
|
|
rm -f "${FSLIST_TMP}"
|
|
|
|
|
|
|
|
finished
|