libstorage-ng
Mountable.h
1 /*
2  * Copyright (c) [2014-2015] Novell, Inc.
3  * Copyright (c) [2016-2018] SUSE LLC
4  *
5  * All Rights Reserved.
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of version 2 of the GNU General Public License as published
9  * by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, contact Novell, Inc.
18  *
19  * To contact Novell about this file by physical or electronic mail, you may
20  * find current contact information at www.novell.com.
21  */
22 
23 
24 #ifndef STORAGE_MOUNTABLE_H
25 #define STORAGE_MOUNTABLE_H
26 
27 
28 #include <vector>
29 
30 #include "storage/Devices/Device.h"
31 #include "storage/Utils/Swig.h"
32 
33 
34 namespace storage
35 {
36 
37  class MountPoint;
38  class Filesystem;
39 
40 
41  enum class FsType {
42  UNKNOWN, AUTO, REISERFS, EXT2, EXT3, EXT4, BTRFS, VFAT, XFS, JFS, HFS, NTFS,
43  SWAP, HFSPLUS, NFS, NFS4, TMPFS, ISO9660, UDF, NILFS2, MINIX, NTFS3G, F2FS,
44  EXFAT
45  };
46 
47 
48  std::string get_fs_type_name(FsType fs_type);
49 
50 
55  enum class MountByType {
56 
61  DEVICE,
62 
66  UUID,
67 
71  LABEL,
72 
76  ID,
77 
81  PATH
82  };
83 
84 
85  std::string get_mount_by_name(MountByType mount_by_type);
86 
87 
88  // abstract class
89 
90  class Mountable : public Device
91  {
92  public:
93 
94  static std::vector<Mountable*> get_all(Devicegraph* devicegraph);
95  static std::vector<const Mountable*> get_all(const Devicegraph* devicegraph);
96 
102  MountPoint* create_mount_point(const std::string& path);
103 
107  bool has_mount_point() const;
108 
113 
117  const MountPoint* get_mount_point() const;
118 
124  void remove_mount_point();
125 
129  bool has_filesystem() const;
130 
136 
140  const Filesystem* get_filesystem() const;
141 
142  MountByType get_mount_by() const ST_DEPRECATED;
143  void set_mount_by(MountByType mount_by) ST_DEPRECATED;
144 
145  const std::vector<std::string>& get_mount_opts() const ST_DEPRECATED;
146  void set_mount_opts(const std::vector<std::string>& mount_opts) ST_DEPRECATED;
147 
148  const std::vector<std::string>& get_fstab_options() const ST_DEPRECATED;
149  void set_fstab_options(const std::vector<std::string>& mount_opts) ST_DEPRECATED;
150 
151  public:
152 
153  class Impl;
154 
155  Impl& get_impl();
156  const Impl& get_impl() const;
157 
158  protected:
159 
160  Mountable(Impl* impl);
161 
162  };
163 
164 
165  bool is_mountable(const Device* device);
166 
173  Mountable* to_mountable(Device* device);
174 
178  const Mountable* to_mountable(const Device* device);
179 
180 }
181 
182 #endif
One of the links in /dev/disk/by-id.
bool has_filesystem() const
Checks whether the mountable has a filesystem.
Filesystem * get_filesystem()
Return the filesystem of the mountable.
MountPoint * create_mount_point(const std::string &path)
Create a new mount point for the mountable with path.
bool has_mount_point() const
Checks whether the mountable has a mount point.
The master container of the libstorage.
Definition: Devicegraph.h:153
Definition: Mountable.h:90
Class to represent a mount point.
Definition: MountPoint.h:48
MountPoint * get_mount_point()
Returns the mount point of the mountable.
One of the links in /dev/disk/by-path.
An abstract base class of storage devices, and a vertex in the Devicegraph.
Definition: Device.h:75
Definition: Filesystem.h:40
The storage namespace.
Definition: Actiongraph.h:37
The kernel device name or a link in /dev (but not in /dev/disk).
Mountable * to_mountable(Device *device)
Converts pointer to Device to pointer to Mountable.
void remove_mount_point()
Removes the mount point from the mountable.
MountByType
The key by which the mount program identifies a mountable.
Definition: Mountable.h:55