NetlinkHandler.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (C) 2008 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <errno.h>
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #include <android-base/logging.h>
  21. #include <sysutils/NetlinkEvent.h>
  22. #include "NetlinkHandler.h"
  23. #include "VolumeManager.h"
  24. NetlinkHandler::NetlinkHandler(int listenerSocket) : NetlinkListener(listenerSocket) {}
  25. NetlinkHandler::~NetlinkHandler() {}
  26. int NetlinkHandler::start() {
  27. return this->startListener();
  28. }
  29. int NetlinkHandler::stop() {
  30. return this->stopListener();
  31. }
  32. void NetlinkHandler::onEvent(NetlinkEvent* evt) {
  33. VolumeManager* vm = VolumeManager::Instance();
  34. const char* subsys = evt->getSubsystem();
  35. if (!subsys) {
  36. LOG(WARNING) << "No subsystem found in netlink event";
  37. return;
  38. }
  39. if (std::string(subsys) == "block") {
  40. vm->handleBlockEvent(evt);
  41. }
  42. }