1/*
2 SPDX-FileCopyrightText: 2006-2007 Kevin Ottens <ervin@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#ifndef SOLID_BLOCK_H
8#define SOLID_BLOCK_H
9
10#include <solid/solid_export.h>
11
12#include <solid/deviceinterface.h>
13
14namespace Solid
15{
16class BlockPrivate;
17class Device;
18
19/*!
20 * \class Solid::Block
21 * \inheaderfile Solid/Block
22 * \inmodule Solid
23 *
24 * \brief This device interface is available on block devices.
25 *
26 * A block device is an addressable device such as drive or partition.
27 * It is possible to interact with such a device using a special file
28 * in the system.
29 */
30class SOLID_EXPORT Block : public DeviceInterface
31{
32 Q_OBJECT
33
34 /*!
35 * \property Solid::Block::major
36 */
37 Q_PROPERTY(int major READ deviceMajor)
38
39 /*!
40 * \property Solid::Block::minor
41 */
42 Q_PROPERTY(int minor READ deviceMinor)
43
44 /*!
45 * \property Solid::Block::device
46 */
47 Q_PROPERTY(QString device READ device)
48
49 /*!
50 * \property Solid::Block::isSystem
51 */
52 Q_PROPERTY(bool isSystem READ isSystem)
53
54 Q_DECLARE_PRIVATE(Block)
55 friend class Device;
56
57private:
58 /*!
59 * \internal
60 *
61 * Creates a new Block object.
62 *
63 * You generally won't need this. It's created when necessary using
64 * Device::as().
65 *
66 * \a backendObject the device interface object provided by the backend
67 */
68 SOLID_NO_EXPORT explicit Block(QObject *backendObject);
69
70public:
71 ~Block() override;
72
73 /*!
74 * Get the Solid::DeviceInterface::Type of the Block device interface.
75 *
76 * Returns the Block device interface type
77 * \sa Solid::Ifaces::Enums::DeviceInterface::Type
78 */
79 static Type deviceInterfaceType()
80 {
81 return DeviceInterface::Block;
82 }
83
84 /*!
85 * Retrieves the major number of the node file to interact with
86 * the device.
87 *
88 * Returns the device major number
89 */
90 int deviceMajor() const;
91
92 /*!
93 * Retrieves the minor number of the node file to interact with
94 * the device.
95 *
96 * Returns the device minor number
97 */
98 int deviceMinor() const;
99
100 /*!
101 * Retrieves the absolute path of the special file to interact
102 * with the device.
103 *
104 * Returns the absolute path of the special file to interact with
105 * the device
106 */
107 QString device() const;
108
109 /*!
110 * Whether this block is considered a system block,
111 * that it requires additional permissions to access (mount/umount)
112 *
113 * It defaults to false, if the backend does not support it.
114 *
115 * \since 6.15
116 */
117 bool isSystem() const;
118};
119}
120
121#endif
122

source code of solid/src/solid/devices/frontend/block.h