• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 #pragma once
18 
19 #include <stdio.h>
20 
21 #include <memory>
22 #include <set>
23 #include <string>
24 
25 #include "epoll.h"
26 
27 namespace android {
28 namespace init {
29 
30 struct MountHandlerEntry {
31     MountHandlerEntry(const std::string& blk_device, const std::string& mount_point,
32                       const std::string& fs_type);
33 
34     bool operator<(const MountHandlerEntry& r) const;
35 
36     const std::string blk_device;
37     const std::string mount_point;
38     const std::string fs_type;
39 };
40 
41 class MountHandler {
42   public:
43     explicit MountHandler(Epoll* epoll);
44     MountHandler(const MountHandler&) = delete;
45     MountHandler(MountHandler&&) = delete;
46     MountHandler& operator=(const MountHandler&) = delete;
47     MountHandler& operator=(MountHandler&&) = delete;
48     ~MountHandler();
49 
50   private:
51     void MountHandlerFunction();
52 
53     Epoll* epoll_;
54     std::unique_ptr<FILE, decltype(&fclose)> fp_;
55     std::set<MountHandlerEntry> mounts_;
56 };
57 
58 }  // namespace init
59 }  // namespace android
60