sys_pipe.c (102003) | sys_pipe.c (102115) |
---|---|
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 102003 2002-08-17 02:36:16Z rwatson $ | 19 * $FreeBSD: head/sys/kern/sys_pipe.c 102115 2002-08-19 16:59:37Z rwatson $ |
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 */ --- 436 unchanged lines hidden (view full) --- 464 465 PIPE_LOCK(rpipe); 466 ++rpipe->pipe_busy; 467 error = pipelock(rpipe, 1); 468 if (error) 469 goto unlocked_error; 470 471#ifdef MAC | 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 */ --- 436 unchanged lines hidden (view full) --- 464 465 PIPE_LOCK(rpipe); 466 ++rpipe->pipe_busy; 467 error = pipelock(rpipe, 1); 468 if (error) 469 goto unlocked_error; 470 471#ifdef MAC |
472 error = mac_check_pipe_op(active_cred, rpipe, MAC_OP_PIPE_READ); | 472 error = mac_check_pipe_read(active_cred, rpipe); |
473 if (error) 474 goto locked_error; 475#endif 476 477 while (uio->uio_resid) { 478 /* 479 * normal pipe buffer receive 480 */ --- 399 unchanged lines hidden (view full) --- 880 /* 881 * detect loss of pipe read side, issue SIGPIPE if lost. 882 */ 883 if ((wpipe == NULL) || (wpipe->pipe_state & PIPE_EOF)) { 884 PIPE_UNLOCK(rpipe); 885 return (EPIPE); 886 } 887#ifdef MAC | 473 if (error) 474 goto locked_error; 475#endif 476 477 while (uio->uio_resid) { 478 /* 479 * normal pipe buffer receive 480 */ --- 399 unchanged lines hidden (view full) --- 880 /* 881 * detect loss of pipe read side, issue SIGPIPE if lost. 882 */ 883 if ((wpipe == NULL) || (wpipe->pipe_state & PIPE_EOF)) { 884 PIPE_UNLOCK(rpipe); 885 return (EPIPE); 886 } 887#ifdef MAC |
888 error = mac_check_pipe_op(active_cred, wpipe, MAC_OP_PIPE_WRITE); | 888 error = mac_check_pipe_write(active_cred, wpipe); |
889 if (error) { 890 PIPE_UNLOCK(rpipe); 891 return (error); 892 } 893#endif 894 ++wpipe->pipe_busy; 895 896 /* --- 331 unchanged lines hidden (view full) --- 1228 int revents = 0; 1229#ifdef MAC 1230 int error; 1231#endif 1232 1233 wpipe = rpipe->pipe_peer; 1234 PIPE_LOCK(rpipe); 1235#ifdef MAC | 889 if (error) { 890 PIPE_UNLOCK(rpipe); 891 return (error); 892 } 893#endif 894 ++wpipe->pipe_busy; 895 896 /* --- 331 unchanged lines hidden (view full) --- 1228 int revents = 0; 1229#ifdef MAC 1230 int error; 1231#endif 1232 1233 wpipe = rpipe->pipe_peer; 1234 PIPE_LOCK(rpipe); 1235#ifdef MAC |
1236 error = mac_check_pipe_op(active_cred, rpipe, MAC_OP_PIPE_POLL); | 1236 error = mac_check_pipe_poll(active_cred, rpipe); |
1237 if (error) 1238 goto locked_error; 1239#endif 1240 if (events & (POLLIN | POLLRDNORM)) 1241 if ((rpipe->pipe_state & PIPE_DIRECTW) || 1242 (rpipe->pipe_buffer.cnt > 0) || 1243 (rpipe->pipe_state & PIPE_EOF)) 1244 revents |= events & (POLLIN | POLLRDNORM); --- 39 unchanged lines hidden (view full) --- 1284 struct ucred *active_cred; 1285 struct thread *td; 1286{ 1287 struct pipe *pipe = (struct pipe *)fp->f_data; 1288#ifdef MAC 1289 int error; 1290 1291 /* XXXMAC: Pipe should be locked for this check. */ | 1237 if (error) 1238 goto locked_error; 1239#endif 1240 if (events & (POLLIN | POLLRDNORM)) 1241 if ((rpipe->pipe_state & PIPE_DIRECTW) || 1242 (rpipe->pipe_buffer.cnt > 0) || 1243 (rpipe->pipe_state & PIPE_EOF)) 1244 revents |= events & (POLLIN | POLLRDNORM); --- 39 unchanged lines hidden (view full) --- 1284 struct ucred *active_cred; 1285 struct thread *td; 1286{ 1287 struct pipe *pipe = (struct pipe *)fp->f_data; 1288#ifdef MAC 1289 int error; 1290 1291 /* XXXMAC: Pipe should be locked for this check. */ |
1292 error = mac_check_pipe_op(active_cred, pipe, MAC_OP_PIPE_STAT); | 1292 error = mac_check_pipe_stat(active_cred, pipe); |
1293 if (error) 1294 return (error); 1295#endif 1296 bzero(ub, sizeof(*ub)); 1297 ub->st_mode = S_IFIFO; 1298 ub->st_blksize = pipe->pipe_buffer.size; 1299 ub->st_size = pipe->pipe_buffer.cnt; 1300 ub->st_blocks = (ub->st_size + ub->st_blksize - 1) / ub->st_blksize; --- 205 unchanged lines hidden --- | 1293 if (error) 1294 return (error); 1295#endif 1296 bzero(ub, sizeof(*ub)); 1297 ub->st_mode = S_IFIFO; 1298 ub->st_blksize = pipe->pipe_buffer.size; 1299 ub->st_size = pipe->pipe_buffer.cnt; 1300 ub->st_blocks = (ub->st_size + ub->st_blksize - 1) / ub->st_blksize; --- 205 unchanged lines hidden --- |