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

Function alq_open_flags

freebsd/kern/kern_alq.c:430–480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

428 */
429
430int
431alq_open_flags(struct alq **alqp, const char *file, struct ucred *cred, int cmode,
432 int size, int flags)
433{
434 struct thread *td;
435 struct nameidata nd;
436 struct alq *alq;
437 int oflags;
438 int error;
439
440 KASSERT((size > 0), ("%s: size <= 0", __func__));
441
442 *alqp = NULL;
443 td = curthread;
444
445 NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, file, td);
446 oflags = FWRITE | O_NOFOLLOW | O_CREAT;
447
448 error = vn_open_cred(&nd, &oflags, cmode, 0, cred, NULL);
449 if (error)
450 return (error);
451
452 NDFREE(&nd, NDF_ONLY_PNBUF);
453 /* We just unlock so we hold a reference */
454 VOP_UNLOCK(nd.ni_vp);
455
456 alq = malloc(sizeof(*alq), M_ALD, M_WAITOK|M_ZERO);
457 alq->aq_vp = nd.ni_vp;
458 alq->aq_cred = crhold(cred);
459
460 mtx_init(&alq->aq_mtx, "ALD Queue", NULL, MTX_SPIN|MTX_QUIET);
461
462 alq->aq_buflen = size;
463 alq->aq_entmax = 0;
464 alq->aq_entlen = 0;
465
466 alq->aq_freebytes = alq->aq_buflen;
467 alq->aq_entbuf = malloc(alq->aq_buflen, M_ALD, M_WAITOK|M_ZERO);
468 alq->aq_writehead = alq->aq_writetail = 0;
469 if (flags & ALQ_ORDERED)
470 alq->aq_flags |= AQ_ORDERED;
471
472 if ((error = ald_add(alq)) != 0) {
473 alq_destroy(alq);
474 return (error);
475 }
476
477 *alqp = alq;
478
479 return (0);
480}
481
482int
483alq_open(struct alq **alqp, const char *file, struct ucred *cred, int cmode,

Callers 1

alq_openFunction · 0.85

Calls 7

vn_open_credFunction · 0.85
NDFREEFunction · 0.85
mallocFunction · 0.85
mtx_initFunction · 0.85
ald_addFunction · 0.85
alq_destroyFunction · 0.85
crholdFunction · 0.70

Tested by

no test coverage detected