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

File systems report names with leading slashes #14635

Closed
2 tasks done
chrysn opened this issue Jul 28, 2020 · 3 comments
Closed
2 tasks done

File systems report names with leading slashes #14635

chrysn opened this issue Jul 28, 2020 · 3 comments
Labels
Area: fs Area: File systems Community: help wanted The contributors require help from other members of the community Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Type: tracking The issue tracks and organizes the sub-tasks of a larger effort

Comments

@chrysn
Copy link
Member

chrysn commented Jul 28, 2020

Description

Several file systems (at least constfs and littlefs) return file names with leading slashes.

Steps to reproduce the issue

In the filesystems example with the default littlefs backend for sda:

> ls /const
/hello-world
/hello-riot
total 2 files
> format
> mount
> tee /sda/foo hello
> ls /sda
/.
/..
/foo
total 3 files

In contrast, fatfs (with an externally created image) gives slash-free names:

> ls /sda
FOO
EMPTY
FOLDER
GARBAGE
total 4 files

Expected results

The vfs_dirent_t struct describes a field for "file name, relative to its containing directory".

That indicates that it can only be a file name, ie. a string that contains any characters except '\0' and '/'. It may also help to have some explicit statement in here.

Context

This was found in #14397, which (working as a file server with URIs) has stricter requirements on the precision of names.

As this affects at least two file systems, this should be tracked in separate bugs for:

I can create and look into those in particular, but a statement from someone more familiar with the design of the file systems calls would be useful (thus the "help" tag, feel free to remove that with a clarifying remark).

Versions

current RIOT master (6ef4276) on native

@chrysn chrysn added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Community: help wanted The contributors require help from other members of the community Area: fs Area: File systems Type: tracking The issue tracks and organizes the sub-tasks of a larger effort labels Jul 28, 2020
@benpicco
Copy link
Contributor

benpicco commented Aug 21, 2020

IIRC spiffs also starts with a leading /, so fatfs would be the odd one here.
Can you open files with and without the leading slashes?

@chrysn
Copy link
Member Author

chrysn commented Oct 23, 2020

Testing with constfs:

> ls /const
/hello-world
/hello-riot
total 2 files
> cat /const/hello-world
Hello World!
> cat /const//hello-world
file /const//hello-world does not exist

I can open the files as they should be assembled in full paths; thing is, the leading slash inside the file name that is shown in ls can't even be expressed in a path. (In a URI it'd make a /const/%2Fhello-world, POSIX-ish paths have no such escapes).

My impression of how this came about is that a) file systems expect to be mounted at /, and b) may be disposed to list all files nested in a directory.

chrysn added a commit to chrysn-pull-requests/RIOT that referenced this issue Oct 25, 2020
@MrKevinWeiss MrKevinWeiss added this to the Release 2021.07 milestone Jun 21, 2021
@MrKevinWeiss MrKevinWeiss removed this from the Release 2021.07 milestone Jul 15, 2021
@chrysn
Copy link
Member Author

chrysn commented Feb 9, 2022

Thanks @benpicco for addressing this in both affected file systems; closing. (If this comes back in any other file system, that can be addressed in a separate issue; for now the popular ones set the style and are consistent).

@chrysn chrysn closed this as completed Feb 9, 2022
benpicco pushed a commit to benpicco/RIOT that referenced this issue Apr 13, 2022
benpicco pushed a commit to benpicco/RIOT that referenced this issue Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: fs Area: File systems Community: help wanted The contributors require help from other members of the community Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Type: tracking The issue tracks and organizes the sub-tasks of a larger effort
Projects
None yet
Development

No branches or pull requests

3 participants