KySdkDisk(3) Disk Information D-Bus Library KySdkDisk(3)
KySdkDisk.3

KySdkDisk - Class for generating D-Bus signals for disk information

#include <kysdkdbus.h>

The KySdkDisk class is mainly used to generate D-Bus signals for disk list, number of sectors, bytes per sector, capacity, model, serial number, number of sub-partitions, type, and firmware version information.

This class inherits from QObject.

QStringList getDiskList () const

Get the list of all disks.

Return value:

List of disks, each string represents the absolute path of a disk

unsigned int getDiskSectorSize (const QString diskname) const

Get the number of bytes per sector of the disk.

Parameters:

Specify the disk name, should be an absolute path such as /dev/sda

Return value:

Number of bytes per sector

double getDiskTotalSizeMiB (const QString diskname) const

Get the disk capacity.

Parameters:

Specify the disk name, should be an absolute path such as /dev/sda

Return value:

Disk capacity in MiB

QString getDiskModel (const QString diskname) const

Get the disk model.

Parameters:

Specify the disk name, should be an absolute path such as /dev/sda

Return value:

Disk model

QString getDiskSerial (const QString diskname) const

Get the disk serial number.

Parameters:

Specify the disk name, should be an absolute path such as /dev/sda

Return value:

Disk serial number

unsigned int getDiskPartitionNums (const QString diskname) const

Get the number of sub-partitions under the disk/partition.

Parameters:

Specify the disk name, should be an absolute path such as /dev/sda

Return value:

Number of sub-partitions under this disk/partition

QString getDiskType (const QString diskname) const

Get the disk type.

Parameters:

Specify the disk name, should be an absolute path such as /dev/sda

Return value:

Disk type, SSD or HDD or Hybrid

QString getDiskVersion (const QString diskname) const

Get the disk firmware version information.

Parameters:

Specify the disk name, should be an absolute path such as /dev/sda

Return value:

Firmware version information

unsigned long long getDiskSectorNum (const QString diskname) const

Get the number of disk sectors.

Parameters:

Specify the disk name, should be an absolute path such as /dev/sda

Return value:

Number of sectors

#include <kysdkdbus.h>
#include <QCoreApplication>
int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
    KySdkDisk diskInfo;
    // Get disk list
    QStringList disks = diskInfo.getDiskList();
    // Get information of the first disk
    if (!disks.isEmpty()) {
        QString diskName = disks.first();
        QString model = diskInfo.getDiskModel(diskName);
        double size = diskInfo.getDiskTotalSizeMiB(diskName);
        // ... use other methods
    }
    return 0;
}

QObject(3qt5), D-Bus(1), libkyfilewatcher(3)

Generated automatically by Doxygen for kysdkdbus.h from the source code.

Wed Sep 20 2023 1.0