FreeBSD/sys/security/audit/audit_pipe.c
/*
 * Allocate a new audit pipe.  Connects the pipe, on success, to the global
 * list and updates statistics.
 */
Allocate a new audit pipe.  Connects the pipe, on success, to the global
list and updates statistics.
Allocate a new audit pipe . Connects the pipe on success to the global list and updates statistics .
static struct audit_pipe *
audit_pipe_alloc(void)
{
	struct audit_pipe *ap;
	ap = malloc(sizeof(*ap), M_AUDIT_PIPE, M_NOWAIT | M_ZERO);
	if (ap == NULL)
		return (NULL);
	ap->ap_qlimit = AUDIT_PIPE_QLIMIT_DEFAULT;
	TAILQ_INIT(&ap->ap_queue);
	knlist_init_mtx(&ap->ap_selinfo.si_note, AUDIT_PIPE_MTX(ap));
	AUDIT_PIPE_LOCK_INIT(ap);
	AUDIT_PIPE_SX_LOCK_INIT(ap);
	cv_init(&ap->ap_cv, "audit_pipe");
	bzero(&ap->ap_preselect_flags, sizeof(ap->ap_preselect_flags));
	bzero(&ap->ap_preselect_naflags, sizeof(ap->ap_preselect_naflags));
	TAILQ_INIT(&ap->ap_preselect_list);
	ap->ap_preselect_mode = AUDITPIPE_PRESELECT_MODE_TRAIL;
	AUDIT_PIPE_LIST_WLOCK();
	TAILQ_INSERT_HEAD(&audit_pipe_list, ap, ap_list);
	audit_pipe_count++;
	audit_pipe_ever++;
	AUDIT_PIPE_LIST_WUNLOCK();
	return (ap);
}
static struct audit_pipe * audit_pipe_alloc ( void ) { struct audit_pipe * ap ; ap = malloc ( sizeof ( * ap ) , M_AUDIT_PIPE , M_NOWAIT | M_ZERO ) ; if ( ap == NULL ) return ( NULL ) ; ap -> ap_qlimit = AUDIT_PIPE_QLIMIT_DEFAULT ; TAILQ_INIT ( & ap -> ap_queue ) ; knlist_init_mtx ( & ap -> ap_selinfo . si_note , AUDIT_PIPE_MTX ( ap ) ) ; AUDIT_PIPE_LOCK_INIT ( ap ) ; AUDIT_PIPE_SX_LOCK_INIT ( ap ) ; cv_init ( & ap -> ap_cv , " " ) ; bzero ( & ap -> ap_preselect_flags , sizeof ( ap -> ap_preselect_flags ) ) ; bzero ( & ap -> ap_preselect_naflags , sizeof ( ap -> ap_preselect_naflags ) ) ; TAILQ_INIT ( & ap -> ap_preselect_list ) ; ap -> ap_preselect_mode = AUDITPIPE_PRESELECT_MODE_TRAIL ; AUDIT_PIPE_LIST_WLOCK ( ) ; TAILQ_INSERT_HEAD ( & audit_pipe_list , ap , ap_list ) ; audit_pipe_count ++ ; audit_pipe_ever ++ ; AUDIT_PIPE_LIST_WUNLOCK ( ) ; return ( ap ) ; }
Allocate a new audit pipe.
Allocate a new audit pipe .
/*
	 * Default flags, naflags, and auid-specific preselection settings to
	 * 0.  Initialize the mode to the global trail so that if praudit(1)
	 * is run on /dev/auditpipe, it sees events associated with the
	 * default trail.  Pipe-aware application can clear the flag, set
	 * custom masks, and flush the pipe as needed.
	 */ /*
	 * Add to global list and update global statistics.
	 */