return ret;
}
-static void blkid_get_topology(const char *device, int *sunit, int *swidth, int *sectorsize)
+static void blkid_get_topology(
+ const char *device,
+ int *sunit,
+ int *swidth,
+ int *sectorsize,
+ int force_overwrite)
{
+
blkid_topology tp;
blkid_probe pr;
unsigned long val;
fprintf(stderr,
_("warning: device is not properly aligned %s\n"),
device);
+
+ if (!force_overwrite) {
+ fprintf(stderr,
+ _("Use -f to force usage of a misaligned device\n"));
+
+ exit(EXIT_FAILURE);
+ }
+ /* force a 512b sector size if the device is misaligned */
+ *sectorsize = BBSIZE;
}
blkid_free_probe(pr);
device);
}
-static void get_topology(libxfs_init_t *xi, struct fs_topology *ft)
+static void get_topology(
+ libxfs_init_t *xi,
+ struct fs_topology *ft,
+ int force_overwrite)
{
if (!xi->disfile) {
const char *dfile = xi->volname ? xi->volname : xi->dname;
blkid_get_topology(dfile, &ft->dsunit, &ft->dswidth,
- &ft->sectorsize);
+ &ft->sectorsize, force_overwrite);
}
if (xi->rtname && !xi->risfile) {
int dummy;
- blkid_get_topology(xi->rtname, &dummy, &ft->rtswidth, &dummy);
+ blkid_get_topology(xi->rtname, &dummy, &ft->rtswidth,
+ &dummy, force_overwrite);
}
}
#else /* ENABLE_BLKID */
return 0;
}
-static void get_topology(libxfs_init_t *xi, struct fs_topology *ft)
+static void get_topology(
+ libxfs_init_t *xi,
+ struct fs_topology *ft,
+ int force_overwrite)
{
+
char *dfile = xi->volname ? xi->volname : xi->dname;
int bsz = BBSIZE;
}
memset(&ft, 0, sizeof(ft));
- get_topology(&xi, &ft);
+ get_topology(&xi, &ft, force_overwrite);
if (ft.sectoralign) {
/*