diff options
author | Benji Dial <benji6283@gmail.com> | 2020-09-06 13:44:20 -0400 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2020-09-06 13:44:20 -0400 |
commit | 73bb0e48640b842824a0b45fe4854df8ff7faf7b (patch) | |
tree | 077dec8a426db1e835393964da4736e91ff4c69d /src/user/knob/file.c | |
parent | cbc85f6e897808b29e2f712156e2fa4d073d8277 (diff) | |
download | portland-os-73bb0e48640b842824a0b45fe4854df8ff7faf7b.tar.gz |
bugfixes, init program, hello world
Diffstat (limited to 'src/user/knob/file.c')
-rw-r--r-- | src/user/knob/file.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/user/knob/file.c b/src/user/knob/file.c index 8ab7acd..0032cf2 100644 --- a/src/user/knob/file.c +++ b/src/user/knob/file.c @@ -9,9 +9,9 @@ struct file { uint32_t length; }; -static const char *try_remove_prefix(const char *path, uint8_t *dn_out) { +const char *remove_prefix(const char *path, uint8_t *dn_out) { if ((path[0] != 's') || (path[1] != 'd')) - return 0; + goto no_prefix; const char *num_part = path + 2; for (uint32_t i = 0; num_part[i]; ++i) @@ -19,22 +19,20 @@ static const char *try_remove_prefix(const char *path, uint8_t *dn_out) { uint32_t dn_large; if (!try_sntoi(num_part, i, &dn_large) || dn_large > 255) - return 0; + goto no_prefix; *dn_out = (uint8_t)dn_large; return num_part + i + 1; } - return 0; +no_prefix: + *dn_out = current_drive; + return path; } struct file *open_file(const char *path) { uint8_t dn; - const char *path_part = try_remove_prefix(path, &dn); - if (path_part) - path = path_part; - else - dn = current_drive; + path = remove_prefix(path, &dn); _file_handle_t h = _open_file(dn, path); if (!h) |