Skip to content

glm.c: detect 9p via statfs f_type, not the /mnt/ path prefix#340

Merged
JustVugg merged 1 commit into
JustVugg:devfrom
tonuonu:fix/fs-detect-9p-statfs
Jul 17, 2026
Merged

glm.c: detect 9p via statfs f_type, not the /mnt/ path prefix#340
JustVugg merged 1 commit into
JustVugg:devfrom
tonuonu:fix/fs-detect-9p-statfs

Conversation

@tonuonu

@tonuonu tonuonu commented Jul 17, 2026

Copy link
Copy Markdown

Problem

The slow-filesystem warning at model load fires for any model path under /mnt/:

if(!strncmp(snap,"/mnt/",5))
    fprintf(stderr,"WARNING: the model is on %s (slow 9p/Windows filesystem; fadvise is ineffective).\n"
                   "         Keep it on ext4 (for example, /home/...) ...", snap);

The intent is to catch WSL, where Windows drives (/mnt/c, …) are slow 9p mounts. But /mnt/ is also a perfectly normal mount point on native Linux — ZFS/ext4/xfs/NFS pools commonly live there. On such a box this is a false positive that tells users their fast local storage is slow.

Repro: put the model on a native-Linux mount under /mnt (e.g. a ZFS pool at /mnt/data) → WARNING: ... slow 9p/Windows filesystem ... even though it's fast local storage.

Fix

Check the actual filesystem type via statfs() against the 9p superblock magic (0x01021997) instead of guessing from the path. Linux-only (<sys/vfs.h>); no change on macOS/Windows. A real WSL /mnt/c (9p) still warns; native /mnt/* (ZFS 0x2fc12fc1, ext4 0xef53, xfs, NFS…) no longer does.

Test

Native-Linux box, model on a ZFS pool at /mnt/data:

  • Before: WARNING: ... slow 9p/Windows filesystem ...
  • After: no warning. statfs("/mnt/data").f_type == 0x2fc12fc1 (ZFS) ≠ 0x01021997 (9p). Builds clean (make glm).

+13 −3, single file.

The slow-filesystem warning fired for any model path under /mnt/, which
false-positives on native-Linux mounts (ZFS/ext4/xfs/NFS) that commonly
live there. Check the actual filesystem type via statfs() against the 9p
superblock magic (0x01021997) instead, so it only warns for a genuine
WSL 9p mount. Linux-only (statfs); no behavior change on other platforms.
@JustVugg
JustVugg changed the base branch from main to dev July 17, 2026 17:19
@JustVugg
JustVugg merged commit 59d74ae into JustVugg:dev Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants