Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
System
KPMCore
Commits
a5bdd5a4
Commit
a5bdd5a4
authored
Dec 24, 2021
by
Andrius Štikonas
Browse files
Switch to ntfsinfo to read NTFS usage.
BUG: 447248
parent
31921c59
Pipeline
#113693
passed with stage
in 1 minute and 3 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/fs/ntfs.cpp
View file @
a5bdd5a4
...
...
@@ -47,7 +47,8 @@ ntfs::ntfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QStr
void
ntfs
::
init
()
{
m_Shrink
=
m_Grow
=
m_Check
=
m_GetUsed
=
findExternal
(
QStringLiteral
(
"ntfsresize"
))
?
cmdSupportFileSystem
:
cmdSupportNone
;
m_Shrink
=
m_Grow
=
m_Check
=
findExternal
(
QStringLiteral
(
"ntfsresize"
))
?
cmdSupportFileSystem
:
cmdSupportNone
;
m_GetUsed
=
findExternal
(
QStringLiteral
(
"ntfsinfo"
))
?
cmdSupportFileSystem
:
cmdSupportNone
;
m_GetLabel
=
cmdSupportCore
;
m_SetLabel
=
findExternal
(
QStringLiteral
(
"ntfslabel"
))
?
cmdSupportFileSystem
:
cmdSupportNone
;
m_Create
=
findExternal
(
QStringLiteral
(
"mkfs.ntfs"
))
?
cmdSupportFileSystem
:
cmdSupportNone
;
...
...
@@ -97,18 +98,27 @@ int ntfs::maxLabelLength() const
qint64
ntfs
::
readUsedCapacity
(
const
QString
&
deviceNode
)
const
{
ExternalCommand
cmd
(
QStringLiteral
(
"ntfs
resize
"
),
{
QStringLiteral
(
"--
info
"
),
QStringLiteral
(
"--force"
),
QStringLiteral
(
"--no-progress-bar"
),
deviceNode
});
ExternalCommand
cmd
(
QStringLiteral
(
"ntfs
info
"
),
{
QStringLiteral
(
"--
mft
"
),
QStringLiteral
(
"--force"
),
deviceNode
});
if
(
cmd
.
run
(
-
1
)
&&
cmd
.
exitCode
()
==
0
)
{
qint64
usedBytes
=
-
1
;
QRegularExpression
re
(
QStringLiteral
(
"resize at (
\\
d+) bytes"
));
QRegularExpressionMatch
reUsedBytes
=
re
.
match
(
cmd
.
output
());
QRegularExpression
re
(
QStringLiteral
(
"Cluster Size: (
\\
d+)"
));
QRegularExpressionMatch
reClusterSize
=
re
.
match
(
cmd
.
output
());
qint64
clusterSize
=
reClusterSize
.
hasMatch
()
?
reClusterSize
.
captured
(
1
).
toLongLong
()
:
-
1
;
QRegularExpression
re2
(
QStringLiteral
(
"Free Clusters: (
\\
d+)"
));
QRegularExpressionMatch
reFreeClusters
=
re2
.
match
(
cmd
.
output
());
qint64
freeClusters
=
reFreeClusters
.
hasMatch
()
?
reFreeClusters
.
captured
(
1
).
toLongLong
()
:
-
1
;
if
(
reUsedBytes
.
hasMatch
())
usedBytes
=
reUsedBytes
.
captured
(
1
).
toLongLong
();
QRegularExpression
re3
(
QStringLiteral
(
"Volume Size in Clusters: (
\\
d+)"
));
QRegularExpressionMatch
reVolumeSize
=
re3
.
match
(
cmd
.
output
());
qint64
volumeSize
=
reVolumeSize
.
hasMatch
()
?
reVolumeSize
.
captured
(
1
).
toLongLong
()
:
-
1
;
if
(
usedBytes
>
-
1
)
return
usedBytes
;
qint64
usedBytes
=
-
1
;
qDebug
()
<<
volumeSize
<<
freeClusters
<<
clusterSize
;
if
(
clusterSize
>
-
1
&&
freeClusters
>
-
1
&&
volumeSize
>
-
1
)
{
usedBytes
=
(
volumeSize
-
freeClusters
)
*
clusterSize
;
}
return
usedBytes
;
}
return
-
1
;
...
...
src/util/externalcommand_whitelist.h
View file @
a5bdd5a4
...
...
@@ -74,6 +74,7 @@ QStringLiteral("nilfs-resize"),
QStringLiteral
(
"ntfsresize"
),
QStringLiteral
(
"mkfs.ntfs"
),
QStringLiteral
(
"ntfsclone"
),
QStringLiteral
(
"ntfsinfo"
),
QStringLiteral
(
"ntfslabel"
),
QStringLiteral
(
"fsck.ocfs2"
),
QStringLiteral
(
"mkfs.ocfs2"
),
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment