unsigned int n, skip;
if (posix_memalign(&buf, 4096, 8192) != 0) {
- fprintf(stderr, Name ": failed to allocate 8192 bytes\n");
+ pr_err("failed to allocate 8192 bytes\n");
return NULL;
}
n = read(fd, buf, 8192);
info = malloc(sizeof(*info));
if (info == NULL) {
#if __GNUC__ < 3
- fprintf(stderr, Name ": failed to allocate %d bytes\n",
+ pr_err("failed to allocate %d bytes\n",
(int)sizeof(*info));
#else
- fprintf(stderr, Name ": failed to allocate %zd bytes\n",
+ pr_err("failed to allocate %zd bytes\n",
sizeof(*info));
#endif
free(buf);
}
if (n < sizeof(info->sb)) {
- fprintf(stderr, Name ": failed to read superblock of bitmap "
- "file: %s\n", strerror(errno));
+ pr_err("failed to read superblock of bitmap "
+ "file: %s\n", strerror(errno));
free(info);
free(buf);
return NULL;
}
if (read_bits < total_bits) { /* file truncated... */
- fprintf(stderr, Name ": WARNING: bitmap file is not large "
+ pr_err("WARNING: bitmap file is not large "
"enough for array size %llu!\n\n",
(unsigned long long)info->sb.sync_size);
total_bits = read_bits;
struct supertype *st = *stp;
if (stat(filename, &stb) < 0) {
- fprintf(stderr, Name ": failed to find file %s: %s\n",
+ pr_err("failed to find file %s: %s\n",
filename, strerror(errno));
return NULL;
}
if ((S_IFMT & stb.st_mode) == S_IFBLK) {
fd = open(filename, O_RDONLY);
if (fd < 0) {
- fprintf(stderr, Name ": failed to open bitmap file %s: %s\n",
+ pr_err("failed to open bitmap file %s: %s\n",
filename, strerror(errno));
return NULL;
}
/* just look at device... */
lseek(fd, 0, 0);
} else if (!st->ss->locate_bitmap) {
- fprintf(stderr, Name ": No bitmap possible with %s metadata\n",
+ pr_err("No bitmap possible with %s metadata\n",
st->ss->name);
return NULL;
} else
} else {
fd = open(filename, O_RDONLY|O_DIRECT);
if (fd < 0) {
- fprintf(stderr, Name ": failed to open bitmap file %s: %s\n",
+ pr_err("failed to open bitmap file %s: %s\n",
filename, strerror(errno));
return NULL;
}
printf(" Filename : %s\n", filename);
printf(" Magic : %08x\n", sb->magic);
if (sb->magic != BITMAP_MAGIC) {
- fprintf(stderr, Name ": invalid bitmap magic 0x%x, the bitmap file appears to be corrupted\n", sb->magic);
+ pr_err("invalid bitmap magic 0x%x, the bitmap file appears to be corrupted\n", sb->magic);
}
printf(" Version : %d\n", sb->version);
if (sb->version < BITMAP_MAJOR_LO ||
sb->version > BITMAP_MAJOR_HI) {
- fprintf(stderr, Name ": unknown bitmap version %d, either the bitmap file is corrupted or you need to upgrade your tools\n", sb->version);
+ pr_err("unknown bitmap version %d, either the bitmap file is corrupted or you need to upgrade your tools\n", sb->version);
goto free_info;
}
long long bytes, filesize;
if (!force && access(filename, F_OK) == 0) {
- fprintf(stderr, Name ": bitmap file %s already exists, use --force to overwrite\n", filename);
+ pr_err("bitmap file %s already exists, use --force to overwrite\n", filename);
return rv;
}
fp = fopen(filename, "w");
if (fp == NULL) {
- fprintf(stderr, Name ": failed to open bitmap file %s: %s\n",
+ pr_err("failed to open bitmap file %s: %s\n",
filename, strerror(errno));
return rv;
}
sb_cpu_to_le(&sb); /* convert to on-disk byte ordering */
if (fwrite(&sb, sizeof(sb), 1, fp) != 1) {
- fprintf(stderr, Name ": failed to write superblock to bitmap file %s: %s\n", filename, strerror(errno));
+ pr_err("failed to write superblock to bitmap file %s: %s\n", filename, strerror(errno));
goto out;
}
while (bytes > 0) {
if (fwrite(block, sizeof(block), 1, fp) != 1) {
- fprintf(stderr, Name ": failed to write bitmap file %s: %s\n", filename, strerror(errno));
+ pr_err("failed to write bitmap file %s: %s\n", filename, strerror(errno));
goto out;
}
bytes -= sizeof(block);