Date: Mon, 8 Apr 2002 21:21:14 -0700 (PDT) From: "Andrew R. Reiter" <arr@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 9426 for review Message-ID: <200204090421.g394LED72201@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=9426 Change 9426 by arr@arr_shibby on 2002/04/08 21:21:08 - Some style cleanup. - Better the usage of the record queue mutex. Affected files ... ... //depot/projects/trustedbsd/audit/sys/kern/kern_audit.c#19 edit Differences ... ==== //depot/projects/trustedbsd/audit/sys/kern/kern_audit.c#19 (text+ko) ==== @@ -63,8 +63,6 @@ SYSCTL_DECL(_security); SYSCTL_NODE(_security, OID_AUTO, audit, CTLFLAG_RW, 0, ""); -SYSCTL_OID(_security_audit, OID_AUTO, enabled, CTLFLAG_RW|CTLTYPE_UINT, - &audit_system_state, 0, sysctl_handle_enable, "IU", ""); static __inline audit_record_t * @@ -100,15 +98,16 @@ { audit_record_t *rec; audit_header_t *h; + vm_zone_t z; audit_id_t *id; u_long *lease; - vm_zone_t z; AINFO_LOCK(ai); lease = &ai->ai_leased; z = ai->ai_zone; id = &ai->ai_id; AINFO_UNLOCK(ai); + rec = audit_record_alloc(z, lease); bzero(rec, sizeof(*rec)); h = &rec->ar_hdr; @@ -117,7 +116,7 @@ h->ah_len = AUDIT_RECORD_SZ + evsz; h->ah_type = type; nanotime(&h->ah_evtime); - return(rec); + return (rec); } @@ -127,9 +126,9 @@ void audit_init(void) { + struct vnode *vp; struct audit_info *ai; struct ucred *cred; - struct vnode *vp; vm_zone_t zone; char *sptr; int err = 0; @@ -142,7 +141,8 @@ sptr = malloc(strlen(AUDLOG), M_TEMP, M_WAITOK|M_ZERO); strcpy(sptr, AUDLOG); - vp = audit_write_init(sptr, td, &cred); + /* XXX curthread */ + vp = audit_write_init(sptr, curthread, &cred); if (vp == NULL) panic("Unable to init audit system.\n"); @@ -171,9 +171,9 @@ void audit_shutdown(int what, void *arg, struct thread *td) { + struct vnode *vp; struct audit_info *ai = arg; struct ucred *cred; - struct vnode *vp; vm_zone_t zone = NULL; char *ptr; @@ -216,29 +216,22 @@ NDINIT(&ni, LOOKUP, NOFOLLOW, UIO_SYSSPACE, path, td); err = namei(&ni); if (err != 0) - return(NULL); + return (NULL); err = vn_open(&ni, &flag, S_IRUSR | S_IWUSR); if (err != 0) - return(NULL); + return (NULL); NDFREE(&ni, NDF_ONLY_PNBUF); vp = ni.ni_vp; VOP_UNLOCK(vp, 0, td); - return(vp); + return (vp); } void audit_write_shutdown(struct vnode *vp, struct thread *td, struct ucred *cred) { - struct proc *p = td->td_proc; - - /* - * XXX arr: Essentially this is a temporary function - * that here for debugging purposes. - */ vn_close(vp, 0, cred, td); crfree(cred); - return; } int @@ -267,10 +260,10 @@ lf.l_type = F_WRLCK; err = VOP_ADVLOCK(vp, (caddr_t)td->td_proc, F_SETLK, &lf, F_FLOCK); if (err != 0) - return(err); + return (err); err = vn_start_write(vp, &mp, V_NOWAIT); - if (err != 0) { + if (err != 0) /* * If we can't write to the audit file from kernel * land, then something is wrong. In the future, @@ -278,8 +271,6 @@ * but for now, we panic. */ panic("unable to write to audit log."); - - } vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); VOP_LEASE(vp, td, td->td_ucred, LEASE_WRITE); @@ -293,7 +284,7 @@ td->td_proc->p_ucred); VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); - return(ar->ar_hdr.ah_len); + return (ar->ar_hdr.ah_len); } void @@ -304,25 +295,24 @@ u_long *lease; vm_zone_t z; - mtx_lock(&record_queue_mtx); for (;;) { ar = NULL; + mtx_lock(&record_queue_mtx); TAILQ_REMOVE(&record_queue, ar, ar_next); + mtx_unlock(&record_queue_mtx); if (ar) { - (void)audit_record_write(ar, NULL, NULL); /* XXX */ + /* XXX */ + (void)audit_record_write(ar, NULL, NULL); AINFO_LOCK(ai); z = ai->ai_zone; lease = &ai->ai_leased; AINFO_UNLOCK(ai); audit_record_free(ar, z, lease); } else if (ar == NULL && audit_shutdown_flag) { - mtx_unlock(&record_queue_mtx); mtx_destroy(&record_queue_mtx); kthread_exit(0); } if (audit_shutdown_flag) continue; - msleep(&record_queue, &record_queue_mtx, PPAUSE, - "Record queue", 0); } } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204090421.g394LED72201>