修改了参数大小
This commit is contained in:
parent
b8b38d9efe
commit
6042a767a3
|
|
@ -14,12 +14,13 @@ ConfigData *load_config() {
|
|||
DEBUG_LOG("Attaching to shared memory for config data");
|
||||
|
||||
// 不指定大小,让shmget自动获取已存在的共享内存段大小
|
||||
int shm_id = shmget(SHM_KEY, SHM_SIZE, 0); // 把size参数设为0
|
||||
int shm_id = shmget(SHM_KEY, SHM_SIZE, IPC_CREAT | 0640); // 把size参数设为0
|
||||
|
||||
DEBUG_LOG("shm_id is: %d", shm_id);
|
||||
|
||||
if (shm_id == -1) {
|
||||
DEBUG_LOG("shmget failed");
|
||||
DEBUG_LOG("err: %d", errno);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -31,6 +32,6 @@ ConfigData *load_config() {
|
|||
return NULL;
|
||||
}
|
||||
DEBUG_LOG("Successfully attached to shared memory");
|
||||
DEBUG_LOG("Current configuration has %d rules", shared_config->rule_count);
|
||||
DEBUG_LOG("Current configuration has %d rules", shared_config == NULL? -1 : shared_config->rule_count);
|
||||
return shared_config;
|
||||
}
|
||||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "exec_hook.h"
|
||||
|
||||
#define HOOK 1
|
||||
|
||||
ConfigData *load_config();
|
||||
|
||||
#endif // CONFIG_H
|
||||
|
|
@ -51,6 +51,6 @@
|
|||
#define ANSI_COLOR_BLUE "\x1b[34m"
|
||||
|
||||
#define SHM_KEY 0x78945
|
||||
#define SHM_SIZE 512 * 1024
|
||||
#define SHM_SIZE 1024 * 1024
|
||||
|
||||
#endif // EXEC_HOOK_H
|
||||
14
src/struct.h
14
src/struct.h
|
|
@ -3,13 +3,17 @@
|
|||
|
||||
#define _GNU_SOURCE
|
||||
#define MAX_RULES 128
|
||||
#define MAX_ARGS 10
|
||||
#define MAX_ARGS 32
|
||||
#define MAX_RULE_CMD_LEN 256
|
||||
#define MAX_TYPE_LEN 32
|
||||
#define MAX_MSG_LEN 256
|
||||
#define MAX_ARGS_LEN 128
|
||||
|
||||
typedef struct {
|
||||
char cmd[256];
|
||||
char type[32];
|
||||
char msg[1024];
|
||||
char args[MAX_ARGS][256];
|
||||
char cmd[MAX_RULE_CMD_LEN];
|
||||
char type[MAX_TYPE_LEN];
|
||||
char msg[MAX_MSG_LEN];
|
||||
char args[MAX_ARGS][MAX_ARGS_LEN];
|
||||
int arg_count;
|
||||
} Rule;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue