libstorage-ng
MountPoint.h
1 /*
2  * Copyright (c) [2017-2021] SUSE LLC
3  *
4  * All Rights Reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of version 2 of the GNU General Public License as published
8  * by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, contact Novell, Inc.
17  *
18  * To contact Novell about this file by physical or electronic mail, you may
19  * find current contact information at www.novell.com.
20  */
21 
22 
23 #ifndef STORAGE_MOUNT_POINT_H
24 #define STORAGE_MOUNT_POINT_H
25 
26 
27 #include "storage/Devices/Device.h"
28 #include "storage/Filesystems/Mountable.h"
29 
30 
31 namespace storage
32 {
33 
34  class Devicegraph;
35 
36 
38  {
39  public:
40 
41  InvalidMountPointPath(const std::string& path);
42  };
43 
44 
48  class MountPoint : public Device
49  {
50  public:
51 
55  static MountPoint* create(Devicegraph* devicegraph, const std::string& path);
56 
57  static MountPoint* load(Devicegraph* devicegraph, const xmlNode* node);
58 
62  static std::vector<MountPoint*> get_all(Devicegraph* devicegraph);
63 
67  static std::vector<const MountPoint*> get_all(const Devicegraph* devicegraph);
68 
69  const std::string& get_path() const;
70 
74  void set_path(const std::string& path);
75 
84  bool is_rootprefixed() const;
85 
91  void set_rootprefixed(bool rootprefixed);
92 
96  static std::string normalize_path(const std::string& path);
97 
101  MountByType get_mount_by() const;
102 
106  void set_mount_by(MountByType mount_by);
107 
112  void set_default_mount_by();
113 
121  std::vector<MountByType> possible_mount_bys() const;
122 
126  const std::vector<std::string>& get_mount_options() const;
127 
132  void set_mount_options(const std::vector<std::string>& mount_options);
133 
138  std::vector<std::string> default_mount_options() const;
139 
146 
151  FsType get_mount_type() const;
152 
159  void set_mount_type(FsType mount_type);
160 
166  int get_freq() const;
167 
173  void set_freq(int freq);
174 
180  int get_passno() const;
181 
186  void set_passno(int passno);
187 
191  bool is_active() const;
192 
196  void set_active(bool active);
197 
202  bool is_in_etc_fstab() const;
203 
207  void set_in_etc_fstab(bool in_etc_fstab);
208 
213  bool has_mountable() const;
214 
221 
225  const Mountable* get_mountable() const;
226 
233 
237  const Filesystem* get_filesystem() const;
238 
242  static std::vector<const MountPoint*> find_by_path(const Devicegraph* devicegraph,
243  const std::string& path);
244 
254  void immediate_activate();
255 
265  void immediate_deactivate();
266 
267  public:
268 
269  class Impl;
270 
271  Impl& get_impl();
272  const Impl& get_impl() const;
273 
274  virtual MountPoint* clone() const override;
275 
276  protected:
277 
278  MountPoint(Impl* impl);
279 
280  };
281 
282 
288  bool is_mount_point(const Device* device);
289 
296  MountPoint* to_mount_point(Device* device);
297 
301  const MountPoint* to_mount_point(const Device* device);
302 
303 }
304 
305 #endif
void immediate_deactivate()
Immediately deactivate (unmount) the mount point object.
int get_passno() const
Get the passno field from fstab(5).
static std::vector< const MountPoint * > find_by_path(const Devicegraph *devicegraph, const std::string &path)
Find all MountPoints with path.
void set_passno(int passno)
bool is_rootprefixed() const
Return whether the path of the mount point will be prefixed with the rootprefix during mount operatio...
MountByType get_mount_by() const
Get the mount-by method.
void immediate_activate()
Immediately activate (mount) the mount point.
int get_freq() const
Get the freq field from fstab(5).
void set_default_mount_options()
Set the mount options to the default mount options.
static std::string normalize_path(const std::string &path)
Return normalized form of path.
Definition: MountPoint.h:37
std::vector< std::string > default_mount_options() const
Default mount options.
bool is_active() const
Return whether the mount point is active (mounted).
The main container of the libstorage-ng.
Definition: Devicegraph.h:169
Definition: Mountable.h:111
Class to represent a mount point.
Definition: MountPoint.h:48
std::vector< MountByType > possible_mount_bys() const
Returns the possible mount-by methods for the mount point.
static MountPoint * create(Devicegraph *devicegraph, const std::string &path)
An abstract base class for storage devices.
Definition: Device.h:81
Filesystem * get_filesystem()
Return the filesystem of mountable of the mount point.
void set_mount_by(MountByType mount_by)
Set the mount-by method.
bool is_mount_point(const Device *device)
Checks whether device points to a MountPoint.
void set_rootprefixed(bool rootprefixed)
Sets whether the path is rootprefixed.
MountPoint * to_mount_point(Device *device)
Converts pointer to Device to pointer to Mountpoint.
bool is_in_etc_fstab() const
Query whether the mount point is present (probed devicegraph) or will be present (staging devicegraph...
void set_default_mount_by()
Set the mount-by method to the global default, see Storage::get_default_mount_by().
Definition: Filesystem.h:40
bool has_mountable() const
Checks whether the mount point has a mountable.
void set_path(const std::string &path)
Base class for storage exceptions.
Definition: Exception.h:113
void set_active(bool active)
Sets whether the mount point is active (mounted).
static std::vector< MountPoint * > get_all(Devicegraph *devicegraph)
Get all MountPoints.
void set_mount_type(FsType mount_type)
Set the filesystem type to be used to mount the device.
The storage namespace.
Definition: Actiongraph.h:38
void set_mount_options(const std::vector< std::string > &mount_options)
Set the mount options.
const std::vector< std::string > & get_mount_options() const
Get the mount options.
void set_freq(int freq)
Set the freq field.
void set_in_etc_fstab(bool in_etc_fstab)
Set whether the mount point will be present in /etc/fstab.
FsType get_mount_type() const
Get the filesystem type used to mount the device, as specified in fstab(5) and/or in the mount(8) com...
MountByType
The key by which the mount program identifies a mountable.
Definition: Mountable.h:60
Mountable * get_mountable()
Return the mountable of the mount point.