10#include <private/qcore_unix_p.h>
11#include <private/qtools_p.h>
16#include <sys/statfs.h>
20# define FSLABEL_MAX 256
22#ifndef FS_IOC_GETFSLABEL
23# define FS_IOC_GETFSLABEL _IOR(0x94, 49, char[FSLABEL_MAX])
28# define ST_RDONLY 0x0001
43 return std::move(
str);
47 auto ptr =
reinterpret_cast<char16_t *
>(decoded.
begin());
55 int c = fromHex(
ptr[
in + 2]) << 4;
58 c = QChar::ReplacementCharacter;
91 if (major(deviceId) != 0)
99 if (QT_STAT(
device, &st) < 0)
101 if (!S_ISBLK(st.st_mode))
108 static const char pathDiskByLabel[] =
"/dev/disk/by-label";
109 static constexpr auto LabelFileFilter =
165void QStorageInfoPrivate::retrieveVolumeInfo()
167 struct statfs64 statfs_buf;
174 bytesTotal = statfs_buf.f_blocks * statfs_buf.f_frsize;
175 bytesFree = statfs_buf.f_bfree * statfs_buf.f_frsize;
176 bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_frsize;
178 readOnly = (statfs_buf.f_flags &
ST_RDONLY) != 0;
194void QStorageInfoPrivate::doStat()
196 retrieveVolumeInfo();
201 if (rootPath.isEmpty())
225 for (
auto it = infos.rbegin();
it != infos.rend(); ++
it) {
228 if (rootPathDevId ==
it->stDev) {
240 auto stDev = best->stDev;
241 setFromMountInfo(std::move(*best));
246QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes()
250 return QList{root()};
253 auto labelForDevice = [&labelMap](
const QStorageInfoPrivate &
d,
quint64 devid) {
254 if (
d.fileSystemType ==
"tmpfs")
266 for (
auto &[deviceLabel, deviceId] :
std::as_const(*labelMap)) {
267 if (devid == deviceId)
273 QList<QStorageInfo> volumes;
275 const auto infoStDev =
info.stDev;
276 QStorageInfoPrivate
d(std::move(
info));
277 d.retrieveVolumeInfo();
278 if (
d.bytesTotal <= 0 &&
d.rootPath != u
'/')
282 d.name = labelForDevice(
d, infoStDev);
283 volumes.emplace_back(
QStorageInfo(*
new QStorageInfoPrivate(std::move(
d))));
IOBluetoothDevice * device
The QDirListing class provides an STL-style iterator for directory entries.
void close() override
Calls QFileDevice::flush() and closes the file.
QString canonicalFilePath() const
Returns the file system entry's canonical path, including the entry's name, that is,...
QFILE_MAYBE_NODISCARD bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
static QByteArray encodeName(const QString &fileName)
Converts fileName to an 8-bit encoding that you can use in native APIs.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
\macro QT_RESTRICTED_CAST_FROM_ASCII
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first character in the string.
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
qsizetype size() const noexcept
Returns the number of characters in this string.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void resize(qsizetype size)
Sets the size of the string to size characters.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
constexpr T * to_address(T *p) noexcept
static int qt_safe_open(const char *pathname, int flags, mode_t mode=0777)
#define QT_EINTR_LOOP(var, cmd)
static ControlElement< T > * ptr(QWidget *widget)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLsizei const GLchar * label
[43]
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLsizei const GLchar *const * path
static std::optional< QString > retrieveLabelViaIoctl(const QString &path)
static QString retrieveLabel(const QStorageInfoPrivate &d, quint64 deviceId)
static quint64 retrieveDeviceId(const QByteArray &device, quint64 deviceId=0)
#define FS_IOC_GETFSLABEL
static QDirListing devicesByLabel()
static QString decodeFsEncString(QString &&str)
static std::vector< MountInfo > parseMountInfo(FilterMountInfo filter=FilterMountInfo::All)
static auto retrieveLabels()
static dev_t deviceIdForPath(const QString &device)
static std::vector< MountInfo > doParseMountInfo(const QByteArray &mountinfo, FilterMountInfo filter=FilterMountInfo::All)
QStorageInfoPrivate::MountInfo MountInfo
QT_BEGIN_NAMESPACE static Q_LOGGING_CATEGORY(lcStorageInfo, "qt.core.qstorageinfo", QtWarningMsg) class QStorageInfoPrivate bool isParentOf(const String &parent, const QString &dirName)
unsigned long long quint64
QTextStream out(stdout)
[7]