diff mbox series

utils: is_path_on_nfs: strip not existing path

Message ID 20260212172327.14204-2-quaresma.jose@gmail.com
State New
Headers show
Series utils: is_path_on_nfs: strip not existing path | expand

Commit Message

Jose Quaresma Feb. 12, 2026, 5:23 p.m. UTC
From: Jose Quaresma <jose.quaresma@oss.qualcomm.com>

When the user provide a path that does not exist it fails with:
| stat: cannot read file system information for '/path/to/my/hashserve': No such file or directory

We can strip the non exising part in the path and pass just that to the stat.

Signed-off-by: Jose Quaresma <jose.quaresma@oss.qualcomm.com>
---
 lib/bb/utils.py | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 974611bc7..b2bda08cb 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -2269,6 +2269,11 @@  def is_path_on_nfs(path):
     """
     Returns True if ``path`` argument is on a NFS mount.
     """
+    # strip not existing path
+    if os.path.isabs(path):
+        while not os.path.exists(path):
+            path = os.path.dirname(path)
+
     import bb.process
     fstype = bb.process.run("stat -f -c %T {}".format(path))[0].strip()
     return fstype == "nfs"