libstorage-ng
Dasd.h
1 /*
2  * Copyright (c) [2014-2015] Novell, Inc.
3  * Copyright (c) [2016-2020] 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 
53  class Dasd : public Partitionable
54  {
55  public:
56 
63  static Dasd* create(Devicegraph* devicegraph, const std::string& name);
64 
68  static Dasd* create(Devicegraph* devicegraph, const std::string& name,
69  const Region& region);
70 
74  static Dasd* create(Devicegraph* devicegraph, const std::string& name,
75  unsigned long long size);
76 
77  static Dasd* load(Devicegraph* devicegraph, const xmlNode* node);
78 
82  static std::vector<Dasd*> get_all(Devicegraph* devicegraph);
83 
87  static std::vector<const Dasd*> get_all(const Devicegraph* devicegraph);
88 
92  std::string get_bus_id() const;
93 
102  void set_bus_id(std::string bus_id);
103 
109  bool is_rotational() const;
110 
116  DasdType get_type() const;
117 
126  void set_type(DasdType type);
127 
133  DasdFormat get_format() const;
134 
143  void set_format(DasdFormat format);
144 
151  static Dasd* find_by_name(Devicegraph* devicegraph, const std::string& name);
152 
156  static const Dasd* find_by_name(const Devicegraph* devicegraph, const std::string& name);
157 
158  public:
159 
160  class Impl;
161 
162  Impl& get_impl();
163  const Impl& get_impl() const;
164 
165  virtual Dasd* clone() const override;
166 
167  protected:
168 
169  Dasd(Impl* impl);
170 
171  };
172 
173 
179  bool is_dasd(const Device* device);
180 
187  Dasd* to_dasd(Device* device);
188 
192  const Dasd* to_dasd(const Device* device);
193 
194 }
195 
196 #endif
A physical DASD device.
Definition: Dasd.h:53
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:73
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.
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
The storage namespace.
Definition: Actiongraph.h:38
DasdFormat get_format() const
Get the DASD format.