{
- "fs_name": "lustre",
+ "fs_name": "testfs",
+ "mount": "/mnt/lustre/testfs",
"dump_path": "/mnt/audit",
"mdts": [
{"mdt_idx": 0, "reader_id": "cl1"},
.B fs_name
gives the name of the file system to retrieve audit information from.
.PP
+.B mount
+gives the mount path of the file system to retrieve audit information from.
+.PP
.B dump_path
is the path where to dump audit records.
.PP
Here is an example of laudit configuration file:
.RS
{
- "fs_name": "lustre",
+ "fs_name": "testfs",
+ "mount": "/mnt/lustre/testfs",
"dump_path": "/mnt/audit",
"mdts": [
{"mdt_idx": 0, "reader_id": "cl1"},
#define MAX_MDTS 256
struct audit_config {
char fs_name[9];
+ char mount[PATH_MAX + 1];
char dump_path[PATH_MAX + 1];
int parse_interval_sec;
int sync_every_n_entries;
/* config file is in JSON format, of the form:
* {
- * "fs_name": "mylustre",
+ * "fs_name": "testfs",
+ * "mount": "/mnt/lustre/testfs",
* "dump_path": "/mnt/audit1",
* "mdts": [
* {"mdt_idx": "0", "reader_id": "cl1"},
*/
static int get_config(char *cfg_file)
{
- struct json_object *root, *fs_name, *dump_path, *mdts;
+ struct json_object *root, *fs_name, *mount, *dump_path, *mdts;
struct json_object *parse_interval_sec, *sync_every_n_entries;
struct json_object *max_syncs_before_sleep;
int i;
goto out;
}
+ rc = json_object_object_get_ex(root, "mount", &mount);
+ if (!rc) {
+ fprintf(stderr,
+ "%s config error: %s does not have a mount entry\n",
+ progname, cfg_file);
+ goto out;
+ }
+ if (!json_object_is_type(mount, json_type_string)) {
+ fprintf(stderr,
+ "%s config error: mount is not a string\n",
+ progname);
+ goto out;
+ }
+ if (snprintf(cfg.mount, sizeof(cfg.mount), "%s",
+ json_object_get_string(mount)) >= sizeof(cfg.mount)) {
+ fprintf(stderr,
+ "%s config error: mount is too long\n",
+ progname);
+ goto out;
+ }
+
rc = json_object_object_get_ex(root, "dump_path", &dump_path);
if (!rc) {
fprintf(stderr,
return;
printf("FS name: %s\n", cfg.fs_name);
+ printf("Mount path: %s\n", cfg.mount);
printf("Dump path: %s\n", cfg.dump_path);
for (idx = 0; idx < MAX_MDTS; idx++) {
if (strcmp(file_to_audit, base) == 0) {
matches = true;
- printinfo("\t%s /%s/%s\n", ep->d_name,
- cfg.fs_name, line);
+ printinfo("\t%s %s/%s\n", ep->d_name,
+ cfg.mount, line);
break;
}
} else {
if (strcmp(line, file_to_audit +
- strlen(cfg.fs_name) + 2) == 0) {
+ strlen(cfg.mount) + 1) == 0) {
rc = get_audit_for_file(ep->d_name,
user_to_audit);
break;
char main_dir[PATH_MAX + 1];
int rc = 0;
- rc = snprintf(main_dir, sizeof(main_dir), "/%s/", cfg.fs_name);
+ rc = snprintf(main_dir, sizeof(main_dir), "%s/", cfg.mount);
if (rc >= sizeof(main_dir))
rc = -ENAMETOOLONG;
if (rc < 0) {
#define MAX_MDTS 256
struct audit_config {
char fs_name[9];
+ char mount[PATH_MAX + 1];
char dump_path[PATH_MAX + 1];
int parse_interval_sec;
int sync_every_n_entries;
/* config file is in JSON format, of the form:
* {
* "fs_name": "mylustre",
+ * "mount": "/mnt/lustre/testfs",
* "dump_path": "/mnt/audit1",
* "mdts": [
* {"mdt_idx": "0", "reader_id": "cl1"},
*/
static int get_config(char *cfg_file)
{
- struct json_object *root, *fs_name, *dump_path, *mdts;
+ struct json_object *root, *fs_name, *mount, *dump_path, *mdts;
struct json_object *parse_interval_sec, *sync_every_n_entries;
struct json_object *max_syncs_before_sleep;
int i;
goto out;
}
+ rc = json_object_object_get_ex(root, "mount", &mount);
+ if (!rc) {
+ fprintf(stderr,
+ "%s config error: %s does not have a mount entry\n",
+ progname, cfg_file);
+ goto out;
+ }
+ if (!json_object_is_type(mount, json_type_string)) {
+ fprintf(stderr,
+ "%s config error: mount is not a string\n",
+ progname);
+ goto out;
+ }
+ if (snprintf(cfg.mount, sizeof(cfg.mount), "%s",
+ json_object_get_string(mount)) >= sizeof(cfg.mount)) {
+ fprintf(stderr,
+ "%s config error: mount is too long\n",
+ progname);
+ goto out;
+ }
+
rc = json_object_object_get_ex(root, "dump_path", &dump_path);
if (!rc) {
fprintf(stderr,
return;
printf("FS name: %s\n", cfg.fs_name);
+ printf("Mount path: %s\n", cfg.mount);
printf("Dump path: %s\n", cfg.dump_path);
for (idx = 0; idx < MAX_MDTS; idx++) {
int sz_max;
FILE *fp;
- rc = snprintf(rootpath, sizeof(rootpath), "/%s", cfg.fs_name);
+ rc = snprintf(rootpath, sizeof(rootpath), "%s", cfg.mount);
if (rc >= sizeof(rootpath))
rc = -ENAMETOOLONG;
if (rc < 0)
rc = snprintf(tfid_pathinfo,
sizeof(tfid_pathinfo),
- "/%s/", cfg.fs_name);
+ "%s/", cfg.mount);
if (rc >= sizeof(tfid_pathinfo))
rc = -ENAMETOOLONG;
if (rc < 0)