/* * linux/fs/pipe.c * * (C) 1991 Linus Torvalds */ #include #include #include /* for get_free_page */ #include int sys_pipe2(unsigned long * fildes,int flag) { struct m_inode * inode; struct file * f[2]; int fd[2]; int i,j; if(flag==0){ j=0; for(i=0;j<2 && if_count++; if (j==1) f[0]->f_count=0; if (j<2) return -1; j=0; for(i=0;j<2 && ifilp[i]) { current->filp[ fd[j]=i ] = f[j]; j++; } if (j==1) current->filp[fd[0]]=NULL; if (j<2) { f[0]->f_count=f[1]->f_count=0; return -1; } if (!(inode=get_pipe_inode())) { current->filp[fd[0]] = current->filp[fd[1]] = NULL; f[0]->f_count = f[1]->f_count = 0; return -1; } f[0]->f_inode = f[1]->f_inode = inode; f[0]->f_pos = f[1]->f_pos = 0; f[0]->f_mode = 1; /* read */ f[1]->f_mode = 2; /* write */ put_fs_long(fd[0],0+fildes); put_fs_long(fd[1],1+fildes); } return 0; }