PERFORCE change 165040 for review
Zhao Shuai
zhaoshuai at FreeBSD.org
Wed Jun 24 10:52:20 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=165040
Change 165040 by zhaoshuai at zhaoshuai on 2009/06/24 10:51:32
keep the order of fifo functions as its original version.
Affected files ...
.. //depot/projects/soc2009/fifo/sys/fs/fifofs/fifo_vnops.c#18 edit
Differences ...
==== //depot/projects/soc2009/fifo/sys/fs/fifofs/fifo_vnops.c#18 (text+ko) ====
@@ -257,40 +257,6 @@
}
/*
- * Device close routine
- */
-/* ARGSUSED */
-static int
-fifo_close(ap)
- struct vop_close_args /* {
- struct vnode *a_vp;
- int a_fflag;
- struct ucred *a_cred;
- struct thread *a_td;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct fifoinfo *fip = vp->v_fifoinfo;
-
- ASSERT_VOP_ELOCKED(vp, "fifo_close");
- if (ap->a_fflag & FREAD) {
- fip->fi_readers--;
- if (fip->fi_readers == 0)
- pipe_close(fip->fi_rpipe);
- }
- if (ap->a_fflag & FWRITE) {
- fip->fi_writers--;
- if (fip->fi_writers == 0)
- pipe_close(fip->fi_wpipe);
- }
- if (fip->fi_readers == 0 && fip->fi_writers == 0) {
- vp->v_fifoinfo = NULL;
- free(fip, M_VNODE);
- }
- return (0);
-}
-
-/*
* Now unused vnode ioctl routine.
*/
/* ARGSUSED */
@@ -326,8 +292,110 @@
return (EINVAL);
}
+static void
+filt_fifodetach(struct knote *kn)
+{
+ struct pipe *pipe = (struct pipe *)kn->kn_hook;
+
+ PIPE_LOCK(pipe);
+ knlist_remove(&pipe->pipe_sel.si_note, kn, 1);
+ PIPE_UNLOCK(pipe);
+}
+
+static int
+filt_fiforead(struct knote *kn, long hint)
+{
+ struct pipe *rpipe = (struct pipe *)kn->kn_hook;
+ struct pipe *wpipe = rpipe->pipe_peer;
+ int ret;
+
+ PIPE_LOCK(rpipe);
+ kn->kn_data = rpipe->pipe_buffer.cnt;
+ if ((kn->kn_data == 0) && (rpipe->pipe_state & PIPE_DIRECTW))
+ kn->kn_data = rpipe->pipe_map.cnt;
+
+ if ((rpipe->pipe_state & PIPE_EOF) ||
+ wpipe->pipe_present != PIPE_ACTIVE ||
+ (wpipe->pipe_state & PIPE_EOF)) {
+ kn->kn_flags |= EV_EOF;
+ PIPE_UNLOCK(rpipe);
+ return (1);
+ }
+ ret = kn->kn_data > 0;
+ PIPE_UNLOCK(rpipe);
+ return ret;
+}
+
+static int
+filt_fifowrite(struct knote *kn, long hint)
+{
+ struct pipe *wpipe = (struct pipe *)kn->kn_hook;
+
+ PIPE_LOCK(wpipe);
+ if (wpipe->pipe_present != PIPE_ACTIVE ||
+ (wpipe->pipe_state & PIPE_EOF)) {
+ kn->kn_data = 0;
+ kn->kn_flags |= EV_EOF;
+ PIPE_UNLOCK(wpipe);
+ return (1);
+ }
+ kn->kn_data = wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt;
+ if (wpipe->pipe_state & PIPE_DIRECTW)
+ kn->kn_data = 0;
+
+ PIPE_UNLOCK(wpipe);
+ return (kn->kn_data >= PIPE_BUF);
+}
+
+static void
+filt_fifodetach_notsup(struct knote *kn)
+{
+
+}
+
+static int
+filt_fifo_notsup(struct knote *kn, long hint)
+{
+
+ return (0);
+}
+
/*
- * Print out internel contents of a fifo vnode
+ * Device close routine
+ */
+/* ARGSUSED */
+static int
+fifo_close(ap)
+ struct vop_close_args /* {
+ struct vnode *a_vp;
+ int a_fflag;
+ struct ucred *a_cred;
+ struct thread *a_td;
+ } */ *ap;
+{
+ struct vnode *vp = ap->a_vp;
+ struct fifoinfo *fip = vp->v_fifoinfo;
+
+ ASSERT_VOP_ELOCKED(vp, "fifo_close");
+ if (ap->a_fflag & FREAD) {
+ fip->fi_readers--;
+ if (fip->fi_readers == 0)
+ pipe_close(fip->fi_rpipe);
+ }
+ if (ap->a_fflag & FWRITE) {
+ fip->fi_writers--;
+ if (fip->fi_writers == 0)
+ pipe_close(fip->fi_wpipe);
+ }
+ if (fip->fi_readers == 0 && fip->fi_writers == 0) {
+ vp->v_fifoinfo = NULL;
+ free(fip, M_VNODE);
+ }
+ return (0);
+}
+
+/*
+ * Print out internal contents of a fifo vnode.
*/
int
fifo_printinfo(struct vnode *vp)
@@ -339,7 +407,7 @@
return (0);
}
printf(", fifo with %ld readers and %ld writers",
- fip->fi_readers, fip->fi_writers);
+ fip->fi_readers, fip->fi_writers);
return (0);
}
@@ -352,7 +420,7 @@
struct vnode *a_vp;
} */ *ap;
{
- printf(" ");
+ printf(" ");
fifo_printinfo(ap->a_vp);
printf("\n");
return (0);
@@ -393,10 +461,10 @@
fifo_advlock(ap)
struct vop_advlock_args /* {
struct vnode *a_vp;
- caddr_t a_id;
- int a_op;
+ caddr_t a_id;
+ int a_op;
struct flock *a_fl;
- int a_flags;
+ int a_flags;
} */ *ap;
{
@@ -404,47 +472,6 @@
}
static int
-fifo_read_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td)
-{
-
- struct fifoinfo *fip = fp->f_data;
-
- /* The 4th argument of pipe_read is file flag */
- return (pipe_read(fip->fi_rpipe, uio, cred, fp->f_flag, td));
-}
-
-static int
-fifo_write_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td)
-{
-
- struct fifoinfo *fip = fp->f_data;
-
- /* The 4th argument of pipe_write is file flag */
- return (pipe_write(fip->fi_wpipe, uio, cred, fp->f_flag, td));
-}
-
-static int
-fifo_stat_f(struct file *fp, struct stat *sb, struct ucred *cred, struct thread *td)
-{
- struct fifoinfo *fip = fp->f_data;
- int error;
-
- error = pipe_stat(fip->fi_rpipe, sb, cred, td);
- if (error)
- return (error);
- sb->st_uid = fp->f_cred->cr_uid;
- sb->st_gid = fp->f_cred->cr_gid;
- return (0);
-}
-
-static int
-fifo_truncate_f(struct file *fp, off_t length, struct ucred *cred, struct thread *td)
-{
-
- return (vnops.fo_truncate(fp, length, cred, td));
-}
-
-static int
fifo_close_f(struct file *fp, struct thread *td)
{
@@ -463,10 +490,10 @@
*/
static int
fifo_ioctl_f(struct file *fp, u_long com, void *data, struct ucred *cred,
- struct thread *td)
+ struct thread *td)
{
+ int error = ENOTTY;
struct fifoinfo *fip = fp->f_data;
- int error = ENOTTY;
switch (com) {
case FIONBIO:
@@ -552,86 +579,58 @@
return (0);
}
-static void
-filt_fifodetach(struct knote *kn)
+static int
+fifo_poll_f(struct file *fp, int events, struct ucred *cred, struct thread *td)
{
- struct pipe *pipe = (struct pipe *)kn->kn_hook;
+ struct fifoinfo *fip = fp->f_data;
+ int levents, revents = 0;
- PIPE_LOCK(pipe);
- knlist_remove(&pipe->pipe_sel.si_note, kn, 1);
- PIPE_UNLOCK(pipe);
+ levents = events & (POLLIN | POLLRDNORM);
+ if ((fp->f_flag & FREAD) && levents)
+ revents |= pipe_poll(fip->fi_rpipe, levents, cred, td);
+ levents = events & (POLLOUT | POLLWRNORM);
+ if ((fp->f_flag & FWRITE) && levents)
+ revents |= pipe_poll(fip->fi_wpipe, levents, cred, td);
+ return (revents);
}
static int
-filt_fiforead(struct knote *kn, long hint)
+fifo_read_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td)
{
- struct pipe *rpipe = (struct pipe *)kn->kn_hook;
- struct pipe *wpipe = rpipe->pipe_peer;
- int ret;
- PIPE_LOCK(rpipe);
- kn->kn_data = rpipe->pipe_buffer.cnt;
- if ((kn->kn_data == 0) && (rpipe->pipe_state & PIPE_DIRECTW))
- kn->kn_data = rpipe->pipe_map.cnt;
+ struct fifoinfo *fip = fp->f_data;
- if ((rpipe->pipe_state & PIPE_EOF) ||
- wpipe->pipe_present != PIPE_ACTIVE ||
- (wpipe->pipe_state & PIPE_EOF)) {
- kn->kn_flags |= EV_EOF;
- PIPE_UNLOCK(rpipe);
- return (1);
- }
- ret = kn->kn_data > 0;
- PIPE_UNLOCK(rpipe);
- return ret;
+ /* The 4th argument of pipe_read is file flag */
+ return (pipe_read(fip->fi_rpipe, uio, cred, fp->f_flag, td));
}
static int
-filt_fifowrite(struct knote *kn, long hint)
+fifo_stat_f(struct file *fp, struct stat *sb, struct ucred *cred, struct thread *td)
{
- struct pipe *wpipe = (struct pipe *)kn->kn_hook;
+ struct fifoinfo *fip = fp->f_data;
+ int error;
- PIPE_LOCK(wpipe);
- if (wpipe->pipe_present != PIPE_ACTIVE ||
- (wpipe->pipe_state & PIPE_EOF)) {
- kn->kn_data = 0;
- kn->kn_flags |= EV_EOF;
- PIPE_UNLOCK(wpipe);
- return (1);
- }
- kn->kn_data = wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt;
- if (wpipe->pipe_state & PIPE_DIRECTW)
- kn->kn_data = 0;
-
- PIPE_UNLOCK(wpipe);
- return (kn->kn_data >= PIPE_BUF);
+ error = pipe_stat(fip->fi_rpipe, sb, cred, td);
+ if (error)
+ return (error);
+ sb->st_uid = fp->f_cred->cr_uid;
+ sb->st_gid = fp->f_cred->cr_gid;
+ return (0);
}
-static void
-filt_fifodetach_notsup(struct knote *kn)
+static int
+fifo_truncate_f(struct file *fp, off_t length, struct ucred *cred, struct thread *td)
{
-
+
+ return (vnops.fo_truncate(fp, length, cred, td));
}
static int
-filt_fifo_notsup(struct knote *kn, long hint)
+fifo_write_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td)
{
- return (0);
-}
-
-static int
-fifo_poll_f(struct file *fp, int events, struct ucred *cred, struct thread *td)
-{
struct fifoinfo *fip = fp->f_data;
- int levents, revents = 0;
- levents = events & (POLLIN | POLLRDNORM);
- if ((fp->f_flag & FREAD) && levents)
- revents |= pipe_poll(fip->fi_rpipe, levents, cred, td);
- levents = events & (POLLOUT | POLLWRNORM);
- if ((fp->f_flag & FWRITE) && levents)
- revents |= pipe_poll(fip->fi_wpipe, levents, cred, td);
- return (revents);
+ /* The 4th argument of pipe_write is file flag */
+ return (pipe_write(fip->fi_wpipe, uio, cred, fp->f_flag, td));
}
-
More information about the p4-projects
mailing list