aboutsummaryrefslogtreecommitdiff
path: root/kernel/api/syscall.c
diff options
context:
space:
mode:
authorMichael Foiani <mfoiani@cs.brown.edu>2024-05-14 17:16:42 -0400
committerMichael Foiani <mfoiani@cs.brown.edu>2024-05-14 17:16:42 -0400
commit53b54f664ed2b4630c23cacc9e216a6a5935b57f (patch)
treef0138f1ed2f8894efa560e0e9721e510883f439b /kernel/api/syscall.c
parentb90313ddfa4c03f688c6c1cd5ded34aff1bf39c5 (diff)
fixes to work on dept machine
Diffstat (limited to 'kernel/api/syscall.c')
-rw-r--r--kernel/api/syscall.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/kernel/api/syscall.c b/kernel/api/syscall.c
index 7c76e51..c5fea6d 100644
--- a/kernel/api/syscall.c
+++ b/kernel/api/syscall.c
@@ -77,10 +77,11 @@ static long sys_read(read_args_t *args)
ERROR_OUT_RET(ret);
// Allocate a temporary buffer (a page-aligned block of n pages that are enough space to store the number of bytes to read)
- size_t size_in_pages = 0;
- while(++size_in_pages * PAGE_SIZE < kargs.nbytes)
- ;
- void *addr = page_alloc_n(size_in_pages);
+ // size_t size_in_pages = 0;
+ // while(++size_in_pages * PAGE_SIZE < kargs.nbytes)
+ // ;
+ size_t size_in_pages = ADDR_TO_PN(PAGE_ALIGN_UP(kargs.nbytes));
+ char *addr = (char *)page_alloc_n(size_in_pages);
if (!addr)
{
ret = -ENOMEM;
@@ -134,6 +135,11 @@ static long sys_write(write_args_t *args)
long ret = copy_from_user(&kargs, args, sizeof(kargs));
ERROR_OUT_RET(ret);
+ if (kargs.nbytes == 0)
+ {
+ return 0;
+ }
+
// Allocate a temporary buffer (a page-aligned block of n pages that are enough space to store the number of bytes to write)
size_t size_in_pages = 0;
while(++size_in_pages * PAGE_SIZE < kargs.nbytes)