]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mountpoint-util: make name_to_handle_at_loop() gracefully handle NULL path
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 3 Feb 2026 15:07:02 +0000 (00:07 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 3 Feb 2026 15:07:02 +0000 (00:07 +0900)
src/basic/mountpoint-util.c

index 9c04d381f392f4536b7d65dda57f5d6e1089150b..3bb82ef239bfa1351dc07aeee21b2a3b0c3f2378 100644 (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);