MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pipe_paircreate

Function pipe_paircreate

freebsd/kern/sys_pipe.c:339–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337}
338
339static int
340pipe_paircreate(struct thread *td, struct pipepair **p_pp)
341{
342 struct pipepair *pp;
343 struct pipe *rpipe, *wpipe;
344 int error;
345
346 *p_pp = pp = uma_zalloc(pipe_zone, M_WAITOK);
347#ifdef MAC
348 /*
349 * The MAC label is shared between the connected endpoints. As a
350 * result mac_pipe_init() and mac_pipe_create() are called once
351 * for the pair, and not on the endpoints.
352 */
353 mac_pipe_init(pp);
354 mac_pipe_create(td->td_ucred, pp);
355#endif
356 rpipe = &pp->pp_rpipe;
357 wpipe = &pp->pp_wpipe;
358
359 knlist_init_mtx(&rpipe->pipe_sel.si_note, PIPE_MTX(rpipe));
360 knlist_init_mtx(&wpipe->pipe_sel.si_note, PIPE_MTX(wpipe));
361
362 /*
363 * Only the forward direction pipe is backed by big buffer by
364 * default.
365 */
366 error = pipe_create(rpipe, true);
367 if (error != 0)
368 goto fail;
369 error = pipe_create(wpipe, false);
370 if (error != 0) {
371 /*
372 * This cleanup leaves the pipe inode number for rpipe
373 * still allocated, but never used. We do not free
374 * inode numbers for opened pipes, which is required
375 * for correctness because numbers must be unique.
376 * But also it avoids any memory use by the unr
377 * allocator, so stashing away the transient inode
378 * number is reasonable.
379 */
380 pipe_free_kmem(rpipe);
381 goto fail;
382 }
383
384 rpipe->pipe_state |= PIPE_DIRECTOK;
385 wpipe->pipe_state |= PIPE_DIRECTOK;
386 return (0);
387
388fail:
389 knlist_destroy(&rpipe->pipe_sel.si_note);
390 knlist_destroy(&wpipe->pipe_sel.si_note);
391#ifdef MAC
392 mac_pipe_destroy(pp);
393#endif
394 return (error);
395}
396

Callers 2

pipe_named_ctorFunction · 0.85
kern_pipeFunction · 0.85

Calls 8

mac_pipe_initFunction · 0.85
mac_pipe_createFunction · 0.85
knlist_init_mtxFunction · 0.85
pipe_createFunction · 0.85
pipe_free_kmemFunction · 0.85
knlist_destroyFunction · 0.85
mac_pipe_destroyFunction · 0.85
uma_zallocFunction · 0.50

Tested by

no test coverage detected