-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FS/littlefs: it is possible to write to already deleted file #32990
Comments
@pabigot I encountered this issue while testing FS log backend. |
I think that behavior is correct: unlinking simply removes the directory entry, it won't invalidate the file. That idiom has long been used on Unix systems to create a temporary file to hold data so the space is reclaimed when the last open descriptor closes. |
IOW, I don't think this is a bug, unless the FS API explicitly requires a failure when writing to an open file where the underlying storage has been deleted. And if that's so, it may not be something that can be fixed. |
cc @de-nordic |
Maybe expected behavior should be that the file which is opened can't be unlinked. |
This is VFS design compromise that is deficiency when parallel access to file system is exercised.
This will require rework of VFS, because the VFS does not hold registry of all opened files, as the user is responsible for providing structures for file system information, so it is not aware of files that are currently opened or being accessed. |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
Describe the bug
It is possible to write to file which was removed if it had been opened before removal.
To Reproduce
fs_open(&f, "lfs1/fname", FS_O_CREATE | FS_O_WRITE);
fs_write(&f, data, length);
fs_unlink("lfs1/fname");
fs_write(&f, data, length); /* will succedd */
Expected behavior
shouldn't be possible to write to a unlinked file
Alternative Expected behavior
the file which is opened can't be unlinked.
Impact
Thread which writes to the file might be not aware that another thread deleted the file. This cause data lost.
The text was updated successfully, but these errors were encountered: