Deleted Added
full compact
sys_pipe.c (70915) sys_pipe.c (72521)
1/*
2 * Copyright (c) 1996 John S. Dyson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice immediately at the beginning of the file, without modification,
10 * this list of conditions, and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Absolutely no warranty of function or purpose is made by the author
15 * John S. Dyson.
16 * 4. Modifications may be freely made to this file if the above conditions
17 * are met.
18 *
1/*
2 * Copyright (c) 1996 John S. Dyson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice immediately at the beginning of the file, without modification,
10 * this list of conditions, and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Absolutely no warranty of function or purpose is made by the author
15 * John S. Dyson.
16 * 4. Modifications may be freely made to this file if the above conditions
17 * are met.
18 *
19 * $FreeBSD: head/sys/kern/sys_pipe.c 70915 2001-01-11 00:13:54Z dwmalone $
19 * $FreeBSD: head/sys/kern/sys_pipe.c 72521 2001-02-15 16:34:11Z jlemon $
20 */
21
22/*
23 * This file contains a high-performance replacement for the socket-based
24 * pipes scheme originally used in FreeBSD/4.4Lite. It does not support
25 * all features of sockets, but does do everything that pipes normally
26 * do.
27 */

--- 62 unchanged lines hidden (view full) ---

90 */
91static int pipe_read __P((struct file *fp, struct uio *uio,
92 struct ucred *cred, int flags, struct proc *p));
93static int pipe_write __P((struct file *fp, struct uio *uio,
94 struct ucred *cred, int flags, struct proc *p));
95static int pipe_close __P((struct file *fp, struct proc *p));
96static int pipe_poll __P((struct file *fp, int events, struct ucred *cred,
97 struct proc *p));
20 */
21
22/*
23 * This file contains a high-performance replacement for the socket-based
24 * pipes scheme originally used in FreeBSD/4.4Lite. It does not support
25 * all features of sockets, but does do everything that pipes normally
26 * do.
27 */

--- 62 unchanged lines hidden (view full) ---

90 */
91static int pipe_read __P((struct file *fp, struct uio *uio,
92 struct ucred *cred, int flags, struct proc *p));
93static int pipe_write __P((struct file *fp, struct uio *uio,
94 struct ucred *cred, int flags, struct proc *p));
95static int pipe_close __P((struct file *fp, struct proc *p));
96static int pipe_poll __P((struct file *fp, int events, struct ucred *cred,
97 struct proc *p));
98static int pipe_kqfilter __P((struct file *fp, struct knote *kn));
98static int pipe_stat __P((struct file *fp, struct stat *sb, struct proc *p));
99static int pipe_ioctl __P((struct file *fp, u_long cmd, caddr_t data, struct proc *p));
100
99static int pipe_stat __P((struct file *fp, struct stat *sb, struct proc *p));
100static int pipe_ioctl __P((struct file *fp, u_long cmd, caddr_t data, struct proc *p));
101
101static struct fileops pipeops =
102 { pipe_read, pipe_write, pipe_ioctl, pipe_poll, pipe_stat, pipe_close };
102static struct fileops pipeops = {
103 pipe_read, pipe_write, pipe_ioctl, pipe_poll, pipe_kqfilter,
104 pipe_stat, pipe_close
105};
103
106
104static int filt_pipeattach(struct knote *kn);
105static void filt_pipedetach(struct knote *kn);
106static int filt_piperead(struct knote *kn, long hint);
107static int filt_pipewrite(struct knote *kn, long hint);
108
107static void filt_pipedetach(struct knote *kn);
108static int filt_piperead(struct knote *kn, long hint);
109static int filt_pipewrite(struct knote *kn, long hint);
110
109struct filterops pipe_rwfiltops[] = {
110 { 1, filt_pipeattach, filt_pipedetach, filt_piperead },
111 { 1, filt_pipeattach, filt_pipedetach, filt_pipewrite },
112};
111static struct filterops pipe_rfiltops =
112 { 1, NULL, filt_pipedetach, filt_piperead };
113static struct filterops pipe_wfiltops =
114 { 1, NULL, filt_pipedetach, filt_pipewrite };
113
115
116
114/*
115 * Default pipe buffer size(s), this can be kind-of large now because pipe
116 * space is pageable. The pipe code will try to maintain locality of
117 * reference for performance reasons, so small amounts of outstanding I/O
118 * will not wipe the cache.
119 */
120#define MINPIPESIZE (PIPE_SIZE/3)
121#define MAXPIPESIZE (2*PIPE_SIZE/3)

--- 1059 unchanged lines hidden (view full) ---

1181 cpipe->pipe_map.kva,
1182 cpipe->pipe_buffer.size + PAGE_SIZE);
1183 }
1184#endif
1185 zfree(pipe_zone, cpipe);
1186 }
1187}
1188
117/*
118 * Default pipe buffer size(s), this can be kind-of large now because pipe
119 * space is pageable. The pipe code will try to maintain locality of
120 * reference for performance reasons, so small amounts of outstanding I/O
121 * will not wipe the cache.
122 */
123#define MINPIPESIZE (PIPE_SIZE/3)
124#define MAXPIPESIZE (2*PIPE_SIZE/3)

--- 1059 unchanged lines hidden (view full) ---

1184 cpipe->pipe_map.kva,
1185 cpipe->pipe_buffer.size + PAGE_SIZE);
1186 }
1187#endif
1188 zfree(pipe_zone, cpipe);
1189 }
1190}
1191
1192/*ARGSUSED*/
1189static int
1193static int
1190filt_pipeattach(struct knote *kn)
1194pipe_kqfilter(struct file *fp, struct knote *kn)
1191{
1192 struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;
1193
1195{
1196 struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;
1197
1198 switch (kn->kn_filter) {
1199 case EVFILT_READ:
1200 kn->kn_fop = &pipe_rfiltops;
1201 break;
1202 case EVFILT_WRITE:
1203 kn->kn_fop = &pipe_wfiltops;
1204 break;
1205 default:
1206 return (1);
1207 }
1208
1194 SLIST_INSERT_HEAD(&rpipe->pipe_sel.si_note, kn, kn_selnext);
1195 return (0);
1196}
1197
1198static void
1199filt_pipedetach(struct knote *kn)
1200{
1201 struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;

--- 41 unchanged lines hidden ---
1209 SLIST_INSERT_HEAD(&rpipe->pipe_sel.si_note, kn, kn_selnext);
1210 return (0);
1211}
1212
1213static void
1214filt_pipedetach(struct knote *kn)
1215{
1216 struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;

--- 41 unchanged lines hidden ---