]> Devi Nivas Git - cs3210-lab1.git/commitdiff
shell nits
authorRobert Morris <rtm@csail.mit.edu>
Mon, 8 Aug 2016 17:06:38 +0000 (13:06 -0400)
committerRobert Morris <rtm@csail.mit.edu>
Mon, 8 Aug 2016 17:06:38 +0000 (13:06 -0400)
fix Regehr complaint

sh.c
vm.c

diff --git a/sh.c b/sh.c
index 16e325b1a4f8206946978a878bab710966e9caf1..3ac6f5bd30fb3d6cd17aa7fd6250ad91f72e5d42 100644 (file)
--- a/sh.c
+++ b/sh.c
@@ -147,7 +147,7 @@ main(void)
   static char buf[100];
   int fd;
   
-  // Assumes three file descriptors open.
+  // Ensure that three file descriptors are open.
   while((fd = open("console", O_RDWR)) >= 0){
     if(fd >= 3){
       close(fd);
@@ -158,8 +158,7 @@ main(void)
   // Read and run input commands.
   while(getcmd(buf, sizeof(buf)) >= 0){
     if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
-      // Clumsy but will have to do for now.
-      // Chdir has no effect on the parent if run in the child.
+      // Chdir must be called by the parent, not the child.
       buf[strlen(buf)-1] = 0;  // chop \n
       if(chdir(buf+3) < 0)
         printf(2, "cannot cd %s\n", buf+3);
diff --git a/vm.c b/vm.c
index 5326d14a5934a97a67faea5981d11f1f8c6e79f2..85f6ce23b4fe94f312fec0ba575613162bf529a8 100644 (file)
--- a/vm.c
+++ b/vm.c
@@ -237,7 +237,12 @@ allocuvm(pde_t *pgdir, uint oldsz, uint newsz)
       return 0;
     }
     memset(mem, 0, PGSIZE);
-    mappages(pgdir, (char*)a, PGSIZE, v2p(mem), PTE_W|PTE_U);
+    if(mappages(pgdir, (char*)a, PGSIZE, v2p(mem), PTE_W|PTE_U) < 0){
+      cprintf("allocuvm out of memory (2)\n");
+      deallocuvm(pgdir, newsz, oldsz);
+      kfree(mem);
+      return 0;
+    }
   }
   return newsz;
 }