-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
tmpfs: tmpfs_statfs recursively removes files #912
Comments
@Oxore thanks for the detailed bug report and analysis. Your change looks correctly, could you open a PR? |
Oxore
added a commit
to Oxore/incubator-nuttx
that referenced
this issue
Apr 30, 2020
btashton
pushed a commit
that referenced
this issue
Apr 30, 2020
raiden00pl
pushed a commit
to raiden00pl/nuttx
that referenced
this issue
May 2, 2020
sonicyang
pushed a commit
to sonicyang/incubator-nuttx
that referenced
this issue
Jul 12, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce
Prerequisites
Linux environment.
arm-none-eabi-gcc
toolchain, gcc version 9.3.0. QEMU with ARM emulation.NuttX commit: 5b83906
Apps commit: dcc620e
Preparation
Let's assume we have cloned NuttX repo into
/nuttx
and apps repo into/apps
. Current working directory:/nuttx
. Prepare config:Adjust configuration:
Build:
Run:
Go to
serial0
(Ctrl+Alt+3) and get the console.Actual steps to reproduce
At
nsh
prompt type:You can see created files and directory. Now run the following:
or:
then run:
There is no
/tmp/dir/file2
anymore, but/tmp/file
still exists, though. So files in/tmp
always exist, but any directory in/tmp
becomes recursively cleaned up.I expect, that when I run
df
, all my files in/tmp
and deeper do not get changed or deleted, but they disappear.Possible fix or just pointing to a buggy line of code
When file
/proc/fs/usage
is being read, it'sread
op callstmpfs_statfs
, that has subsequent call totmpfs_foreach
, which contains unconditional recursive call to itself withtmpfs_free_callout
value being passed to the argumentcallout
. This is why all files in all directories of/tmp
disappear, but files and directories in/tmp
(the root oftmpfs
) stay on.Here is an "one line" fix:
So...
Does it fix the bug? Yes, it looks like it fixes it. If we create more files we get values increased in
df
output for/tmp
and all files in/tmp
and in it's directories persist.Does it introduce more bugs? I don't know.
How can I test it? I hope that original author has better understanding of what is going on here and how to properly fix the bug.
I can try to open a pull request and carefully adjust all the code around, if somebody explain how I test my changes or at least point the places where to put attention to.
The text was updated successfully, but these errors were encountered: