libstorage-ng
Loading...
Searching...
No Matches
Mountable.h
1/*
2 * Copyright (c) [2014-2015] Novell, Inc.
3 * Copyright (c) [2016-2022] 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
34namespace 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, BITLOCKER, VBOXSF
45 };
46
47
53 std::string get_fs_type_name(FsType fs_type);
54
55
60 enum class MountByType {
61
66 DEVICE,
67
71 UUID,
72
76 LABEL,
77
81 ID,
82
86 PATH,
87
92
97
98 };
99
100
106 std::string get_mount_by_name(MountByType mount_by_type);
107
108
109 // abstract class
110
111 class Mountable : public Device
112 {
113 public:
114
118 static std::vector<Mountable*> get_all(Devicegraph* devicegraph);
119
123 static std::vector<const Mountable*> get_all(const Devicegraph* devicegraph);
124
134 bool supports_mount() const;
135
140 static bool is_valid_path(FsType fs_type, const std::string& path);
141
147 MountPoint* create_mount_point(const std::string& path);
148
152 bool has_mount_point() const;
153
158
163
170
174 bool has_filesystem() const;
175
181
186
187 MountByType get_mount_by() const ST_DEPRECATED;
188 void set_mount_by(MountByType mount_by) ST_DEPRECATED;
189
190 const std::vector<std::string>& get_mount_opts() const ST_DEPRECATED;
191 void set_mount_opts(const std::vector<std::string>& mount_opts) ST_DEPRECATED;
192
193 const std::vector<std::string>& get_fstab_options() const ST_DEPRECATED;
194 void set_fstab_options(const std::vector<std::string>& mount_opts) ST_DEPRECATED;
195
196 public:
197
198 class Impl;
199
200 Impl& get_impl();
201 const Impl& get_impl() const;
202
203 protected:
204
205 Mountable(Impl* impl);
206
207 };
208
209
215 bool is_mountable(const Device* device);
216
224
228 const Mountable* to_mountable(const Device* device);
229
230}
231
232#endif
An abstract base class for storage devices.
Definition: Device.h:82
The main container of the libstorage-ng.
Definition: Devicegraph.h:170
Definition: Filesystem.h:41
Class to represent a mount point.
Definition: MountPoint.h:49
Definition: Mountable.h:112
Filesystem * get_filesystem()
Return the filesystem of the mountable.
static std::vector< const Mountable * > get_all(const Devicegraph *devicegraph)
Get all Mountables.
MountPoint * create_mount_point(const std::string &path)
Create a new mount point for the mountable with path.
static bool is_valid_path(FsType fs_type, const std::string &path)
Checks whether the path is valid.
static std::vector< Mountable * > get_all(Devicegraph *devicegraph)
Get all Mountables.
bool supports_mount() const
Checks whether the library supports mounting the mountable.
const MountPoint * get_mount_point() const
Returns the mount point of the mountable.
const Filesystem * get_filesystem() const
Return the filesystem of the mountable.
MountPoint * get_mount_point()
Returns the mount point of the mountable.
bool has_filesystem() const
Checks whether the mountable has a filesystem.
bool has_mount_point() const
Checks whether the mountable has a mount point.
void remove_mount_point()
Removes the mount point from the mountable.
The storage namespace.
Definition: Actiongraph.h:40
Mountable * to_mountable(Device *device)
Converts pointer to Device to pointer to Mountable.
std::string get_mount_by_name(MountByType mount_by_type)
Convert the MountByType mount_by_type to a string.
MountByType
The key by which the mount program identifies a mountable.
Definition: Mountable.h:60
@ PARTLABEL
Partition label, only for partitions on GPT.
@ UUID
Filesystem UUID.
@ PATH
One of the links in /dev/disk/by-path.
@ PARTUUID
Partition UUID, only for partitions on GPT.
@ LABEL
Filesystem label.
@ ID
One of the links in /dev/disk/by-id.
@ DEVICE
The kernel device name or a link in /dev (but not in /dev/disk).
std::string get_fs_type_name(FsType fs_type)
Convert the FsType fs_type to a string.
bool is_mountable(const Device *device)
Checks whether device points to a Mountable.