Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new device API #111

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions udev/udev-block-add-change
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,18 @@ if [ -n "$DM_NAME" ]; then
DESC="$DM_NAME"
fi

if [ -f /sys$DEVPATH/partition ]; then
parent=$(basename "$(dirname "$DEVPATH")")
elif echo "$DEVPATH" | grep -q '/host'; then
parent=$(basename "$(sed 's|/host.*$||' <<< "$DEVPATH")")
fi

# The last one is meant to trigger watches
qubesdb-write \
"$QDB_KEY/desc" "$DESC" \
"$QDB_KEY/size" "$SIZE" \
"$QDB_KEY/mode" "$MODE" \
"$QDB_KEY/parent" "$parent" \
/qubes-block-devices ''

# Make sure that block backend is loaded
Expand Down
1 change: 1 addition & 0 deletions udev/udev-block-remove
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ QDB_KEY="/qubes-block-devices/$NAME"
# Trailing slash is intentional - it will remove the whole directory, instead of
# a single base entry
qubesdb-rm "$QDB_KEY/"
# This is meant to trigger watches
qubesdb-write /qubes-block-devices ''

if [ -r /run/qubes/block-slave-cache-$NAME ]; then
Expand Down
16 changes: 8 additions & 8 deletions udev/udev-usb-add-change
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
# qubesdb doesn't allow dot in key name
XSNAME=`basename ${DEVPATH} | tr . _`

# FIXME: For some devices (my Cherry keyboard) ID_SERIAL does not
# contain proper human-readable name, should find better method to
# build devide description.
#DESC=`python -c "dev='%d-%d' % (int('${BUSNUM}'.lstrip('0')), (int('${DEVNUM}'.lstrip('0'))-1)); from xen.util import vusb_util; print vusb_util.get_usbdevice_info(dev);"`
DESC="${ID_VENDOR_ID}:${ID_MODEL_ID} ${ID_SERIAL}"
# in general ID_SERIAL = "${ID_VENDOR}_${ID_MODEL}_${ID_SERIAL_SHORT}"
DESC="${ID_VENDOR_ID}:${ID_MODEL_ID} ${ID_VENDOR_ENC} ${ID_MODEL_ENC} ${ID_SERIAL_SHORT}"

VERSION=`cat /sys/$DEVPATH/version | tr -d ' '|cut -f 1 -d .`

Expand All @@ -31,9 +28,12 @@ fi

QDB_KEY="/qubes-usb-devices/$XSNAME"

qubesdb-write "$QDB_KEY/desc" "$DESC"
qubesdb-write "$QDB_KEY/usb-ver" "$VERSION"
qubesdb-write /qubes-usb-devices ''
# The last one is meant to trigger watches
qubesdb-write \
"$QDB_KEY/desc" "$DESC" \
"$QDB_KEY/usb-ver" "$VERSION" \
"$QDB_KEY/interfaces" "$ID_USB_INTERFACES" \
/qubes-usb-devices ''

# Make sure PVUSB backend driver is loaded.
/sbin/modprobe xen-usbback 2> /dev/null || true
1 change: 1 addition & 0 deletions udev/udev-usb-remove
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ NAME=`basename ${DEVPATH} | tr . _`
QDB_KEY="/qubes-usb-devices/$NAME/"

qubesdb-rm "$QDB_KEY"
# This is meant to trigger watches
qubesdb-write /qubes-usb-devices ''