libstorage-ng
Dasd.h
1 /*
2  * Copyright (c) [2014-2015] Novell, Inc.
3  * Copyright (c) [2016-2021] 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_DASD_H
25 #define STORAGE_DASD_H
26 
27 
28 #include "storage/Devices/Partitionable.h"
29 
30 
31 namespace storage
32 {
33 
37  enum class DasdType {
38  UNKNOWN, ECKD, FBA
39  };
40 
41 
45  enum class DasdFormat {
46  NONE, LDL, CDL
47  };
48 
49 
55  std::string get_dasd_type_name(DasdType dasd_type);
56 
57 
63  std::string get_dasd_format_name(DasdFormat dasd_format);
64 
65 
69  class Dasd : public Partitionable
70  {
71  public:
72 
79  static Dasd* create(Devicegraph* devicegraph, const std::string& name);
80 
84  static Dasd* create(Devicegraph* devicegraph, const std::string& name,
85  const Region& region);
86 
90  static Dasd* create(Devicegraph* devicegraph, const std::string& name,
91  unsigned long long size);
92 
93  static Dasd* load(Devicegraph* devicegraph, const xmlNode* node);
94 
98  static std::vector<Dasd*> get_all(Devicegraph* devicegraph);
99 
103  static std::vector<const Dasd*> get_all(const Devicegraph* devicegraph);
104 
108  std::string get_bus_id() const;
109 
118  void set_bus_id(std::string bus_id);
119 
125  bool is_rotational() const;
126 
132  DasdType get_type() const;
133 
142  void set_type(DasdType type);
143 
149  DasdFormat get_format() const;
150 
159  void set_format(DasdFormat format);
160 
167  static Dasd* find_by_name(Devicegraph* devicegraph, const std::string& name);
168 
172  static const Dasd* find_by_name(const Devicegraph* devicegraph, const std::string& name);
173 
174  public:
175 
176  class Impl;
177 
178  Impl& get_impl();
179  const Impl& get_impl() const;
180 
181  virtual Dasd* clone() const override;
182 
183  Dasd(Impl* impl);
184 
185  };
186 
187 
193  bool is_dasd(const Device* device);
194 
201  Dasd* to_dasd(Device* device);
202 
206  const Dasd* to_dasd(const Device* device);
207 
208 }
209 
210 #endif
A physical DASD device.
Definition: Dasd.h:69
void set_bus_id(std::string bus_id)
Set the bus ID of the DASD.
DasdType
The DASD type.
Definition: Dasd.h:37
static Dasd * find_by_name(Devicegraph *devicegraph, const std::string &name)
Find a Dasd by its name.
std::string get_bus_id() const
Get the bus ID of the DASD.
A start/length pair with a block size.
Definition: Region.h:84
void set_type(DasdType type)
Set the DASD type.
The main container of the libstorage-ng.
Definition: Devicegraph.h:169
Dasd * to_dasd(Device *device)
Converts pointer to Device to pointer to Dasd.
std::string get_dasd_type_name(DasdType dasd_type)
Convert the DASD type dasd_type to a string.
DasdType get_type() const
Get the DASD type.
static Dasd * create(Devicegraph *devicegraph, const std::string &name)
Create a device of type Dasd.
DasdFormat
The layout with which the ECKD DASD was formatted.
Definition: Dasd.h:45
void set_format(DasdFormat format)
Set the DASD format.
bool is_dasd(const Device *device)
Checks whether device points to a Dasd.
bool is_rotational() const
Return whether the DASD is of rotational or non-rotational type.
An abstract base class for storage devices.
Definition: Device.h:81
static std::vector< Dasd * > get_all(Devicegraph *devicegraph)
Get all Dasds.
Definition: Partitionable.h:39
std::string get_dasd_format_name(DasdFormat dasd_format)
Convert the DASD format dasd_format to a string.
The storage namespace.
Definition: Actiongraph.h:39
DasdFormat get_format() const
Get the DASD format.