22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include <sys/param.h>
27 #include <sys/types.h>
28 #include <sys/kmem.h>
29 #include <c2/audit.h>
30 #include <c2/audit_kernel.h>
31
32
33 /* process audit data (pad) cache */
34 kmem_cache_t *au_pad_cache;
35
36 /*
37 * increment audit path reference count
38 */
39 void
40 au_pathhold(struct audit_path *app)
41 {
42 atomic_add_32(&app->audp_ref, 1);
43 }
44
45 /*
46 * decrement audit path reference count
47 */
48 void
49 au_pathrele(struct audit_path *app)
50 {
51 if (atomic_add_32_nv(&app->audp_ref, -1) > 0)
52 return;
53 kmem_free(app, app->audp_size);
54 }
55
56 /*
57 * allocate a new auditpath
58 * newsect = increment sections count,
59 * charincr = change in strings storage
60 */
61
62 struct audit_path *
63 au_pathdup(const struct audit_path *oldapp, int newsect, int charincr)
64 {
65 struct audit_path *newapp;
66 int i, alloc_size, oldlen;
67 char *oldcp, *newcp;
68
69 newsect = (newsect != 0);
70 oldcp = oldapp->audp_sect[0];
71 oldlen = (oldapp->audp_sect[oldapp->audp_cnt] - oldcp);
|
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include <sys/param.h>
27 #include <sys/types.h>
28 #include <sys/kmem.h>
29 #include <c2/audit.h>
30 #include <c2/audit_kernel.h>
31
32
33 /* process audit data (pad) cache */
34 kmem_cache_t *au_pad_cache;
35
36 /*
37 * increment audit path reference count
38 */
39 void
40 au_pathhold(struct audit_path *app)
41 {
42 atomic_inc_32(&app->audp_ref);
43 }
44
45 /*
46 * decrement audit path reference count
47 */
48 void
49 au_pathrele(struct audit_path *app)
50 {
51 if (atomic_dec_32_nv(&app->audp_ref) > 0)
52 return;
53 kmem_free(app, app->audp_size);
54 }
55
56 /*
57 * allocate a new auditpath
58 * newsect = increment sections count,
59 * charincr = change in strings storage
60 */
61
62 struct audit_path *
63 au_pathdup(const struct audit_path *oldapp, int newsect, int charincr)
64 {
65 struct audit_path *newapp;
66 int i, alloc_size, oldlen;
67 char *oldcp, *newcp;
68
69 newsect = (newsect != 0);
70 oldcp = oldapp->audp_sect[0];
71 oldlen = (oldapp->audp_sect[oldapp->audp_cnt] - oldcp);
|