Reverted some root-related errors to EXIST/ISDIR
Changed:
- lfsr_mkdir(&lfs, "/") => LFS_ERR_EXIST
- lfsr_file_open(&lfs, &file, "/", *) => LFS_ERR_ISDIR
Unchanged:
- lfsr_remove(&lfs, "/") => LFS_ERR_INVAL
- lfsr_rename(&lfs, "/", *) => LFS_ERR_INVAL
- lfsr_rename(&lfs, *, "/") => LFS_ERR_INVAL
This better matches what Linux, etc, does: prefering a normal
dir-related error unless the only issue is that the dir in question is
the root.
Though Linux, etc, usually return EBUSY, which seems to also be used for
special device files. We could add LFS_ERR_BUSY, but I'm not sure it's
really worth it for such a rare error. It's not like the name would help
anything...
Internally, lfsr_mtree_pathlookup always returns LFS_ERR_INVAL for root,
so this unfortunately requires a bit more code to map to the correct
errors:
code stack
before: 33598 2592
after 33634 (+0.1%) 2592 (+0.0%)
This commit is contained in:
@@ -283,14 +283,14 @@ code = '''
|
||||
}
|
||||
|
||||
// try to make root, which doesn't make sense
|
||||
lfsr_mkdir(&lfs, "/") => LFS_ERR_INVAL;
|
||||
lfsr_mkdir(&lfs, "/") => LFS_ERR_EXIST;
|
||||
|
||||
// make a directory
|
||||
err = lfsr_mkdir(&lfs, "ardvark");
|
||||
assert(!err || (TEST_PLS && err == LFS_ERR_EXIST));
|
||||
|
||||
// try to make root, which doesn't make sense
|
||||
lfsr_mkdir(&lfs, "/") => LFS_ERR_INVAL;
|
||||
lfsr_mkdir(&lfs, "/") => LFS_ERR_EXIST;
|
||||
|
||||
for (int remount = 0; remount < 2; remount++) {
|
||||
// remount?
|
||||
|
||||
Reference in New Issue
Block a user