Pipe cleanup (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 21 Jan 2014 21:16:52 +0000 (13:16 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 21 Jan 2014 21:16:52 +0000 (13:16 -0800)
Using the 9ns pipes exclusively, so no need for SYS_npipe.

Note the omode change.  That goes back to 424240126c, and it'll be a
concern for all new devices.

Reinstall your kernel headers (or just don't use SYS_npipe).

kern/drivers/dev/pipe.c
kern/include/ros/bits/syscall.h
kern/src/syscall.c

index ba643ef..f4d6585 100644 (file)
@@ -222,10 +222,9 @@ pipeopen(struct chan *c, int omode)
        Pipe *p;
 
        if(c->qid.type & QTDIR){
-               /* let it go however */
-               if(omode != OREAD)
-                       printk/*error*/("Can only open directories OREAD, mode is %d", omode);
-               c->mode = OREAD; //omode;
+               if ((omode & OREAD) != OREAD)
+                       error("Can only open directories OREAD, mode is %o oct", omode);
+               c->mode = openmode(omode);
                c->flag |= COPEN;
                c->offset = 0;
                return c;
index d7afedb..8778da6 100644 (file)
@@ -77,7 +77,6 @@
 #define SYS_nbind                              145
 #define SYS_nmount                             146
 #define SYS_nunmount                   147
-#define SYS_npipe                              148
 #define SYS_fd2path                            149
 
 /* Syscalls we plan to remove someday */
index 0ae92d9..9f0109c 100644 (file)
@@ -1444,39 +1444,16 @@ intreg_t sys_pipe(struct proc *p, int *u_pipefd, int flags)
 {
        int pipefd[2] = {0};
        int retval = syspipe(pipefd);
-       int fd;
-       struct file *pipe_files[2] = {0};
 
        if (retval)
                return -1;
-       fd = insert_file(&p->open_files, pipe_files[0], 0);
-       if (!fd) {
-               set_errno(ENFILE);
-               goto failed_first;
-       }
-       pipefd[0] = fd;
-       fd = insert_file(&p->open_files, pipe_files[1], 0);
-       if (!fd) {
-               set_errno(ENFILE);
-               goto failed_second;
-       }
-       pipefd[1] = fd;
        if (memcpy_to_user_errno(p, u_pipefd, pipefd, sizeof(pipefd))) {
+               sysclose(pipefd[0]);
+               sysclose(pipefd[1]);
                set_errno(EFAULT);
-               goto failed_memcpy;
+               return -1;
        }
-       goto all_out;
-
-failed_memcpy:
-       put_file_from_fd(&p->open_files, pipefd[1]);
-failed_second:
-       put_file_from_fd(&p->open_files, pipefd[0]);
-failed_first:
-       retval = -1;
-all_out:
-       kref_put(&pipe_files[0]->f_kref);
-       kref_put(&pipe_files[1]->f_kref);
-       return retval;
+       return 0;
 }
 
 intreg_t sys_gettimeofday(struct proc *p, int *buf)
@@ -1607,14 +1584,6 @@ intreg_t sys_nbind(struct proc *p,
        return ret;
 }
 
-/* int npipe(int *fd) */
-intreg_t sys_npipe(struct proc *p, int *retfd)
-
-{
-       /* TODO: validate addresses of retfd (UMEM) */
-       return syspipe(retfd);
-}
-
 /* int mount(int fd, int afd, char* onto_path, int flag, char* aname); */
 intreg_t sys_nmount(struct proc *p,
                     int fd,
@@ -1747,7 +1716,6 @@ const static struct sys_table_entry syscall_table[] = {
        [SYS_nbind] ={(syscall_t)sys_nbind, "nbind"},
        [SYS_nmount] ={(syscall_t)sys_nmount, "nmount"},
        [SYS_nunmount] ={(syscall_t)sys_nunmount, "nunmount"},
-       [SYS_npipe] ={(syscall_t)sys_npipe, "npipe"},
        [SYS_fd2path] ={(syscall_t)sys_fd2path, "fd2path"},
 
 };