Miscellaneous utils

Miscellaneous utils — mix of various utils for low-level and high-level API

Synopsis

typedef             blkid_loff_t;
char *              blkid_devno_to_devname              (dev_t devno);
int                 blkid_devno_to_wholedisk            (dev_t dev,
                                                         char *diskname,
                                                         size_t len,
                                                         dev_t *diskdevno);
blkid_loff_t        blkid_get_dev_size                  (int fd);
int                 blkid_get_library_version           (const char **ver_string,
                                                         const char **date_string);
int                 blkid_parse_tag_string              (const char *token,
                                                         char **ret_type,
                                                         char **ret_val);
int                 blkid_parse_version_string          (const char *ver_string);
int                 blkid_send_uevent                   (const char *devname,
                                                         const char *action);
#define             BLKID_VERSION
#define             BLKID_DATE
#define             BLKID_FLTR_NOTIN
#define             BLKID_FLTR_ONLYIN
#define             BLKID_DEV_CREATE
#define             BLKID_DEV_FIND
#define             BLKID_DEV_NORMAL
#define             BLKID_DEV_VERIFY
#define             BLKID_PARTS_ENTRY_DETAILS
#define             BLKID_PARTS_FORCE_GPT
#define             BLKID_PARTS_MAGIC
#define             BLKID_PROBREQ_LABEL
#define             BLKID_PROBREQ_LABELRAW
#define             BLKID_PROBREQ_SECTYPE
#define             BLKID_PROBREQ_TYPE
#define             BLKID_PROBREQ_USAGE
#define             BLKID_PROBREQ_UUID
#define             BLKID_PROBREQ_UUIDRAW
#define             BLKID_PROBREQ_VERSION
#define             BLKID_SUBLKS_DEFAULT
#define             BLKID_SUBLKS_LABEL
#define             BLKID_SUBLKS_LABELRAW
#define             BLKID_SUBLKS_MAGIC
#define             BLKID_SUBLKS_SECTYPE
#define             BLKID_SUBLKS_TYPE
#define             BLKID_SUBLKS_USAGE
#define             BLKID_SUBLKS_UUID
#define             BLKID_SUBLKS_UUIDRAW
#define             BLKID_SUBLKS_VERSION
#define             BLKID_USAGE_CRYPTO
#define             BLKID_USAGE_FILESYSTEM
#define             BLKID_USAGE_OTHER
#define             BLKID_USAGE_RAID

Description

Details

blkid_loff_t

typedef int64_t blkid_loff_t;

64-bit signed number for offsets and sizes


blkid_devno_to_devname ()

char *              blkid_devno_to_devname              (dev_t devno);

This function finds the pathname to a block device with a given device number.

devno :

device number

Returns :

a pointer to allocated memory to the pathname on success, and NULL on failure.

blkid_devno_to_wholedisk ()

int                 blkid_devno_to_wholedisk            (dev_t dev,
                                                         char *diskname,
                                                         size_t len,
                                                         dev_t *diskdevno);

This function uses sysfs to convert the devno device number to the *name* of the whole disk. The function DOES NOT return full device name. The dev argument could be partition or whole disk -- both is converted.

For example: sda1, 0x0801 --> sda, 0x0800

For conversion to the full disk *path* use blkid_devno_to_devname(), for example:

1
2
3
4
5
6
7
8
9
10
11
dev_t dev = 0x0801, disk;       // sda1 = 8:1
char *diskpath, diskname[32];

blkid_devno_to_wholedisk(dev, diskname, sizeof(diskname), &disk);
diskpath = blkid_devno_to_devname(disk);

// print "0x0801: sda, /dev/sda, 8:0
printf("0x%x: %s, %s, %d:%d\n",
    dev, diskname, diskpath, major(disk), minor(disk));

free(diskpath);

dev :

device number

diskname :

buffer to return diskname (or NULL)

len :

diskname buffer size (or 0)

diskdevno :

pointer to returns devno of entire disk (or NULL)

Returns :

0 on success or -1 in case of error.

blkid_get_dev_size ()

blkid_loff_t        blkid_get_dev_size                  (int fd);

fd :

file descriptor

Returns :

size (in bytes) of the block device or size of the regular file or 0.

blkid_get_library_version ()

int                 blkid_get_library_version           (const char **ver_string,
                                                         const char **date_string);

ver_string :

returns relese version (!= SONAME version)

date_string :

returns date

Returns :

release version code.

blkid_parse_tag_string ()

int                 blkid_parse_tag_string              (const char *token,
                                                         char **ret_type,
                                                         char **ret_val);

blkid_parse_version_string ()

int                 blkid_parse_version_string          (const char *ver_string);

ver_string :

version string (e.g. "2.16.0")

