libparted确定使用的部门

libparted determine used sector

本文关键字:libparted      更新时间:2023-10-16

我尝试确定分区中使用的扇区。但是LibParted似乎没有支持NTFS/EXT4来调整大小的大小,在我的代码中,我只需要知道使用了多少扇区即可。

错误代码:"错误:不支持调整NTFS文件系统大小"

SLPartition::SLPartition(PedPartition *partition, SLDrive *drive) :
    _pedPartition(0),
    _drive(0),
    _mountInfo(QString()),
    _path(QString()),
    _name(QString()),
    _start(0),
    _end(0),
    _size(0),
    _sector(0)
{
    if(partition)
    {
        this->_pedPartition = partition;
        this->_drive        = drive;
        this->_path         = ped_partition_get_path(partition);
        this->_name         = QString::number(partition->num);
        this->_start        = partition->geom.start;
        this->_end          = partition->geom.end;
        this->_sector       = partition->geom.length;
        this->_size         = partition->geom.length / 2;

        qint64 usedSector = -1;
        PedFileSystem *pedFileSystem = ped_file_system_open(&partition->geom);
        if(pedFileSystem)
        {
            if(PedConstraint* pedConstraint = ped_file_system_get_resize_constraint(pedFileSystem))
            {
                usedSector = pedConstraint->min_size;
                ped_constraint_destroy(pedConstraint);
            }
            ped_file_system_close(pedFileSystem);
        }
        qDebug() << usedSector;
        // TODO MountInfo
    }
}

有其他解决方案吗?谢谢。

一种选择是将机器可放松输出的sfdisk弹出。