Whamcloud - gitweb
b=7391
[fs/lustre-release.git] / lustre / include / linux / lustre_audit.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2001-2003 Cluster File Systems, Inc. <info@clusterfs.com>
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  *   smfs data structures.
22  *   See also lustre_idl.h for wire formats of requests.
23  *
24  */
25
26 #ifndef __LUSTRE_AUDIT_H
27 #define __LUSTRE_AUDIT_H
28
29 /* Audit plugin stuff */
30 #define AUDIT_MDS_NAME    "audit_mds"
31 #define AUDIT_OST_NAME    "audit_ost"
32 #define AUDIT_CLI_NAME    "audit_client-"
33 #define AUDIT_ATTR_EA     "audit"
34 #define AUDIT_ATTR_FILE   "audit_setting"
35 //AUDIT OPCODES, also bit number in audit_setting mask
36
37 typedef enum {
38         AUDIT_NONE = 0,
39         AUDIT_CREATE,
40         AUDIT_LINK,
41         AUDIT_UNLINK,
42         AUDIT_RENAME,
43         AUDIT_SETATTR,
44         AUDIT_WRITE,
45         AUDIT_READ,
46         AUDIT_OPEN,
47         AUDIT_STAT,
48         AUDIT_MMAP,
49         AUDIT_READLINK,
50         AUDIT_READDIR,
51         AUDIT_MAX,
52 } audit_op;
53
54 #define AUDIT_FAIL AUDIT_MAX
55 #define AUDIT_DIR  (AUDIT_MAX + 1)
56 #define AUDIT_FS   (AUDIT_MAX + 2)
57
58 #define AUD_BIT(a) (1 << a)
59
60 #define AUDIT_ALL_OPS ((1 << AUDIT_MAX) - 1)
61 #define AUDIT_OFF 0
62
63 #define IS_AUDIT_OP(mask,op) (mask & (1<<op))
64 #define IS_AUDIT(mask) (mask & AUDIT_ALL_OPS)
65 #define SET_AUDIT_OP(mask,op) (mask |= (1<<op))
66
67 //llog audit record 24 bytes
68 struct audit_record {
69         __u64 nid;
70         __u32 uid;
71         __u32 gid;
72         __u32 time;
73         __u16 opcode;
74         __u16 result;
75 } __attribute__ ((packed));
76
77 //32 bytes
78 struct audit_id_record {
79         __u64 au_num;
80         __u64 au_fid;
81         __u32 au_gen;
82         __u32 au_type;
83         __u64 au_mds;
84 } __attribute__ ((packed));
85
86 //1 + namelen
87 struct audit_name_record {
88         __u8 name_len;
89         char name[0];
90 } __attribute__ ((packed));
91
92 struct audit_info {
93         struct audit_msg m;
94         char * name;
95         __u32 namelen;
96 };
97
98 struct audit_lov_msg {
99         struct lov_stripe_md * lsm;
100         __u64 mask;
101         uid_t uid;
102         gid_t gid;
103 };
104
105 #endif