Skip to content

Commit

Permalink
fix: Make root partition fstype detection compatible with macOS using…
Browse files Browse the repository at this point in the history
… psutil (#1728)
  • Loading branch information
achimnol authored Nov 22, 2023
1 parent d8c9622 commit 2143f7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions changes/1728.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make root partition filesystem type detection compatible with macOS using psutil
12 changes: 4 additions & 8 deletions src/ai/backend/common/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import aiodns
import ifaddr
import psutil

from .utils import curl

Expand Down Expand Up @@ -98,14 +99,9 @@ def fetch_local_ipaddrs(cidr: BaseIPNetwork) -> Iterable[BaseIPAddress]:


def get_root_fs_type() -> tuple[PosixPath, str]:
with open(Path("/proc/mounts"), "r") as f:
for line in f:
fields = line.split()
if line.startswith("#"):
continue
if len(fields) < 3 or fields[1] != "/":
continue
return PosixPath(fields[0]), fields[2]
for partition in psutil.disk_partitions():
if partition.mountpoint == "/":
return PosixPath(partition.device), partition.fstype
raise RuntimeError("Could not find the root filesystem from the mounts.")


Expand Down

0 comments on commit 2143f7c

Please sign in to comment.