mirror of
https://gitee.com/openharmony/filemanagement_storage_service
synced 2024-11-26 16:53:57 +00:00
code sync
Signed-off-by: zhangyaomaggie <zhangyao128@huawei.com>
This commit is contained in:
parent
a163c71d1d
commit
4e04b280dc
@ -44,4 +44,5 @@
|
||||
[公共文件访问框架](https://gitee.com/openharmony/filemanagement_user_file_service)
|
||||
[文件访问接口](https://gitee.com/openharmony/filemanagement_file_api)
|
||||
[分布式文件服务](https://gitee.com/openharmony/filemanagement_dfs_service)
|
||||
[应用文件服务](https://gitee.com/openharmony/filemanagement_app_file_service)
|
||||
[**存储管理服务**](https://gitee.com/openharmony/filemanagement_storage_service)
|
@ -34,6 +34,7 @@
|
||||
"ability_base",
|
||||
"ability_runtime",
|
||||
"access_token",
|
||||
"app_file_service",
|
||||
"bounds_checking_function",
|
||||
"bundle_framework",
|
||||
"c_utils",
|
||||
|
@ -60,7 +60,6 @@ ohos_shared_library("storage_manager_acl") {
|
||||
|
||||
innerapi_tags = [
|
||||
"chipsetsdk_indirect",
|
||||
"platformsdk",
|
||||
]
|
||||
part_name = "storage_service"
|
||||
subsystem_name = "filemanagement"
|
||||
|
@ -53,6 +53,8 @@ namespace StorageManager {
|
||||
NOTIFY_VOLUME_STATE_CHANGED,
|
||||
MOUNT,
|
||||
UNMOUNT,
|
||||
MOUNT_DFS_DOCS,
|
||||
UMOUNT_DFS_DOCS,
|
||||
GET_ALL_VOLUMES,
|
||||
NOTIFY_DISK_CREATED,
|
||||
NOTIFY_DISK_DESTROYED,
|
||||
@ -78,8 +80,6 @@ namespace StorageManager {
|
||||
GET_USER_STATS_BY_TYPE,
|
||||
UPDATE_MEM_PARA,
|
||||
GET_BUNDLE_STATS_INCREASE,
|
||||
MOUNT_DFS_DOCS,
|
||||
UMOUNT_DFS_DOCS,
|
||||
GENERATE_APP_KEY,
|
||||
DELETE_APP_KEY,
|
||||
};
|
||||
|
@ -27,10 +27,6 @@ class StorageRlMap : public NoCopyable {
|
||||
public:
|
||||
StorageRlMap() {}
|
||||
~StorageRlMap() {}
|
||||
V& operator[](const K& key)
|
||||
{
|
||||
return map_[key];
|
||||
}
|
||||
V ReadVal(const K& key)
|
||||
{
|
||||
Utils::UniqueWriteGuard<Utils::RWLock> mapGuard(this->rl_);
|
||||
|
@ -22,7 +22,7 @@ namespace OHOS {
|
||||
namespace StorageService {
|
||||
const int START_USER_ID = 100;
|
||||
const int MAX_USER_ID = 1099;
|
||||
const int ZERO_USER_ID = 0;
|
||||
const int ZERO_USER = 0;
|
||||
const int UID_FILE_MANAGER = 1006;
|
||||
const uid_t USER_ID_BASE = 200000;
|
||||
}
|
||||
|
@ -55,12 +55,12 @@ public:
|
||||
const std::vector<uint8_t> &token,
|
||||
const std::vector<uint8_t> &secret);
|
||||
static int32_t GetLockScreenStatus(uint32_t userId, bool &lockScreenStatus);
|
||||
static int32_t GenerateAppkey(uint32_t userId, uint32_t appUid, std::string &keyId);
|
||||
static int32_t DeleteAppkey(uint32_t userId, const std::string keyId);
|
||||
static int32_t MountDfsDocs(int32_t userId, const std::string &relativePath,
|
||||
const std::string &networkId, const std::string &deviceId);
|
||||
static int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
||||
const std::string &networkId, const std::string &deviceId);
|
||||
static int32_t GenerateAppkey(uint32_t userId, uint32_t appUid, std::string &keyId);
|
||||
static int32_t DeleteAppkey(uint32_t userId, const std::string keyId);
|
||||
|
||||
private:
|
||||
static sptr<IStorageDaemon> GetStorageDaemonProxy(void);
|
||||
|
@ -59,7 +59,7 @@ bool StorageDaemonClient::CheckServiceStatus(uint32_t serviceFlags)
|
||||
|
||||
auto samgr = OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (samgr == nullptr) {
|
||||
LOGW("samgr empty, retry");
|
||||
LOGW("samgr is nullptr, retry");
|
||||
for (uint32_t i = 0; i < CHECK_SERVICE_TIMES; i++) {
|
||||
samgr = OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (samgr != nullptr) {
|
||||
@ -69,7 +69,7 @@ bool StorageDaemonClient::CheckServiceStatus(uint32_t serviceFlags)
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME_PRE_CHECK));
|
||||
}
|
||||
if (samgr == nullptr) {
|
||||
LOGE("samgr empty error");
|
||||
LOGE("samgr is nullptr, retry failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -321,8 +321,7 @@ int32_t StorageDaemonClient::LockUserScreen(uint32_t userId)
|
||||
return client->LockUserScreen(userId);
|
||||
}
|
||||
|
||||
int32_t StorageDaemonClient::UnlockUserScreen(uint32_t userId,
|
||||
const std::vector<uint8_t> &token,
|
||||
int32_t StorageDaemonClient::UnlockUserScreen(uint32_t userId, const std::vector<uint8_t> &token,
|
||||
const std::vector<uint8_t> &secret)
|
||||
{
|
||||
if (!CheckServiceStatus(STORAGE_SERVICE_FLAG)) {
|
||||
|
@ -60,10 +60,10 @@ private:
|
||||
int32_t HandleActiveUserKey(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleInactiveUserKey(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleUpdateKeyContext(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleMountCryptoPathAgain(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleLockUserScreen(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleUnlockUserScreen(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetLockScreenStatus(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleMountCryptoPathAgain(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGenerateAppkey(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleDeleteAppkey(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
|
@ -34,11 +34,6 @@ struct DirInfo {
|
||||
gid_t gid;
|
||||
};
|
||||
|
||||
struct ProcessInfo {
|
||||
int pid;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
constexpr uid_t OID_ROOT = 0;
|
||||
constexpr uid_t OID_SYSTEM = 1000;
|
||||
constexpr uid_t OID_FILE_MANAGER = 1006;
|
||||
@ -73,17 +68,12 @@ public:
|
||||
const std::string &networkId, const std::string &deviceId);
|
||||
int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
||||
const std::string &networkId, const std::string &deviceId);
|
||||
void UMountCryptoPathAgain(uint32_t userId);
|
||||
int32_t UMountAllPath(int32_t userId);
|
||||
void SetCloudState(bool active);
|
||||
int32_t RestoreconSystemServiceDirs(int32_t userId);
|
||||
int32_t FindMountPointsToMap(std::map<std::string, std::list<std::string>> &mountMap, int32_t userId);
|
||||
void MountPointToList(std::list<std::string> &hmdfsList, std::list<std::string> &hmfsList,
|
||||
std::list<std::string> &sharefsList, std::string &line, int32_t userId);
|
||||
int32_t FindProcess(int32_t userId);
|
||||
bool CheckMaps(const std::string &path, const std::string &prefix);
|
||||
bool CheckSymlink(const std::string &path, const std::string &prefix);
|
||||
bool GetProcessInfo(const std::string &filename, ProcessInfo &info);
|
||||
|
||||
private:
|
||||
bool SupportHmdfs();
|
||||
|
@ -84,14 +84,14 @@ StorageDaemonStub::StorageDaemonStub()
|
||||
&StorageDaemonStub::HandleUpdateMemoryPara;
|
||||
opToInterfaceMap_[static_cast<uint32_t>(StorageDaemonInterfaceCode::GET_BUNDLE_STATS_INCREASE)] =
|
||||
&StorageDaemonStub::HandleGetBundleStatsForIncrease;
|
||||
opToInterfaceMap_[static_cast<uint32_t>(StorageDaemonInterfaceCode::MOUNT_DFS_DOCS)] =
|
||||
&StorageDaemonStub::HandleMountDfsDocs;
|
||||
opToInterfaceMap_[static_cast<uint32_t>(StorageDaemonInterfaceCode::UMOUNT_DFS_DOCS)] =
|
||||
&StorageDaemonStub::HandleUMountDfsDocs;
|
||||
opToInterfaceMap_[static_cast<uint32_t>(StorageDaemonInterfaceCode::GENERATE_APP_KEY)] =
|
||||
&StorageDaemonStub::HandleGenerateAppkey;
|
||||
opToInterfaceMap_[static_cast<uint32_t>(StorageDaemonInterfaceCode::DELETE_APP_KEY)] =
|
||||
&StorageDaemonStub::HandleDeleteAppkey;
|
||||
opToInterfaceMap_[static_cast<uint32_t>(StorageDaemonInterfaceCode::MOUNT_DFS_DOCS)] =
|
||||
&StorageDaemonStub::HandleMountDfsDocs;
|
||||
opToInterfaceMap_[static_cast<uint32_t>(StorageDaemonInterfaceCode::UMOUNT_DFS_DOCS)] =
|
||||
&StorageDaemonStub::HandleUMountDfsDocs;
|
||||
}
|
||||
|
||||
int32_t StorageDaemonStub::OnRemoteRequest(uint32_t code,
|
||||
|
@ -79,6 +79,18 @@ public:
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
virtual int32_t MountDfsDocs(int32_t userId, const std::string &relativePath,
|
||||
const std::string &networkId, const std::string &deviceId) override
|
||||
{
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
virtual int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
||||
const std::string &networkId, const std::string &deviceId) override
|
||||
{
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
virtual int32_t PrepareUserDirs(int32_t userId, uint32_t flags) override
|
||||
{
|
||||
return E_OK;
|
||||
@ -140,18 +152,6 @@ public:
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
virtual int32_t MountDfsDocs(int32_t userId, const std::string &relativePath,
|
||||
const std::string &networkId, const std::string &deviceId) override
|
||||
{
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
virtual int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
||||
const std::string &networkId, const std::string &deviceId) override
|
||||
{
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
virtual int32_t GetLockScreenStatus(uint32_t userId, bool &lockScreenStatus) override
|
||||
{
|
||||
return E_OK;
|
||||
|
@ -790,7 +790,7 @@ HWTEST_F(StorageDaemonStubTest, Storage_Manager_StorageDaemonTest_HandleDeleteAp
|
||||
MessageParcel reply2;
|
||||
EXPECT_CALL(mock, DeleteAppkey(testing::_, testing::_)).WillOnce(testing::Return(E_ERR));
|
||||
ret = mock.HandleDeleteAppkey(data2, reply2);
|
||||
EXPECT_EQ(ret, E_OK);
|
||||
EXPECT_EQ(ret == E_OK);
|
||||
err = reply2.ReadInt32();
|
||||
EXPECT_TRUE(err == E_ERR);
|
||||
|
||||
|
@ -49,7 +49,6 @@ using namespace OHOS::FileManagement::CloudFile;
|
||||
#endif
|
||||
using namespace OHOS::StorageService;
|
||||
constexpr int32_t UMOUNT_RETRY_TIMES = 3;
|
||||
constexpr int32_t ONE_KB = 1024;
|
||||
std::shared_ptr<MountManager> MountManager::instance_ = nullptr;
|
||||
|
||||
const string SANDBOX_ROOT_PATH = "/mnt/sandbox/";
|
||||
@ -199,7 +198,6 @@ int32_t MountManager::HmdfsMount(int32_t userId, std::string relativePath, bool
|
||||
hmdfsMntArgs.GetFlags(), hmdfsMntArgs.OptionsToString().c_str());
|
||||
if (ret != 0 && errno != EEXIST && errno != EBUSY) {
|
||||
LOGE("failed to mount hmdfs, err %{public}d", errno);
|
||||
FindProcess(userId);
|
||||
return E_MOUNT;
|
||||
}
|
||||
|
||||
@ -211,110 +209,6 @@ int32_t MountManager::HmdfsMount(int32_t userId, std::string relativePath, bool
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
int32_t MountManager::FindProcess(int32_t userId)
|
||||
{
|
||||
if (userId <= 0) return E_OK;
|
||||
LOGI("FindProcess start, userId is %{public}d", userId);
|
||||
Utils::MountArgument argument(Utils::MountArgumentDescriptors::Alpha(userId, ""));
|
||||
const string &prefix = argument.GetMountPointPrefix();
|
||||
DIR *dir = opendir("/proc");
|
||||
if (dir == nullptr) {
|
||||
LOGE("failed to open dir proc, err %{public}d", errno);
|
||||
return -errno;
|
||||
}
|
||||
std::vector<ProcessInfo> processInfos;
|
||||
struct dirent *entry;
|
||||
while ((entry = readdir(dir)) != nullptr) {
|
||||
if (entry->d_type != DT_DIR) continue;
|
||||
std::string name = entry->d_name;
|
||||
bool isNum = true;
|
||||
for (char c : name) {
|
||||
if (!isdigit(c)) {
|
||||
isNum = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isNum) continue;
|
||||
std::string pidPath = "/proc/" + name;
|
||||
bool found = false;
|
||||
found |= CheckMaps(pidPath + "/maps", prefix);
|
||||
found |= CheckSymlink(pidPath + "/cwd", prefix);
|
||||
found |= CheckSymlink(pidPath + "/root", prefix);
|
||||
found |= CheckSymlink(pidPath + "/exe", prefix);
|
||||
if (!found) continue;
|
||||
std::string filename = "/proc/" + name + "/stat";
|
||||
ProcessInfo info;
|
||||
if (GetProcessInfo(filename, info)) {
|
||||
LOGE("find a link pid is %{public}d, processName is %{public}s.", info.pid, info.name.c_str());
|
||||
processInfos.push_back(info);
|
||||
}
|
||||
}
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
bool MountManager::GetProcessInfo(const std::string &filename, ProcessInfo &info)
|
||||
{
|
||||
if (filename.empty()) {
|
||||
return false;
|
||||
}
|
||||
std::ifstream inputStream(filename.c_str(), std::ios::in);
|
||||
if (!inputStream.is_open()) {
|
||||
LOGE("unable to open %{public}s, err %{public}d", filename.c_str(), errno);
|
||||
return false;
|
||||
}
|
||||
std::string line;
|
||||
std::getline(inputStream, line);
|
||||
if (line.empty()) {
|
||||
return false;
|
||||
}
|
||||
std::stringstream ss(line);
|
||||
std::string pid;
|
||||
ss >> pid;
|
||||
std::string processName;
|
||||
ss >> processName;
|
||||
info.pid = std::stoi(pid);
|
||||
info.name = processName;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MountManager::CheckMaps(const std::string &path, const std::string &prefix)
|
||||
{
|
||||
bool found = false;
|
||||
std::ifstream inputStream(path.c_str(), std::ios::in);
|
||||
if (!inputStream.is_open()) {
|
||||
LOGE("unable to open %{public}s, err %{public}d", path.c_str(), errno);
|
||||
}
|
||||
std::string tmpLine;
|
||||
while (std::getline(inputStream, tmpLine)) {
|
||||
std::string::size_type pos = tmpLine.find("/");
|
||||
if (pos != std::string::npos) {
|
||||
tmpLine = tmpLine.substr(pos);
|
||||
if (tmpLine.find(prefix) == 0) {
|
||||
LOGE("find a fd %{public}s", tmpLine.c_str());
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
bool MountManager::CheckSymlink(const std::string &path, const std::string &prefix)
|
||||
{
|
||||
char realPath[ONE_KB];
|
||||
int res = readlink(path.c_str(), realPath, sizeof(realPath) - 1);
|
||||
if (res < 0 || res >= ONE_KB) {
|
||||
return false;
|
||||
}
|
||||
realPath[res] = '\0';
|
||||
std::string realPathStr(realPath);
|
||||
if (realPathStr.find(prefix) == 0) {
|
||||
LOGE("find a fd %{public}s", realPathStr.c_str());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t MountManager::CloudMount(int32_t userId, const string& path)
|
||||
{
|
||||
LOGI("cloud mount start");
|
||||
@ -797,7 +691,6 @@ int32_t MountManager::LocalUMount(int32_t userId)
|
||||
|
||||
int32_t MountManager::UmountByUser(int32_t userId)
|
||||
{
|
||||
FindProcess(userId);
|
||||
int32_t count = 0;
|
||||
while (count < UMOUNT_RETRY_TIMES) {
|
||||
int32_t err = E_OK;
|
||||
|
@ -14,8 +14,9 @@
|
||||
*/
|
||||
|
||||
#include "user/user_manager.h"
|
||||
#include <cstdlib>
|
||||
#include "bundle_mgr_client.h"
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef USER_CRYPTO_MANAGER
|
||||
#include "crypto/key_manager.h"
|
||||
#endif
|
||||
@ -333,16 +334,6 @@ int32_t UserManager::DestroyEl1Dir(int32_t userId)
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
int32_t UserManager::CheckUserIdRange(int32_t userId)
|
||||
{
|
||||
if ((userId < StorageService::START_USER_ID && userId != StorageService::ZERO_USER_ID)||
|
||||
userId > StorageService::MAX_USER_ID) {
|
||||
LOGE("UserManager: userId:%{public}d is out of range", userId);
|
||||
return E_USERID_RANGE;
|
||||
}
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
void UserManager::CreateBundleDataDir(uint32_t userId)
|
||||
{
|
||||
OHOS::AppExecFwk::BundleMgrClient client;
|
||||
@ -351,6 +342,16 @@ void UserManager::CreateBundleDataDir(uint32_t userId)
|
||||
LOGI("CreateBundleDataDir end: userId %{public}u, ret %{public}d", userId, ret);
|
||||
}
|
||||
|
||||
int32_t UserManager::CheckUserIdRange(int32_t userId)
|
||||
{
|
||||
if ((userId < StorageService::START_USER_ID && userId != StorageService::ZERO_USER) ||
|
||||
userId > StorageService::MAX_USER_ID) {
|
||||
LOGE("UserManager: userId:%{public}d is out of range", userId);
|
||||
return E_USERID_RANGE;
|
||||
}
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
int32_t UserManager::CheckCrypto(int32_t userId, uint32_t flags)
|
||||
{
|
||||
int32_t err = CheckUserIdRange(userId);
|
||||
|
@ -162,13 +162,12 @@ int32_t FileSystemCrypto::GetLockScreenStatus(uint32_t userId, bool &lockScreenS
|
||||
|
||||
int32_t FileSystemCrypto::GenerateAppkey(uint32_t appUid, std::string &keyId)
|
||||
{
|
||||
std::vector<int32_t> ids;
|
||||
int ret = AccountSA::OsAccountManager::QueryActiveOsAccountIds(ids);
|
||||
if (ret != 0 || ids.empty()) {
|
||||
LOGE("Query active userid failed, ret = %{public}u", ret);
|
||||
int32_t userId = -1;
|
||||
int ret = AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(appUid, userId);
|
||||
if (ret != 0 || userId == -1) {
|
||||
LOGE("Get os account userid from appUid failed, ret = %{public}u", ret);
|
||||
return ret;
|
||||
}
|
||||
int32_t userId = ids[0];
|
||||
LOGI("UserId: %{public}u", userId);
|
||||
int32_t err = CheckUserIdRange(userId);
|
||||
if (err != E_OK) {
|
||||
|
@ -53,12 +53,12 @@ public:
|
||||
const std::vector<uint8_t> &secret);
|
||||
int32_t InactiveUserKey(uint32_t userId);
|
||||
int32_t UpdateKeyContext(uint32_t userId);
|
||||
int32_t MountCryptoPathAgain(int32_t userId);
|
||||
int32_t LockUserScreen(uint32_t userId);
|
||||
int32_t UnlockUserScreen(uint32_t userId,
|
||||
const std::vector<uint8_t> &token,
|
||||
const std::vector<uint8_t> &secret);
|
||||
int32_t GetLockScreenStatus(uint32_t userId, bool &lockScreenStatus);
|
||||
int32_t MountCryptoPathAgain(int32_t userId);
|
||||
int32_t GenerateAppkey(uint32_t userId, uint32_t appUid, std::string &keyId);
|
||||
int32_t DeleteAppkey(uint32_t userId, const std::string keyId);
|
||||
|
||||
|
@ -170,14 +170,14 @@ StorageManagerStub::StorageManagerStub()
|
||||
&StorageManagerStub::HandleUpdateMemoryPara;
|
||||
opToInterfaceMap_[static_cast<uint32_t>(StorageManagerInterfaceCode::GET_BUNDLE_STATS_INCREASE)] =
|
||||
&StorageManagerStub::HandleGetBundleStatsForIncrease;
|
||||
opToInterfaceMap_[static_cast<uint32_t>(StorageManagerInterfaceCode::MOUNT_DFS_DOCS)] =
|
||||
&StorageManagerStub::HandleMountDfsDocs;
|
||||
opToInterfaceMap_[static_cast<uint32_t>(StorageManagerInterfaceCode::UMOUNT_DFS_DOCS)] =
|
||||
&StorageManagerStub::HandleUMountDfsDocs;
|
||||
opToInterfaceMap_[static_cast<uint32_t>(StorageManagerInterfaceCode::GENERATE_APP_KEY)] =
|
||||
&StorageManagerStub::HandleGenerateAppkey;
|
||||
opToInterfaceMap_[static_cast<uint32_t>(StorageManagerInterfaceCode::DELETE_APP_KEY)] =
|
||||
&StorageManagerStub::HandleDeleteAppkey;
|
||||
opToInterfaceMap_[static_cast<uint32_t>(StorageManagerInterfaceCode::MOUNT_DFS_DOCS)] =
|
||||
&StorageManagerStub::HandleMountDfsDocs;
|
||||
opToInterfaceMap_[static_cast<uint32_t>(StorageManagerInterfaceCode::UMOUNT_DFS_DOCS)] =
|
||||
&StorageManagerStub::HandleUMountDfsDocs;
|
||||
}
|
||||
|
||||
int32_t StorageManagerStub::OnRemoteRequest(uint32_t code,
|
||||
|
@ -59,6 +59,7 @@ ohos_unittest("storage_manager_proxy_test") {
|
||||
"ability_base:base",
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"app_file_service:fileshare_native",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hilog:libhilog",
|
||||
@ -119,6 +120,7 @@ ohos_unittest("storage_manager_stub_test") {
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libnativetoken",
|
||||
"access_token:libtoken_setproc",
|
||||
"app_file_service:fileshare_native",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
@ -176,6 +178,7 @@ ohos_unittest("storage_manager_stub_nonpermission_test") {
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"app_file_service:fileshare_native",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <cstring>
|
||||
|
||||
#include "message_parcel.h"
|
||||
#include "mount_argument_utils.h"
|
||||
#include "storage_daemon_ipc_interface_code.h"
|
||||
#include "storage_daemon_stub.h"
|
||||
#include "storage_daemon.h"
|
||||
@ -53,31 +52,8 @@ bool StorageDaemonCreateShareFileFuzzTest(std::unique_ptr<char[]> data, size_t s
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MountArgumentUtilsFuzzTest(std::unique_ptr<char[]> data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size < sizeof(uint32_t))) {
|
||||
return false;
|
||||
}
|
||||
struct Utils::MountArgument argument = {};
|
||||
argument.GetFullSrc();
|
||||
argument.GetFullDst();
|
||||
argument.GetShareSrc();
|
||||
argument.GetShareDst();
|
||||
argument.GetUserIdPara();
|
||||
argument.GetCommFullPath();
|
||||
argument.GetCloudFullPath();
|
||||
argument.GetCachePath();
|
||||
argument.GetCtrlPath();
|
||||
argument.OptionsToString();
|
||||
argument.GetFullCloud();
|
||||
argument.GetFullMediaCloud();
|
||||
argument.GetCloudDocsPath();
|
||||
argument.GetLocalDocsPath();
|
||||
argument.GetFlags();
|
||||
return true;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
@ -97,7 +73,5 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
return 0;
|
||||
}
|
||||
OHOS::StorageDaemonCreateShareFileFuzzTest(move(str), size);
|
||||
OHOS::MountArgumentUtilsFuzzTest(move(str), size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user