]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lib/loopdev: introduce loopcxt_get_device_nr() helper
authorKarel Zak <kzak@redhat.com>
Thu, 16 Oct 2025 09:42:03 +0000 (11:42 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 21 Oct 2025 09:17:47 +0000 (11:17 +0200)
commit04619aacdb31ecdf451f07fa2cf93b67387c1638
treeb4b2f9f02243ae030f4aaa21ca98c002e20ea854
parent7b62b2dd72d4f004e66234cc63abf8da94e1926e
lib/loopdev: introduce loopcxt_get_device_nr() helper

Add a new static helper function loopcxt_get_device_nr() to extract
the loop device number from the device path. This eliminates code
duplication in loopcxt_remove_device() and loopcxt_add_device().

The helper function supports both /dev/loop<N> and /dev/loop/<N>
formats and provides consistent error handling with debug logging.

Signed-off-by: Karel Zak <kzak@redhat.com>
lib/loopdev.c