mirror of
https://gitee.com/openharmony/filemanagement_storage_service
synced 2024-11-23 06:59:59 +00:00
storage_service告警清理
Signed-off-by: lvyuanyuan <lvyuanyuan7@huawei.com> Change-Id: I0986b957c16d22f0f07f266fffb5af277bfcfb3b
This commit is contained in:
parent
30255d6d83
commit
1e6b2249eb
@ -74,8 +74,8 @@ bool StorageDaemonClient::CheckServiceStatus(uint32_t serviceFlags)
|
||||
}
|
||||
}
|
||||
|
||||
bool exist = false;
|
||||
if (serviceFlags & STORAGE_SERVICE_FLAG) {
|
||||
bool exist = false;
|
||||
for (uint32_t i = 0; i < CHECK_SERVICE_TIMES; i++) {
|
||||
auto object = samgr->CheckSystemAbility(STORAGE_DAEMON_SAID, exist);
|
||||
if (object != nullptr) {
|
||||
|
@ -30,7 +30,6 @@ static const std::string CRYPTO_NAME_PREFIXES[] = {"ext4", "f2fs", "fscrypt"};
|
||||
bool FscryptKeyV1::ActiveKey(uint32_t flag, const std::string &mnt)
|
||||
{
|
||||
uint32_t elType;
|
||||
uint32_t sdpClass;
|
||||
(void)mnt;
|
||||
LOGD("enter");
|
||||
if (!GenerateKeyDesc()) {
|
||||
@ -43,6 +42,7 @@ bool FscryptKeyV1::ActiveKey(uint32_t flag, const std::string &mnt)
|
||||
return false;
|
||||
}
|
||||
if (elType == TYPE_EL3 || elType == TYPE_EL4) {
|
||||
uint32_t sdpClass;
|
||||
if (elType == TYPE_EL3) {
|
||||
sdpClass = FSCRYPT_SDP_SECE_CLASS;
|
||||
} else {
|
||||
|
@ -116,11 +116,10 @@ int DiskInfo::Create()
|
||||
|
||||
int DiskInfo::Destroy()
|
||||
{
|
||||
int ret;
|
||||
auto volume = VolumeManager::Instance();
|
||||
|
||||
for (auto volumeId : volumeId_) {
|
||||
ret = volume->DestroyVolume(volumeId);
|
||||
auto ret = volume->DestroyVolume(volumeId);
|
||||
if (ret != E_OK) {
|
||||
LOGE("Destroy volume %{public}s failed", volumeId.c_str());
|
||||
return E_ERR;
|
||||
|
@ -147,7 +147,7 @@ char *Acl::Serialize(size_t &bufSize)
|
||||
size_t restSize = bufSize - sizeof(AclXattrHeader);
|
||||
AclXattrEntry *ptr = reinterpret_cast<AclXattrEntry *>(buf + sizeof(AclXattrHeader));
|
||||
for (const auto &e : entries) {
|
||||
auto err = memcpy_s(ptr++, restSize, &e, sizeof(AclXattrEntry));
|
||||
err = memcpy_s(ptr++, restSize, &e, sizeof(AclXattrEntry));
|
||||
if (err != EOK) {
|
||||
errno = err;
|
||||
delete[] buf;
|
||||
|
@ -27,7 +27,7 @@ const std::string MMC_MAX_VOLUMES_PATH = "/sys/module/mmcblk/parameters/perdev_m
|
||||
|
||||
int CreateDiskNode(const std::string &path, dev_t dev);
|
||||
int DestroyDiskNode(const std::string &path);
|
||||
int GetDevSize(std::string path, uint64_t *size);
|
||||
int GetDevSize(const std::string &path, uint64_t *size);
|
||||
int GetMaxVolume(dev_t device);
|
||||
int32_t ReadMetadata(const std::string &path, std::string &uuid, std::string &type, std::string &label);
|
||||
std::string GetBlkidData(const std::string &devPath, const std::string &type);
|
||||
|
@ -46,7 +46,7 @@ bool PrepareDir(const std::string &path, mode_t mode, uid_t uid, gid_t gid);
|
||||
bool DestroyDir(const std::string &path);
|
||||
bool MkDirRecurse(const std::string& path, mode_t mode);
|
||||
bool RmDirRecurse(const std::string &path);
|
||||
void TravelChmod(std::string path, mode_t mode);
|
||||
void TravelChmod(const std::string &path, mode_t mode);
|
||||
int32_t Mount(const std::string &source, const std::string &target, const char *type,
|
||||
unsigned long flags, const void *data);
|
||||
int32_t UMount(const std::string &path);
|
||||
@ -54,11 +54,11 @@ int32_t UMount2(const std::string &path, int flag);
|
||||
void GetSubDirs(const std::string &path, std::vector<std::string> &dirList);
|
||||
void ReadDigitDir(const std::string &path, std::vector<FileList> &dirInfo);
|
||||
bool StringToUint32(const std::string &str, uint32_t &num);
|
||||
bool ReadFile(std::string path, std::string *str);
|
||||
bool ReadFile(const std::string &path, std::string *str);
|
||||
int ForkExec(std::vector<std::string> &cmd, std::vector<std::string> *output = nullptr);
|
||||
void TraverseDirUevent(const std::string &path, bool flag);
|
||||
void ChownRecursion(const std::string dir, uid_t uid, gid_t gid);
|
||||
int IsSameGidUid(const std::string dir, uid_t uid, gid_t gid);
|
||||
void ChownRecursion(const std::string &dir, uid_t uid, gid_t gid);
|
||||
int IsSameGidUid(const std::string &dir, uid_t uid, gid_t gid);
|
||||
void MoveFileManagerData(const std::string &filesPath);
|
||||
void OpenSubFile(const std::string &path, std::vector<std::string> &dirInfo);
|
||||
}
|
||||
|
@ -716,7 +716,7 @@ static std::map<std::string, struct FileStat> FilterExtensionPath(int64_t lastBa
|
||||
{
|
||||
// all file with stats in include directory
|
||||
std::map<std::string, struct FileStat> fileStats;
|
||||
for (auto &includeDir : includes) {
|
||||
for (const auto &includeDir : includes) {
|
||||
// Check if includeDir is a file path
|
||||
auto [isSucc, isDir] = CheckIfDirForIncludes(includeDir, lastBackupTime, fileStats, pathMap);
|
||||
if (!isSucc) {
|
||||
@ -730,7 +730,7 @@ static std::map<std::string, struct FileStat> FilterExtensionPath(int64_t lastBa
|
||||
|
||||
// all file with stats in exclude directory
|
||||
std::set<std::string> excludeFiles;
|
||||
for (auto &excludeDir : excludes) {
|
||||
for (const auto &excludeDir : excludes) {
|
||||
auto [isSuccess, isDir] = CheckIfDirForExcludes(excludeDir, excludeFiles);
|
||||
if (!isSuccess) {
|
||||
LOGE("GetExcludesFile dir path invaild");
|
||||
@ -744,7 +744,7 @@ static std::map<std::string, struct FileStat> FilterExtensionPath(int64_t lastBa
|
||||
|
||||
// clear exclude directory
|
||||
std::map<std::string, struct FileStat>::iterator it;
|
||||
for (auto &excludeFile : excludeFiles) {
|
||||
for (const auto &excludeFile : excludeFiles) {
|
||||
it = fileStats.find(excludeFile);
|
||||
if (it != fileStats.end()) {
|
||||
fileStats.erase(it);
|
||||
@ -822,7 +822,7 @@ static void DealWithIncludeFiles(const BundleStatsParas ¶s, const std::vecto
|
||||
{
|
||||
uint32_t userId = paras.userId;
|
||||
std::string bundleName = paras.bundleName;
|
||||
for (auto &include : includes) {
|
||||
for (const auto &include : includes) {
|
||||
std::string includeStr = include;
|
||||
if (includeStr.front() != FILE_SEPARATOR_CHAR) {
|
||||
includeStr = FILE_SEPARATOR_CHAR + includeStr;
|
||||
@ -869,7 +869,7 @@ static void GetBundleStatsForIncreaseEach(uint32_t userId, std::string &bundleNa
|
||||
|
||||
// recognize physical path for exclude directory
|
||||
std::vector<std::string> phyExcludes;
|
||||
for (auto &exclude : excludes) {
|
||||
for (const auto &exclude : excludes) {
|
||||
std::string excludeStr = exclude;
|
||||
if (excludeStr.front() != FILE_SEPARATOR_CHAR) {
|
||||
excludeStr = FILE_SEPARATOR_CHAR + excludeStr;
|
||||
|
@ -50,7 +50,7 @@ int DestroyDiskNode(const std::string &path)
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
int GetDevSize(std::string path, uint64_t *size)
|
||||
int GetDevSize(const std::string &path, uint64_t *size)
|
||||
{
|
||||
const char *kPath = path.c_str();
|
||||
int fd = open(kPath, O_RDONLY);
|
||||
@ -123,8 +123,7 @@ std::string GetBlkidDataByCmd(std::vector<std::string> &cmd)
|
||||
}
|
||||
|
||||
if (output.size() > 0) {
|
||||
size_t sep = string::npos;
|
||||
sep = output[0].find_first_of("\n");
|
||||
size_t sep = output[0].find_first_of("\n");
|
||||
if (sep != string::npos)
|
||||
output[0].resize(sep);
|
||||
return output[0];
|
||||
|
@ -207,7 +207,7 @@ bool RmDirRecurse(const std::string &path)
|
||||
return true;
|
||||
}
|
||||
|
||||
void TravelChmod(std::string path, mode_t mode)
|
||||
void TravelChmod(const std::string &path, mode_t mode)
|
||||
{
|
||||
struct stat st;
|
||||
DIR *d = nullptr;
|
||||
@ -359,7 +359,7 @@ void OpenSubFile(const std::string &path, std::vector<std::string> &file)
|
||||
(void)closedir(dir);
|
||||
}
|
||||
|
||||
bool ReadFile(std::string path, std::string *str)
|
||||
bool ReadFile(const std::string &path, std::string *str)
|
||||
{
|
||||
std::ifstream infile;
|
||||
int cnt = 0;
|
||||
@ -485,7 +485,7 @@ void TraverseDirUevent(const std::string &path, bool flag)
|
||||
(void)closedir(dir);
|
||||
}
|
||||
|
||||
int IsSameGidUid(const std::string dir, uid_t uid, gid_t gid)
|
||||
int IsSameGidUid(const std::string &dir, uid_t uid, gid_t gid)
|
||||
{
|
||||
struct stat st;
|
||||
if (TEMP_FAILURE_RETRY(lstat(dir.c_str(), &st)) == E_ERR) {
|
||||
@ -526,7 +526,7 @@ void MoveFileManagerData(const std::string &filesPath)
|
||||
MoveDataShell(filesPath + ".Trash/", docsPath);
|
||||
}
|
||||
|
||||
void ChownRecursion(const std::string dir, uid_t uid, gid_t gid)
|
||||
void ChownRecursion(const std::string &dir, uid_t uid, gid_t gid)
|
||||
{
|
||||
std::vector<std::string> cmd = {
|
||||
"/system/bin/chown",
|
||||
|
@ -42,7 +42,7 @@ std::string StringPrintf(const char *format, ...)
|
||||
int count = vsnprintf_s(buf, sizeof(buf), sizeof(buf), format, apBackup);
|
||||
if (count < 0) {
|
||||
LOGE("vsnprintf_s error, errno %{public}d", errno);
|
||||
} else if (count >= 0 && count < BUFF_SIZE) {
|
||||
} else if (count < BUFF_SIZE) {
|
||||
result.append(buf, count);
|
||||
} else {
|
||||
LOGI("allocate larger buffer, len = %{public}d", count + 1);
|
||||
|
@ -39,7 +39,7 @@ bool CheckClientPermission(const std::string& permissionStr)
|
||||
Security::AccessToken::AccessTokenID tokenCaller = IPCSkeleton::GetCallingTokenID();
|
||||
auto uid = IPCSkeleton::GetCallingUid();
|
||||
auto tokenType = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(tokenCaller);
|
||||
int res = Security::AccessToken::PermissionState::PERMISSION_DENIED;
|
||||
int res;
|
||||
if (tokenType == Security::AccessToken::TOKEN_NATIVE && uid == ACCOUNT_UID) {
|
||||
res = Security::AccessToken::PermissionState::PERMISSION_GRANTED;
|
||||
} else {
|
||||
|
@ -23,7 +23,7 @@
|
||||
namespace OHOS {
|
||||
bool FscryptUtilsFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size <= 0)) {
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
namespace OHOS {
|
||||
bool FileUtilFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size <= 0)) {
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
Parcel parcel;
|
||||
|
@ -20,7 +20,7 @@ namespace OHOS {
|
||||
namespace StorageManager {
|
||||
bool StorageTotalStatusServiceFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size <= 0)) {
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<StorageTotalStatusService> service = DelayedSingleton<StorageTotalStatusService>::GetInstance();
|
||||
|
Loading…
Reference in New Issue
Block a user