mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2025-02-26 05:35:43 +00:00
commit
81e8356d58
@ -23,12 +23,18 @@
|
||||
#include <poll.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <climits>
|
||||
|
||||
FTRACE_NS_BEGIN
|
||||
FtraceDataReader::FtraceDataReader(const std::string& path) : path_(path), readFd_(-1)
|
||||
{
|
||||
readFd_ = open(path.c_str(), O_CLOEXEC | O_NONBLOCK);
|
||||
CHECK_TRUE(readFd_ >= 0, NO_RETVAL, "open %s failed, %d", path_.c_str(), errno);
|
||||
char realPath[PATH_MAX + 1] = {0};
|
||||
|
||||
if ((path.length() > PATH_MAX) || (realpath(path.c_str(), realPath) == nullptr)) {
|
||||
HILOG_ERROR(LOG_CORE, "%s:so filename invalid, errno=%d", __func__, errno);
|
||||
}
|
||||
readFd_ = open(realPath, O_CLOEXEC | O_NONBLOCK);
|
||||
CHECK_TRUE(readFd_ >= 0, NO_RETVAL, "open %s failed, %d", realPath, errno);
|
||||
}
|
||||
|
||||
FtraceDataReader::~FtraceDataReader()
|
||||
|
@ -28,16 +28,20 @@ FileCache::~FileCache()
|
||||
|
||||
bool FileCache::Open(const std::string& file)
|
||||
{
|
||||
if (path_.length() > PATH_MAX) {
|
||||
std::string path = path_ + file;
|
||||
char realPath[PATH_MAX + 1] = {0};
|
||||
|
||||
if ((path.length() > PATH_MAX) || (realpath(path.c_str(), realPath) == nullptr)) {
|
||||
HILOG_ERROR(LOG_CORE, "%s:so filename invalid, errno=%d", __func__, errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (access(path_.c_str(), F_OK) != 0) {
|
||||
int32_t ret = mkdir(path_.c_str(), 0777);
|
||||
CHECK_TRUE(ret == 0, false, "FileCache: mkdir failed(%s), error(%d)!", path_.c_str(), errno);
|
||||
}
|
||||
|
||||
std::string path = path_ + file;
|
||||
fp_ = fopen(path.c_str(), "wb+");
|
||||
fp_ = fopen(realPath, "wb+");
|
||||
CHECK_NOTNULL(fp_, -1, "FileCache: open(%s) Failed, errno(%d)", path.c_str(), errno);
|
||||
|
||||
return true;
|
||||
|
@ -395,6 +395,7 @@ bool HilogPlugin::StringToL(const char* word, long& value)
|
||||
bool HilogPlugin::TimeStringToNS(const char* data, struct timespec *tsTime)
|
||||
{
|
||||
struct tm tmTime = {0};
|
||||
struct tm* pTM = nullptr;
|
||||
time_t timetTime;
|
||||
char* end = nullptr;
|
||||
char* pTmp = nullptr;
|
||||
@ -403,7 +404,7 @@ bool HilogPlugin::TimeStringToNS(const char* data, struct timespec *tsTime)
|
||||
long fixHour;
|
||||
|
||||
nSeconds = time(nullptr);
|
||||
struct tm* pTM = localtime(&nSeconds);
|
||||
localtime_r(&nSeconds, pTM);
|
||||
if (pTM == nullptr) {
|
||||
const int bufSize = 1024;
|
||||
char buf[bufSize] = { 0 };
|
||||
|
Loading…
x
Reference in New Issue
Block a user