libstorage-ng
BlkDevice.h
1 /*
2  * Copyright (c) [2014-2015] Novell, Inc.
3  * Copyright (c) 2016 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_BLK_DEVICE_H
25 #define STORAGE_BLK_DEVICE_H
26 
27 
28 #include "storage/Devices/Device.h"
29 #include "storage/Filesystems/Filesystem.h"
30 
31 
32 namespace storage
33 {
34 
35  class Region;
36  class Encryption;
37 
38 
40  class BlkDevice : public Device
41  {
42  public:
43 
44  const std::string& get_name() const;
45  void set_name(const std::string& name);
46 
47  const Region& get_region() const;
48  void set_region(const Region& region);
49 
50  unsigned long long get_size() const;
51  void set_size(unsigned long long size);
52 
53  std::string get_size_string() const;
54 
55  const std::string& get_sysfs_name() const;
56  const std::string& get_sysfs_path() const;
57 
58  const std::vector<std::string>& get_udev_paths() const;
59  const std::vector<std::string>& get_udev_ids() const;
60 
65  const std::string& get_dm_table_name() const;
66 
67  void set_dm_table_name(const std::string& dm_table_name);
68 
69  ResizeInfo detect_resize_info() const override;
70 
71  static std::vector<BlkDevice*> get_all(Devicegraph* devicegraph);
72  static std::vector<const BlkDevice*> get_all(const Devicegraph* devicegraph);
73 
74  static BlkDevice* find_by_name(Devicegraph* devicegraph, const std::string& name);
75  static const BlkDevice* find_by_name(const Devicegraph* devicegraph, const std::string& name);
76 
77  Filesystem* create_filesystem(FsType fs_type);
78 
79  bool has_filesystem() const;
80 
81  Filesystem* get_filesystem();
82  const Filesystem* get_filesystem() const;
83 
87  Encryption* create_encryption(const std::string& dm_name);
88 
89  bool has_encryption() const;
90 
91  Encryption* get_encryption();
92  const Encryption* get_encryption() const;
93 
94  public:
95 
96  class Impl;
97 
98  Impl& get_impl();
99  const Impl& get_impl() const;
100 
101  protected:
102 
103  BlkDevice(Impl* impl);
104 
105  };
106 
107 
108  bool is_blk_device(const Device* device);
109 
110  BlkDevice* to_blk_device(Device* device);
111  const BlkDevice* to_blk_device(const Device* device);
112 
113 }
114 
115 #endif
Encryption * create_encryption(const std::string &dm_name)
TODO parameter for encryption type? do all encryptions need a dm_name?
A start/length pair with a block size.
Definition: Region.h:71
An encryption layer on a blk device.
Definition: Encryption.h:45
const std::string & get_dm_table_name() const
Return device-mapper table name (dm-table-name for short).
The master container of the libstorage.
Definition: Devicegraph.h:133
An abstract Block Device.
Definition: BlkDevice.h:40
An abstract base class of storage devices, and a vertex in the Devicegraph.
Definition: Device.h:73
Definition: Filesystem.h:58
The storage namespace.
Definition: Actiongraph.h:36