mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 04:52:59 +01:00
pkg/littlefs*: align readdir() with documentation
`readdir()` should only output the name of the file, but littleFS adds a leading `/`. Neither FAT nor Linux will exhibit this behavior. struct dirent *entry; DIR *dir = opendir("."); while ((entry = readdir(dir))) { printf("%s\n", entry->d_name); } This results in surprising failures of code that expects filenames to match that was tested on a different FS, when suddenly there is a `/` in front of the filename.
This commit is contained in:
parent
865df2056b
commit
6a361795ee
@ -493,8 +493,7 @@ static int _readdir(vfs_DIR *dirp, vfs_dirent_t *entry)
|
||||
int ret = lfs_dir_read(&fs->fs, dir, &info);
|
||||
if (ret >= 0) {
|
||||
entry->d_ino = info.type;
|
||||
entry->d_name[0] = '/';
|
||||
strncpy(entry->d_name + 1, info.name, VFS_NAME_MAX - 1);
|
||||
strncpy(entry->d_name, info.name, VFS_NAME_MAX - 1);
|
||||
}
|
||||
|
||||
mutex_unlock(&fs->lock);
|
||||
|
@ -499,8 +499,7 @@ static int _readdir(vfs_DIR *dirp, vfs_dirent_t *entry)
|
||||
int ret = lfs_dir_read(&fs->fs, dir, &info);
|
||||
if (ret >= 0) {
|
||||
entry->d_ino = info.type;
|
||||
entry->d_name[0] = '/';
|
||||
strncpy(entry->d_name + 1, info.name, VFS_NAME_MAX - 1);
|
||||
strncpy(entry->d_name, info.name, VFS_NAME_MAX - 1);
|
||||
}
|
||||
|
||||
mutex_unlock(&fs->lock);
|
||||
|
Loading…
Reference in New Issue
Block a user