summaryrefslogtreecommitdiff
path: root/src/kernel/arch/amd64/driver/pata.c
diff options
context:
space:
mode:
authordzwdz2022-08-28 14:35:31 +0200
committerdzwdz2022-08-28 14:35:31 +0200
commit83567c386e4a50cc4303d2c3966d7518331e129f (patch)
tree1b6c74526310ccb0a7fb84b070ff6810c731729e /src/kernel/arch/amd64/driver/pata.c
parenta8e0cd702f97ffc74dd29f4b873e8813b7e9f27c (diff)
kernel/driver: clean up ps2, add the reqpathcmp() macro
Diffstat (limited to 'src/kernel/arch/amd64/driver/pata.c')
-rw-r--r--src/kernel/arch/amd64/driver/pata.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/kernel/arch/amd64/driver/pata.c b/src/kernel/arch/amd64/driver/pata.c
index b6ed05e..3118e86 100644
--- a/src/kernel/arch/amd64/driver/pata.c
+++ b/src/kernel/arch/amd64/driver/pata.c
@@ -17,25 +17,17 @@ void pata_init(void) {
vfs_root_register("/ata", accept);
}
-
-static bool exacteq(struct vfs_request *req, const char *str) {
- size_t len = strlen(str);
- assert(req->input.kern);
- return req->input.len == len && !memcmp(req->input.buf_kern, str, len);
-}
-
static void accept(struct vfs_request *req) {
int ret;
long id = (long __force)req->id;
switch (req->type) {
case VFSOP_OPEN:
- if (!req->input.kern) panic_invalid_state();
- ret = -ENOENT;
- if (exacteq(req, "/")) ret = root_id;
- else if (exacteq(req, "/0")) ret = 0;
- else if (exacteq(req, "/1")) ret = 1;
- else if (exacteq(req, "/2")) ret = 2;
- else if (exacteq(req, "/3")) ret = 3;
+ if (reqpathcmp(req, "/")) ret = root_id;
+ else if (reqpathcmp(req, "/0")) ret = 0;
+ else if (reqpathcmp(req, "/1")) ret = 1;
+ else if (reqpathcmp(req, "/2")) ret = 2;
+ else if (reqpathcmp(req, "/3")) ret = 3;
+ else ret = -ENOENT;
vfsreq_finish_short(req, ret);
break;