mount_handler.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (C) 2019 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. #pragma once
  17. #include <stdio.h>
  18. #include <memory>
  19. #include <set>
  20. #include <string>
  21. #include "epoll.h"
  22. namespace android {
  23. namespace init {
  24. struct MountHandlerEntry {
  25. MountHandlerEntry(const std::string& blk_device, const std::string& mount_point,
  26. const std::string& fs_type);
  27. bool operator<(const MountHandlerEntry& r) const;
  28. const std::string blk_device;
  29. const std::string mount_point;
  30. const std::string fs_type;
  31. };
  32. class MountHandler {
  33. public:
  34. explicit MountHandler(Epoll* epoll);
  35. MountHandler(const MountHandler&) = delete;
  36. MountHandler(MountHandler&&) = delete;
  37. MountHandler& operator=(const MountHandler&) = delete;
  38. MountHandler& operator=(MountHandler&&) = delete;
  39. ~MountHandler();
  40. private:
  41. void MountHandlerFunction();
  42. Epoll* epoll_;
  43. std::unique_ptr<FILE, decltype(&fclose)> fp_;
  44. std::set<MountHandlerEntry> mounts_;
  45. };
  46. } // namespace init
  47. } // namespace android