2 # shellcheck disable=SC2154
4 # Track changes to enumerated pools for use in early-boot
7 FSLIST
="@sysconfdir@/zfs/zfs-list.cache/${ZEVENT_POOL}"
8 FSLIST_TMP
="@runstatedir@/zfs-list.cache@${ZEVENT_POOL}"
10 # If the pool specific cache file is not writeable, abort
11 [ -w "${FSLIST}" ] ||
exit 0
13 [ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && .
"${ZED_ZEDLET_DIR}/zed.rc"
14 .
"${ZED_ZEDLET_DIR}/zed-functions.sh"
16 [ "$ZEVENT_SUBCLASS" != "history_event" ] && exit 0
17 zed_check_cmd
"${ZFS}" sort diff
19 # If we are acting on a snapshot, we have nothing to do
20 [ "${ZEVENT_HISTORY_DSNAME%@*}" = "${ZEVENT_HISTORY_DSNAME}" ] ||
exit 0
22 # We lock the output file to avoid simultaneous writes.
23 # If we run into trouble, log and drop the lock
25 zed_log_msg
"Error updating zfs-list.cache for ${ZEVENT_POOL}!"
26 zed_unlock
"${FSLIST}"
30 zed_unlock
"${FSLIST}"
35 case "${ZEVENT_HISTORY_INTERNAL_NAME}" in
36 create|
"finish receiving"|import|destroy|rename
)
47 # Only act if one of the tracked properties is altered.
48 case "${ZEVENT_HISTORY_INTERNAL_STR%%=*}" in
49 canmount|mountpoint|atime|relatime|devices|
exec|
readonly| \
50 setuid|nbmand|encroot|keylocation|org.openzfs.systemd
:requires| \
51 org.openzfs.systemd
:requires-mounts-for| \
52 org.openzfs.systemd
:before|org.openzfs.systemd
:after| \
53 org.openzfs.systemd
:wanted-by|org.openzfs.systemd
:required-by| \
54 org.openzfs.systemd
:nofail|org.openzfs.systemd
:ignore \
61 # Ignore all other events.
69 PROPS
="name,mountpoint,canmount,atime,relatime,devices,exec\
70 ,readonly,setuid,nbmand,encroot,keylocation\
71 ,org.openzfs.systemd:requires,org.openzfs.systemd:requires-mounts-for\
72 ,org.openzfs.systemd:before,org.openzfs.systemd:after\
73 ,org.openzfs.systemd:wanted-by,org.openzfs.systemd:required-by\
74 ,org.openzfs.systemd:nofail,org.openzfs.systemd:ignore"
76 "${ZFS}" list -H -t filesystem -o "${PROPS}" -r "${ZEVENT_POOL}" > "${FSLIST_TMP}"
78 # Sort the output so that it is stable
79 sort "${FSLIST_TMP}" -o "${FSLIST_TMP}"
81 # Don't modify the file if it hasn't changed
82 diff -q "${FSLIST_TMP}" "${FSLIST}" || cat "${FSLIST_TMP}" > "${FSLIST}"