mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-05 02:40:37 +00:00
HV:Acrn-hypvervisor Root Directory Clean-up and create misc/ folder for Acrn daemons, services and tools.
This patch is to clean-up acrn-hypervisor root directory, targt only 5 folders under acrn-hypervisor:1.hypervisor,2.devicemodel,3.misc,4.doc,5.build Tracked-On: #3482 Signed-off-by: Terry Zou <terry.zou@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
8
misc/tools/acrn-crashlog/common/include/cmdutils.h
Normal file
8
misc/tools/acrn-crashlog/common/include/cmdutils.h
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
int execv_out2file(char * const argv[], const char *outfile);
|
||||
int exec_out2file(const char *outfile, const char *fmt, ...);
|
||||
ssize_t exec_out2mem(char **outmem, const char *fmt, ...);
|
135
misc/tools/acrn-crashlog/common/include/fsutils.h
Normal file
135
misc/tools/acrn-crashlog/common/include/fsutils.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 Intel Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __FSUTILS_H__
|
||||
#define __FSUTILS_H__
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define MIN(a, b) (((a) > (b)) ? (b) : (a))
|
||||
|
||||
#define KB (1024)
|
||||
#define MB (KB * KB)
|
||||
#define MAXLINESIZE (PATH_MAX + 128)
|
||||
#define CPBUFFERSIZE (4 * KB)
|
||||
#define PAGE_SIZE (4 * KB)
|
||||
|
||||
struct mm_file_t {
|
||||
char *path;
|
||||
int fd;
|
||||
char *begin;
|
||||
ssize_t size;
|
||||
};
|
||||
|
||||
struct ac_filter_data {
|
||||
const char *str;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
static inline int file_exists(const char *filename)
|
||||
{
|
||||
struct stat info;
|
||||
|
||||
return (stat(filename, &info) == 0);
|
||||
}
|
||||
|
||||
static inline int directory_exists(const char *path)
|
||||
{
|
||||
struct stat info;
|
||||
|
||||
return (stat(path, &info) == 0 && S_ISDIR(info.st_mode));
|
||||
}
|
||||
|
||||
static inline ssize_t get_file_size(const char *filepath)
|
||||
{
|
||||
struct stat info;
|
||||
|
||||
if (filepath == NULL)
|
||||
return -ENOENT;
|
||||
|
||||
if (stat(filepath, &info) < 0)
|
||||
return -errno;
|
||||
|
||||
return info.st_size;
|
||||
}
|
||||
|
||||
static inline ssize_t get_file_blocks_size(const char *filepath)
|
||||
{
|
||||
struct stat info;
|
||||
|
||||
if (filepath == NULL)
|
||||
return -ENOENT;
|
||||
|
||||
if (stat(filepath, &info) < 0)
|
||||
return -errno;
|
||||
|
||||
return info.st_blocks * 512;
|
||||
}
|
||||
|
||||
char *mm_get_line(struct mm_file_t *mfile, int line);
|
||||
int mkdir_p(const char *path);
|
||||
int remove_r(const char *dir);
|
||||
int mm_count_lines(struct mm_file_t *mfile);
|
||||
struct mm_file_t *mmap_file(const char *path);
|
||||
void unmap_file(struct mm_file_t *mfile);
|
||||
int do_copy_tail(const char *src, const char *dest, int limit);
|
||||
int do_mv(char *src, char *dest);
|
||||
ssize_t append_file(const char *filename, const char *text, size_t tlen);
|
||||
int replace_file_head(char *filename, char *text);
|
||||
int overwrite_file(const char *filename, const char *value);
|
||||
int readline(int fd, char buffer[MAXLINESIZE]);
|
||||
ssize_t file_read_string(const char *file, char *string, const int size);
|
||||
void file_reset_init(const char *filename);
|
||||
int file_read_int(const char *filename, unsigned int *pcurrent);
|
||||
int file_update_int(const char *filename, unsigned int current,
|
||||
unsigned int max);
|
||||
int do_copy_limit(const char *src, const char *des, size_t limitsize);
|
||||
int space_available(const char *path, int quota);
|
||||
int count_lines_in_file(const char *filename);
|
||||
int read_full_binary_file(const char *path, unsigned long *size,
|
||||
void **data);
|
||||
ssize_t file_read_key_value(char *value, const size_t limit, const char *path,
|
||||
const char *key, size_t klen);
|
||||
ssize_t file_read_key_value_r(char *value, const size_t limit, const char *path,
|
||||
const char *key, size_t klen);
|
||||
int ac_scandir(const char *dirp, struct dirent ***namelist,
|
||||
int (*filter)(const struct dirent *, const void *),
|
||||
const void *farg,
|
||||
int (*compar)(const struct dirent **,
|
||||
const struct dirent **));
|
||||
int filter_filename_substr(const struct dirent *entry, const void *arg);
|
||||
int filter_filename_exactly(const struct dirent *entry, const void *arg);
|
||||
int filter_filename_startswith(const struct dirent *entry,
|
||||
const void *arg);
|
||||
int dir_contains(const char *dir, const char *filename, size_t flen, int exact);
|
||||
int lsdir(const char *dir, char *fullname[], int limit);
|
||||
int find_file(const char *dir, size_t dlen, const char *target_file,
|
||||
size_t tflen, int depth, char *path[], int limit);
|
||||
int dir_blocks_size(const char *dir, size_t dlen, size_t *size);
|
||||
int read_file(const char *path, unsigned long *size, void **data);
|
||||
int is_ac_filefmt(const char *file_fmt);
|
||||
int config_fmt_to_files(const char *file_fmt, char ***out);
|
||||
|
||||
#endif
|
48
misc/tools/acrn-crashlog/common/include/log_sys.h
Normal file
48
misc/tools/acrn-crashlog/common/include/log_sys.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) <2018> Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef __LOG_SYS_H__
|
||||
#define __LOG_SYS_H__
|
||||
|
||||
#include <syslog.h>
|
||||
#include <systemd/sd-journal.h>
|
||||
|
||||
void debug_log(int level, const char *func, int line, ...);
|
||||
|
||||
#define LOG_LEVEL LOG_WARNING
|
||||
|
||||
#ifdef DEBUG_ACRN_CRASHLOG
|
||||
#define LOGE(...) \
|
||||
debug_log(LOG_ERR, __func__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#define LOGW(...) \
|
||||
debug_log(LOG_WARNING, __func__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#define LOGI(...) \
|
||||
debug_log(LOG_INFO, __func__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#define LOGD(...) \
|
||||
debug_log(LOG_DEBUG, __func__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define ac_log(level, ...) \
|
||||
do { \
|
||||
if (level <= LOG_LEVEL) \
|
||||
sd_journal_print(level, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define LOGE(...) \
|
||||
ac_log(LOG_ERR, __VA_ARGS__)
|
||||
|
||||
#define LOGW(...) \
|
||||
ac_log(LOG_WARNING, __VA_ARGS__)
|
||||
|
||||
#define LOGI(...) \
|
||||
ac_log(LOG_INFO, __VA_ARGS__)
|
||||
|
||||
#define LOGD(...) \
|
||||
ac_log(LOG_DEBUG, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#endif
|
22
misc/tools/acrn-crashlog/common/include/strutils.h
Normal file
22
misc/tools/acrn-crashlog/common/include/strutils.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef __STRUTILS_H__
|
||||
#define __STRUTILS_H__
|
||||
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
#define s_not_expect(res, size) (res < 0 || (size_t)res >= size)
|
||||
|
||||
char *get_line(const char *str, size_t str_size,
|
||||
const char *area, size_t area_size,
|
||||
const char *search_from, size_t *len);
|
||||
ssize_t strlinelen(const char *str, size_t size);
|
||||
char *strrstr(const char *s, const char *str);
|
||||
char *strtrim(char *str, size_t len);
|
||||
int strcnt(char *str, char c);
|
||||
char *strings_ind(char *strings, size_t size, int index, size_t *slen);
|
||||
int str_split_ere(const char *str, size_t slen,
|
||||
const char *fmt, size_t flen, ...);
|
||||
#endif
|
Reference in New Issue
Block a user