libstorage-ng
BtrfsSubvolume.h
1 /*
2  * Copyright (c) 2017 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 
31 namespace storage
32 {
33 
34  class Btrfs;
35 
36 
40  class BtrfsSubvolume : public Mountable
41  {
42  public:
43 
44  static BtrfsSubvolume* create(Devicegraph* devicegraph, const std::string& path);
45  static BtrfsSubvolume* load(Devicegraph* devicegraph, const xmlNode* node);
46 
47  long get_id() const;
48 
49  bool is_top_level() const;
50 
51  const std::string& get_path() const;
52 
53  bool is_nocow() const;
54  void set_nocow(bool nocow);
55 
56  bool is_default_btrfs_subvolume() const;
57  void set_default_btrfs_subvolume();
58 
59  Btrfs* get_btrfs();
60  const Btrfs* get_btrfs() const;
61 
62  BtrfsSubvolume* get_top_level_btrfs_subvolume();
63  const BtrfsSubvolume* get_top_level_btrfs_subvolume() const;
64 
65  BtrfsSubvolume* create_btrfs_subvolume(const std::string& path);
66 
70  static bool compare_by_id(const BtrfsSubvolume* lhs, const BtrfsSubvolume* rhs);
71 
72  public:
73 
74  class Impl;
75 
76  Impl& get_impl();
77  const Impl& get_impl() const;
78 
79  virtual BtrfsSubvolume* clone() const override;
80 
81  protected:
82 
83  BtrfsSubvolume(Impl* impl);
84 
85  };
86 
87 
88  bool is_btrfs_subvolume(const Device* device);
89 
97 
101  const BtrfsSubvolume* to_btrfs_subvolume(const Device* device);
102 
103 }
104 
105 #endif
Definition: Btrfs.h:46
BtrfsSubvolume * to_btrfs_subvolume(Device *device)
Converts pointer to Device to pointer to BtrfsSubvolume.
Class to represent a btrfs subvolume.
Definition: BtrfsSubvolume.h:40
The master container of the libstorage.
Definition: Devicegraph.h:153
Definition: Mountable.h:89
An abstract base class of storage devices, and a vertex in the Devicegraph.
Definition: Device.h:75
static bool compare_by_id(const BtrfsSubvolume *lhs, const BtrfsSubvolume *rhs)
Compare (less than) two BtrfsSubvolumes by id.
The storage namespace.
Definition: Actiongraph.h:37