/* 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 */
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);
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
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);
/*
* 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)));