1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001-2003 Cluster File Systems, Inc. <info@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
21 * smfs data structures.
22 * See also lustre_idl.h for wire formats of requests.
29 #include <linux/lustre_audit.h>
31 /* SMFS plugin stuff */
32 #define SMFS_PLG_KML 0x0001L
33 #define SMFS_PLG_LRU 0x0004L
34 #define SMFS_PLG_COW 0x0020L
35 #define SMFS_PLG_UNDO 0x0100L
36 #define SMFS_PLG_AUDIT 0x0200L
37 #define SMFS_PLG_DUMMY 0x1000L
38 #define SMFS_PLG_ALL (~0L)
40 #define SMFS_SET(flags, mask) (flags |= mask)
41 #define SMFS_IS(flags, mask) (flags & mask)
42 #define SMFS_CLEAR(flags, mask) (flags &= ~mask)
72 typedef int (*smfs_plg_hook)(hook_op hook_code, struct inode *,
73 void *arg, int rc, void * priv);
74 typedef int (*smfs_plg_func)(int help_code, struct super_block *,
75 void *arg, void * priv);
78 struct list_head plg_list;
81 smfs_plg_hook plg_pre_op;
82 smfs_plg_hook plg_post_op;
83 smfs_plg_func plg_helper;
85 int (* plg_exit)(struct super_block *, void *);
87 /* KML plugin stuff */
88 #define KML_LOG_NAME "smfs_kml"
91 /* llog pack function */
92 int (*pack_fn)(int, char *, struct dentry *,
93 struct inode *, void *, void *);
97 struct llog_ctxt *audit_ctxt;
98 void * audit_get_record;
101 int audit_null; //to prevent output to syslog. just for testing overhead
105 typedef int (*audit_get_op)(struct inode *, void *, struct audit_priv *,
109 struct dentry * dentry;
113 struct hook_link_msg {
114 struct dentry * dentry;
115 struct dentry * new_dentry;
117 struct hook_unlink_msg {
118 struct dentry * dentry;
122 struct hook_symlink_msg {
123 struct dentry * dentry;
128 struct hook_rename_msg {
129 struct dentry * dentry;
130 struct inode * old_dir;
131 struct inode * new_dir;
132 struct dentry * new_dentry;
135 struct hook_readdir_msg {
136 struct dentry * dentry;
142 struct hook_write_msg {
143 struct dentry * dentry;
148 struct hook_attr_msg {
149 struct dentry * dentry;
153 struct hook_xattr_msg {
161 struct lustre_id *id;
164 void smfs_pre_hook (struct inode*, hook_op, void*);
165 void smfs_post_hook(struct inode*, hook_op, void*, int);
167 #define SMFS_PRE_HOOK(inode, op, msg) smfs_pre_hook (inode, op, msg)
168 #define SMFS_POST_HOOK(inode, op, msg, rc) smfs_post_hook(inode, op, msg, rc)
171 #define PLG_TRANS_SIZE 1
172 #define PLG_TEST_INODE 2
173 #define PLG_SET_INODE 3
176 #define PLG_SET_INFO 6
177 #define PLG_HELPER_MAX 7
184 struct plg_info_msg {
188 int smfs_helper (struct super_block *, int, void *);
189 #define SMFS_PLG_HELP(sb, op, data) smfs_helper(sb, op, data)
191 int smfs_register_plugin(struct super_block *, struct smfs_plugin *);
192 struct smfs_plugin * smfs_deregister_plugin(struct super_block *, int);
194 int smfs_init_dummy(struct super_block *);
195 int smfs_init_kml(struct super_block *);
196 int smfs_init_lru(struct super_block *);
197 int smfs_init_cow(struct super_block *);
198 int smfs_init_audit(struct super_block *);
199 //int audit_mds_op(hook_op, struct inode *, void *, struct audit_priv *);
200 int audit_client_log(struct super_block*, struct audit_msg *);
201 int audit_mds_setup(struct obd_device *, struct super_block *, struct audit_priv *);
202 int audit_ost_setup(struct obd_device *, struct super_block *, struct audit_priv *);
203 int smfs_set_audit(struct super_block *, struct inode *, __u64 *);
204 int smfs_get_audit(struct super_block *, struct inode *,
205 struct inode *, __u64 *);
207 static inline int audit_rec_from_id (char **pbuf, struct lustre_id * id)
209 struct audit_id_record * rec = (void*)(*pbuf);
210 int len = sizeof(*rec);
212 rec->au_num = id_ino(id);
213 rec->au_fid = id_fid(id);
214 rec->au_gen = id_gen(id);
215 rec->au_type = id_type(id);
216 rec->au_mds = id_group(id);
222 static inline int audit_fill_name_rec (char **pbuf, const char * name, int nlen)
224 struct audit_name_record * n_rec = (void*)(*pbuf);
225 int len = sizeof(*n_rec) + nlen;
227 memcpy(n_rec->name, name, nlen);
228 n_rec->name_len = nlen;