fix: Improve ext* filesystem usage display logic#158
Merged
Conversation
Changes: 1. Reserved space handling - Now counts reserved blocks as used space for ext2/3/4 filesystems - Matches behavior of standard tools like df 2. Mounted device detection - Uses stat-based calculation for accurate free space on mounted devices - Falls back to previous method for unmounted devices Technical Impact: - Fixes discrepancy between displayed and actual available space - Provides more consistent behavior with system utilities Log: Improved ext* filesystem space calculation accuracy Bug: https://pms.uniontech.com/bug-view-323359.html
Reviewer's GuideThis PR refactors the ext* filesystem space calculation to parse and account for reserved blocks from dumpe2fs output, converts all metrics to sector units, and—when a partition is mounted—leverages statvfs for more accurate free‐space reporting; it also corrects statvfs field usage in Utils to match system utilities. Class diagram for updated EXT2 usage calculationclassDiagram
class EXT2 {
+void setUsedSectors(Partition &partition)
-long long blockCount
-long long blockSize
-long long freeBlocks
-long long reservedBlocks
-Sector totalSectors
-Sector availableSectors
-Sector statAvailableSectors
}
class Partition {
+QString getPath()
+QString getMountPoint()
+bool m_busy
+QList<QString> getMountPoints()
+void setSectorUsage(Sector total, Sector available)
+int m_sectorSize
+int m_fsBlockSize
}
class Utils {
+static bool executCmd(QString, QString&, QString&)
+static int getMountedFileSystemUsage(QString, Byte_Value&, Byte_Value&)
+static QString regexpLabel(QString, QString)
}
EXT2 --> Partition : uses
EXT2 --> Utils : uses
Utils --> Partition : uses mountpoint
Flow diagram for ext* filesystem usage calculation logicflowchart TD
A[Start setUsedSectors] --> B{Partition mounted?}
B -- Yes --> C[Call getMountedFileSystemUsage]
C --> D[Use statvfs: f_bsize, f_bavail]
D --> E[Set sector usage with stat data]
B -- No --> F[Parse dumpe2fs output]
F --> G[Calculate userAvailableBlocks = freeBlocks - reservedBlocks]
G --> H[Convert to sector units]
H --> I[Set sector usage with calculated data]
E --> J[End]
I --> J[End]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review代码审查意见:
总体来说,代码的修改提高了代码的可读性和健壮性,但需要注意以下几点:
|
max-lvs
approved these changes
Jul 10, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: itsXuSt, max-lvs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes:
1. Reserved space handling
2. Mounted device detection
Technical Impact:
Log: Improved ext* filesystem space calculation accuracy
Bug: https://pms.uniontech.com/bug-view-323359.html
Summary by Sourcery
Improve ext* filesystem usage reporting by accounting for reserved blocks and using statvfs data for mounted partitions to align displayed values with actual available space.
Bug Fixes:
Enhancements: