• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "netlink/netlink_handler.h"
16 
17 #include "netlink/netlink_data.h"
18 #include "storage_service_errno.h"
19 #include "storage_service_log.h"
20 #include "disk/disk_manager.h"
21 
22 namespace OHOS {
23 namespace StorageDaemon {
NetlinkHandler(int32_t socket)24 NetlinkHandler::NetlinkHandler(int32_t socket) : NetlinkListener(socket) {}
25 
Start()26 int32_t NetlinkHandler::Start()
27 {
28     return this->StartListener();
29 }
30 
Stop()31 int32_t NetlinkHandler::Stop()
32 {
33     return this->StopListener();
34 }
35 
OnEvent(char * msg)36 void NetlinkHandler::OnEvent(char *msg)
37 {
38     auto nlData = std::make_unique<NetlinkData>();
39 
40     nlData->Decode(msg);
41     if (strcmp(nlData->GetSubsystem().c_str(), "block") == 0) {
42         DiskManager::Instance()->HandleDiskEvent(nlData.get());
43     }
44 }
45 } // StorageDaemon
46 } // OHOS
47