Reworked how unknown file types are handled
This changes how we approach unknown file types.
Before:
> Unknown file types are allowed and may leak resources if modified,
> so attempted modification (rename/remove) will error with
> LFS_ERR_NOTSUP.
Now:
> Unknown file types are only allowed in RDONLY mode. This avoids the
> whole leaking resources headache.
Additionally, unknown types are now mapped to LFS_TYPE_UNKNOWN, instead
of just being forwarded to the user. This allows us to add internal
types/tags to the LFSR_TAG_NAME type space without worrying about
conflicts with future types:
- reg -> LFS_TYPE_REG
- dir -> LFS_TYPE_DIR
- stickynote -> LFS_TYPE_STICKYNOTE
- everything else -> LFS_TYPE_UNKNOWN
Thinking about potential future types, it seems most (symlinks,
compressed files, etc) can be better implemented via custom attributes.
Using custom attributes doesn't mean the filesystem _can't_ inject
special behavior, and custom attributes allow for perfect backwards
compatibility.
So with future types less likely, forwarding type info to users is less
important (and potentially error prone). Instead, allowing on-disk +
internal types to be represented densely is much more useful.
And it avoids setting an upper bound on future types prematurely.
---
This also includes a minor rcompat/wcompat rework. Since we're probably
going to end up with 32-bit rcompat flags anyways, might as well make
them more human-readable (nibble-aligned):
LFS_RCOMPAT_NONSTANDARD 0x00000001 Non-standard filesystem format
LFS_RCOMPAT_WRONLY 0x00000002 Reading is disallowed
LFS_RCOMPAT_BMOSS 0x00000010 Files may use inlined data
LFS_RCOMPAT_BSPROUT 0x00000020 Files may use block pointers
LFS_RCOMPAT_BSHRUB 0x00000040 Files may use inlined btrees
LFS_RCOMPAT_BTREE 0x00000080 Files may use btrees
LFS_RCOMPAT_MMOSS 0x00000100 May use an inlined mdir
LFS_RCOMPAT_MSPROUT 0x00000200 May use an mdir pointer
LFS_RCOMPAT_MSHRUB 0x00000400 May use an inlined mtree
LFS_RCOMPAT_MTREE 0x00000800 May use an mdir btree
LFS_RCOMPAT_GRM 0x00001000 Global-remove in use
LFS_WCOMPAT_NONSTANDARD 0x00000001 Non-standard filesystem format
LFS_WCOMPAT_RDONLY 0x00000002 Writing is disallowed
LFS_WCOMPAT_REG 0x00000010 Regular file types in use
LFS_WCOMPAT_DIR 0x00000020 Directory file types in use
LFS_WCOMPAT_STICKYNOTE 0x00000040 Stickynote file types in use
LFS_WCOMPAT_GCKSUM 0x00001000 Global-checksum in use
---
Code changes:
code stack ctx
before: 35928 2440 640
after: 35924 (-0.0%) 2440 (+0.0%) 640 (+0.0%)
This commit is contained in:
+5
-15
@@ -1146,14 +1146,15 @@ code = '''
|
||||
LFSR_DATA_BUF(path, lfsr_path_namelen(path))))) => 0;
|
||||
lfsr_unmount(&lfs) => 0;
|
||||
|
||||
// mount
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
// mount, note the LFS_M_RDONLY, new types should be added with
|
||||
// new wcompat flags to prevent resource leaks
|
||||
lfsr_mount(&lfs, LFS_M_RDONLY, CFG) => 0;
|
||||
|
||||
// our file should appear as an unknown type
|
||||
struct lfs_info info;
|
||||
lfsr_stat(&lfs, "b", &info) => 0;
|
||||
assert(strcmp(info.name, "b") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
assert(info.size == 0);
|
||||
|
||||
lfsr_dir_t dir;
|
||||
@@ -1172,7 +1173,7 @@ code = '''
|
||||
assert(info.size == strlen("hi a!"));
|
||||
lfsr_dir_read(&lfs, &dir, &info) => 0;
|
||||
assert(strcmp(info.name, "b") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
assert(info.size == 0);
|
||||
lfsr_dir_read(&lfs, &dir, &info) => 0;
|
||||
assert(strcmp(info.name, "c") == 0);
|
||||
@@ -1181,19 +1182,8 @@ code = '''
|
||||
lfsr_dir_read(&lfs, &dir, &info) => LFS_ERR_NOENT;
|
||||
lfsr_dir_close(&lfs, &dir) => 0;
|
||||
|
||||
// removing/renaming unknown files should return NOTSUP, we could
|
||||
// remove the metadata entry, but we would probably leak stuff
|
||||
lfsr_remove(&lfs, "b") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs, "b", "d") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs, "b", "c") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs, "a", "b") => LFS_ERR_NOTSUP;
|
||||
|
||||
lfsr_file_open(&lfs, &file, "b",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
lfsr_file_open(&lfs, &file, "b",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
|
||||
lfsr_mkdir(&lfs, "b") => LFS_ERR_EXIST;
|
||||
|
||||
lfsr_unmount(&lfs) => 0;
|
||||
'''
|
||||
|
||||
+142
-575
@@ -4615,22 +4615,22 @@ code = '''
|
||||
struct lfs_info info;
|
||||
lfsr_stat(&lfs, "coffee/drip", &info) => 0;
|
||||
assert(strcmp(info.name, "drip") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/coldbrew", &info) => 0;
|
||||
assert(strcmp(info.name, "coldbrew") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/turkish", &info) => 0;
|
||||
assert(strcmp(info.name, "turkish") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/tubruk", &info) => 0;
|
||||
assert(strcmp(info.name, "tubruk") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/vietnamese", &info) => 0;
|
||||
assert(strcmp(info.name, "vietnamese") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/thai", &info) => 0;
|
||||
assert(strcmp(info.name, "thai") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
|
||||
// file open paths, only works on files!
|
||||
lfsr_file_t file;
|
||||
@@ -4656,81 +4656,28 @@ code = '''
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/vietnamese") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/thai") => LFS_ERR_NOTDIR;
|
||||
|
||||
// rename paths
|
||||
lfsr_mkdir(&lfs, "espresso") => 0;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip",
|
||||
"espresso/espresso") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew",
|
||||
"espresso/americano") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish",
|
||||
"espresso/macchiato") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk",
|
||||
"espresso/latte") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese",
|
||||
"espresso/cappuccino") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai",
|
||||
"espresso/mocha") => LFS_ERR_NOTSUP;
|
||||
|
||||
// here's a weird one, what happens if our rename is also a noop?
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip",
|
||||
"coffee/drip") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew",
|
||||
"coffee/coldbrew") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish",
|
||||
"coffee/turkish") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk",
|
||||
"coffee/tubruk") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese",
|
||||
"coffee/vietnamese") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai",
|
||||
"coffee/thai") => LFS_ERR_NOTSUP;
|
||||
|
||||
// remove paths
|
||||
lfsr_remove(&lfs, "coffee/drip") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/coldbrew") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/turkish") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/tubruk") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/vietnamese") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/thai") => LFS_ERR_NOTSUP;
|
||||
// note write operations should normally be rejected during mount
|
||||
// by wcompat flags
|
||||
|
||||
// stat paths
|
||||
lfsr_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
|
||||
|
||||
lfsr_stat(&lfs, "coffee/drip", &info) => 0;
|
||||
assert(strcmp(info.name, "drip") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/coldbrew", &info) => 0;
|
||||
assert(strcmp(info.name, "coldbrew") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/turkish", &info) => 0;
|
||||
assert(strcmp(info.name, "turkish") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/tubruk", &info) => 0;
|
||||
assert(strcmp(info.name, "tubruk") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/vietnamese", &info) => 0;
|
||||
assert(strcmp(info.name, "vietnamese") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/thai", &info) => 0;
|
||||
assert(strcmp(info.name, "thai") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
|
||||
lfsr_unmount(&lfs) => 0;
|
||||
'''
|
||||
@@ -4798,86 +4745,86 @@ code = '''
|
||||
LFSR_DATA_BUF(path, lfsr_path_namelen(path))))) => 0;
|
||||
|
||||
if (DIR) {
|
||||
lfsr_mkdir(&lfs, "drip/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_mkdir(&lfs, "coldbrew/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_mkdir(&lfs, "turkish/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_mkdir(&lfs, "tubruk/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_mkdir(&lfs, "vietnamese/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_mkdir(&lfs, "thai/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_mkdir(&lfs, "drip/coffee") => LFS_ERR_NOTDIR;
|
||||
lfsr_mkdir(&lfs, "coldbrew/coffee") => LFS_ERR_NOTDIR;
|
||||
lfsr_mkdir(&lfs, "turkish/coffee") => LFS_ERR_NOTDIR;
|
||||
lfsr_mkdir(&lfs, "tubruk/coffee") => LFS_ERR_NOTDIR;
|
||||
lfsr_mkdir(&lfs, "vietnamese/coffee") => LFS_ERR_NOTDIR;
|
||||
lfsr_mkdir(&lfs, "thai/coffee") => LFS_ERR_NOTDIR;
|
||||
} else {
|
||||
lfsr_file_t file;
|
||||
lfsr_file_open(&lfs, &file, "drip/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coldbrew/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "turkish/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "tubruk/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "vietnamese/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "thai/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
}
|
||||
|
||||
// stat paths
|
||||
struct lfs_info info;
|
||||
lfsr_stat(&lfs, "drip/coffee", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coldbrew/coffee", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "turkish/coffee", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "tubruk/coffee", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "vietnamese/coffee", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "thai/coffee", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "drip/coffee", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "coldbrew/coffee", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "turkish/coffee", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "tubruk/coffee", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "vietnamese/coffee", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "thai/coffee", &info) => LFS_ERR_NOTDIR;
|
||||
|
||||
// file open paths, only works on files!
|
||||
lfsr_file_t file;
|
||||
lfsr_file_open(&lfs, &file, "drip/coffee",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coldbrew/coffee",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "turkish/coffee",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "tubruk/coffee",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "vietnamese/coffee",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "thai/coffee",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
|
||||
lfsr_file_open(&lfs, &file, "drip/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coldbrew/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "turkish/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "tubruk/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "vietnamese/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "thai/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
|
||||
lfsr_file_open(&lfs, &file, "drip/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coldbrew/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "turkish/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "tubruk/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "vietnamese/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "thai/coffee",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
|
||||
// dir open paths, only works on dirs!
|
||||
lfsr_dir_t dir;
|
||||
lfsr_dir_open(&lfs, &dir, "drip/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "coldbrew/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "turkish/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "tubruk/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "vietnamese/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "thai/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "drip/coffee") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "coldbrew/coffee") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "turkish/coffee") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "tubruk/coffee") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "vietnamese/coffee") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "thai/coffee") => LFS_ERR_NOTDIR;
|
||||
|
||||
// make some normal paths so we have something to rename
|
||||
lfsr_mkdir(&lfs, "coffee") => 0;
|
||||
@@ -4910,104 +4857,10 @@ code = '''
|
||||
lfsr_file_close(&lfs, &file) => 0;
|
||||
}
|
||||
|
||||
// rename paths
|
||||
lfsr_mkdir(&lfs, "espresso") => 0;
|
||||
// bad source
|
||||
lfsr_rename(&lfs,
|
||||
"drip/coffee",
|
||||
"espresso/espresso") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coldbrew/coffee",
|
||||
"espresso/americano") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"turkish/coffee",
|
||||
"espresso/macchiato") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"tubruk/coffee",
|
||||
"espresso/latte") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"vietnamese/coffee",
|
||||
"espresso/cappuccino") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"thai/coffee",
|
||||
"espresso/mocha") => LFS_ERR_NOTSUP;
|
||||
|
||||
// bad destination
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip",
|
||||
"drip/espresso") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew",
|
||||
"coldbrew/espresso") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish",
|
||||
"turkish/espresso") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk",
|
||||
"tubruk/espresso") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese",
|
||||
"vietnamese/espresso") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai",
|
||||
"thai/espresso") => LFS_ERR_NOTSUP;
|
||||
|
||||
// bad source and bad destination
|
||||
lfsr_rename(&lfs,
|
||||
"drip/coffee",
|
||||
"drip/espresso") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coldbrew/coffee",
|
||||
"coldbrew/espresso") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"turkish/coffee",
|
||||
"turkish/espresso") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"tubruk/coffee",
|
||||
"tubruk/espresso") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"vietnamese/coffee",
|
||||
"vietnamese/espresso") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"thai/coffee",
|
||||
"thai/espresso") => LFS_ERR_NOTSUP;
|
||||
|
||||
// here's a weird one, what happens if our rename is also a noop?
|
||||
lfsr_rename(&lfs,
|
||||
"drip/coffee",
|
||||
"drip/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coldbrew/coffee",
|
||||
"coldbrew/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"turkish/coffee",
|
||||
"turkish/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"tubruk/coffee",
|
||||
"tubruk/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"vietnamese/coffee",
|
||||
"vietnamese/coffee") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"thai/coffee",
|
||||
"thai/coffee") => LFS_ERR_NOTSUP;
|
||||
|
||||
// remove paths
|
||||
lfsr_stat(&lfs, "drip/espresso", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coldbrew/espresso", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "turkish/espresso", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "tubruk/espresso", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "vietnamese/espresso", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "thai/espresso", &info) => LFS_ERR_NOTSUP;
|
||||
// note write operations should normally be rejected during mount
|
||||
// by wcompat flags
|
||||
|
||||
// stat paths
|
||||
lfsr_stat(&lfs, "drip/espresso", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coldbrew/espresso", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "turkish/espresso", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "tubruk/espresso", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "vietnamese/espresso", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "thai/espresso", &info) => LFS_ERR_NOTSUP;
|
||||
|
||||
lfsr_stat(&lfs, "coffee/drip", &info) => 0;
|
||||
assert(strcmp(info.name, "drip") == 0);
|
||||
assert(info.type == ((DIR) ? LFS_TYPE_DIR : LFS_TYPE_REG));
|
||||
@@ -5095,179 +4948,85 @@ code = '''
|
||||
|
||||
// stat paths
|
||||
struct lfs_info info;
|
||||
lfsr_stat(&lfs, "coffee/drip//////", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coffee/coldbrew/////", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coffee/turkish////", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coffee/tubruk///", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coffee/vietnamese//", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coffee/thai/", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coffee/drip//////", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "coffee/coldbrew/////", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "coffee/turkish////", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "coffee/tubruk///", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "coffee/vietnamese//", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "coffee/thai/", &info) => LFS_ERR_NOTDIR;
|
||||
|
||||
// file open paths, only works on files!
|
||||
lfsr_file_t file;
|
||||
lfsr_file_open(&lfs, &file, "coffee/drip/",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/coldbrew//",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/turkish///",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/tubruk////",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/vietnamese/////",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/thai//////",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
|
||||
lfsr_file_open(&lfs, &file, "coffee/drip/",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/coldbrew//",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/turkish///",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/tubruk////",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/vietnamese/////",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/thai//////",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
|
||||
lfsr_file_open(&lfs, &file, "coffee/drip/",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/coldbrew//",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/turkish///",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/tubruk////",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/vietnamese/////",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/thai//////",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
|
||||
// dir open paths, only works on dirs!
|
||||
lfsr_dir_t dir;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/drip/") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/coldbrew//") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/turkish///") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/tubruk////") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/vietnamese/////") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/thai//////") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/drip/") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/coldbrew//") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/turkish///") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/tubruk////") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/vietnamese/////") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/thai//////") => LFS_ERR_NOTDIR;
|
||||
|
||||
// rename paths
|
||||
lfsr_mkdir(&lfs, "espresso") => 0;
|
||||
// bad source
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip//////",
|
||||
"espresso/espresso") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew/////",
|
||||
"espresso/americano") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish////",
|
||||
"espresso/macchiato") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk///",
|
||||
"espresso/latte") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese//",
|
||||
"espresso/cappuccino") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai/",
|
||||
"espresso/mocha") => LFS_ERR_NOTSUP;
|
||||
|
||||
// bad destination
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip",
|
||||
"espresso/espresso/") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew",
|
||||
"espresso/americano//") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish",
|
||||
"espresso/macchiato///") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk",
|
||||
"espresso/latte////") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese",
|
||||
"espresso/cappuccino/////") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai",
|
||||
"espresso/mocha//////") => LFS_ERR_NOTSUP;
|
||||
|
||||
// bad source and bad destination
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip//////",
|
||||
"espresso/espresso/") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew/////",
|
||||
"espresso/americano//") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish////",
|
||||
"espresso/macchiato///") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk///",
|
||||
"espresso/latte////") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese//",
|
||||
"espresso/cappuccino/////") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai/",
|
||||
"espresso/mocha//////") => LFS_ERR_NOTSUP;
|
||||
|
||||
// here's a weird one, what happens if our rename is also a noop?
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip//////",
|
||||
"coffee/drip//////") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew/////",
|
||||
"coffee/coldbrew/////") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish////",
|
||||
"coffee/turkish////") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk///",
|
||||
"coffee/tubruk///") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese//",
|
||||
"coffee/vietnamese//") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai/",
|
||||
"coffee/thai/") => LFS_ERR_NOTSUP;
|
||||
|
||||
// remove paths
|
||||
lfsr_remove(&lfs, "coffee/drip/") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/coldbrew//") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/turkish///") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/tubruk////") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/vietnamese/////") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/thai//////") => LFS_ERR_NOTSUP;
|
||||
// note write operations should normally be rejected during mount
|
||||
// by wcompat flags
|
||||
|
||||
// stat paths
|
||||
lfsr_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
|
||||
|
||||
lfsr_stat(&lfs, "coffee/drip", &info) => 0;
|
||||
assert(strcmp(info.name, "drip") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/coldbrew", &info) => 0;
|
||||
assert(strcmp(info.name, "coldbrew") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/turkish", &info) => 0;
|
||||
assert(strcmp(info.name, "turkish") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/tubruk", &info) => 0;
|
||||
assert(strcmp(info.name, "tubruk") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/vietnamese", &info) => 0;
|
||||
assert(strcmp(info.name, "vietnamese") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/thai", &info) => 0;
|
||||
assert(strcmp(info.name, "thai") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
|
||||
lfsr_unmount(&lfs) => 0;
|
||||
'''
|
||||
@@ -5337,179 +5096,85 @@ code = '''
|
||||
|
||||
// stat paths
|
||||
struct lfs_info info;
|
||||
lfsr_stat(&lfs, "coffee/drip/./././././.", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coffee/coldbrew/././././.", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coffee/turkish/./././.", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coffee/tubruk/././.", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coffee/vietnamese/./.", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coffee/thai/.", &info) => LFS_ERR_NOTSUP;
|
||||
lfsr_stat(&lfs, "coffee/drip/./././././.", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "coffee/coldbrew/././././.", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "coffee/turkish/./././.", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "coffee/tubruk/././.", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "coffee/vietnamese/./.", &info) => LFS_ERR_NOTDIR;
|
||||
lfsr_stat(&lfs, "coffee/thai/.", &info) => LFS_ERR_NOTDIR;
|
||||
|
||||
// file open paths, only works on files!
|
||||
lfsr_file_t file;
|
||||
lfsr_file_open(&lfs, &file, "coffee/drip/.",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/coldbrew/./.",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/turkish/././.",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/tubruk/./././.",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/vietnamese/././././.",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/thai/./././././.",
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTSUP;
|
||||
LFS_O_RDONLY) => LFS_ERR_NOTDIR;
|
||||
|
||||
lfsr_file_open(&lfs, &file, "coffee/drip/.",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/coldbrew/./.",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/turkish/././.",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/tubruk/./././.",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/vietnamese/././././.",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/thai/./././././.",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_NOTDIR;
|
||||
|
||||
lfsr_file_open(&lfs, &file, "coffee/drip/.",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/coldbrew/./.",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/turkish/././.",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/tubruk/./././.",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/vietnamese/././././.",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
lfsr_file_open(&lfs, &file, "coffee/thai/./././././.",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTSUP;
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_NOTDIR;
|
||||
|
||||
// dir open paths, only works on dirs!
|
||||
lfsr_dir_t dir;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/drip/.") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/coldbrew/./.") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/turkish/././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/tubruk/./././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/vietnamese/././././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/thai/./././././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/drip/.") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/coldbrew/./.") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/turkish/././.") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/tubruk/./././.") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/vietnamese/././././.") => LFS_ERR_NOTDIR;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/thai/./././././.") => LFS_ERR_NOTDIR;
|
||||
|
||||
// rename paths
|
||||
lfsr_mkdir(&lfs, "espresso") => 0;
|
||||
// bad source
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip/./././././.",
|
||||
"espresso/espresso") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew/././././.",
|
||||
"espresso/americano") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish/./././.",
|
||||
"espresso/macchiato") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk/././.",
|
||||
"espresso/latte") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese/./.",
|
||||
"espresso/cappuccino") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai/.",
|
||||
"espresso/mocha") => LFS_ERR_NOTSUP;
|
||||
|
||||
// bad destination
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip",
|
||||
"espresso/espresso/.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew",
|
||||
"espresso/americano/./.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish",
|
||||
"espresso/macchiato/././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk",
|
||||
"espresso/latte/./././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese",
|
||||
"espresso/cappuccino/././././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai",
|
||||
"espresso/mocha/./././././.") => LFS_ERR_NOTSUP;
|
||||
|
||||
// bad source and bad destination
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip/./././././.",
|
||||
"espresso/espresso/.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew/././././.",
|
||||
"espresso/americano/./.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish/./././.",
|
||||
"espresso/macchiato/././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk/././.",
|
||||
"espresso/latte/./././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese/./.",
|
||||
"espresso/cappuccino/././././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai/.",
|
||||
"espresso/mocha/./././././.") => LFS_ERR_NOTSUP;
|
||||
|
||||
// here's a weird one, what happens if our rename is also a noop?
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip/./././././.",
|
||||
"coffee/drip/./././././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew/././././.",
|
||||
"coffee/coldbrew/././././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish/./././.",
|
||||
"coffee/turkish/./././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk/././.",
|
||||
"coffee/tubruk/././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese/./.",
|
||||
"coffee/vietnamese/./.") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai/.",
|
||||
"coffee/thai/.") => LFS_ERR_NOTSUP;
|
||||
|
||||
// remove paths
|
||||
lfsr_remove(&lfs, "coffee/drip/.") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/coldbrew/./.") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/turkish/././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/tubruk/./././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/vietnamese/././././.") => LFS_ERR_NOTSUP;
|
||||
lfsr_remove(&lfs, "coffee/thai/./././././.") => LFS_ERR_NOTSUP;
|
||||
// note write operations should normally be rejected during mount
|
||||
// by wcompat flags
|
||||
|
||||
// stat paths
|
||||
lfsr_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
|
||||
|
||||
lfsr_stat(&lfs, "coffee/drip", &info) => 0;
|
||||
assert(strcmp(info.name, "drip") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/coldbrew", &info) => 0;
|
||||
assert(strcmp(info.name, "coldbrew") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/turkish", &info) => 0;
|
||||
assert(strcmp(info.name, "turkish") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/tubruk", &info) => 0;
|
||||
assert(strcmp(info.name, "tubruk") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/vietnamese", &info) => 0;
|
||||
assert(strcmp(info.name, "vietnamese") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/thai", &info) => 0;
|
||||
assert(strcmp(info.name, "thai") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
|
||||
lfsr_unmount(&lfs) => 0;
|
||||
'''
|
||||
@@ -5616,126 +5281,28 @@ code = '''
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/vietnamese/../../../../..") => LFS_ERR_INVAL;
|
||||
lfsr_dir_open(&lfs, &dir, "coffee/thai/../../../../../..") => LFS_ERR_INVAL;
|
||||
|
||||
// rename paths
|
||||
lfsr_mkdir(&lfs, "espresso") => 0;
|
||||
// bad source
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip/../../../../../..",
|
||||
"espresso/espresso") => LFS_ERR_INVAL;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew/../../../../..",
|
||||
"espresso/americano") => LFS_ERR_INVAL;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish/../../../..",
|
||||
"espresso/macchiato") => LFS_ERR_INVAL;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk/../../..",
|
||||
"espresso/latte") => LFS_ERR_INVAL;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese/../..",
|
||||
"espresso/cappuccino") => LFS_ERR_INVAL;
|
||||
// this one works
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai/..",
|
||||
"espresso/mocha") => 0;
|
||||
lfsr_rename(&lfs,
|
||||
"espresso/mocha",
|
||||
"coffee") => 0;
|
||||
|
||||
// bad destination
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip",
|
||||
"espresso/espresso/..") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew",
|
||||
"espresso/americano/../..") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish",
|
||||
"espresso/macchiato/../../..") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk",
|
||||
"espresso/latte/../../../..") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese",
|
||||
"espresso/cappuccino/../../../../..") => LFS_ERR_NOTSUP;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai",
|
||||
"espresso/mocha/../../../../../..") => LFS_ERR_NOTSUP;
|
||||
|
||||
// bad source and bad destination
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip/../../../../../..",
|
||||
"espresso/espresso/..") => LFS_ERR_INVAL;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew/../../../../..",
|
||||
"espresso/americano/../..") => LFS_ERR_INVAL;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish/../../../..",
|
||||
"espresso/macchiato/../../..") => LFS_ERR_INVAL;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk/../../..",
|
||||
"espresso/latte/../../../..") => LFS_ERR_INVAL;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese/../..",
|
||||
"espresso/cappuccino/../../../../..") => LFS_ERR_INVAL;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai/..",
|
||||
"espresso/mocha/../../../../../..") => LFS_ERR_INVAL;
|
||||
|
||||
// here's a weird one, what happens if our rename is also a noop?
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/drip/../../../../../..",
|
||||
"coffee/drip/../../../../../..") => LFS_ERR_INVAL;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/coldbrew/../../../../..",
|
||||
"coffee/coldbrew/../../../../..") => LFS_ERR_INVAL;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/turkish/../../../..",
|
||||
"coffee/turkish/../../../..") => LFS_ERR_INVAL;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/tubruk/../../..",
|
||||
"coffee/tubruk/../../..") => LFS_ERR_INVAL;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/vietnamese/../..",
|
||||
"coffee/vietnamese/../..") => LFS_ERR_INVAL;
|
||||
lfsr_rename(&lfs,
|
||||
"coffee/thai/..",
|
||||
"coffee/thai/..") => 0;
|
||||
|
||||
// remove paths
|
||||
lfsr_remove(&lfs, "coffee/drip/..") => LFS_ERR_NOTEMPTY;
|
||||
lfsr_remove(&lfs, "coffee/coldbrew/../..") => LFS_ERR_INVAL;
|
||||
lfsr_remove(&lfs, "coffee/turkish/../../..") => LFS_ERR_INVAL;
|
||||
lfsr_remove(&lfs, "coffee/tubruk/../../../..") => LFS_ERR_INVAL;
|
||||
lfsr_remove(&lfs, "coffee/vietnamese/../../../../..") => LFS_ERR_INVAL;
|
||||
lfsr_remove(&lfs, "coffee/thai/../../../../../..") => LFS_ERR_INVAL;
|
||||
// note write operations should normally be rejected during mount
|
||||
// by wcompat flags
|
||||
|
||||
// stat paths
|
||||
lfsr_stat(&lfs, "espresso/espresso", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/americano", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/macchiato", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/latte", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/cappuccino", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "espresso/mocha", &info) => LFS_ERR_NOENT;
|
||||
lfsr_stat(&lfs, "coffee/drip", &info) => 0;
|
||||
|
||||
assert(strcmp(info.name, "drip") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/coldbrew", &info) => 0;
|
||||
assert(strcmp(info.name, "coldbrew") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/turkish", &info) => 0;
|
||||
assert(strcmp(info.name, "turkish") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/tubruk", &info) => 0;
|
||||
assert(strcmp(info.name, "tubruk") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/vietnamese", &info) => 0;
|
||||
assert(strcmp(info.name, "vietnamese") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
lfsr_stat(&lfs, "coffee/thai", &info) => 0;
|
||||
assert(strcmp(info.name, "thai") == 0);
|
||||
assert(info.type == 0x13);
|
||||
assert(info.type == LFS_TYPE_UNKNOWN);
|
||||
|
||||
lfsr_unmount(&lfs) => 0;
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user