diff --git a/.gitignore b/.gitignore index e69de29b..600d2d33 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +.vscode \ No newline at end of file diff --git a/services/storage_daemon/BUILD.gn b/services/storage_daemon/BUILD.gn index 6381b014..93dcba06 100644 --- a/services/storage_daemon/BUILD.gn +++ b/services/storage_daemon/BUILD.gn @@ -38,7 +38,7 @@ ohos_executable("storage_daemon") { deps = [ "//utils/native/base:utils", ] - + external_deps = [ "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/storage_daemon/include/disk/disk_manager.h b/services/storage_daemon/include/disk/disk_manager.h index 645dde2a..a01b20f3 100644 --- a/services/storage_daemon/include/disk/disk_manager.h +++ b/services/storage_daemon/include/disk/disk_manager.h @@ -16,7 +16,7 @@ #ifndef OHOS_STORAGE_DAEMON_DISK_MANAGER_H #define OHOS_STORAGE_DAEMON_DISK_MANAGER_H -#include "nocopyable.h" +#include "utils/nocopyable.h" namespace OHOS { namespace StorageDaemon { diff --git a/services/storage_daemon/include/ipc/istorage_daemon.h b/services/storage_daemon/include/ipc/istorage_daemon.h index ced918c4..2d043b2b 100644 --- a/services/storage_daemon/include/ipc/istorage_daemon.h +++ b/services/storage_daemon/include/ipc/istorage_daemon.h @@ -16,13 +16,11 @@ #ifndef OHOS_STORAGE_DAEMON_ISTORAGE_DAEMON_H #define OHOS_STORAGE_DAEMON_ISTORAGE_DAEMON_H -#include - #include "iremote_broker.h" +#include namespace OHOS { namespace StorageDaemon { -using namespace std; class IStorageDaemon : public IRemoteBroker { public: enum { @@ -34,17 +32,17 @@ public: FORMAT, ADD_USER, - DEL_USER, + REMOVE_USER, PREPARE_USER_DIRS, DESTROY_USER_DIRS, }; virtual int32_t Shutdown(); - virtual int32_t Mount(string volId, uint32_t flags); - virtual int32_t UMount(string volId); - virtual int32_t Check(string volId); - virtual int32_t Format(string voldId); + virtual int32_t Mount(std::string volId, uint32_t flags); + virtual int32_t UMount(std::string volId); + virtual int32_t Check(std::string volId); + virtual int32_t Format(std::string voldId); virtual int32_t AddUser(int32_t userId); virtual int32_t RemoveUser(int32_t userId); diff --git a/services/storage_daemon/include/ipc/storage_daemon.h b/services/storage_daemon/include/ipc/storage_daemon.h index b9e5332d..998f3755 100644 --- a/services/storage_daemon/include/ipc/storage_daemon.h +++ b/services/storage_daemon/include/ipc/storage_daemon.h @@ -17,7 +17,6 @@ #define OHOS_STORAGE_DAEMON_STORAGE_DAEMON_H #include "ipc/storage_daemon_stub.h" -#include "utils/errno.h" namespace OHOS { namespace StorageDaemon { @@ -25,10 +24,10 @@ class StorageDaemon : StorageDaemonStub { public: virtual int32_t Shutdown() override; - virtual int32_t Mount(string volId, uint32_t flags) override; - virtual int32_t UMount(string volId) override; - virtual int32_t Check(string volId) override; - virtual int32_t Format(string voldId) override; + virtual int32_t Mount(std::string volId, uint32_t flags) override; + virtual int32_t UMount(std::string volId) override; + virtual int32_t Check(std::string volId) override; + virtual int32_t Format(std::string voldId) override; virtual int32_t AddUser(int32_t userId) override; virtual int32_t RemoveUser(int32_t userId) override; diff --git a/services/storage_daemon/include/ipc/storage_daemon_proxy.h b/services/storage_daemon/include/ipc/storage_daemon_proxy.h index 5c54dd1a..d9ef3532 100644 --- a/services/storage_daemon/include/ipc/storage_daemon_proxy.h +++ b/services/storage_daemon/include/ipc/storage_daemon_proxy.h @@ -26,10 +26,10 @@ public: StorageDaemonProxy(const sptr &impl); virtual int32_t Shutdown() override; - virtual int32_t Mount(string volId, uint32_t flags) override; - virtual int32_t UMount(string volId) override; - virtual int32_t Check(string volId) override; - virtual int32_t Format(string voldId) override; + virtual int32_t Mount(std::string volId, uint32_t flags) override; + virtual int32_t UMount(std::string volId) override; + virtual int32_t Check(std::string volId) override; + virtual int32_t Format(std::string voldId) override; virtual int32_t AddUser(int32_t userId) override; virtual int32_t RemoveUser(int32_t userId) override; diff --git a/services/storage_daemon/include/netlink/netlink_manager.h b/services/storage_daemon/include/netlink/netlink_manager.h index 9d93c41b..ee181338 100644 --- a/services/storage_daemon/include/netlink/netlink_manager.h +++ b/services/storage_daemon/include/netlink/netlink_manager.h @@ -16,7 +16,7 @@ #ifndef OHOS_STORAGE_DAEMON_NETLINK_MANAGER_H #define OHOS_STORAGE_DAEMON_NETLINK_MANAGER_H -#include "nocopyable.h" +#include "utils/nocopyable.h" namespace OHOS { namespace StorageDaemon { diff --git a/services/storage_daemon/include/user/user_manager.h b/services/storage_daemon/include/user/user_manager.h index 53702eef..f23aacdf 100644 --- a/services/storage_daemon/include/user/user_manager.h +++ b/services/storage_daemon/include/user/user_manager.h @@ -19,14 +19,8 @@ #include #include "user/user_info.h" -#include "nocopyable.h" +#include "utils/nocopyable.h" -#define DISABLE_COPY_ASSIGN_MOVE(ClassName) \ - ClassName(const ClassName &) = delete; \ - ClassName(ClassName &&) = delete; \ - ClassName& operator=(const ClassName &) = delete; \ - ClassName& operator=(ClassName &&) = delete - namespace OHOS { namespace StorageDaemon { class UserManager final { diff --git a/services/storage_daemon/include/utils/nocopyable.h b/services/storage_daemon/include/utils/nocopyable.h new file mode 100644 index 00000000..4176b444 --- /dev/null +++ b/services/storage_daemon/include/utils/nocopyable.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef STORAGE_DAEMON_UTILS_NO_COPYABLE_H +#define STORAGE_DAEMON_UTILS_NO_COPYABLE_H + +namespace OHOS { +namespace StorageDaemon { +#define DISABLE_COPY_ASSIGN_MOVE(ClassName) \ + ClassName(const ClassName &) = delete; \ + ClassName(ClassName &&) = delete; \ + ClassName& operator=(const ClassName &) = delete; \ + ClassName& operator=(ClassName &&) = delete +} // STORAGE_DAEMON +} // OHOS +#endif // STORAGE_DAEMON_UTILS_NO_COPYABLE_H \ No newline at end of file diff --git a/services/storage_daemon/include/volume/volume_manager.h b/services/storage_daemon/include/volume/volume_manager.h index d0dfbcd2..289dc84b 100644 --- a/services/storage_daemon/include/volume/volume_manager.h +++ b/services/storage_daemon/include/volume/volume_manager.h @@ -16,7 +16,7 @@ #ifndef OHOS_STORAGE_DAEMON_VOLUME_MANAGER_H #define OHOS_STORAGE_DAEMON_VOLUME_MANAGER_H -#include "nocopyable.h" +#include "utils/nocopyable.h" namespace OHOS { namespace StorageDaemon { diff --git a/services/storage_daemon/ipc/src/storage_daemon.cpp b/services/storage_daemon/ipc/src/storage_daemon.cpp index c3c012f1..b7836674 100644 --- a/services/storage_daemon/ipc/src/storage_daemon.cpp +++ b/services/storage_daemon/ipc/src/storage_daemon.cpp @@ -15,6 +15,7 @@ #include "ipc/storage_daemon.h" #include "user/user_manager.h" +#include "utils/errno.h" namespace OHOS { namespace StorageDaemon { @@ -25,22 +26,22 @@ int32_t Shutdown() return E_OK; } -int32_t Mount(string volId) +int32_t Mount(std::string volId) { return E_OK; } -int32_t UMount(string volId) +int32_t UMount(std::string volId) { return E_OK; } -int32_t Check(string volId) +int32_t Check(std::string volId) { return E_OK; } -int32_t Format(string voldId) +int32_t Format(std::string voldId) { return E_OK; } diff --git a/services/storage_daemon/ipc/src/storage_daemon_proxy.cpp b/services/storage_daemon/ipc/src/storage_daemon_proxy.cpp index a52002df..007b961b 100644 --- a/services/storage_daemon/ipc/src/storage_daemon_proxy.cpp +++ b/services/storage_daemon/ipc/src/storage_daemon_proxy.cpp @@ -32,22 +32,22 @@ int32_t StorageDaemonProxy::Shutdown() return Remote()->SendRequest(SHUTDOWN, data, reply, option); } -int32_t StorageDaemonProxy::Mount(string volId, uint32_t flags) +int32_t StorageDaemonProxy::Mount(std::string volId, uint32_t flags) { return E_OK; } -int32_t StorageDaemonProxy::UMount(string volId) +int32_t StorageDaemonProxy::UMount(std::string volId) { return E_OK; } -int32_t StorageDaemonProxy::Check(string volId) +int32_t StorageDaemonProxy::Check(std::string volId) { return E_OK; } -int32_t StorageDaemonProxy::Format(string voldId) +int32_t StorageDaemonProxy::Format(std::string voldId) { return E_OK; } @@ -81,7 +81,7 @@ int32_t StorageDaemonProxy::RemoveUser(int32_t userId) if (!data.WriteInt32(userId)) { return E_IPC_ERROR; } - int err = Remote()->SendRequest(DEL_USER, data, reply, option); + int err = Remote()->SendRequest(REMOVE_USER, data, reply, option); if (err != E_OK) { return E_IPC_ERROR; } diff --git a/services/storage_daemon/ipc/src/storage_daemon_stub.cpp b/services/storage_daemon/ipc/src/storage_daemon_stub.cpp index 357ec286..1cfa62ec 100644 --- a/services/storage_daemon/ipc/src/storage_daemon_stub.cpp +++ b/services/storage_daemon/ipc/src/storage_daemon_stub.cpp @@ -32,7 +32,7 @@ int32_t StorageDaemonStub::OnRemoteRequest(uint32_t code, MessageParcel &data, case SHUTDOWN: err = HandleShutdown(); break; case ADD_USER: err = HandleAddUser(data, reply); break; - case DEL_USER: err = HandleRemoveUser(data, reply); break; + case REMOVE_USER: err = HandleRemoveUser(data, reply); break; case PREPARE_USER_DIRS: err = HandlePrepareUserDirs(data, reply); break; case DESTROY_USER_DIRS: err = HandleDestroyUserDirs(data, reply); break; default: {