summaryrefslogtreecommitdiff
path: root/src/user/knob
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/knob')
-rw-r--r--src/user/knob/file.c16
-rw-r--r--src/user/knob/task.c13
2 files changed, 20 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)
diff --git a/src/user/knob/task.c b/src/user/knob/task.c
new file mode 100644
index 0000000..aa18eab
--- /dev/null
+++ b/src/user/knob/task.c
@@ -0,0 +1,13 @@
+#include <stdbool.h>
+#include <pland/syscall.h>
+#include <knob/file.h>
+
+bool try_run_command(const char *path) {
+ uint8_t dn;
+ path = remove_prefix(path, &dn);
+ return _start_task(dn, path);
+}
+
+void yield_task() {
+ _yield_task();
+} \ No newline at end of file