From owner-p4-projects@FreeBSD.ORG Sat Mar 18 16:01:40 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 11E7216A422; Sat, 18 Mar 2006 16:01:40 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C02CE16A401 for ; Sat, 18 Mar 2006 16:01:39 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6D53943D48 for ; Sat, 18 Mar 2006 16:01:39 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k2IG1di8093940 for ; Sat, 18 Mar 2006 16:01:39 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k2IG1dVs093937 for perforce@freebsd.org; Sat, 18 Mar 2006 16:01:39 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sat, 18 Mar 2006 16:01:39 GMT Message-Id: <200603181601.k2IG1dVs093937@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 93506 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Mar 2006 16:01:40 -0000 http://perforce.freebsd.org/chv.cgi?CH=93506 Change 93506 by rwatson@rwatson_peppercorn on 2006/03/18 16:01:07 Add ioctls to audit pipes in order to allow querying of the current record queue state, setting of the queue limit, and querying of pipe statistics. Affected files ... .. //depot/projects/trustedbsd/audit3/sys/security/audit/audit_ioctl.h#1 add .. //depot/projects/trustedbsd/audit3/sys/security/audit/audit_pipe.c#11 edit Differences ... ==== //depot/projects/trustedbsd/audit3/sys/security/audit/audit_pipe.c#11 (text+ko) ==== @@ -48,6 +48,7 @@ #include #include +#include #include /* @@ -68,6 +69,7 @@ * Audit pipe buffer parameters. */ #define AUDIT_PIPE_QLIMIT_DEFAULT (32) +#define AUDIT_PIPE_QLIMIT_MIN (0) #define AUDIT_PIPE_QLIMIT_MAX (1024) /* @@ -379,8 +381,8 @@ } /* - * Audit pipe ioctl() routine. Nothing for now, but eventually will allow - * setting and retrieval of current queue depth, queue limit, flush, etc. + * Audit pipe ioctl() routine. Handle file descriptor and audit pipe layer + * commands. * * Would be desirable to support filtering, although perhaps something simple * like an event mask, as opposed to something complicated like BPF. @@ -433,6 +435,47 @@ case FIOGETOWN: *(int *)data = fgetown(&ap->ap_sigio); error = 0; + break; + + case AUDITPIPE_GET_QLEN: + *(u_int *)data = ap->ap_qlen; + error = 0; + break; + + case AUDITPIPE_GET_QLIMIT: + *(u_int *)data = ap->ap_qlimit; + error = 0; + break; + + case AUDITPIPE_SET_QLIMIT: + /* Lockless integer write. */ + if (*(u_int *)data >= AUDIT_PIPE_QLIMIT_MIN || + *(u_int *)data <= AUDIT_PIPE_QLIMIT_MAX) { + ap->ap_qlimit = *(u_int *)data; + error = 0; + } else + error = EINVAL; + break; + + case AUDITPIPE_GET_INSERTS: + *(u_int *)data = ap->ap_inserts; + error = 0; + break; + + case AUDITPIPE_GET_READS: + *(u_int *)data = ap->ap_reads; + error = 0; + break; + + case AUDITPIPE_GET_DROPS: + *(u_int *)data = ap->ap_drops; + error = 0; + break; + + case AUDITPIPE_GET_TRUNCATES: + *(u_int *)data = ap->ap_truncates; + error = 0; + break; default: error = ENOTTY;