Returns :

release version code.

blkid_send_uevent ()

int                 blkid_send_uevent                   (const char *devname,
                                                         const char *action);

devname :

absolute path to the device

action :

event string

Returns :

-1 in case of failure, or 0 on success.

BLKID_VERSION

#define BLKID_VERSION   "2.23.0"

BLKID_DATE

#define BLKID_DATE      "25-Apr-2013"

BLKID_FLTR_NOTIN

#define BLKID_FLTR_NOTIN		1

BLKID_FLTR_ONLYIN

#define BLKID_FLTR_ONLYIN		2

BLKID_DEV_CREATE

#define BLKID_DEV_CREATE 0x0001

BLKID_DEV_FIND

#define BLKID_DEV_FIND		0x0000

BLKID_DEV_NORMAL

#define BLKID_DEV_NORMAL (BLKID_DEV_CREATE | BLKID_DEV_VERIFY)

BLKID_DEV_VERIFY

#define BLKID_DEV_VERIFY 0x0002

BLKID_PARTS_ENTRY_DETAILS

#define BLKID_PARTS_ENTRY_DETAILS (1 << 2)

BLKID_PARTS_FORCE_GPT

#define BLKID_PARTS_FORCE_GPT		(1 << 1)

BLKID_PARTS_MAGIC

#define BLKID_PARTS_MAGIC		(1 << 3)

BLKID_PROBREQ_LABEL

#define BLKID_PROBREQ_LABEL     BLKID_SUBLKS_LABEL

Warning

BLKID_PROBREQ_LABEL is deprecated and should not be used in newly-written code.


BLKID_PROBREQ_LABELRAW

#define BLKID_PROBREQ_LABELRAW  BLKID_SUBLKS_LABELRAW

Warning

BLKID_PROBREQ_LABELRAW is deprecated and should not be used in newly-written code.


BLKID_PROBREQ_SECTYPE

#define BLKID_PROBREQ_SECTYPE   BLKID_SUBLKS_SECTYPE

Warning

BLKID_PROBREQ_SECTYPE is deprecated and should not be used in newly-written code.


BLKID_PROBREQ_TYPE

#define BLKID_PROBREQ_TYPE      BLKID_SUBLKS_TYPE

Warning

BLKID_PROBREQ_TYPE is deprecated and should not be used in newly-written code.


BLKID_PROBREQ_USAGE

#define BLKID_PROBREQ_USAGE     BLKID_SUBLKS_USAGE

Warning

BLKID_PROBREQ_USAGE is deprecated and should not be used in newly-written code.


BLKID_PROBREQ_UUID

#define BLKID_PROBREQ_UUID      BLKID_SUBLKS_UUID

Warning

BLKID_PROBREQ_UUID is deprecated and should not be used in newly-written code.


BLKID_PROBREQ_UUIDRAW

#define BLKID_PROBREQ_UUIDRAW   BLKID_SUBLKS_UUIDRAW

Warning

BLKID_PROBREQ_UUIDRAW is deprecated and should not be used in newly-written code.


BLKID_PROBREQ_VERSION

#define BLKID_PROBREQ_VERSION   BLKID_SUBLKS_VERSION

Warning

BLKID_PROBREQ_VERSION is deprecated and should not be used in newly-written code.


BLKID_SUBLKS_DEFAULT

#define             BLKID_SUBLKS_DEFAULT

BLKID_SUBLKS_LABEL

#define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */

BLKID_SUBLKS_LABELRAW

#define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/

BLKID_SUBLKS_MAGIC

#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */

BLKID_SUBLKS_SECTYPE

#define BLKID_SUBLKS_SECTYPE (1 << 6) /* define compatible fs type (second type) */

BLKID_SUBLKS_TYPE

#define BLKID_SUBLKS_TYPE (1 << 5) /* define TYPE result value */

BLKID_SUBLKS_USAGE

#define BLKID_SUBLKS_USAGE (1 << 7) /* define USAGE result value */

BLKID_SUBLKS_UUID

#define BLKID_SUBLKS_UUID (1 << 3) /* read UUID from superblock */

BLKID_SUBLKS_UUIDRAW

#define BLKID_SUBLKS_UUIDRAW (1 << 4) /* read and define UUID_RAW result value */

BLKID_SUBLKS_VERSION

#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */

BLKID_USAGE_CRYPTO

#define BLKID_USAGE_CRYPTO		(1 << 3)

BLKID_USAGE_FILESYSTEM

#define BLKID_USAGE_FILESYSTEM		(1 << 1)

BLKID_USAGE_OTHER

#define BLKID_USAGE_OTHER		(1 << 4)

BLKID_USAGE_RAID

#define BLKID_USAGE_RAID		(1 << 2)