tools:acrn-crashlog: request resources of SOS in crashlog

Dispatch the new event id and log directory in one place.

Tracked-On: #1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Liu, Xiaojing <xiaojing.liu@intel.com>
Acked-by: Chen, Gang <gang.c.chen@intel.com>
This commit is contained in:
Liu, Xinwu
2019-04-19 13:46:46 +08:00
committed by ACRN System Integration
parent 901ce53971
commit 728a480693
7 changed files with 162 additions and 136 deletions

View File

@@ -368,35 +368,36 @@ void generate_crashfile(const char *dir,
*
* @param mode Mode for log storage.
* @param hashkey Event id.
* @param[out] dir_len Length of generated dir.
*
* @return a pointer to generated path if successful, or NULL if not.
*/
char *generate_log_dir(enum e_dir_mode mode, char *hashkey)
char *generate_log_dir(enum e_dir_mode mode, char *hashkey, size_t *dir_len)
{
char *path;
char dir[PATH_MAX];
unsigned int current;
int ret;
int len;
ret = reserve_log_folder(mode, dir, &current);
if (ret)
if (reserve_log_folder(mode, dir, &current))
return NULL;
ret = asprintf(&path, "%s%d_%s", dir, current, hashkey);
if (ret == -1) {
len = asprintf(&path, "%s%d_%s", dir, current, hashkey);
if (len == -1) {
LOGE("construct log path failed, out of memory\n");
hist_raise_infoerror("DIR CREATE", 10);
return NULL;
}
ret = mkdir(path, 0777);
if (ret == -1) {
if (mkdir(path, 0777) == -1) {
LOGE("Cannot create dir %s\n", path);
hist_raise_infoerror("DIR CREATE", 10);
free(path);
return NULL;
}
if (dir_len)
*dir_len = (size_t)len;
return path;
}