PERFORCE change 163165 for review
Zhao Shuai
zhaoshuai at FreeBSD.org
Sun May 31 13:20:20 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=163165
Change 163165 by zhaoshuai at zhaoshuai on 2009/05/31 13:20:06
new version of subr_pipe.c and sys_pipe.c, tested
Affected files ...
.. //depot/projects/soc2009/fifo/sys/conf/files#3 edit
.. //depot/projects/soc2009/fifo/sys/kern/subr_pipe.c#2 edit
.. //depot/projects/soc2009/fifo/sys/kern/sys_pipe.c#5 edit
.. //depot/projects/soc2009/fifo/sys/sys/pipe.h#4 edit
Differences ...
==== //depot/projects/soc2009/fifo/sys/conf/files#3 (text+ko) ====
@@ -1988,6 +1988,7 @@
kern/subr_msgbuf.c standard
kern/subr_param.c standard
kern/subr_pcpu.c standard
+kern/subr_pipe.c standard
kern/subr_power.c standard
kern/subr_prf.c standard
kern/subr_prof.c standard
==== //depot/projects/soc2009/fifo/sys/kern/subr_pipe.c#2 (text+ko) ====
@@ -175,7 +175,6 @@
&piperesizeallowed, 0, "Pipe resizing allowed");
static void pipeinit(void *dummy __unused);
-static void pipeclose(struct pipe *cpipe);
static void pipe_free_kmem(struct pipe *cpipe);
static int pipe_create(struct pipe *pipe, int backing);
static __inline int pipelock(struct pipe *cpipe, int catch);
@@ -446,7 +445,6 @@
return (error);
}
-/* ARGSUSED */
int
generic_pipe_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
int flags, struct thread *td)
@@ -1261,7 +1259,7 @@
* We shouldn't need locks here as we're doing a read and this should
* be a natural race.
*/
-static int
+int
generic_pipe_stat(struct file *fp, struct stat *ub, struct ucred *active_cred,
struct thread *td)
{
@@ -1323,8 +1321,7 @@
* shutdown the pipe
*/
void
-pipeclose(cpipe)
- struct pipe *cpipe;
+pipeclose(struct pipe *cpipe)
{
struct pipepair *pp;
struct pipe *ppipe;
@@ -1489,23 +1486,25 @@
}
int
-generic_pipe_create(struct pipepair **p_pp, struct thread *td)
+generic_pipe_create(struct thread *td, struct pipe **p_rpipe, struct pipe **p_wpipe)
{
struct pipepair *pp;
struct pipe *rpipe, *wpipe;
+ int error;
pp = uma_zalloc(pipe_zone, M_WAITOK);
- *p_pp = pp;
rpipe = &pp->pp_rpipe;
wpipe = &pp->pp_wpipe;
+ *p_rpipe = rpipe;
+ *p_wpipe = wpipe;
knlist_init(&rpipe->pipe_sel.si_note, PIPE_MTX(rpipe), NULL, NULL,
NULL);
knlist_init(&wpipe->pipe_sel.si_note, PIPE_MTX(wpipe), NULL, NULL,
NULL);
- if (pipe_create(rpipe, 1) != 0 ||
- pipe_create(wpipe, 0) != 0) {
+ if ((error = pipe_create(rpipe, 1)) != 0 ||
+ (error = pipe_create(wpipe, 0)) != 0) {
pipeclose(rpipe);
pipeclose(wpipe);
return (error);
==== //depot/projects/soc2009/fifo/sys/kern/sys_pipe.c#5 (text+ko) ====
@@ -74,16 +74,16 @@
{
struct filedesc *fdp = td->td_proc->p_fd;
struct file *rf, *wf;
- struct pipepair *pp;
+ struct pipe *rpipe, *wpipe;
int fd, error;
- if ((error = generic_pipe_create(&pp, td)) != 0)
+ if ((error = generic_pipe_create(td, &rpipe, &wpipe)) != 0)
return (error);
error = falloc(td, &rf, &fd);
if (error) {
- pipeclose(&pp->rpipe);
- pipeclose(&pp->wpipe);
+ pipeclose(rpipe);
+ pipeclose(wpipe);
return (error);
}
/* An extra reference on `rf' has been held for us by falloc(). */
@@ -95,17 +95,17 @@
* to avoid races against processes which manage to dup() the read
* side while we are blocked trying to allocate the write side.
*/
- finit(rf, FREAD | FWRITE, DTYPE_PIPE, &pp->rpipe, &pipeops);
+ finit(rf, FREAD | FWRITE, DTYPE_PIPE, rpipe, &pipeops);
error = falloc(td, &wf, &fd);
if (error) {
fdclose(fdp, rf, fildes[0], td);
fdrop(rf, td);
/* rpipe has been closed by fdrop(). */
- pipeclose(&pp->wpipe);
+ pipeclose(wpipe);
return (error);
}
/* An extra reference on `wf' has been held for us by falloc(). */
- finit(wf, FREAD | FWRITE, DTYPE_PIPE, &pp->wpipe, &pipeops);
+ finit(wf, FREAD | FWRITE, DTYPE_PIPE, wpipe, &pipeops);
fdrop(wf, td);
fildes[1] = fd;
fdrop(rf, td);
@@ -175,6 +175,9 @@
return generic_pipe_stat(fp, ub, active_cred, td);
}
+/*
+ * TODO: implement generic_pipe_close() in subr_pipe.c
+ */
static int
pipe_close(struct file *fp, struct thread *td)
{
==== //depot/projects/soc2009/fifo/sys/sys/pipe.h#4 (text+ko) ====
@@ -139,13 +139,20 @@
#define PIPE_UNLOCK(pipe) mtx_unlock(PIPE_MTX(pipe))
#define PIPE_LOCK_ASSERT(pipe, type) mtx_assert(PIPE_MTX(pipe), (type))
-/*
- * The following functions are used by FIFO,
- * see fs/fifo_vnops.c
- */
-struct pipepair *pipepair_create(void);
-fo_rdwr_t pipe_read;
-fo_rdwr_t pipe_write;
-void pipeclose(struct pipe *);
+void pipeclose(struct pipe *cpipe);
+int generic_pipe_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
+ int flags, struct thread *td);
+int generic_pipe_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
+ int flags, struct thread *td);
+int generic_pipe_truncate(struct file *fp, off_t length, struct ucred *active_cred,
+ struct thread *td);
+int generic_pipe_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
+ struct thread *td);
+int generic_pipe_poll(struct file *fp, int events, struct ucred *active_cred,
+ struct thread *td);
+int generic_pipe_stat(struct file *fp, struct stat *ub, struct ucred *active_cred,
+ struct thread *td);
+int generic_pipe_kqfilter(struct file *fp, struct knote *kn);
+int generic_pipe_create(struct thread *td, struct pipe **p_rpipe, struct pipe **p_wpipe);
#endif /* !_SYS_PIPE_H_ */
More information about the p4-projects
mailing list