【问题标题】:libparted determine used sectorlibparted 确定使用的扇区
【发布时间】:2014-03-06 22:39:55
【问题描述】:

我尝试确定分区中使用的扇区。但是 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
    }
}

是否有替代解决方案?谢谢。

【问题讨论】:

    标签: c++ c qt


    【解决方案1】:

    另一种选择是使用具有机器可解析输出的sfdisk

    【讨论】:

      猜你喜欢
      • 2011-08-22
      • 2012-03-16
      • 1970-01-01
      • 1970-01-01
      • 2017-02-25
      • 2017-04-10
      • 2019-12-05
      • 2012-09-20
      • 2022-09-25
      相关资源
      最近更新 更多