libstorage-ng
Loading...
Searching...
No Matches
BtrfsSubvolume.h
1/*
2 * Copyright (c) [2017-2020] 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_BTRFS_SUBVOLUME_H
24#define STORAGE_BTRFS_SUBVOLUME_H
25
26
27#include "storage/Filesystems/Mountable.h"
28#include "storage/Devicegraph.h"
29
30
31namespace storage
32{
33
34 class Btrfs;
35 class BtrfsQgroup;
36
37
44 {
45 public:
46
53 static BtrfsSubvolume* create(Devicegraph* devicegraph, const std::string& path);
54
55 static BtrfsSubvolume* load(Devicegraph* devicegraph, const xmlNode* node);
56
61 long get_id() const;
62
66 bool is_top_level() const;
67
71 const std::string& get_path() const;
72
76 bool is_nocow() const;
77
83 void set_nocow(bool nocow);
84
89
96
101
105 const Btrfs* get_btrfs() const;
106
113
118
122 bool has_snapshots() const;
123
129 std::vector<BtrfsSubvolume*> get_snapshots();
130
134 std::vector<const BtrfsSubvolume*> get_snapshots() const;
135
149 bool has_origin() const;
150
159
164
168 bool has_btrfs_qgroup() const;
169
176
181
190
199 BtrfsSubvolume* create_btrfs_subvolume(const std::string& path);
200
206 static bool compare_by_id(const BtrfsSubvolume* lhs, const BtrfsSubvolume* rhs);
207
208 public:
209
210 class Impl;
211
212 Impl& get_impl();
213 const Impl& get_impl() const;
214
215 virtual BtrfsSubvolume* clone() const override;
216
217 protected:
218
219 BtrfsSubvolume(Impl* impl);
220
221 };
222
223
229 bool is_btrfs_subvolume(const Device* device);
230
238
243
244}
245
246#endif
Class to represent a qgroup of a btrfs filesystem.
Definition: BtrfsQgroup.h:45
Class to represent a btrfs subvolume in the devicegraph.
Definition: BtrfsSubvolume.h:44
const std::string & get_path() const
Get the path of the btrfs subvolume.
BtrfsSubvolume * get_top_level_btrfs_subvolume()
Return the top-level subvolume.
const BtrfsSubvolume * get_origin() const
Get the origin of the btrfs subvolume if it has one.
BtrfsSubvolume * get_origin()
Get the origin of the btrfs subvolume if it has one.
const BtrfsQgroup * get_btrfs_qgroup() const
Return the corresponding level 0 qgroup of the subvolume.
long get_id() const
Get the id of the btrfs subvolume.
BtrfsQgroup * create_btrfs_qgroup()
Create the corresponding level 0 qgroup for the subvolume.
bool has_origin() const
Check whether the btrfs subvolume has an origin.
BtrfsSubvolume * create_btrfs_subvolume(const std::string &path)
Create a btrfs subvolume for the btrfs subvolume.
void set_default_btrfs_subvolume()
Set the subvolume to be the default subvolume.
bool is_top_level() const
Check whether the subvolume is the top-level subvolume.
bool is_nocow() const
Get the copy-on-write (COW) flag of the btrfs subvolume.
std::vector< const BtrfsSubvolume * > get_snapshots() const
Get snapshots of the btrfs subvolume.
bool has_snapshots() const
Check whether the btrfs subvolume has snapshots.
bool is_default_btrfs_subvolume() const
Check whether the subvolume is the default subvolume.
static bool compare_by_id(const BtrfsSubvolume *lhs, const BtrfsSubvolume *rhs)
Compare (less than) two BtrfsSubvolumes by id.
void set_nocow(bool nocow)
Set the copy-on-write (COW) flag of the btrfs subvolume.
std::vector< BtrfsSubvolume * > get_snapshots()
Get snapshots of the btrfs subvolume.
BtrfsQgroup * get_btrfs_qgroup()
Return the corresponding level 0 qgroup of the subvolume.
const Btrfs * get_btrfs() const
Return the btrfs filesystem of the btrfs subvolume.
bool has_btrfs_qgroup() const
Return whether the subvolume as a corresponding level 0 qgroup.
const BtrfsSubvolume * get_top_level_btrfs_subvolume() const
Return the top-level subvolume.
static BtrfsSubvolume * create(Devicegraph *devicegraph, const std::string &path)
Create a device of type BtrfsSubvolume.
Btrfs * get_btrfs()
Return the btrfs filesystem of the btrfs subvolume.
Class to represent a btrfs filesystem https://en.wikipedia.org/wiki/Btrfs in the devicegraph.
Definition: Btrfs.h:80
An abstract base class for storage devices.
Definition: Device.h:82
The main container of the libstorage-ng.
Definition: Devicegraph.h:170
Definition: Mountable.h:112
The storage namespace.
Definition: Actiongraph.h:40
bool is_btrfs_subvolume(const Device *device)
Checks whether device points to a BtrfsSubvolume.
BtrfsSubvolume * to_btrfs_subvolume(Device *device)
Converts pointer to Device to pointer to BtrfsSubvolume.