summaryrefslogtreecommitdiff
path: root/src/kernel/vfs
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/vfs')
-rw-r--r--src/kernel/vfs/path.c10
-rw-r--r--src/kernel/vfs/path.h4
2 files changed, 7 insertions, 7 deletions
diff --git a/src/kernel/vfs/path.c b/src/kernel/vfs/path.c
index 8662f03..bd17e29 100644
--- a/src/kernel/vfs/path.c
+++ b/src/kernel/vfs/path.c
@@ -1,9 +1,9 @@
#include <kernel/vfs/path.h>
#include <kernel/panic.h>
-bool path_simplify(const char *in, char *out, size_t len) {
- if (len == 0) return false; // empty paths are invalid
- if (in[0] != '/') return false; // so are relative paths
+int path_simplify(const char *in, char *out, size_t len) {
+ if (len == 0) return -1; // empty paths are invalid
+ if (in[0] != '/') return -1; // so are relative paths
int depth = 0;
int seg_len; // the length of the current path segment
@@ -33,12 +33,12 @@ bool path_simplify(const char *in, char *out, size_t len) {
} else if (seg_len == 2 && in[i + 1] == '.' && in[i + 2] == '.') {
// the segment is /../
if (--depth < 0)
- return false;
+ return -1;
} else {
// normal segment
depth++;
}
}
- return true;
+ return 1; // TODO
}
diff --git a/src/kernel/vfs/path.h b/src/kernel/vfs/path.h
index 22dc754..3aefccf 100644
--- a/src/kernel/vfs/path.h
+++ b/src/kernel/vfs/path.h
@@ -6,6 +6,6 @@
* *in and *out can't overlap unless they're equal. Then, the path is modified
* in-place.
*
- * @return Was the path valid? If this is false, *out is undefined
+ * @return length of the string in *out, always less than len. Negative if the path was invalid.
*/
-bool path_simplify(const char *in, char *out, size_t len);
+int path_simplify(const char *in, char *out, size_t len);