1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (C) 2021 Huawei Technologies Co., Ltd. All rights reserved. 4 */ 5 6 #ifndef BLACKBOX_COMMON_H 7 #define BLACKBOX_COMMON_H 8 9 #include <linux/types.h> 10 11 /* bbox/BBOX - blackbox */ 12 #define YEAR_BASE 1900 13 #define SECONDS_PER_MINUTE 60 14 #define AID_ROOT 0 15 #define AID_SYSTEM 1000 16 #define BBOX_DIR_LIMIT 0775 17 #define BBOX_FILE_LIMIT 0664 18 #define PATH_MAX_LEN 256 19 20 /* 21 * format: 22 * [topCategoryName],module[moduleName],category[categoryName],\ 23 * event[eventName],time[seconds from 1970-01-01 00:00:00 UTC-tick],\ 24 * sysreboot[true|false],errordesc[errorDescription],logpath[logpath]\n 25 */ 26 #define HISTORY_LOG_FORMAT "[%s],module[%s],category[%s],event[%s],"\ 27 "time[%s],sysreboot[%s],errdesc[%s],logpath[%s]\n" 28 #define TIMESTAMP_FORMAT "%04d%02d%02d%02d%02d%02d-%08llu" 29 30 void sys_reset(void); 31 void change_own(char *path, int uid, int gid); 32 int full_write_file(const char *pfile_path, char *buf, 33 size_t buf_size, bool read_file); 34 int file_exists(const char *name); 35 int create_log_dir(const char *path); 36 unsigned long long get_ticks(void); 37 struct file *file_open(const char *filename, int open_mode, int mode); 38 void file_close(struct file *filp); 39 ssize_t file_read(struct file *file, loff_t offset, unsigned char *data, 40 size_t size); 41 int file_delete(struct file *filp); 42 char *getfullpath(struct file *filp); 43 44 #endif /* BLACKBOX_COMMON_H */ 45