Browse Source

libblkid: merge FS* flags into one FSINFO

Put BLOCK_SIZE, FSSIZE and FSLASTBLOCK tags under one FSINFO flag.
These, and probably future ones, are read directly from the
superblock (with minor post-processing). These properties are
combined under one flag to escape adding a flag per superblock
member.

Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
pull/1678/head
Andrey Albershteyn 4 months ago
parent
commit
c9b2297eb1
  1. 3
      libblkid/samples/superblocks.c
  2. 23
      libblkid/src/blkid.h.in
  3. 9
      libblkid/src/superblocks/superblocks.c
  4. 3
      misc-utils/blkid.c

3
libblkid/samples/superblocks.c

@ -44,8 +44,7 @@ int main(int argc, char *argv[])
BLKID_SUBLKS_UUID | BLKID_SUBLKS_UUIDRAW |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
BLKID_SUBLKS_MAGIC | BLKID_SUBLKS_FSSIZE |
BLKID_SUBLKS_FSLASTBLOCK);
BLKID_SUBLKS_MAGIC | BLKID_SUBLKS_FSINFO);
rc = blkid_do_safeprobe(pr);
if (rc == -1)

23
libblkid/src/blkid.h.in

@ -271,18 +271,17 @@ extern int blkid_superblocks_get_name(size_t idx, const char **name, int *usage)
extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable)
__ul_attribute__((nonnull));
#define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */
#define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/
#define BLKID_SUBLKS_UUID (1 << 3) /* read UUID from superblock */
#define BLKID_SUBLKS_UUIDRAW (1 << 4) /* read and define UUID_RAW result value */
#define BLKID_SUBLKS_TYPE (1 << 5) /* define TYPE result value */
#define BLKID_SUBLKS_SECTYPE (1 << 6) /* define compatible fs type (second type) */
#define BLKID_SUBLKS_USAGE (1 << 7) /* define USAGE result value */
#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
#define BLKID_SUBLKS_FSSIZE (1 << 11) /* read and define FSSIZE from superblock */
#define BLKID_SUBLKS_FSLASTBLOCK (1 << 12) /* read and define FSLASTBLOCK from superblock */
#define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */
#define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/
#define BLKID_SUBLKS_UUID (1 << 3) /* read UUID from superblock */
#define BLKID_SUBLKS_UUIDRAW (1 << 4) /* read and define UUID_RAW result value */
#define BLKID_SUBLKS_TYPE (1 << 5) /* define TYPE result value */
#define BLKID_SUBLKS_SECTYPE (1 << 6) /* define compatible fs type (second type) */
#define BLKID_SUBLKS_USAGE (1 << 7) /* define USAGE result value */
#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
#define BLKID_SUBLKS_FSINFO (1 << 11) /* read and define fs properties from superblock */
#define BLKID_SUBLKS_DEFAULT (BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | \
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE)

9
libblkid/src/superblocks/superblocks.c

@ -562,6 +562,11 @@ int blkid_probe_sprintf_version(blkid_probe pr, const char *fmt, ...)
int blkid_probe_set_block_size(blkid_probe pr, unsigned block_size)
{
struct blkid_chain *chn = blkid_probe_get_chain(pr);
if (!(chn->flags & BLKID_SUBLKS_FSINFO))
return 0;
return blkid_probe_sprintf_value(pr, "BLOCK_SIZE", "%u", block_size);
}
@ -591,7 +596,7 @@ int blkid_probe_set_fssize(blkid_probe pr, uint64_t size)
{
struct blkid_chain *chn = blkid_probe_get_chain(pr);
if (!(chn->flags & BLKID_SUBLKS_FSSIZE))
if (!(chn->flags & BLKID_SUBLKS_FSINFO))
return 0;
return blkid_probe_sprintf_value(pr, "FSSIZE", "%" PRIu64, size);
@ -601,7 +606,7 @@ int blkid_probe_set_fslastblock(blkid_probe pr, uint64_t lastblock)
{
struct blkid_chain *chn = blkid_probe_get_chain(pr);
if (!(chn->flags & BLKID_SUBLKS_FSLASTBLOCK))
if (!(chn->flags & BLKID_SUBLKS_FSINFO))
return 0;
return blkid_probe_sprintf_value(pr, "FSLASTBLOCK", "%" PRIu64,

3
misc-utils/blkid.c

@ -922,8 +922,7 @@ int main(int argc, char **argv)
BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
BLKID_SUBLKS_FSSIZE | BLKID_SUBLKS_FSLASTBLOCK);
BLKID_SUBLKS_FSINFO);
if (fltr_usage &&
blkid_probe_filter_superblocks_usage(pr, fltr_flag, fltr_usage))

Loading…
Cancel
Save