mnt: handle EROFS from mkdir/open on read-only mounts#260
Merged
robertswiecki merged 1 commit intogoogle:masterfrom Apr 2, 2026
Merged
mnt: handle EROFS from mkdir/open on read-only mounts#260robertswiecki merged 1 commit intogoogle:masterfrom
robertswiecki merged 1 commit intogoogle:masterfrom
Conversation
mkdir() can return EROFS instead of EEXIST for existing entries on read-only mounts (e.g. NFS). Fall back to stat()/fstatat() on EROFS and proceed if the entry exists with the expected type.
3581327 to
033adf6
Compare
Contributor
Author
|
Hi @robertswiecki, just wanted to check if you've had a chance to look at this. Happy to adjust the approach if you'd prefer something different. We're hitting this in production with read-only NFS mounts and the EROFS handling has been solid on our side. Let me know if there's anything I can do to make this easier to review. |
Collaborator
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When using
--chrooton a read-only NFS export, nsjail aborts during mount target creation. Directories like/devand/tmpalready exist in the chroot image, butmkdir()returnsEROFSinstead ofEEXIST.On NFSv3/v4 with a cold dentry cache, the NFS client's exclusive-create optimization (
nfs_is_exclusive_createinfs/nfs/dir.c) skips the on-wire LOOKUP, leaving a negative dentry. The VFS then hits the deferredmnt_want_write()error before discovering the entry already exists.nsjail only tolerates
EEXISTaftermkdir/open(O_CREAT), soEROFSis treated as fatal (exit 255).Fix
On
EROFS, fall back tostat()/fstatat()and proceed if the entry exists with the expected type (S_ISDIR/S_ISREG). All 7 mkdir/mkdirat/open sites patched acrossmnt.cc,mnt_legacy.cc,mnt_newapi.cc, andutil.cc.