The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/cmd/zed/zed.d/history_event-zfs-list-cacher.sh.in

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #!/bin/sh
    2 # shellcheck disable=SC2154
    3 #
    4 # Track changes to enumerated pools for use in early-boot
    5 set -ef
    6 
    7 FSLIST="@sysconfdir@/zfs/zfs-list.cache/${ZEVENT_POOL}"
    8 FSLIST_TMP="@runstatedir@/zfs-list.cache@${ZEVENT_POOL}"
    9 
   10 # If the pool specific cache file is not writeable, abort
   11 [ -w "${FSLIST}" ] || exit 0
   12 
   13 [ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
   14 . "${ZED_ZEDLET_DIR}/zed-functions.sh"
   15 
   16 [ "$ZEVENT_SUBCLASS" != "history_event" ] && exit 0
   17 zed_check_cmd "${ZFS}" sort diff
   18 
   19 # If we are acting on a snapshot, we have nothing to do
   20 [ "${ZEVENT_HISTORY_DSNAME%@*}" = "${ZEVENT_HISTORY_DSNAME}" ] || exit 0
   21 
   22 # We lock the output file to avoid simultaneous writes.
   23 # If we run into trouble, log and drop the lock
   24 abort_alter() {
   25   zed_log_msg "Error updating zfs-list.cache for ${ZEVENT_POOL}!"
   26   zed_unlock "${FSLIST}"
   27 }
   28 
   29 finished() {
   30   zed_unlock "${FSLIST}"
   31   trap - EXIT
   32   exit 0
   33 }
   34 
   35 case "${ZEVENT_HISTORY_INTERNAL_NAME}" in
   36     create|"finish receiving"|import|destroy|rename)
   37       ;;
   38 
   39     export)
   40         zed_lock "${FSLIST}"
   41         trap abort_alter EXIT
   42         echo > "${FSLIST}"
   43         finished
   44       ;;
   45 
   46     set|inherit)
   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 \
   55             ) ;;
   56             *) exit 0 ;;
   57         esac
   58       ;;
   59 
   60     *)
   61         # Ignore all other events.
   62         exit 0
   63       ;;
   64 esac
   65 
   66 zed_lock "${FSLIST}"
   67 trap abort_alter EXIT
   68 
   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"
   75 
   76 "${ZFS}" list -H -t filesystem -o "${PROPS}" -r "${ZEVENT_POOL}" > "${FSLIST_TMP}"
   77 
   78 # Sort the output so that it is stable
   79 sort "${FSLIST_TMP}" -o "${FSLIST_TMP}"
   80 
   81 # Don't modify the file if it hasn't changed
   82 diff -q "${FSLIST_TMP}" "${FSLIST}" || cat "${FSLIST_TMP}" > "${FSLIST}"
   83 rm -f "${FSLIST_TMP}"
   84 
   85 finished

Cache object: 9af5696e4d8ea56856e7deebb674c456


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.