Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 43 additions & 4 deletions src/utils/system-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,58 @@ function discoverContainerMounts(isContainer: boolean): DockerMount[] {
const mountsContent = fs.readFileSync('/proc/mounts', 'utf8');
const mountLines = mountsContent.split('\n');

// System filesystem types that are never user mounts
const systemFsTypes = new Set([
'overlay', 'tmpfs', 'proc', 'sysfs', 'devpts', 'cgroup', 'cgroup2',
'mqueue', 'debugfs', 'securityfs', 'pstore', 'configfs', 'fusectl',
'hugetlbfs', 'autofs', 'devtmpfs', 'bpf', 'tracefs', 'shm'
]);

// Filesystem types that indicate host mounts
const hostMountFsTypes = new Set(['fakeowner', '9p', 'virtiofs', 'fuse.sshfs']);

for (const line of mountLines) {
const parts = line.split(' ');
if (parts.length >= 4) {
const device = parts[0];
const mountPoint = parts[1];
const fsType = parts[2];
const options = parts[3];

// Look for user mounts (skip system mounts)
if (mountPoint.startsWith('/mnt/') ||
// Skip system mount points
const isSystemMountPoint =
mountPoint === '/' ||
mountPoint.startsWith('/dev') ||
mountPoint.startsWith('/sys') ||
mountPoint.startsWith('/proc') ||
mountPoint.startsWith('/run') ||
mountPoint.startsWith('/sbin') ||
mountPoint === '/etc/resolv.conf' ||
mountPoint === '/etc/hostname' ||
mountPoint === '/etc/hosts';

if (isSystemMountPoint) {
continue;
}

// Detect user mounts by:
// 1. Known host-mount filesystem types (fakeowner, 9p, virtiofs)
// 2. Device from /run/host_mark/ (docker-mcp-gateway pattern)
// 3. Non-system filesystem type with user-like mount point
const isHostMountFs = hostMountFsTypes.has(fsType);
const isHostMarkDevice = device.startsWith('/run/host_mark/');
const isNonSystemFs = !systemFsTypes.has(fsType);
const isUserLikePath = mountPoint.startsWith('/mnt/') ||
mountPoint.startsWith('/workspace') ||
mountPoint.startsWith('/data/') ||
(mountPoint.startsWith('/home/') && !mountPoint.startsWith('/home/root'))) {

mountPoint.startsWith('/home/') ||
mountPoint.startsWith('/Users/') ||
mountPoint.startsWith('/app/') ||
mountPoint.startsWith('/project/') ||
mountPoint.startsWith('/src/') ||
mountPoint.startsWith('/code/');

if (isHostMountFs || isHostMarkDevice || (isNonSystemFs && isUserLikePath)) {
const isReadOnly = options.includes('ro');
Comment on lines +234 to 252

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Tighten read-only detection and consider normalizing user-like path heuristics

The combined condition

if (isHostMountFs || isHostMarkDevice || (isNonSystemFs && isUserLikePath)) {

is a solid improvement and should catch many realistic host mounts.

One minor correctness issue:

const isReadOnly = options.includes('ro');

can misclassify mounts such as rw,errors=remount-ro as read-only because ro appears as a substring. It’s safer to parse mount options by token:

- const isReadOnly = options.includes('ro');
+ const mountOptions = options.split(',');
+ const isReadOnly = mountOptions.includes('ro');

This avoids false positives while preserving behavior for true ro mounts.

As an optional polish, you might also consider whether isUserLikePath should distinguish /workspace from /workspace-* (currently startsWith('/workspace') matches both) and whether any additional project-specific prefixes should be centralized/configurable.

🤖 Prompt for AI Agents
In src/utils/system-info.ts around lines 234 to 252, the read-only detection
uses options.includes('ro') which can falsely match substrings like
"errors=remount-ro"; instead split or tokenize the mount options by comma (and
trim each token) and check for an exact 'ro' token (e.g.,
options.split(',').map(t=>t.trim()).includes('ro')). Update the isReadOnly
assignment to use this tokenized check. Optionally, when updating nearby code,
consider tightening the isUserLikePath heuristics (e.g., match '/workspace'
exactly or use a configurable prefix list) but the immediate fix is to replace
the substring check with a comma-token exact-match check for 'ro'.


mounts.push({
Expand Down