libblkid: add BLKID_PARTS_MAGIC
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
979f1dd5fe
commit
3c83b3b22f
|
@ -278,6 +278,7 @@ extern int blkid_probe_filter_partitions_type(blkid_probe pr, int flag, char *na
|
|||
/* partitions probing flags */
|
||||
#define BLKID_PARTS_FORCE_GPT (1 << 1)
|
||||
#define BLKID_PARTS_ENTRY_DETAILS (1 << 2)
|
||||
#define BLKID_PARTS_MAGIC (1 << 3)
|
||||
extern int blkid_probe_set_partitions_flags(blkid_probe pr, int flags);
|
||||
|
||||
/* binary interface */
|
||||
|
|
|
@ -426,6 +426,8 @@ extern int blkid_probe_vsprintf_value(blkid_probe pr, const char *name,
|
|||
const char *fmt, va_list ap);
|
||||
extern int blkid_probe_sprintf_value(blkid_probe pr, const char *name,
|
||||
const char *fmt, ...);
|
||||
extern int blkid_probe_set_magic(blkid_probe pr, blkid_loff_t offset,
|
||||
size_t len, unsigned char *magic);
|
||||
|
||||
extern void blkid_unparse_uuid(const unsigned char *uuid, char *str, size_t len);
|
||||
extern size_t blkid_rtrim_whitespace(unsigned char *str);
|
||||
|
|
|
@ -1213,6 +1213,39 @@ int blkid_probe_sprintf_value(blkid_probe pr, const char *name,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int blkid_probe_set_magic(blkid_probe pr, blkid_loff_t offset,
|
||||
size_t len, unsigned char *magic)
|
||||
{
|
||||
int rc = 0;
|
||||
struct blkid_chain *chn = blkid_probe_get_chain(pr);
|
||||
|
||||
if (!chn || !magic || !len || chn->binary)
|
||||
return 0;
|
||||
|
||||
switch (chn->driver->id) {
|
||||
case BLKID_CHAIN_SUBLKS:
|
||||
if (!(chn->flags & BLKID_SUBLKS_MAGIC))
|
||||
return 0;
|
||||
rc = blkid_probe_set_value(pr, "SBMAGIC", magic, len);
|
||||
if (!rc)
|
||||
rc = blkid_probe_sprintf_value(pr,
|
||||
"SBMAGIC_OFFSET", "%llu", offset);
|
||||
break;
|
||||
case BLKID_CHAIN_PARTS:
|
||||
if (!(chn->flags & BLKID_PARTS_MAGIC))
|
||||
return 0;
|
||||
rc = blkid_probe_set_value(pr, "PTMAGIC", magic, len);
|
||||
if (!rc)
|
||||
rc = blkid_probe_sprintf_value(pr,
|
||||
"PTMAGIC_OFFSET", "%llu", offset);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* blkid_probe_get_devno:
|
||||
* @pr: probe
|
||||
|
|
|
@ -479,21 +479,6 @@ static int superblocks_safeprobe(blkid_probe pr, struct blkid_chain *chn)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int blkid_probe_set_magic(blkid_probe pr, blkid_loff_t offset,
|
||||
size_t len, unsigned char *magic)
|
||||
{
|
||||
int rc = 0;
|
||||
struct blkid_chain *chn = blkid_probe_get_chain(pr);
|
||||
|
||||
if (magic && len && (chn->flags & BLKID_SUBLKS_MAGIC)) {
|
||||
rc = blkid_probe_set_value(pr, "SBMAGIC", magic, len);
|
||||
if (!rc)
|
||||
rc = blkid_probe_sprintf_value(pr, "SBMAGIC_OFFSET",
|
||||
"%llu", offset);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
int blkid_probe_set_version(blkid_probe pr, const char *version)
|
||||
{
|
||||
struct blkid_chain *chn = blkid_probe_get_chain(pr);
|
||||
|
|
|
@ -72,8 +72,6 @@ extern const struct blkid_idinfo exfat_idinfo;
|
|||
/*
|
||||
* superblock functions
|
||||
*/
|
||||
extern int blkid_probe_set_magic(blkid_probe pr, blkid_loff_t offset,
|
||||
size_t len, unsigned char *magic);
|
||||
extern int blkid_probe_set_version(blkid_probe pr, const char *version);
|
||||
extern int blkid_probe_sprintf_version(blkid_probe pr, const char *fmt, ...)
|
||||
__attribute__ ((format (printf, 2, 3)));
|
||||
|
|
Loading…
Reference in New Issue