#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_DEFAULT (BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | \
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE)
*/
#define BLKID_PROBVAL_BUFSIZ 64
-#define BLKID_NVALS_SUBLKS 10
+#define BLKID_NVALS_SUBLKS 12
#define BLKID_NVALS_TOPLGY 3
#define BLKID_NVALS_PARTS 1
struct blkid_idmag
{
const char *magic; /* magic string */
- unsigned len; /* length of magic */
+ unsigned int len; /* length of magic */
long kboff; /* kilobyte offset of superblock */
- unsigned sboff; /* byte offset within superblock */
+ unsigned int sboff; /* byte offset within superblock */
};
/*
*
* @MOUNT: cluster mount name (?) -- ocfs only
*
- * @SBMAGIC: super block magic string [not-implemented yet]
+ * @SBMAGIC: super block magic string
*
- * @SBOFFSET: offset of superblock [not-implemented yet]
+ * @SBMAGIC_OFFSET: offset of SBMAGIC
*
* @FSSIZE: size of filessystem [not-implemented yet]
*/
for ( ; i < ARRAY_SIZE(idinfos); i++) {
const struct blkid_idinfo *id;
const struct blkid_idmag *mag;
+ blkid_loff_t off = 0;
+
int hasmag = 0;
chn->idx = i;
/* try to detect by magic string */
while(mag && mag->magic) {
- blkid_loff_t off;
unsigned char *buf;
- off = mag->kboff + ((blkid_loff_t) mag->sboff >> 10);
- buf = blkid_probe_get_buffer(pr, off << 10, 1024);
+ off = (mag->kboff + (mag->sboff >> 10)) << 10;
+ buf = blkid_probe_get_buffer(pr, off, 1024);
if (buf && !memcmp(mag->magic,
buf + (mag->sboff & 0x3ff), mag->len)) {
"%s: magic sboff=%u, kboff=%ld\n",
id->name, mag->sboff, mag->kboff));
hasmag = 1;
+ off += mag->sboff & 0x3ff;
break;
}
mag++;
blkid_probe_set_value(pr, "TYPE",
(unsigned char *) id->name,
strlen(id->name) + 1);
+
if (chn->flags & BLKID_SUBLKS_USAGE)
blkid_probe_set_usage(pr, id->usage);
+ if (hasmag && (chn->flags & BLKID_SUBLKS_MAGIC)) {
+ blkid_probe_set_value(pr, "SBMAGIC",
+ (unsigned char *) mag->magic, mag->len);
+ blkid_probe_sprintf_value(pr, "SBMAGIC_OFFSET",
+ "%llu", off);
+ }
+
DBG(DEBUG_LOWPROBE,
printf("<-- leaving probing loop (type=%s) [SUBLKS idx=%d]\n",
id->name, chn->idx));