PERFORCE change 163685 for review
Zhao Shuai
zhaoshuai at FreeBSD.org
Sun Jun 7 08:10:21 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=163685
Change 163685 by zhaoshuai at zhaoshuai on 2009/06/07 08:09:20
generic_pipe_*() no longer use file pointer as the first argument,
they use a pipe pointer.
Affected files ...
.. //depot/projects/soc2009/fifo/sys/fs/fifofs/fifo_vnops.c#8 edit
.. //depot/projects/soc2009/fifo/sys/kern/subr_pipe.c#5 edit
.. //depot/projects/soc2009/fifo/sys/kern/sys_pipe.c#8 edit
.. //depot/projects/soc2009/fifo/sys/sys/pipe.h#7 edit
Differences ...
==== //depot/projects/soc2009/fifo/sys/fs/fifofs/fifo_vnops.c#8 (text+ko) ====
@@ -284,7 +284,20 @@
} */ *ap;
{
- return (0);
+ switch (ap->a_name) {
+ case _PC_LINK_MAX:
+ *ap->a_retval = LINK_MAX;
+ return (0);
+ case _PC_PIPE_BUF:
+ *ap->a_retval = PIPE_BUF;
+ return (0);
+ case _PC_CHOWN_RESTRICTED:
+ *ap->a_retval = 1;
+ return (0);
+ default:
+ return (EINVAL);
+ }
+ /* NOTREACHED */
}
/*
@@ -300,33 +313,28 @@
int a_flags;
} */ *ap;
{
+
return (ap->a_flags & F_FLOCK ? EOPNOTSUPP : EINVAL);
}
static int
fifo_read_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td)
{
- int error;
+
struct fifoinfo *fip = fp->f_data;
+ struct pipe *rpipe = fip->fi_rpipe;
- fp->f_data = fip->fi_rpipe;
- error = generic_pipe_read(fp, uio, cred, flags, td);
- fp->f_data = fip;
-
- return (error);
+ return (generic_pipe_read(rpipe, uio, cred, flags, td));
}
static int
fifo_write_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td)
{
- int error;
+
struct fifoinfo *fip = fp->f_data;
+ struct pipe *wpipe = fip->fi_wpipe;
- fp->f_data = fip->fi_wpipe;
- error = generic_pipe_write(fp, uio, cred, flags, td);
- fp->f_data = fip;
-
- return (error);
+ return (generic_pipe_write(wpipe, uio, cred, flags, td));
}
static int
@@ -346,6 +354,7 @@
static int
fifo_close_f(struct file *fp, struct thread *td)
{
+
return (vnops.fo_close(fp, td));
}
==== //depot/projects/soc2009/fifo/sys/kern/subr_pipe.c#5 (text+ko) ====
@@ -446,10 +446,10 @@
}
int
-generic_pipe_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
- int flags, struct thread *td)
+generic_pipe_read(struct pipe *pipe, struct uio *uio, struct ucred *active_cred,
+ int f_flags, struct thread *td)
{
- struct pipe *rpipe = fp->f_data;
+ struct pipe *rpipe = pipe;
int error;
int nread = 0;
u_int size;
@@ -567,7 +567,7 @@
* Handle non-blocking mode operation or
* wait for more data.
*/
- if (fp->f_flag & FNONBLOCK) {
+ if (f_flags & FNONBLOCK) {
error = EAGAIN;
} else {
rpipe->pipe_state |= PIPE_WANTR;
@@ -844,14 +844,14 @@
#endif
int
-generic_pipe_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
- int flags, struct thread *td)
+generic_pipe_write(struct pipe *pipe, struct uio *uio, struct ucred *active_cred,
+ int f_flags, struct thread *td)
{
int error = 0;
int desiredsize, orig_resid;
- struct pipe *wpipe, *rpipe;
+ struct pipe *rpipe, *wpipe;
- rpipe = fp->f_data;
+ rpipe = pipe;
wpipe = rpipe->pipe_peer;
PIPE_LOCK(rpipe);
@@ -943,7 +943,7 @@
if (uio->uio_segflg == UIO_USERSPACE &&
uio->uio_iov->iov_len >= PIPE_MINDIRECT &&
wpipe->pipe_buffer.size >= PIPE_MINDIRECT &&
- (fp->f_flag & FNONBLOCK) == 0) {
+ (f_flags & FNONBLOCK) == 0) {
pipeunlock(wpipe);
error = pipe_direct_write(wpipe, uio);
if (error)
@@ -1059,7 +1059,7 @@
/*
* don't block on non-blocking I/O
*/
- if (fp->f_flag & FNONBLOCK) {
+ if (f_flags & FNONBLOCK) {
error = EAGAIN;
pipeunlock(wpipe);
break;
@@ -1122,7 +1122,7 @@
}
int
-generic_pipe_truncate(struct file *fp, off_t length, struct ucred *active_cred,
+generic_pipe_truncate(struct pipe *pipe, off_t length, struct ucred *active_cred,
struct thread *td)
{
@@ -1133,10 +1133,10 @@
* we implement a very minimal set of ioctls for compatibility with sockets.
*/
int
-generic_pipe_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
+generic_pipe_ioctl(struct pipe *pipe, u_long cmd, void *data, struct ucred *active_cred,
struct thread *td)
{
- struct pipe *mpipe = fp->f_data;
+ struct pipe *mpipe = pipe;
int error;
PIPE_LOCK(mpipe);
@@ -1200,10 +1200,10 @@
}
int
-generic_pipe_poll(struct file *fp, int events, struct ucred *active_cred,
+generic_pipe_poll(struct pipe *pipe, int events, struct ucred *active_cred,
struct thread *td)
{
- struct pipe *rpipe = fp->f_data;
+ struct pipe *rpipe = pipe;
struct pipe *wpipe;
int revents = 0;
#ifdef MAC
@@ -1261,10 +1261,9 @@
* be a natural race.
*/
int
-generic_pipe_stat(struct file *fp, struct stat *ub, struct ucred *active_cred,
+generic_pipe_stat(struct pipe *pipe, struct stat *ub, struct ucred *active_cred,
struct thread *td)
{
- struct pipe *pipe = fp->f_data;
#ifdef MAC
int error;
@@ -1285,8 +1284,6 @@
ub->st_atimespec = pipe->pipe_atime;
ub->st_mtimespec = pipe->pipe_mtime;
ub->st_ctimespec = pipe->pipe_ctime;
- ub->st_uid = fp->f_cred->cr_uid;
- ub->st_gid = fp->f_cred->cr_gid;
/*
* Left as 0: st_dev, st_ino, st_nlink, st_rdev, st_flags, st_gen.
* XXX (st_dev, st_ino) should be unique.
@@ -1399,11 +1396,9 @@
}
int
-generic_pipe_kqfilter(struct file *fp, struct knote *kn)
+generic_pipe_kqfilter(struct pipe *cpipe, struct knote *kn)
{
- struct pipe *cpipe;
- cpipe = kn->kn_fp->f_data;
PIPE_LOCK(cpipe);
switch (kn->kn_filter) {
case EVFILT_READ:
==== //depot/projects/soc2009/fifo/sys/kern/sys_pipe.c#8 (text+ko) ====
@@ -135,7 +135,9 @@
struct thread *td)
{
- return generic_pipe_read(fp, uio, active_cred, flags, td);
+ struct pipe *pipe = fp->f_data;
+
+ return generic_pipe_read(pipe, uio, active_cred, fp->f_flag, td);
}
int
@@ -143,55 +145,65 @@
struct thread *td)
{
- return generic_pipe_write(fp, uio, active_cred, flags, td);
+ struct pipe *pipe = fp->f_data;
+
+ return generic_pipe_write(pipe, uio, active_cred, fp->f_flag, td);
}
static int
pipe_truncate(struct file *fp, off_t length, struct ucred *active_cred, struct thread *td)
{
- return generic_pipe_truncate(fp, length, active_cred, td);
+ struct pipe *pipe = fp->f_data;
+
+ return generic_pipe_truncate(pipe, length, active_cred, td);
}
static int
pipe_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
struct thread *td)
{
+
+ struct pipe *pipe = fp->f_data;
- return generic_pipe_ioctl(fp, cmd, data, active_cred, td);
+ return generic_pipe_ioctl(pipe, cmd, data, active_cred, td);
}
static int
pipe_poll(struct file *fp, int events, struct ucred *active_cred, struct thread *td)
{
- return generic_pipe_poll(fp, events, active_cred, td);
+ struct pipe *pipe = fp->f_data;
+
+ return generic_pipe_poll(pipe, events, active_cred, td);
}
static int
pipe_stat(struct file *fp, struct stat *ub, struct ucred *active_cred, struct thread *td)
{
- return generic_pipe_stat(fp, ub, active_cred, td);
+ struct pipe *pipe = fp->f_data;
+
+ ub->st_uid = fp->f_cred->cr_uid;
+ ub->st_gid = fp->f_cred->cr_gid;
+ return generic_pipe_stat(pipe, ub, active_cred, td);
}
-/*
- * TODO: implement generic_pipe_close() in subr_pipe.c
- */
static int
pipe_close(struct file *fp, struct thread *td)
{
- struct pipe *cpipe = fp->f_data;
+ struct pipe *pipe = fp->f_data;
fp->f_ops = &badfileops;
fp->f_data = NULL;
- generic_pipe_close(cpipe);
+ generic_pipe_close(pipe);
return (0);
}
static int
pipe_kqfilter(struct file *fp, struct knote *kn)
{
+ struct pipe *pipe = kn->kn_fp->f_data;
- return generic_pipe_kqfilter(fp, kn);
+ return generic_pipe_kqfilter(pipe, kn);
}
==== //depot/projects/soc2009/fifo/sys/sys/pipe.h#7 (text+ko) ====
@@ -139,20 +139,20 @@
#define PIPE_UNLOCK(pipe) mtx_unlock(PIPE_MTX(pipe))
#define PIPE_LOCK_ASSERT(pipe, type) mtx_assert(PIPE_MTX(pipe), (type))
-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,
+int generic_pipe_read(struct pipe *pipe, struct uio *uio, struct ucred *active_cred,
+ int f_flags, struct thread *td);
+int generic_pipe_write(struct pipe *pipe, struct uio *uio, struct ucred *active_cred,
+ int f_flags, struct thread *td);
+int generic_pipe_truncate(struct pipe *pipe, 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,
+int generic_pipe_ioctl(struct pipe *pipe, 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,
+int generic_pipe_poll(struct pipe *pipe, int events, struct ucred *active_cred,
struct thread *td);
-int generic_pipe_stat(struct file *fp, struct stat *ub, struct ucred *active_cred,
+int generic_pipe_stat(struct pipe *pipe, struct stat *ub, struct ucred *active_cred,
struct thread *td);
-int generic_pipe_kqfilter(struct file *fp, struct knote *kn);
+int generic_pipe_kqfilter(struct pipe *pipe, struct knote *kn);
int generic_pipe_create(struct thread *td, struct pipe **p_rpipe, struct pipe **p_wpipe);
-void generic_pipe_close(struct pipe *cpipe);
+void generic_pipe_close(struct pipe *pipe);
#endif /* !_SYS_PIPE_H_ */
More information about the p4-projects
mailing list