/lib/udev/bilibop_disk is in bilibop-rules 0.4.20.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | #!/bin/sh
# vim: set et ts=4 sts=4 sw=4:
# /lib/udev/bilibop_disk {{{
# This script must be called from /lib/udev/rules.d/66-bilibop.rules
# (or any other udev rules filename).
#
# Usage:
# PROGRAM=="bilibop_disk [OPTION] %r/%k"
# RUN+="bilibop_disk [OPTION] %r/%k"
#
# with options:
# -d, --disk
# -h, --hide
# -i, --icon
# -l, --lock
# -n, --name
# -p, --part
# -r, --root
# -t, --test
# No option is the same as --test.
# }}}
PATH="/bin"
device=""
option="test"
for arg
do
case "${arg}" in
-d|--disk) option="disk" ;;
-h|--hide) option="hide" ;;
-i|--icon) option="icon" ;;
-l|--lock) option="lock" ;;
-n|--name) option="name" ;;
-p|--part) option="part" ;;
-r|--root) option="root" ;;
-t|--test) option="test" ;;
/*) device="$arg" ;;
-*) exit 99 ;;
esac
done
# Check if the block device given as argument exists, or go away.
[ -b "${device}" ] || exit 3
udev_root="${device%/*}" # dirname
node_name="${device##*/}" # basename
# Load bilibop shell functions
. /lib/bilibop/rules.sh
# Avoid running some functions if not necessary; take care with the exit code.
case "${option}" in
hide)
[ "${BILIBOP_RULES_PRESENTATION_HIDE}" = "false" ] && exit 1
;;
lock)
[ "${BILIBOP_RULES_SYSTEM_INTERNAL}" = "false" ] && exit 1
;;
esac
# Set BILIBOP_DISK. If a link to the physical hard disk already exists, follow
# it to know the device name. Otherwise, find it with the bilibop functions.
[ -h ${udev_root}/${BILIBOP_COMMON_BASENAME}/disk ] &&
BILIBOP_DISK="$(readlink -f ${udev_root}/${BILIBOP_COMMON_BASENAME}/disk)" ||
BILIBOP_DISK="$(physical_hard_disk /)"
### RUN NOW ###
case "${option}" in
test)
[ "$(physical_hard_disk ${device})" = "${BILIBOP_DISK}" ] || exit 1
;;
disk)
echo "${BILIBOP_COMMON_BASENAME}/disk"
;;
root)
[ -h ${udev_root}/${BILIBOP_COMMON_BASENAME}/part ] &&
BILIBOP_PART="$(readlink -f ${udev_root}/${BILIBOP_COMMON_BASENAME}/part)" ||
BILIBOP_PART="$(underlying_partition /)"
[ "${BILIBOP_PART}" = "${device}" ] &&
echo "${BILIBOP_COMMON_BASENAME}/part"
[ -h ${udev_root}/${BILIBOP_COMMON_BASENAME}/root ] &&
BILIBOP_ROOT="$(readlink -f ${udev_root}/${BILIBOP_COMMON_BASENAME}/root)" ||
BILIBOP_ROOT="$(underlying_device_from_file /)"
[ "${BILIBOP_ROOT}" = "${device}" ] &&
echo "${BILIBOP_COMMON_BASENAME}/root"
;;
part)
underlying_partition "${device}"
;;
lock)
_udisks_system_internal || exit 1
;;
hide)
_udisks_presentation_hide || exit 1
;;
icon)
_udisks_presentation_icon || exit 1
;;
name)
_udisks_presentation_name || exit 1
;;
esac
exit 0
|