const char *hoff; /* hint which contains byte offset to kboff */
long kboff; /* kilobyte offset of superblock */
unsigned int sboff; /* byte offset within superblock */
+
+ int is_zoned; /* indicate magic location is calcluated based on zone position */
+ long zonenum; /* zone number which has superblock */
+ long kboff_inzone; /* kilobyte offset of superblock in a zone */
};
/*
dev_t disk_devno; /* devno of the whole-disk or 0 */
unsigned int blkssz; /* sector size (BLKSSZGET ioctl) */
mode_t mode; /* struct stat.sb_mode */
+ uint64_t zone_size; /* zone size (BLKGETZONESZ ioctl) */
int flags; /* private library flags */
int prob_flags; /* always zeroized by blkid_do_*() */
#ifdef HAVE_LINUX_CDROM_H
#include <linux/cdrom.h>
#endif
+#ifdef HAVE_LINUX_BLKZONED_H
+#include <linux/blkzoned.h>
+#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
pr->disk_devno = parent->disk_devno;
pr->blkssz = parent->blkssz;
pr->flags = parent->flags;
+ pr->zone_size = parent->zone_size;
pr->parent = parent;
pr->flags &= ~BLKID_FL_PRIVATE_FD;
pr->wipe_off = 0;
pr->wipe_size = 0;
pr->wipe_chain = NULL;
+ pr->zone_size = 0;
if (fd < 0)
return 1;
#endif
free(dm_uuid);
+# ifdef HAVE_LINUX_BLKZONED_H
+ if (S_ISBLK(sb.st_mode)) {
+ uint32_t zone_size_sector;
+
+ if (!ioctl(pr->fd, BLKGETZONESZ, &zone_size_sector))
+ pr->zone_size = zone_size_sector << 9;
+ }
+# endif
+
DBG(LOWPROBE, ul_debug("ready for low-probing, offset=%"PRIu64", size=%"PRIu64"",
pr->off, pr->size));
DBG(LOWPROBE, ul_debug("whole-disk: %s, regfile: %s",
/* try to detect by magic string */
while(mag && mag->magic) {
unsigned char *buf;
+ uint64_t kboff;
uint64_t hint_offset;
if (!mag->hoff || blkid_probe_get_hint(pr, mag->hoff, &hint_offset) < 0)
hint_offset = 0;
- off = hint_offset + ((mag->kboff + (mag->sboff >> 10)) << 10);
+ /* If the magic is for zoned device, skip non-zoned device */
+ if (mag->is_zoned && !pr->zone_size) {
+ mag++;
+ continue;
+ }
+
+ if (!mag->is_zoned)
+ kboff = mag->kboff;
+ else
+ kboff = ((mag->zonenum * pr->zone_size) >> 10) + mag->kboff_inzone;
+
+ off = hint_offset + ((kboff + (mag->sboff >> 10)) << 10);
buf = blkid_probe_get_buffer(pr, off, 1024);
if (!buf && errno)
buf + (mag->sboff & 0x3ff), mag->len)) {
DBG(LOWPROBE, ul_debug("\tmagic sboff=%u, kboff=%ld",
- mag->sboff, mag->kboff));
+ mag->sboff, kboff));
if (offset)
*offset = off + (mag->sboff & 0x3ff);
if (res)