From 0a05da0bbcd40a405aba703ee4e6702e49595e8f Mon Sep 17 00:00:00 2001 From: Renata Ravanelli Date: Tue, 1 Aug 2023 16:20:07 -0300 Subject: [PATCH] Replace xxd with dd for google_nvme_id (#56) * Replace xxd with dd for google_nvme_id `google_nvme_id` script currently uses `xxd` to parse nvme device info, but we need to install additional package `xxd` for fedora, `vim-common` and `vim-filesystem` for centos (or rhel) before using it. Replace it with `dd` and we do not need to install additional packages. See coreos/fedora-coreos-config#2412 (comment) We initially tried to replace it with cut, creating a different result than expected. See: #49 Discussion about the use of `dd`vs `cut`. Tests for Fedora CoreOS: ``` nvme id-ns -b /dev/nvme0n1 | xxd -p --seek 384 | xxd -p -r | od -x 0000000 227b 6564 6976 6563 6e5f 6d61 2265 223a 0000020 6570 7372 7369 6574 746e 642d 7369 2d6b 0000040 2230 222c 6964 6b73 745f 7079 2265 223a 0000060 4550 5352 5349 4554 544e 7d22 0000 0000 0000100 0000 0000 0000 0000 0000 0000 0000 0000 * 0007200 nvme id-ns -b /dev/nvme0n1 | dd bs=1 skip=384 2>/dev/null | od -x 0000000 227b 6564 6976 6563 6e5f 6d61 2265 223a 0000020 6570 7372 7369 6574 746e 642d 7369 2d6b 0000040 2230 222c 6964 6b73 745f 7079 2265 223a 0000060 4550 5352 5349 4554 544e 7d22 0000 0000 0000100 0000 0000 0000 0000 0000 0000 0000 0000 * 0007200 ``` Tests for Debian 12 ``` nvme id-ns -b /dev/nvme0n1 | dd bs=1 skip=384 2>/dev/null | od -x 0000000 227b 6564 6976 6563 6e5f 6d61 2265 223a 0000020 6f6c 6163 2d6c 766e 656d 732d 6473 312d 0000040 2c22 6422 7369 5f6b 7974 6570 3a22 4c22 0000060 434f 4c41 535f 4453 7d22 0000 0000 0000 0000100 0000 0000 0000 0000 0000 0000 0000 0000 * 0007200 nvme id-ns -b /dev/nvme0n1 | dd bs=1 skip=384 2>/dev/null | od -x 0000000 227b 6564 6976 6563 6e5f 6d61 2265 223a 0000020 6f6c 6163 2d6c 766e 656d 732d 6473 312d 0000040 2c22 6422 7369 5f6b 7974 6570 3a22 4c22 0000060 434f 4c41 535f 4453 7d22 0000 0000 0000 0000100 0000 0000 0000 0000 0000 0000 0000 0000 * 0007200 ``` Signed-off-by: Renata Ravanelli * Revert "debian packaging: add xxd dependency (#55)" This reverts commit 480f02ae10195412089c133be4a36c19665d6a05. --- packaging/debian/control | 1 - src/lib/udev/google_nvme_id | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packaging/debian/control b/packaging/debian/control index aba41a8..9bf6f87 100644 --- a/packaging/debian/control +++ b/packaging/debian/control @@ -11,7 +11,6 @@ Architecture: all Depends: google-compute-engine-oslogin, google-guest-agent, nvme-cli, - xxd, ${misc:Depends} Recommends: rsyslog | system-log-daemon Provides: irqbalance diff --git a/src/lib/udev/google_nvme_id b/src/lib/udev/google_nvme_id index fc4b047..ef02963 100755 --- a/src/lib/udev/google_nvme_id +++ b/src/lib/udev/google_nvme_id @@ -58,7 +58,7 @@ function err() { ####################################### function get_namespace_device_name() { local nvme_json - nvme_json="$("$nvme_cli_bin" id-ns -b "$1" | xxd -p -seek 384 | xxd -p -r)" + nvme_json="$("$nvme_cli_bin" id-ns -b "$1" | dd bs=1 skip=384 2>/dev/null)" if [[ $? -ne 0 ]]; then return 1 fi