mountpoint-util: make name_to_handle_at_loop() gracefully handle NULL path

This commit is contained in:
Yu Watanabe
2026-02-04 00:07:02 +09:00
parent 055ceec666
commit 09811ccaa1
+6 -1
View File
@@ -63,6 +63,11 @@ int name_to_handle_at_loop(
* This improves on raw name_to_handle_at() also in one other regard: ret_handle and ret_mnt_id can be passed
* as NULL if there's no interest in either. */
if (isempty(path)) {
flags |= AT_EMPTY_PATH;
path = "";
}
for (;;) {
_cleanup_free_ struct file_handle *h = NULL;
int mnt_id = -1;
@@ -73,7 +78,7 @@ int name_to_handle_at_loop(
h->handle_bytes = n;
if (name_to_handle_at(fd, strempty(path), h, &mnt_id, flags) >= 0) {
if (name_to_handle_at(fd, path, h, &mnt_id, flags) >= 0) {
if (ret_handle)
*ret_handle = TAKE_PTR(h);