summaryrefslogtreecommitdiff
path: root/src/kernel/arch
diff options
context:
space:
mode:
authordzwdz2022-07-08 14:40:44 +0200
committerdzwdz2022-07-08 14:40:44 +0200
commit1f7e7501660123ff8f26e8c65e75c2b282b933ef (patch)
tree5ba6cee10ac656b20dcabc9c9f7b079dcd952a45 /src/kernel/arch
parente567ebeee5ea196128f15adcf30cec5dd1137f90 (diff)
syscall/fs_respond: get the file id from the buf argument
Previously, file ids could only be positive integers, so their range was 31 bits - not enough to represent the entire memory. Now, pointers can be safely used as file ids.
Diffstat (limited to 'src/kernel/arch')
-rw-r--r--src/kernel/arch/i386/driver/fsroot.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/kernel/arch/i386/driver/fsroot.c b/src/kernel/arch/i386/driver/fsroot.c
index ccba0b6..e16dd80 100644
--- a/src/kernel/arch/i386/driver/fsroot.c
+++ b/src/kernel/arch/i386/driver/fsroot.c
@@ -45,6 +45,7 @@ static void req_preprocess(struct vfs_request *req, size_t max_len) {
static int handle(struct vfs_request *req) {
assert(req->caller);
+ int id = (int)req->id;
switch (req->type) {
case VFSOP_OPEN:
if (req->flags & OPEN_CREATE) return -1;
@@ -65,7 +66,7 @@ static int handle(struct vfs_request *req) {
return -1;
case VFSOP_READ:
- switch (req->id) {
+ switch (id) {
case HANDLE_ROOT: {
// TODO document directory read format
const char src[] =
@@ -106,7 +107,7 @@ static int handle(struct vfs_request *req) {
char buf[512];
uint32_t sector = req->offset / 512;
size_t len = min(req->output.len, 512 - ((size_t)req->offset & 511));
- ata_read(req->id - HANDLE_ATA, sector, buf);
+ ata_read(id - HANDLE_ATA, sector, buf);
virt_cpy_to(req->caller->pages, req->output.buf, buf, len);
return len;
}
@@ -114,7 +115,7 @@ static int handle(struct vfs_request *req) {
}
case VFSOP_WRITE:
- switch (req->id) {
+ switch (id) {
case HANDLE_VGA: {
void *vga = (void*)0xB8000;
req_preprocess(req, 80*25*2);