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 
117 
126  void set_type(DasdType type);
127 
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
storage::Partitionable
Definition: Partitionable.h:40
storage::Region
A start/length pair with a block size.
Definition: Region.h:74
storage::Dasd::set_format
void set_format(DasdFormat format)
Set the DASD format.
storage
The storage namespace.
Definition: Actiongraph.h:39
storage::DasdType
DasdType
The DASD type.
Definition: Dasd.h:37
storage::Dasd::is_rotational
bool is_rotational() const
Return whether the DASD is of rotational or non-rotational type.
storage::DasdFormat
DasdFormat
The layout with which the ECKD DASD was formatted.
Definition: Dasd.h:45
storage::Dasd::set_type
void set_type(DasdType type)
Set the DASD type.
storage::Dasd::get_bus_id
std::string get_bus_id() const
Get the bus ID of the DASD.
storage::Dasd::get_all
static std::vector< Dasd * > get_all(Devicegraph *devicegraph)
Get all Dasds.
storage::to_dasd
Dasd * to_dasd(Device *device)
Converts pointer to Device to pointer to Dasd.
storage::Devicegraph
The main container of the libstorage-ng.
Definition: Devicegraph.h:170
storage::Dasd::get_format
DasdFormat get_format() const
Get the DASD format.
storage::is_dasd
bool is_dasd(const Device *device)
Checks whether device points to a Dasd.
storage::Dasd::set_bus_id
void set_bus_id(std::string bus_id)
Set the bus ID of the DASD.
storage::Dasd::create
static Dasd * create(Devicegraph *devicegraph, const std::string &name, const Region &region)
Create a device of type Dasd.
storage::Dasd::create
static Dasd * create(Devicegraph *devicegraph, const std::string &name, unsigned long long size)
Create a device of type Dasd.
storage::Dasd::find_by_name
static const Dasd * find_by_name(const Devicegraph *devicegraph, const std::string &name)
Find a Dasd by its name.
storage::Dasd::get_type
DasdType get_type() const
Get the DASD type.
storage::Dasd::find_by_name
static Dasd * find_by_name(Devicegraph *devicegraph, const std::string &name)
Find a Dasd by its name.
storage::Device
An abstract base class for storage devices.
Definition: Device.h:82
storage::Dasd::get_all
static std::vector< const Dasd * > get_all(const Devicegraph *devicegraph)
Get all Dasds.
storage::Dasd::create
static Dasd * create(Devicegraph *devicegraph, const std::string &name)
Create a device of type Dasd.
storage::Dasd
A physical DASD device.
Definition: Dasd.h:54