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/etc/init.d/zfs-mount.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 #!@DEFAULT_INIT_SHELL@
    2 # shellcheck disable=SC2154
    3 #
    4 # zfs-mount     This script will mount/umount the zfs filesystems.
    5 #
    6 # chkconfig:    2345 06 99
    7 # description:  This script will mount/umount the zfs filesystems during
    8 #               system boot/shutdown. Configuration of which filesystems
    9 #               should be mounted is handled by the zfs 'mountpoint' and
   10 #               'canmount' properties. See the zfs(8) man page for details.
   11 #               It is also responsible for all userspace zfs services.
   12 # probe: true
   13 #
   14 ### BEGIN INIT INFO
   15 # Provides:          zfs-mount
   16 # Required-Start:    zfs-import
   17 # Required-Stop:     $local_fs zfs-import
   18 # Default-Start:     S
   19 # Default-Stop:      0 1 6
   20 # X-Start-Before:    mountall
   21 # X-Stop-After:      zfs-zed
   22 # Short-Description: Mount ZFS filesystems and volumes
   23 # Description: Run the `zfs mount -a` or `zfs umount -a` commands.
   24 ### END INIT INFO
   25 #
   26 # Released under the 2-clause BSD license.
   27 #
   28 # This script is based on debian/zfsutils.zfs.init from the
   29 # Debian GNU/kFreeBSD zfsutils 8.1-3 package, written by Aurelien Jarno.
   30 
   31 # Source the common init script
   32 . @sysconfdir@/zfs/zfs-functions
   33 
   34 # ----------------------------------------------------
   35 
   36 chkroot() {
   37         while read -r _ mp _; do
   38                 if [ "$mp" = "/" ]; then
   39                         return 0
   40                 fi
   41         done < /proc/self/mounts
   42 
   43         return 1
   44 }
   45 
   46 do_depend()
   47 {
   48         # Try to allow people to mix and match fstab with ZFS in a way that makes sense.
   49         if [ "$(mountinfo -s /)" = 'zfs' ]
   50         then
   51                 before localmount
   52         else
   53                 after localmount
   54         fi
   55 
   56         # bootmisc will log to /var which may be a different zfs than root.
   57         before bootmisc logger
   58 
   59         after zfs-import sysfs
   60         use mtab
   61         keyword -lxc -openvz -prefix -vserver
   62 }
   63 
   64 # Mount all datasets/filesystems
   65 do_mount()
   66 {
   67         local verbose overlay
   68 
   69         check_boolean "$VERBOSE_MOUNT" && verbose=v
   70         check_boolean "$DO_OVERLAY_MOUNTS" && overlay=O
   71 
   72         zfs_action "Mounting ZFS filesystem(s)" \
   73             "$ZFS" mount "-a$verbose$overlay" "$MOUNT_EXTRA_OPTIONS"
   74 
   75         return 0
   76 }
   77 
   78 # Unmount all filesystems
   79 do_unmount()
   80 {
   81         # This shouldn't really be necessary, as long as one can get
   82         # zfs-import to run sufficiently late in the shutdown/reboot process
   83         # - after unmounting local filesystems. This is just here in case/if
   84         # this isn't possible.
   85         zfs_action "Unmounting ZFS filesystems" "$ZFS" unmount -a
   86 
   87         return 0
   88 }
   89 
   90 do_start()
   91 {
   92         check_boolean "$ZFS_MOUNT" || exit 0
   93 
   94         check_module_loaded "zfs" || exit 0
   95 
   96         # Ensure / exists in /proc/self/mounts.
   97         # This should be handled by rc.sysinit but lets be paranoid.
   98         if ! chkroot
   99         then
  100                 mount -f /
  101         fi
  102 
  103         do_mount
  104 }
  105 
  106 do_stop()
  107 {
  108         check_boolean "$ZFS_UNMOUNT" || exit 0
  109 
  110         check_module_loaded "zfs" || exit 0
  111 
  112         do_unmount
  113 }
  114 
  115 # ----------------------------------------------------
  116 
  117 if [ ! -e /sbin/openrc-run ]
  118 then
  119         case "$1" in
  120                 start)
  121                         do_start
  122                         ;;
  123                 stop)
  124                         do_stop
  125                         ;;
  126                 force-reload|condrestart|reload|restart|status)
  127                         # no-op
  128                         ;;
  129                 *)
  130                         [ -n "$1" ] && echo "Error: Unknown command $1."
  131                         echo "Usage: $0 {start|stop}"
  132                         exit 3
  133                         ;;
  134         esac
  135 
  136         exit $?
  137 else
  138         # Create wrapper functions since Gentoo don't use the case part.
  139         depend() { do_depend; }
  140         start() { do_start; }
  141         stop() { do_stop; }
  142 fi

Cache object: 17bb77af88f2e92ad92c63a59a924d16


[ 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.