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

POSIX stat function returns filesystem statistics, not file statistics #58911

Closed
Tracked by #51211
plinnie opened this issue Jun 6, 2023 · 2 comments · Fixed by #59278
Closed
Tracked by #51211

POSIX stat function returns filesystem statistics, not file statistics #58911

plinnie opened this issue Jun 6, 2023 · 2 comments · Fixed by #59278
Assignees
Labels
area: POSIX POSIX API Library bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@plinnie
Copy link

plinnie commented Jun 6, 2023

Please see Discord discussion https://discord.com/channels/720317445772017664/883450954878439445/1115355325055381625 .

Describe the bug
When using the POSIX function stat the returned statistics are not those of the file passed as an argument, but that from the filesystem the file is located on.

The bug present in the current master, and appears in the POSIX filesystem layer of Zephyr.

To Reproduce
Write application which uses stat function with CONFIG_POSIX_FS=y .

Expected behavior
To get actual information of the file.

Impact
File size and attribute retrieval will not return the expected result. For example our application using mongoose did not function properly, as mongoose uses the stat function to determine the file size when using the default filesystem API.

Environment (please complete the following information):

  • Linux (Ubuntu 20.04)
  • Zephyr SDK 0.15.2
  • Zephyr 3.3.0

Additional context
CONFIG_POSIX_FS=y
See:

rc = fs_statvfs(path, &stat);

I would expect it to call fs_stat and not fs_statvfs as it does now.

@plinnie plinnie added the bug The issue is a bug, or the PR is fixing a bug label Jun 6, 2023
@henrikbrixandersen henrikbrixandersen added the area: POSIX POSIX API Library label Jun 6, 2023
@jgl-meta jgl-meta added the priority: low Low impact/importance bug label Jun 6, 2023
@cfriedt
Copy link
Member

cfriedt commented Jun 6, 2023

@plinnie - are you able to make a PR? Looks like it might be a 1-line fix. Feel free to ping me if you require any assistance.

@plinnie
Copy link
Author

plinnie commented Jun 7, 2023

@plinnie - are you able to make a PR? Looks like it might be a 1-line fix. Feel free to ping me if you require any assistance.

Yes, but at a second glance it is a bit more involved. I need to gather from fs_stat and fs_statvfs. Additionally I will add unit tests. Also some corner cases need to be defined in more detail (e.g.. stat('SD:/', &buf) ). Needs some consideration. I hope somewhere next week

plinnie pushed a commit to plinnie/zephyr that referenced this issue Jun 15, 2023
Fixes zephyrproject-rtos#58911. Previously the stat command returned
information on the filesystem, but not the file itself.
Because block size is still set this function is
backwards compatible with the previous faulty
behavior.

Signed-off-by: Vincent van Beveren <v.van.beveren@nikhef.nl>
plinnie pushed a commit to plinnie/zephyr that referenced this issue Jun 15, 2023
Fixes zephyrproject-rtos#58911. Previously the stat command returned
information on the filesystem, but not the file itself.
Because block size is still set this function is
backwards compatible with the previous faulty
behavior.

Signed-off-by: Vincent van Beveren <v.van.beveren@nikhef.nl>
plinnie pushed a commit to plinnie/zephyr that referenced this issue Jun 15, 2023
Fixes zephyrproject-rtos#58911. Previously the stat command returned
information on the filesystem, but not the file itself.
Because block size is still set this function is
backwards compatible with the previous faulty
behavior.

Signed-off-by: Vincent van Beveren <v.van.beveren@nikhef.nl>
plinnie pushed a commit to plinnie/zephyr that referenced this issue Jun 16, 2023
Fixes zephyrproject-rtos#58911. Previously the stat command returned
information on the filesystem, but not the file itself.
Because block size is still set this function is
backwards compatible with the previous faulty
behavior.

Signed-off-by: Vincent van Beveren <v.van.beveren@nikhef.nl>
plinnie pushed a commit to plinnie/zephyr that referenced this issue Jun 16, 2023
Fixes zephyrproject-rtos#58911. Previously the stat command returned
information on the filesystem, but not the file itself.
Because block size is still set this function is
backwards compatible with the previous faulty
behavior.

Signed-off-by: Vincent van Beveren <v.van.beveren@nikhef.nl>
plinnie pushed a commit to plinnie/zephyr that referenced this issue Jun 16, 2023
Fixes zephyrproject-rtos#58911. Previously the stat command returned
information on the filesystem, but not the file itself.
Because block size is still set this function is
backwards compatible with the previous faulty
behavior.

Signed-off-by: Vincent van Beveren <v.van.beveren@nikhef.nl>
nashif pushed a commit that referenced this issue Jun 23, 2023
Fixes #58911. Previously the stat command returned
information on the filesystem, but not the file itself.
Because block size is still set this function is
backwards compatible with the previous faulty
behavior.

Signed-off-by: Vincent van Beveren <v.van.beveren@nikhef.nl>
hlord2000 pushed a commit to hlord2000/zephyr that referenced this issue Jul 3, 2023
Fixes zephyrproject-rtos#58911. Previously the stat command returned
information on the filesystem, but not the file itself.
Because block size is still set this function is
backwards compatible with the previous faulty
behavior.

Signed-off-by: Vincent van Beveren <v.van.beveren@nikhef.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: POSIX POSIX API Library bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants