Skip to content
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

Correct ROMFS hardlink handling #1546

Merged
merged 1 commit into from
Aug 10, 2020
Merged

Correct ROMFS hardlink handling #1546

merged 1 commit into from
Aug 10, 2020

Conversation

patacongo
Copy link
Contributor

Summary

This PR corrects an error in the ROMFS file system. The error may occur after following a hard link (depending upon how the ROMFS image is organized). The error occurred because some of the information buffered before following the links was stale and, hence, out of sync after following the hard link. This would cause random errors when paths containing hardlinks were used with ROMFS.

This PR resolves Issue #1543. Please compare the following output with the output in Issue #1543 to see how the problem was resolved:

NuttShell (NSH) NuttX-9.1.0
nsh> mount
  /etc type romfs
  /proc type procfs
  /tmp type vfat
nsh> ls -Rl /etc
/etc:
 dr-xr-xr-x       0 .
 dr-xr-xr-x       0 ..
 -r-xr-xr-x      20 group
 dr-xr-xr-x       0 init.d/
 -r-xr-xr-x      35 passwd
/etc/init.d:
 dr-xr-xr-x       0 .
 dr-xr-xr-x       0 ..
 -r-xr-xr-x      71 rcS

nsh> ls -l /etc/init.d
/etc/init.d:
 dr-xr-xr-x       0 .
 dr-xr-xr-x       0 ..
 -r-xr-xr-x      71 rcS
nsh> ls -l /etc/init.d/.
/etc/init.d/.:
 dr-xr-xr-x       0 .
 dr-xr-xr-x       0 ..
 -r-xr-xr-x      71 rcS

nsh> ls -l /etc/init.d/..
/etc/init.d/..:
 dr-xr-xr-x       0 .
 dr-xr-xr-x       0 ..
 -r-xr-xr-x      20 group
 dr-xr-xr-x       0 init.d/
 -r-xr-xr-x      35 passwd
nsh> ls -l /etc/init.d/../.
/etc/init.d/../.:
 dr-xr-xr-x       0 .
 dr-xr-xr-x       0 ..
 -r-xr-xr-x      20 group
 dr-xr-xr-x       0 init.d/
 -r-xr-xr-x      35 passwd
nsh>

Impact

Effects only ROMFS. Should result in reliable performance if hard links are used in paths.

Testing

Testing was performed using the ROMFS file system that is mounted with the sim:nsh configuration.

This PR corrects an error in the ROMFS file system.  The error occurred after following a hard link (depending on how the ROMFS image is organized).  The error occurred because some of the information buffered before following the links was stale and, hence, out of sync after following the hard link.  This would cause random errors when paths containing hardlinks were used with ROMFS.

This PR resolves Issue apache#1543.  Please compare the following output with the output in Issue apache#1543 to see how the problem was resolved:

    NuttShell (NSH) NuttX-9.1.0
    nsh> mount
      /etc type romfs
      /proc type procfs
      /tmp type vfat
    nsh> ls -Rl /etc
    /etc:
     dr-xr-xr-x       0 .
     dr-xr-xr-x       0 ..
     -r-xr-xr-x      20 group
     dr-xr-xr-x       0 init.d/
     -r-xr-xr-x      35 passwd
    /etc/init.d:
     dr-xr-xr-x       0 .
     dr-xr-xr-x       0 ..
     -r-xr-xr-x      71 rcS

    nsh> ls -l /etc/init.d
    /etc/init.d:
     dr-xr-xr-x       0 .
     dr-xr-xr-x       0 ..
     -r-xr-xr-x      71 rcS
    nsh> ls -l /etc/init.d/.
    /etc/init.d/.:
     dr-xr-xr-x       0 .
     dr-xr-xr-x       0 ..
     -r-xr-xr-x      71 rcS

    nsh> ls -l /etc/init.d/..
    /etc/init.d/..:
     dr-xr-xr-x       0 .
     dr-xr-xr-x       0 ..
     -r-xr-xr-x      20 group
     dr-xr-xr-x       0 init.d/
     -r-xr-xr-x      35 passwd
    nsh> ls -l /etc/init.d/../.
    /etc/init.d/../.:
     dr-xr-xr-x       0 .
     dr-xr-xr-x       0 ..
     -r-xr-xr-x      20 group
     dr-xr-xr-x       0 init.d/
     -r-xr-xr-x      35 passwd
    nsh>
Copy link
Contributor

@davids5 davids5 left a comment

Choose a reason for hiding this comment

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

LGTM

@davids5
Copy link
Contributor

davids5 commented Aug 10, 2020

I would be happy to merge this, but I would like consensus: @xiaoxiang781216 OK by you?

@xiaoxiang781216
Copy link
Contributor

@davids5 sure, go ahead.

@davids5 davids5 merged commit 32e9879 into apache:master Aug 10, 2020
@patacongo
Copy link
Contributor Author

This is a simply bug fix. It is not controversial. The code was wrong before. It is correct now.

@patacongo patacongo deleted the romfs branch August 10, 2020 23:58
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.

ROMFS current directory hardlink does not work
4 participants