mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-29 08:47:24 +00:00
tools: acrn-crashlog: refine the configuration structure
1. get string size when parsing configuration. 2. add 'const' for strings got from configuration. Tracked-On: #1254 Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com> Reviewed-by: Yonghua Huang <yonghua.huang@intel.com> Acked-by: Chen Gang <gang.c.chen@intel.com>
This commit is contained in:
parent
fe4d503c3d
commit
6938caa25f
@ -72,7 +72,7 @@ static char *next_vm_event(const char *cursor, const char *data,
|
|||||||
size_t dlen, const struct vm_t *vm)
|
size_t dlen, const struct vm_t *vm)
|
||||||
{
|
{
|
||||||
char *line_to_sync = (char *)~(0);
|
char *line_to_sync = (char *)~(0);
|
||||||
char *syncevent;
|
const char *syncevent;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
if (!cursor || !vm)
|
if (!cursor || !vm)
|
||||||
@ -408,7 +408,7 @@ static void sync_lines_stage2(const struct sender_t *sender,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
vm = get_vm_by_name(vm_name);
|
vm = get_vm_by_name((const char *)vm_name);
|
||||||
if (!vm || !vm->history_data)
|
if (!vm || !vm->history_data)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@ static struct channel_t channels[] = {
|
|||||||
* or NULL on error.
|
* or NULL on error.
|
||||||
*/
|
*/
|
||||||
static struct event_t *create_event(enum event_type_t event_type,
|
static struct event_t *create_event(enum event_type_t event_type,
|
||||||
char *channel, void *private,
|
const char *channel, void *private,
|
||||||
int watchfd, char *path)
|
int watchfd, const char *path)
|
||||||
{
|
{
|
||||||
struct event_t *e;
|
struct event_t *e;
|
||||||
int path_len = 0;
|
int path_len = 0;
|
||||||
|
@ -84,7 +84,7 @@ static int crash_has_mightcontents(const struct crash_t *crash,
|
|||||||
int ret = 1;
|
int ret = 1;
|
||||||
int ret_exp;
|
int ret_exp;
|
||||||
int expid, cntid;
|
int expid, cntid;
|
||||||
char * const *exp;
|
const char * const *exp;
|
||||||
const char *content;
|
const char *content;
|
||||||
|
|
||||||
for_each_expression_crash(expid, exp, crash) {
|
for_each_expression_crash(expid, exp, crash) {
|
||||||
@ -128,7 +128,7 @@ static int crash_match_content(const struct crash_t *crash, const char *file)
|
|||||||
static int _get_data(const char *file, const struct crash_t *crash,
|
static int _get_data(const char *file, const struct crash_t *crash,
|
||||||
char **data, const int index)
|
char **data, const int index)
|
||||||
{
|
{
|
||||||
char *search_key;
|
const char *search_key;
|
||||||
char *value;
|
char *value;
|
||||||
char *end;
|
char *end;
|
||||||
int size;
|
int size;
|
||||||
|
@ -40,12 +40,12 @@
|
|||||||
"#EVENT ID DATE TYPE\n"
|
"#EVENT ID DATE TYPE\n"
|
||||||
|
|
||||||
struct history_entry {
|
struct history_entry {
|
||||||
char *event;
|
const char *event;
|
||||||
char *type;
|
const char *type;
|
||||||
char *log;
|
const char *log;
|
||||||
const char *lastuptime; /* for uptime */
|
const char *lastuptime; /* for uptime */
|
||||||
char *key;
|
const char *key;
|
||||||
char *eventtime;
|
const char *eventtime;
|
||||||
};
|
};
|
||||||
|
|
||||||
char *history_file;
|
char *history_file;
|
||||||
@ -115,8 +115,8 @@ free:
|
|||||||
free(des);
|
free(des);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hist_raise_event(char *event, char *type, char *log, char *lastuptime,
|
void hist_raise_event(const char *event, const char *type, const char *log,
|
||||||
char *key)
|
const char *lastuptime, const char *key)
|
||||||
{
|
{
|
||||||
char line[MAXLINESIZE];
|
char line[MAXLINESIZE];
|
||||||
char eventtime[LONG_TIME_SIZE];
|
char eventtime[LONG_TIME_SIZE];
|
||||||
|
@ -22,7 +22,7 @@ __extension__
|
|||||||
struct event_t {
|
struct event_t {
|
||||||
int watchfd;
|
int watchfd;
|
||||||
enum event_type_t event_type;
|
enum event_type_t event_type;
|
||||||
char *channel;
|
const char *channel;
|
||||||
void *private;
|
void *private;
|
||||||
|
|
||||||
TAILQ_ENTRY(event_t) entries;
|
TAILQ_ENTRY(event_t) entries;
|
||||||
|
@ -29,7 +29,7 @@ extern char *history_file;
|
|||||||
int prepare_history(void);
|
int prepare_history(void);
|
||||||
void hist_raise_infoerror(char *type);
|
void hist_raise_infoerror(char *type);
|
||||||
void hist_raise_uptime(char *lastuptime);
|
void hist_raise_uptime(char *lastuptime);
|
||||||
void hist_raise_event(char *event, char *type, char *log, char *lastuptime,
|
void hist_raise_event(const char *event, const char *type, const char *log,
|
||||||
char *key);
|
const char *lastuptime, const char *key);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
#include <openssl/sha.h>
|
|
||||||
#include <ext2fs/ext2fs.h>
|
#include <ext2fs/ext2fs.h>
|
||||||
#include "event_queue.h"
|
#include "event_queue.h"
|
||||||
#include "probeutils.h"
|
#include "probeutils.h"
|
||||||
@ -25,43 +24,60 @@
|
|||||||
#define VM_EVENT_TYPE_MAX 20
|
#define VM_EVENT_TYPE_MAX 20
|
||||||
|
|
||||||
struct trigger_t {
|
struct trigger_t {
|
||||||
char *name;
|
const char *name;
|
||||||
char *type;
|
size_t name_len;
|
||||||
char *path;
|
const char *type;
|
||||||
|
size_t type_len;
|
||||||
|
const char *path;
|
||||||
|
size_t path_len;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vm_t {
|
struct vm_t {
|
||||||
char *name;
|
const char *name;
|
||||||
char *channel;
|
size_t name_len;
|
||||||
char *interval;
|
const char *channel;
|
||||||
char *syncevent[VM_EVENT_TYPE_MAX];
|
size_t channel_len;
|
||||||
|
const char *interval;
|
||||||
|
size_t interval_len;
|
||||||
|
const char *syncevent[VM_EVENT_TYPE_MAX];
|
||||||
|
size_t syncevent_len[VM_EVENT_TYPE_MAX];
|
||||||
|
|
||||||
ext2_filsys datafs;
|
ext2_filsys datafs;
|
||||||
unsigned long history_size[SENDER_MAX];
|
unsigned long history_size[SENDER_MAX];
|
||||||
char *history_data;
|
char *history_data;
|
||||||
char last_synced_line_key[SENDER_MAX][SHORT_KEY_LENGTH + 1];
|
char last_synced_line_key[SENDER_MAX][SHORT_KEY_LENGTH + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct log_t {
|
struct log_t {
|
||||||
char *name;
|
const char *name;
|
||||||
char *type;
|
size_t name_len;
|
||||||
char *path;
|
const char *type;
|
||||||
char *lines;
|
size_t type_len;
|
||||||
|
const char *path;
|
||||||
|
size_t path_len;
|
||||||
|
const char *lines;
|
||||||
|
size_t lines_len;
|
||||||
|
|
||||||
void (*get)(struct log_t *, void *);
|
void (*get)(struct log_t *, void *);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct crash_t {
|
struct crash_t {
|
||||||
char *name;
|
const char *name;
|
||||||
char *channel;
|
size_t name_len;
|
||||||
char *interval;
|
const char *channel;
|
||||||
|
size_t channel_len;
|
||||||
|
const char *interval;
|
||||||
|
size_t interval_len;
|
||||||
struct trigger_t *trigger;
|
struct trigger_t *trigger;
|
||||||
char *content[CONTENT_MAX];
|
const char *content[CONTENT_MAX];
|
||||||
char *mightcontent[EXPRESSION_MAX][CONTENT_MAX];
|
size_t content_len[CONTENT_MAX];
|
||||||
struct log_t *log[LOG_MAX];
|
const char *mightcontent[EXPRESSION_MAX][CONTENT_MAX];
|
||||||
char *data[DATA_MAX];
|
size_t mightcontent_len[EXPRESSION_MAX][CONTENT_MAX];
|
||||||
|
struct log_t *log[LOG_MAX];
|
||||||
|
const char *data[DATA_MAX];
|
||||||
|
size_t data_len[DATA_MAX];
|
||||||
|
|
||||||
struct crash_t *parents;
|
struct crash_t *parents;
|
||||||
|
|
||||||
TAILQ_ENTRY(crash_t) entries;
|
TAILQ_ENTRY(crash_t) entries;
|
||||||
TAILQ_HEAD(, crash_t) children;
|
TAILQ_HEAD(, crash_t) children;
|
||||||
@ -73,42 +89,53 @@ struct crash_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct info_t {
|
struct info_t {
|
||||||
char *name;
|
const char *name;
|
||||||
char *channel;
|
size_t name_len;
|
||||||
char *interval;
|
const char *channel;
|
||||||
|
size_t channel_len;
|
||||||
|
const char *interval;
|
||||||
|
size_t interval_len;
|
||||||
struct trigger_t *trigger;
|
struct trigger_t *trigger;
|
||||||
struct log_t *log[LOG_MAX];
|
struct log_t *log[LOG_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct uptime_t {
|
struct uptime_t {
|
||||||
char *name;
|
const char *name;
|
||||||
char *frequency;
|
size_t name_len;
|
||||||
char *eventhours;
|
const char *frequency;
|
||||||
|
size_t frequency_len;
|
||||||
|
const char *eventhours;
|
||||||
|
size_t eventhours_len;
|
||||||
|
|
||||||
int wd;
|
int wd;
|
||||||
char *path;
|
char *path;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sender_t {
|
struct sender_t {
|
||||||
char *name;
|
const char *name;
|
||||||
char *outdir;
|
size_t name_len;
|
||||||
char *maxcrashdirs;
|
const char *outdir;
|
||||||
char *maxlines;
|
size_t outdir_len;
|
||||||
char *spacequota;
|
const char *maxcrashdirs;
|
||||||
|
size_t maxcrashdirs_len;
|
||||||
|
const char *maxlines;
|
||||||
|
size_t maxlines_len;
|
||||||
|
const char *spacequota;
|
||||||
|
size_t spacequota_len;
|
||||||
struct uptime_t *uptime;
|
struct uptime_t *uptime;
|
||||||
|
|
||||||
void (*send)(struct event_t *);
|
void (*send)(struct event_t *);
|
||||||
char *log_vmrecordid;
|
char *log_vmrecordid;
|
||||||
int sw_updated; /* each sender has their own record */
|
int sw_updated; /* each sender has their own record */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct conf_t {
|
struct conf_t {
|
||||||
struct sender_t *sender[SENDER_MAX];
|
struct sender_t *sender[SENDER_MAX];
|
||||||
struct vm_t *vm[VM_MAX];
|
struct vm_t *vm[VM_MAX];
|
||||||
struct trigger_t *trigger[TRIGGER_MAX];
|
struct trigger_t *trigger[TRIGGER_MAX];
|
||||||
struct log_t *log[LOG_MAX];
|
struct log_t *log[LOG_MAX];
|
||||||
struct crash_t *crash[CRASH_MAX];
|
struct crash_t *crash[CRASH_MAX];
|
||||||
struct info_t *info[INFO_MAX];
|
struct info_t *info[INFO_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct conf_t conf;
|
struct conf_t conf;
|
||||||
@ -168,7 +195,7 @@ struct conf_t conf;
|
|||||||
({ \
|
({ \
|
||||||
int _ret = 0; \
|
int _ret = 0; \
|
||||||
int _id; \
|
int _id; \
|
||||||
char *content; \
|
const char *content; \
|
||||||
for_each_content_expression(_id, content, exp) { \
|
for_each_content_expression(_id, content, exp) { \
|
||||||
if (content) \
|
if (content) \
|
||||||
_ret = 1; \
|
_ret = 1; \
|
||||||
@ -204,11 +231,11 @@ struct conf_t conf;
|
|||||||
)
|
)
|
||||||
|
|
||||||
int load_conf(const char *path);
|
int load_conf(const char *path);
|
||||||
struct trigger_t *get_trigger_by_name(char *name);
|
struct trigger_t *get_trigger_by_name(const char *name);
|
||||||
struct log_t *get_log_by_name(char *name);
|
struct log_t *get_log_by_name(const char *name);
|
||||||
struct vm_t *get_vm_by_name(const char *name);
|
struct vm_t *get_vm_by_name(const char *name);
|
||||||
int sender_id(const struct sender_t *sender);
|
int sender_id(const struct sender_t *sender);
|
||||||
struct sender_t *get_sender_by_name(char *name);
|
struct sender_t *get_sender_by_name(const char *name);
|
||||||
enum event_type_t get_conf_by_wd(int wd, void **private);
|
enum event_type_t get_conf_by_wd(int wd, void **private);
|
||||||
struct crash_t *get_crash_by_wd(int wd);
|
struct crash_t *get_crash_by_wd(int wd);
|
||||||
int crash_depth(struct crash_t *tcrash);
|
int crash_depth(struct crash_t *tcrash);
|
||||||
|
@ -43,9 +43,9 @@ int get_current_time_long(char buf[32]);
|
|||||||
unsigned long long get_uptime(void);
|
unsigned long long get_uptime(void);
|
||||||
char *generate_event_id(const char *seed1, const char *seed2,
|
char *generate_event_id(const char *seed1, const char *seed2,
|
||||||
enum key_type type);
|
enum key_type type);
|
||||||
void generate_crashfile(char *dir, char *event, char *hashkey,
|
void generate_crashfile(const char *dir, const char *event, const char *hashkey,
|
||||||
char *type, char *data0,
|
const char *type, const char *data0,
|
||||||
char *data1, char *data2);
|
const char *data1, const char *data2);
|
||||||
char *generate_log_dir(enum e_dir_mode mode, char *hashkey);
|
char *generate_log_dir(enum e_dir_mode mode, char *hashkey);
|
||||||
int is_boot_id_changed(void);
|
int is_boot_id_changed(void);
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "load_conf.h"
|
#include "load_conf.h"
|
||||||
#include "event_queue.h"
|
#include "event_queue.h"
|
||||||
#include "log_sys.h"
|
#include "log_sys.h"
|
||||||
|
#include "strutils.h"
|
||||||
|
|
||||||
static void print(void)
|
static void print(void)
|
||||||
{
|
{
|
||||||
@ -21,7 +22,6 @@ static void print(void)
|
|||||||
struct info_t *info;
|
struct info_t *info;
|
||||||
struct crash_t *crash;
|
struct crash_t *crash;
|
||||||
struct crash_t *crash_tmp;
|
struct crash_t *crash_tmp;
|
||||||
char buf[512];
|
|
||||||
|
|
||||||
#define print_id_item(item, root, id) \
|
#define print_id_item(item, root, id) \
|
||||||
LOGD("%-8s(%d): %-15s:(%s)\n", #root, id, #item, root->item)
|
LOGD("%-8s(%d): %-15s:(%s)\n", #root, id, #item, root->item)
|
||||||
@ -90,17 +90,36 @@ static void print(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for_each_crash(id, crash, conf) {
|
for_each_crash(id, crash, conf) {
|
||||||
|
char buf[512];
|
||||||
|
char *tail;
|
||||||
|
int len;
|
||||||
|
|
||||||
if (!crash)
|
if (!crash)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
print_id_item(name, crash, id);
|
print_id_item(name, crash, id);
|
||||||
memset(buf, 0, sizeof(*buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
LOGD("%-8s(%d): properties: %s, %s\n", "crash", id,
|
LOGD("%-8s(%d): properties: %s, %s\n", "crash", id,
|
||||||
is_root_crash(crash) ? "root" : "non-root",
|
is_root_crash(crash) ? "root" : "non-root",
|
||||||
is_leaf_crash(crash) ? "leaf" : "non-leaf");
|
is_leaf_crash(crash) ? "leaf" : "non-leaf");
|
||||||
sprintf(buf + strlen(buf), "%-8s(%d): children: ", "crash", id);
|
len = snprintf(buf, sizeof(buf), "%-8s(%d): children: ",
|
||||||
for_crash_children(crash_tmp, crash)
|
"crash", id);
|
||||||
sprintf(buf + strlen(buf), "%s ", crash_tmp->name);
|
if (s_not_expect(len, sizeof(buf))) {
|
||||||
|
LOGE("failed to construct the children of crash\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
tail = buf + len;
|
||||||
|
for_crash_children(crash_tmp, crash) {
|
||||||
|
if (len + crash_tmp->name_len + 2 >= sizeof(buf)) {
|
||||||
|
LOGE("names of children too long - truncate\n");
|
||||||
|
break;;
|
||||||
|
}
|
||||||
|
tail = mempcpy(tail, crash_tmp->name,
|
||||||
|
crash_tmp->name_len);
|
||||||
|
*tail++ = ' ';
|
||||||
|
len += crash_tmp->name_len + 1;
|
||||||
|
}
|
||||||
|
*tail = '\0';
|
||||||
LOGD("%s\n", buf);
|
LOGD("%s\n", buf);
|
||||||
print_id_item(trigger->name, crash, id);
|
print_id_item(trigger->name, crash, id);
|
||||||
print_id_item(channel, crash, id);
|
print_id_item(channel, crash, id);
|
||||||
@ -173,7 +192,8 @@ static int get_expid_index(xmlNodePtr cur, const int max)
|
|||||||
int _ret = -1; \
|
int _ret = -1; \
|
||||||
load##mem = xmlNodeGetContent(cur); \
|
load##mem = xmlNodeGetContent(cur); \
|
||||||
if (load##mem) { \
|
if (load##mem) { \
|
||||||
type->mem = (char *)load##mem; \
|
type->mem = (const char *)load##mem; \
|
||||||
|
type->mem##_len = xmlStrlen(load##mem); \
|
||||||
_ret = 0; \
|
_ret = 0; \
|
||||||
} \
|
} \
|
||||||
_ret; \
|
_ret; \
|
||||||
@ -190,7 +210,8 @@ static int get_expid_index(xmlNodePtr cur, const int max)
|
|||||||
if (load##mem) { \
|
if (load##mem) { \
|
||||||
index = get_id_index(cur, max); \
|
index = get_id_index(cur, max); \
|
||||||
if (index != -1) { \
|
if (index != -1) { \
|
||||||
type->mem[index] = (char *)load##mem; \
|
type->mem[index] = (const char *)load##mem; \
|
||||||
|
type->mem##_len[index] = xmlStrlen(load##mem); \
|
||||||
_ret = 0; \
|
_ret = 0; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@ -201,9 +222,15 @@ static int get_expid_index(xmlNodePtr cur, const int max)
|
|||||||
#define load_trigger(cur, event) \
|
#define load_trigger(cur, event) \
|
||||||
(__extension__ \
|
(__extension__ \
|
||||||
({ \
|
({ \
|
||||||
|
int _ret = -1; \
|
||||||
xmlChar *content = xmlNodeGetContent(cur); \
|
xmlChar *content = xmlNodeGetContent(cur); \
|
||||||
event->trigger = get_trigger_by_name((char *)content); \
|
if (content) { \
|
||||||
xmlFree(content); \
|
event->trigger = \
|
||||||
|
get_trigger_by_name((const char *)content); \
|
||||||
|
xmlFree(content); \
|
||||||
|
_ret = 0; \
|
||||||
|
} \
|
||||||
|
_ret; \
|
||||||
}) \
|
}) \
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -276,7 +303,7 @@ int sender_id(const struct sender_t *s)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sender_t *get_sender_by_name(char *name)
|
struct sender_t *get_sender_by_name(const char *name)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
struct sender_t *sender;
|
struct sender_t *sender;
|
||||||
@ -291,7 +318,7 @@ struct sender_t *get_sender_by_name(char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct trigger_t *get_trigger_by_name(char *name)
|
struct trigger_t *get_trigger_by_name(const char *name)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
struct trigger_t *trigger;
|
struct trigger_t *trigger;
|
||||||
@ -305,7 +332,7 @@ struct trigger_t *get_trigger_by_name(char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct log_t *get_log_by_name(char *name)
|
struct log_t *get_log_by_name(const char *name)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
struct log_t *log;
|
struct log_t *log;
|
||||||
@ -388,7 +415,9 @@ static int parse_info(xmlNodePtr cur, struct info_t *info)
|
|||||||
if (id == -1)
|
if (id == -1)
|
||||||
return -1;
|
return -1;
|
||||||
content = xmlNodeGetContent(cur);
|
content = xmlNodeGetContent(cur);
|
||||||
info->log[id] = get_log_by_name((char *)content);
|
if (!content)
|
||||||
|
return -1;
|
||||||
|
info->log[id] = get_log_by_name((const char *)content);
|
||||||
xmlFree(content);
|
xmlFree(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,7 +479,9 @@ static int parse_crash(xmlNodePtr cur, struct crash_t *crash)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
content = xmlNodeGetContent(cur);
|
content = xmlNodeGetContent(cur);
|
||||||
crash->log[id] = get_log_by_name((char *)content);
|
if (!content)
|
||||||
|
return -1;
|
||||||
|
crash->log[id] = get_log_by_name((const char *)content);
|
||||||
xmlFree(content);
|
xmlFree(content);
|
||||||
} else if (name_is(cur, "data"))
|
} else if (name_is(cur, "data"))
|
||||||
res = load_cur_content_with_id(cur, crash,
|
res = load_cur_content_with_id(cur, crash,
|
||||||
@ -462,7 +493,10 @@ static int parse_crash(xmlNodePtr cur, struct crash_t *crash)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
content = xmlNodeGetContent(cur);
|
content = xmlNodeGetContent(cur);
|
||||||
crash->mightcontent[expid][id] = (char *)content;
|
if (!content)
|
||||||
|
return -1;
|
||||||
|
crash->mightcontent[expid][id] = (const char *)content;
|
||||||
|
crash->mightcontent_len[expid][id] = xmlStrlen(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
|
@ -206,7 +206,7 @@ static int reserve_log_folder(enum e_dir_mode mode, char *dir,
|
|||||||
int plen;
|
int plen;
|
||||||
int dlen;
|
int dlen;
|
||||||
struct sender_t *crashlog;
|
struct sender_t *crashlog;
|
||||||
char *outdir;
|
const char *outdir;
|
||||||
unsigned int maxdirs;
|
unsigned int maxdirs;
|
||||||
|
|
||||||
crashlog = get_sender_by_name("crashlog");
|
crashlog = get_sender_by_name("crashlog");
|
||||||
@ -273,9 +273,9 @@ static int reserve_log_folder(enum e_dir_mode mode, char *dir,
|
|||||||
* @param type Subtype of this event.
|
* @param type Subtype of this event.
|
||||||
* @param data* String obtained by get_data.
|
* @param data* String obtained by get_data.
|
||||||
*/
|
*/
|
||||||
void generate_crashfile(char *dir, char *event, char *hashkey,
|
void generate_crashfile(const char *dir, const char *event, const char *hashkey,
|
||||||
char *type, char *data0,
|
const char *type, const char *data0,
|
||||||
char *data1, char *data2)
|
const char *data1, const char *data2)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
char *path;
|
char *path;
|
||||||
|
@ -72,7 +72,7 @@ static int close_file(const char *filename, FILE *fp)
|
|||||||
*
|
*
|
||||||
* @return 0 if successful, or a negative errno-style value if not.
|
* @return 0 if successful, or a negative errno-style value if not.
|
||||||
*/
|
*/
|
||||||
int mkdir_p(char *path)
|
int mkdir_p(const char *path)
|
||||||
{
|
{
|
||||||
if (!path)
|
if (!path)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -621,7 +621,7 @@ int do_copy_eof(const char *src, const char *des)
|
|||||||
* @return 1 if the percentage of using space is lower than the specified quota.
|
* @return 1 if the percentage of using space is lower than the specified quota.
|
||||||
* or 0 if not.
|
* or 0 if not.
|
||||||
*/
|
*/
|
||||||
int space_available(char *path, int quota)
|
int space_available(const char *path, int quota)
|
||||||
{
|
{
|
||||||
struct statfs diskInfo;
|
struct statfs diskInfo;
|
||||||
unsigned long long totalBlocks;
|
unsigned long long totalBlocks;
|
||||||
@ -1070,7 +1070,8 @@ free:
|
|||||||
*
|
*
|
||||||
* @return the count of searched files on success, or -1 on error.
|
* @return the count of searched files on success, or -1 on error.
|
||||||
*/
|
*/
|
||||||
int find_file(char *dir, char *target_file, int depth, char *path[], int limit)
|
int find_file(const char *dir, char *target_file, int depth, char *path[],
|
||||||
|
int limit)
|
||||||
{
|
{
|
||||||
int i, ret;
|
int i, ret;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -71,7 +71,7 @@ static inline int get_file_size(const char *filepath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *mm_get_line(struct mm_file_t *mfile, int line);
|
char *mm_get_line(struct mm_file_t *mfile, int line);
|
||||||
int mkdir_p(char *path);
|
int mkdir_p(const char *path);
|
||||||
int mm_count_lines(struct mm_file_t *mfile);
|
int mm_count_lines(struct mm_file_t *mfile);
|
||||||
struct mm_file_t *mmap_file(const char *path);
|
struct mm_file_t *mmap_file(const char *path);
|
||||||
void unmap_file(struct mm_file_t *mfile);
|
void unmap_file(struct mm_file_t *mfile);
|
||||||
@ -89,7 +89,7 @@ int file_read_int(const char *filename, unsigned int *pcurrent);
|
|||||||
int file_update_int(const char *filename, unsigned int current,
|
int file_update_int(const char *filename, unsigned int current,
|
||||||
unsigned int max);
|
unsigned int max);
|
||||||
int do_copy_eof(const char *src, const char *des);
|
int do_copy_eof(const char *src, const char *des);
|
||||||
int space_available(char *path, int quota);
|
int space_available(const char *path, int quota);
|
||||||
int count_lines_in_file(const char *filename);
|
int count_lines_in_file(const char *filename);
|
||||||
int read_full_binary_file(const char *path, unsigned long *size,
|
int read_full_binary_file(const char *path, unsigned long *size,
|
||||||
void **data);
|
void **data);
|
||||||
@ -108,7 +108,8 @@ int filter_filename_startswith(const struct dirent *entry,
|
|||||||
const void *arg);
|
const void *arg);
|
||||||
int dir_contains(const char *dir, const char *filename, int exact);
|
int dir_contains(const char *dir, const char *filename, int exact);
|
||||||
int lsdir(const char *dir, char *fullname[], int limit);
|
int lsdir(const char *dir, char *fullname[], int limit);
|
||||||
int find_file(char *dir, char *target_file, int depth, char *path[], int limit);
|
int find_file(const char *dir, char *target_file, int depth, char *path[],
|
||||||
|
int limit);
|
||||||
int read_file(const char *path, unsigned long *size, void **data);
|
int read_file(const char *path, unsigned long *size, void **data);
|
||||||
int is_ac_filefmt(const char *file_fmt);
|
int is_ac_filefmt(const char *file_fmt);
|
||||||
int config_fmt_to_files(const char *file_fmt, char ***out);
|
int config_fmt_to_files(const char *file_fmt, char ***out);
|
||||||
|
Loading…
Reference in New Issue
Block a user