提交 ad69eace 编写于 作者: 史晓晓 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/startup_init_lite into master

Signed-off-by: N史晓晓 <shixiaoxiao2@huawei.com>
......@@ -104,8 +104,17 @@ void DeviceInfoService::OnStart(void)
}
return;
}
void DeviceInfoService::OnStop()
void DeviceInfoService::OnStop(void)
{
}
int DeviceInfoService::Dump(int fd, const std::vector<std::u16string>& args)
{
(void)args;
DINFO_LOGI("DeviceInfoService Dump");
DINFO_CHECK(fd >= 0, return -1, "Invalid fd for dump %d", fd);
return dprintf(fd, "%s\n", "No information to dump for this service");
}
} // namespace device_info
} // namespace OHOS
......@@ -44,8 +44,9 @@ public:
#ifndef STARTUP_INIT_TEST
protected:
#endif
void OnStart() override;
void OnStop() override;
void OnStart(void) override;
void OnStop(void) override;
int Dump(int fd, const std::vector<std::u16string>& args) override;
};
} // namespace device_info
} // namespace OHOS
......
......@@ -316,7 +316,7 @@ static int GetSlotInfoFromCmdLine(const char *slotInfoName)
char value[MAX_BUFFER_LEN] = {0};
char *buffer = ReadFileData(BOOT_CMD_LINE);
BEGET_ERROR_CHECK(buffer != NULL, return -1, "Failed to read cmdline");
BEGET_ERROR_CHECK(GetProcCmdlineValue(slotInfoName, buffer, value, MAX_BUFFER_LEN) == 0,
BEGET_INFO_CHECK(GetProcCmdlineValue(slotInfoName, buffer, value, MAX_BUFFER_LEN) == 0,
free(buffer); buffer = NULL; return -1, "Failed to get %s value from cmdline", slotInfoName);
free(buffer);
buffer = NULL;
......@@ -336,7 +336,7 @@ static int GetSlotInfoFromMisc(off_t offset, off_t size)
BEGET_ERROR_CHECK(lseek(fd, offset, SEEK_SET) >= 0, close(fd); return -1,
"Failed to lseek misc device fd, errno %d", errno);
int slotInfo = 0;
BEGET_ERROR_CHECK(read(fd, &slotInfo, size) == size, close(fd); return -1,
BEGET_INFO_CHECK(read(fd, &slotInfo, size) == size, close(fd); return -1,
"Failed to read current slot from misc, errno %d", errno);
close(fd);
return slotInfo;
......
......@@ -32,7 +32,7 @@ uiserver:x:1048:
servicectrl:x:1050:root,shell,system,samgr,hdf_devmgr
powerctrl:x:1051:root,shell,system,update,power_host
bootctrl:x:1052:root,shell,system
deviceprivate:x:1053:root,shell,system,samgr,hdf_devmgr,deviceinfo,dsoftbus,dms,account,useriam,device_manager
deviceprivate:x:1053:root,shell,system,samgr,hdf_devmgr,deviceinfo,dsoftbus,dms,account,useriam,access_token,device_manager
hiview:x:1201:
hidumper_service:x:1212:
shell:x:2000:
......
......@@ -24,6 +24,7 @@
#include "param_message.h"
#include "init_param.h"
#include "system_ability_definition.h"
#include "string_ex.h"
#include "watcher_utils.h"
namespace OHOS {
......@@ -435,5 +436,79 @@ int32_t WatcherManager::RefreshWatcher(const std::string &keyPrefix, uint32_t wa
SendLocalChange(keyPrefix, paramWatcher);
return 0;
}
WatcherManager::ParamWatcher *WatcherManager::WatcherGroup::GetNextWatcher(WatcherManager::ParamWatcher *watcher)
{
if (watcher == nullptr) {
if (ListEmpty(watchers_)) {
return nullptr;
}
return reinterpret_cast<WatcherManager::ParamWatcher *>(GetWatchers()->next);
}
if (watcher->GetGroupNode() == nullptr) {
return nullptr;
}
if (watcher->GetGroupNode()->next != GetWatchers()) {
return reinterpret_cast<WatcherManager::ParamWatcher *>(watcher->GetGroupNode()->next);
}
return nullptr;
}
void WatcherManager::DumpWatcherGroup(int fd, const WatcherManager::WatcherGroupPtr &watchGroup)
{
dprintf(fd, "Watch prefix : %s \n", watchGroup->GetKeyPrefix().c_str());
dprintf(fd, "Watch group id : %d \n", watchGroup->GetGroupId());
// watcher id
WatcherManager::ParamWatcher *watcher = watchGroup->GetNextWatcher(nullptr);
if (watcher != nullptr) {
dprintf(fd, "Watch id list : %d", watcher->GetWatcherId());
} else {
return;
}
watcher = watchGroup->GetNextWatcher(watcher);
while (watcher != nullptr) {
dprintf(fd, ", %d", watcher->GetWatcherId());
watcher = watchGroup->GetNextWatcher(watcher);
}
dprintf(fd, "\n");
}
int WatcherManager::Dump(int fd, const std::vector<std::u16string>& args)
{
WATCHER_CHECK(fd >= 0, return -1, "Invalid fd for dump %d", fd);
std::vector<std::string> params;
for (auto& arg : args) {
params.emplace_back(Str16ToStr8(arg));
}
if (params.size() >= 1 && params[0] == "-h") {
std::string dumpInfo = {};
dumpInfo.append("Usage:\n")
.append(" -h ")
.append("|help text for the tool\n")
.append(" -k ")
.append("|dump watcher infomation for key prefix\n");
dprintf(fd, "%s\n", dumpInfo.c_str());
return 0;
}
if (params.size() > 1 && params[0] == "-k") {
auto group = GetWatcherGroup(params[1]);
if (group == NULL) {
dprintf(fd, "Prefix %s not found in watcher list\n", params[1].c_str());
return 0;
}
DumpWatcherGroup(fd, group);
return 0;
}
// all output
std::lock_guard<std::mutex> lock(watcherMutex_);
// dump all watcher
for (auto it = groupMap_.begin(); it != groupMap_.end(); it++) {
if (watcherGroups_.find(it->second) != watcherGroups_.end()) {
DumpWatcherGroup(fd, watcherGroups_[it->second]);
}
}
return 0;
}
} // namespace init_param
} // namespace OHOS
......@@ -126,6 +126,7 @@ public:
{
return &watchers_;
}
ParamWatcher *GetNextWatcher(ParamWatcher *watcher);
private:
uint32_t groupId_;
std::string keyPrefix_ { };
......@@ -144,6 +145,7 @@ protected:
#endif
void OnStart() override;
void OnStop() override;
int Dump(int fd, const std::vector<std::u16string>& args) override;
#ifndef STARTUP_INIT_TEST
private:
#endif
......@@ -161,7 +163,7 @@ private:
int GetServerFd(bool retry);
int GetWatcherId(uint32_t &watcherId);
int GetGroupId(uint32_t &groupId);
void DumpWatcherGroup(int fd, const WatcherGroupPtr &group);
private:
std::atomic<uint32_t> watcherId_ { 0 };
std::atomic<uint32_t> groupId_ { 0 };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册