• 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 
16 #include "netlink/netlink_handler.h"
17 
18 #include "disk/disk_manager.h"
19 #include "netlink/netlink_data.h"
20 #include "storage_service_errno.h"
21 #include "storage_service_log.h"
22 
23 namespace OHOS {
24 namespace StorageDaemon {
NetlinkHandler(int32_t socket)25 NetlinkHandler::NetlinkHandler(int32_t socket) : NetlinkListener(socket) {}
26 
Start()27 int32_t NetlinkHandler::Start()
28 {
29     return this->StartListener();
30 }
31 
Stop()32 int32_t NetlinkHandler::Stop()
33 {
34     return this->StopListener();
35 }
36 
OnEvent(char * msg)37 void NetlinkHandler::OnEvent(char *msg)
38 {
39     auto nlData = std::make_unique<NetlinkData>();
40 
41     nlData->Decode(msg);
42     if (strcmp(nlData->GetSubsystem().c_str(), "block") == 0) {
43         DiskManager::Instance()->HandleDiskEvent(nlData.get());
44     }
45 }
46 } // StorageDaemon
47 } // OHOS
48