free_gpt(st);
- if (posix_memalign((void**)&super, 512, 32*512) != 0) {
- fprintf(stderr, Name ": %s could not allocate superblock\n",
- __func__);
+ if (posix_memalign((void**)&super, 4096, 32*512) != 0) {
+ pr_err("could not allocate superblock\n");
return 1;
}
- ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
-
lseek(fd, 0, 0);
if (read(fd, super, sizeof(*super)) != sizeof(*super)) {
no_read:
if (devname)
- fprintf(stderr, Name ": Cannot read partition table on %s\n",
+ pr_err("Cannot read partition table on %s\n",
devname);
free(super);
return 1;
}
-
+
if (super->magic != MBR_SIGNATURE_MAGIC ||
super->parts[0].part_type != MBR_GPT_PARTITION_TYPE) {
not_found:
if (devname)
- fprintf(stderr, Name ": No partition table found on %s\n",
+ pr_err("No partition table found on %s\n",
devname);
free(super);
return 1;
static struct supertype *match_metadata_desc(char *arg)
{
- struct supertype *st = malloc(sizeof(*st));
+ struct supertype *st = xmalloc(sizeof(*st));
if (!st)
return st;
- if (strcmp(arg, "gpt") != 0)
+ if (strcmp(arg, "gpt") != 0) {
+ free(st);
return NULL;
+ }
st->ss = &gpt;
st->info = NULL;
static int validate_geometry(struct supertype *st, int level,
int layout, int raiddisks,
int *chunk, unsigned long long size,
+ unsigned long long data_offset,
char *subdev, unsigned long long *freesize,
int verbose)
{
- fprintf(stderr, Name ": gpt metadata cannot be used this way\n");
+ pr_err("gpt metadata cannot be used this way\n");
return 0;
}
#endif