sys_pipe.c (9f3d45b6d45423c3e992be6f9575fe76cc032c3c) sys_pipe.c (90f54cbfeb973c0e2ee7b617b7759ac4335a9efe)
1/*-
2 * Copyright (c) 1996 John S. Dyson
3 * Copyright (c) 2012 Giovanni Trematerra
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

401{
402
403 return (kern_pipe2(td, fildes, 0));
404}
405
406int
407kern_pipe2(struct thread *td, int fildes[2], int flags)
408{
1/*-
2 * Copyright (c) 1996 John S. Dyson
3 * Copyright (c) 2012 Giovanni Trematerra
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

401{
402
403 return (kern_pipe2(td, fildes, 0));
404}
405
406int
407kern_pipe2(struct thread *td, int fildes[2], int flags)
408{
409 struct filedesc *fdp;
410 struct file *rf, *wf;
411 struct pipe *rpipe, *wpipe;
412 struct pipepair *pp;
413 int fd, fflags, error;
414
409 struct file *rf, *wf;
410 struct pipe *rpipe, *wpipe;
411 struct pipepair *pp;
412 int fd, fflags, error;
413
415 fdp = td->td_proc->p_fd;
416 pipe_paircreate(td, &pp);
417 rpipe = &pp->pp_rpipe;
418 wpipe = &pp->pp_wpipe;
419 error = falloc(td, &rf, &fd, flags);
420 if (error) {
421 pipeclose(rpipe);
422 pipeclose(wpipe);
423 return (error);

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

433 * Warning: once we've gotten past allocation of the fd for the
434 * read-side, we can only drop the read side via fdrop() in order
435 * to avoid races against processes which manage to dup() the read
436 * side while we are blocked trying to allocate the write side.
437 */
438 finit(rf, fflags, DTYPE_PIPE, rpipe, &pipeops);
439 error = falloc(td, &wf, &fd, flags);
440 if (error) {
414 pipe_paircreate(td, &pp);
415 rpipe = &pp->pp_rpipe;
416 wpipe = &pp->pp_wpipe;
417 error = falloc(td, &rf, &fd, flags);
418 if (error) {
419 pipeclose(rpipe);
420 pipeclose(wpipe);
421 return (error);

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

431 * Warning: once we've gotten past allocation of the fd for the
432 * read-side, we can only drop the read side via fdrop() in order
433 * to avoid races against processes which manage to dup() the read
434 * side while we are blocked trying to allocate the write side.
435 */
436 finit(rf, fflags, DTYPE_PIPE, rpipe, &pipeops);
437 error = falloc(td, &wf, &fd, flags);
438 if (error) {
441 fdclose(fdp, rf, fildes[0], td);
439 fdclose(td, rf, fildes[0]);
442 fdrop(rf, td);
443 /* rpipe has been closed by fdrop(). */
444 pipeclose(wpipe);
445 return (error);
446 }
447 /* An extra reference on `wf' has been held for us by falloc(). */
448 finit(wf, fflags, DTYPE_PIPE, wpipe, &pipeops);
449 fdrop(wf, td);

--- 1395 unchanged lines hidden ---
440 fdrop(rf, td);
441 /* rpipe has been closed by fdrop(). */
442 pipeclose(wpipe);
443 return (error);
444 }
445 /* An extra reference on `wf' has been held for us by falloc(). */
446 finit(wf, fflags, DTYPE_PIPE, wpipe, &pipeops);
447 fdrop(wf, td);

--- 1395 unchanged lines hidden ---