diff --git a/interfaces/kits/js/BUILD.gn b/interfaces/kits/js/BUILD.gn index 9c3fbdd3c97bac5f2c195a3b3a75a36bdda8bc82..ea7436a0c5723a8fd310463e152167e2f8f54343 100644 --- a/interfaces/kits/js/BUILD.gn +++ b/interfaces/kits/js/BUILD.gn @@ -365,6 +365,7 @@ ohos_shared_library("securitylabel") { cflags = [ "-Wno-format" ] + include_dirs = [ "${utils_path}/filemgmt_libhilog" ] sources = [ "src/mod_securitylabel/securitylabel_n_exporter.cpp", "src/mod_securitylabel/securitylabel_napi.cpp", diff --git a/interfaces/kits/js/src/mod_securitylabel/security_label.h b/interfaces/kits/js/src/mod_securitylabel/security_label.h index fbac9b3104a07400e077f1d822d3a66b6f917d55..9b78a35993aaab9f8379ec381cb1e8ca158d430c 100644 --- a/interfaces/kits/js/src/mod_securitylabel/security_label.h +++ b/interfaces/kits/js/src/mod_securitylabel/security_label.h @@ -22,6 +22,8 @@ #include #include +#include "filemgmt_libhilog.h" + namespace OHOS { namespace FileManagement { namespace ModuleSecurityLabel { @@ -33,6 +35,7 @@ public: static bool SetSecurityLabel(const std::string &path, const std::string &dataLevel) { if (DATA_LEVEL.count(dataLevel) != 1) { + HILOGE("The parameter of data level is invalid."); return false; } #ifdef IOS_PLATFORM @@ -40,6 +43,7 @@ public: #else if (setxattr(path.c_str(), XATTR_KEY, dataLevel.c_str(), dataLevel.size(), 0) < 0) { #endif + HILOGE("Failed to set the extension properties, error %{public}d", errno); return false; } return true; @@ -53,6 +57,7 @@ public: auto xattrValueSize = getxattr(path.c_str(), XATTR_KEY, nullptr, 0); #endif if (xattrValueSize == -1 || errno == ENOTSUP) { + HILOGE("Failed to get the extension properties of the filesystem, error: %{public}d", errno); return ""; } if (xattrValueSize <= 0) { @@ -60,6 +65,7 @@ public: } std::unique_ptr xattrValue = std::make_unique((long)xattrValueSize + 1); if (xattrValue == nullptr) { + HILOGE("Failed to request heap memory."); return ""; } #ifdef IOS_PLATFORM @@ -68,6 +74,7 @@ public: xattrValueSize = getxattr(path.c_str(), XATTR_KEY, xattrValue.get(), xattrValueSize); #endif if (xattrValueSize == -1 || errno == ENOTSUP) { + HILOGE("Failed to get the extension properties of the file, error: %{public}d", errno); return ""; } if (xattrValueSize <= 0) {