Jump to main content

##

# 1.2.7.4.43 SYS_FS_DriveSectorGet Function

## C

    SYS_FS_RESULT SYS_FS_DriveSectorGet
    (
        const char* path,
        uint32_t *totalSectors,
        uint32_t *freeSectors
    );

## Summary

Obtains total number of sectors and number of free sectors for the specified drive.

## Description

Function to obtain the total number of sectors and number of free sectors in a drive (media).

## Precondition

The drive for which the information is to be retrieved should be mounted.

## Parameters

Param | Description
--- | ---
path | Path to the volume with the volume name. The string of volume name must be preceded by "/mnt/". Also, the volume name and directory name must be separated by a slash "/".
totalSectors | Pointer to a variable passed to the function, which will contain the total number of sectors available in the drive (media).
freeSectors | Pointer to a variable passed to the function, which will contain the free number of sectors available in the drive (media).

## Returns

SYS_FS_RES_SUCCESS - Sector information get operation was successful.

SYS_FS_RES_FAILURE - Sector information get operation was unsucessful. The reason for the failure can be retrieved with SYS_FS_Error.

## Example

    uint32_t totalSectors, freeSectors;
    SYS_FS_RESULT res;

    if(SYS_FS_Mount("/dev/mmcblka1", "/mnt/myDrive", FAT, 0, NULL) != SYS_FS_RES_SUCCESS)
    {
        // Failure, try mounting again
    }
    else
    {
        // Mount was successful.
        // Do other FS stuffs.
    }
    // Perform usual FS tasks.
    //....
    //....

    // Now, determine the total sectors and free sectors
    res = SYS_FS_DriveSectorGet("/mnt/myDrive", &totalSectors, &freeSectors);

    if(res == SYS_FS_RES_FAILURE)
    {
        //Sector information get operation failed.
    }

## Remarks

None.