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/zpool/zpool.d/model

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 #
    3 # Print some common lsblk values
    4 #
    5 # Any (lowercased) name symlinked to the lsblk script will be passed to lsblk
    6 # as one of its --output names.  Here's a partial list of --output names
    7 # from the lsblk binary:
    8 #
    9 # Available columns (for --output):
   10 #        NAME  device name
   11 #       KNAME  internal kernel device name
   12 #     MAJ:MIN  major:minor device number
   13 #      FSTYPE  filesystem type
   14 #  MOUNTPOINT  where the device is mounted
   15 #       LABEL  filesystem LABEL
   16 #        UUID  filesystem UUID
   17 #          RA  read-ahead of the device
   18 #          RO  read-only device
   19 #          RM  removable device
   20 #       MODEL  device identifier
   21 #        SIZE  size of the device
   22 #       STATE  state of the device
   23 #       OWNER  user name
   24 #       GROUP  group name
   25 #        MODE  device node permissions
   26 #   ALIGNMENT  alignment offset
   27 #      MIN-IO  minimum I/O size
   28 #      OPT-IO  optimal I/O size
   29 #     PHY-SEC  physical sector size
   30 #     LOG-SEC  logical sector size
   31 #        ROTA  rotational device
   32 #       SCHED  I/O scheduler name
   33 #     RQ-SIZE  request queue size
   34 #        TYPE  device type
   35 #    DISC-ALN  discard alignment offset
   36 #   DISC-GRAN  discard granularity
   37 #    DISC-MAX  discard max bytes
   38 #   DISC-ZERO  discard zeroes data
   39 #
   40 # If the script is run as just 'lsblk' then print out disk size, vendor,
   41 # and model number.
   42 
   43 
   44 helpstr="
   45 label:  Show filesystem label.
   46 model:  Show disk model number.
   47 size:   Show the disk capacity.
   48 vendor: Show the disk vendor.
   49 lsblk:  Show the disk size, vendor, and model number."
   50 
   51 script="${0##*/}"
   52 
   53 if [ "$1" = "-h" ] ; then
   54         echo "$helpstr" | grep "$script:" | tr -s '\t' | cut -f 2-
   55         exit
   56 fi
   57 
   58 if [ "$script" = "lsblk" ] ; then
   59         list="size vendor model"
   60 else
   61         list=$(echo "$script" | tr '[:upper:]' '[:lower:]')
   62 fi
   63 
   64 # Sometimes, UPATH ends up /dev/(null).
   65 # That should be corrected, but for now...
   66 # shellcheck disable=SC2154
   67 if [ ! -b "$VDEV_UPATH" ]; then
   68         somepath="${VDEV_PATH}"
   69 else
   70         somepath="${VDEV_UPATH}"
   71 fi
   72 
   73 # Older versions of lsblk don't support all these values (like SERIAL).
   74 for i in $list ; do
   75 
   76         # Special case: Looking up the size of a file-based vdev can't
   77         # be done with lsblk.
   78         if [ "$i" = "size" ] && [ -f "$somepath" ] ; then
   79                 size=$(du -h --apparent-size "$somepath" | cut -f 1)
   80                 echo "size=$size"
   81                 continue
   82         fi
   83 
   84 
   85         val=""
   86         if val=$(eval "lsblk -dl -n -o $i $somepath 2>/dev/null") ; then
   87                 # Remove leading/trailing whitespace from value
   88                 val=$(echo "$val" | sed -e 's/^[[:space:]]*//' \
   89                      -e 's/[[:space:]]*$//')
   90         fi
   91         echo "$i=$val"
   92 done

Cache object: 38cccc1ebdbaa8465bfe1e3e6ff8e028


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