makefs: improve error messages
- remove \n - use __func__ - err adds the error string itself NetBSD revs: cd9660.c 1.48 1.49 ffs/buf.c 1.21 ffs/mkfs.c 1.27 Obtained from: NetBSD
This commit is contained in:
parent
b0b1dbdd49
commit
870952f562
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=315321
@ -374,7 +374,7 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts)
|
||||
assert(option != NULL);
|
||||
|
||||
if (debug & DEBUG_FS_PARSE_OPTS)
|
||||
printf("cd9660_parse_opts: got `%s'\n", option);
|
||||
printf("%s: got `%s'\n", __func__, option);
|
||||
|
||||
i = set_option(cd9660_options, option, buf, sizeof(buf));
|
||||
if (i == -1)
|
||||
@ -434,7 +434,7 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts)
|
||||
*/
|
||||
if (buf[0] == '\0') {
|
||||
warnx("The Boot Image Directory parameter"
|
||||
" requires a directory name\n");
|
||||
" requires a directory name");
|
||||
rv = 0;
|
||||
} else {
|
||||
diskStructure->boot_image_directory =
|
||||
@ -489,11 +489,11 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
|
||||
iso9660_disk *diskStructure = fsopts->fs_specific;
|
||||
|
||||
if (diskStructure->verbose_level > 0)
|
||||
printf("cd9660_makefs: ISO level is %i\n",
|
||||
printf("%s: ISO level is %i\n", __func__,
|
||||
diskStructure->isoLevel);
|
||||
if (diskStructure->isoLevel < 2 &&
|
||||
diskStructure->allow_multidot)
|
||||
errx(1, "allow-multidot requires iso level of 2\n");
|
||||
errx(EXIT_FAILURE, "allow-multidot requires iso level of 2");
|
||||
|
||||
assert(image != NULL);
|
||||
assert(dir != NULL);
|
||||
@ -508,7 +508,7 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
|
||||
}
|
||||
|
||||
if (diskStructure->verbose_level > 0)
|
||||
printf("cd9660_makefs: image %s directory %s root %p\n",
|
||||
printf("%s: image %s directory %s root %p\n", __func__,
|
||||
image, dir, root);
|
||||
|
||||
/* Set up some constants. Later, these will be defined with options */
|
||||
@ -539,13 +539,13 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
|
||||
&numDirectories, &error);
|
||||
|
||||
if (TAILQ_EMPTY(&real_root->cn_children)) {
|
||||
errx(1, "cd9660_makefs: converted directory is empty. "
|
||||
"Tree conversion failed\n");
|
||||
errx(EXIT_FAILURE, "%s: converted directory is empty. "
|
||||
"Tree conversion failed", __func__);
|
||||
} else if (error != 0) {
|
||||
errx(1, "cd9660_makefs: tree conversion failed\n");
|
||||
errx(EXIT_FAILURE, "%s: tree conversion failed", __func__);
|
||||
} else {
|
||||
if (diskStructure->verbose_level > 0)
|
||||
printf("cd9660_makefs: tree converted\n");
|
||||
printf("%s: tree converted\n", __func__);
|
||||
}
|
||||
|
||||
/* Add the dot and dot dot records */
|
||||
@ -554,7 +554,7 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
|
||||
cd9660_setup_root_node(diskStructure);
|
||||
|
||||
if (diskStructure->verbose_level > 0)
|
||||
printf("cd9660_makefs: done converting tree\n");
|
||||
printf("%s: done converting tree\n", __func__);
|
||||
|
||||
/* non-SUSP extensions */
|
||||
if (diskStructure->archimedes_enabled)
|
||||
@ -578,7 +578,7 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
|
||||
firstAvailableSector = cd9660_setup_boot(diskStructure,
|
||||
firstAvailableSector);
|
||||
if (firstAvailableSector < 0)
|
||||
errx(1, "setup_boot failed");
|
||||
errx(EXIT_FAILURE, "setup_boot failed");
|
||||
}
|
||||
/* LE first, then BE */
|
||||
diskStructure->primaryLittleEndianTableSector = firstAvailableSector;
|
||||
@ -592,8 +592,9 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
|
||||
diskStructure->dataFirstSector =
|
||||
diskStructure->primaryBigEndianTableSector + pathTableSectors;
|
||||
if (diskStructure->verbose_level > 0)
|
||||
printf("cd9660_makefs: Path table conversion complete. "
|
||||
"Each table is %i bytes, or %" PRIu64 " sectors.\n",
|
||||
printf("%s: Path table conversion complete. "
|
||||
"Each table is %i bytes, or %" PRIu64 " sectors.\n",
|
||||
__func__,
|
||||
diskStructure->pathTableLength, pathTableSectors);
|
||||
|
||||
startoffset = diskStructure->sectorSize*diskStructure->dataFirstSector;
|
||||
@ -621,13 +622,14 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
|
||||
|
||||
/* Debugging output */
|
||||
if (diskStructure->verbose_level > 0) {
|
||||
printf("cd9660_makefs: Sectors 0-15 reserved\n");
|
||||
printf("cd9660_makefs: Primary path tables starts in sector %"
|
||||
PRId64 "\n", diskStructure->primaryLittleEndianTableSector);
|
||||
printf("cd9660_makefs: File data starts in sector %"
|
||||
PRId64 "\n", diskStructure->dataFirstSector);
|
||||
printf("cd9660_makefs: Total sectors: %"
|
||||
PRId64 "\n", diskStructure->totalSectors);
|
||||
printf("%s: Sectors 0-15 reserved\n", __func__);
|
||||
printf("%s: Primary path tables starts in sector %"
|
||||
PRId64 "\n", __func__,
|
||||
diskStructure->primaryLittleEndianTableSector);
|
||||
printf("%s: File data starts in sector %"
|
||||
PRId64 "\n", __func__, diskStructure->dataFirstSector);
|
||||
printf("%s: Total sectors: %"
|
||||
PRId64 "\n", __func__, diskStructure->totalSectors);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -649,7 +651,7 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
|
||||
cd9660_free_structure(real_root);
|
||||
|
||||
if (diskStructure->verbose_level > 0)
|
||||
printf("cd9660_makefs: done\n");
|
||||
printf("%s: done\n", __func__);
|
||||
}
|
||||
|
||||
/* Generic function pointer - implement later */
|
||||
@ -895,8 +897,7 @@ cd9660_translate_node(iso9660_disk *diskStructure, fsnode *node,
|
||||
{
|
||||
if (node == NULL) {
|
||||
if (diskStructure->verbose_level > 0)
|
||||
printf("cd9660_translate_node: NULL node passed, "
|
||||
"returning\n");
|
||||
printf("%s: NULL node passed, returning\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
if ((newnode->isoDirRecord =
|
||||
@ -1270,7 +1271,7 @@ cd9660_count_collisions(cd9660node *copy)
|
||||
}
|
||||
#if 0
|
||||
if ((next = TAILQ_NEXT(iter, cn_next_child)) != NULL) {
|
||||
printf("cd9660_recurse_on_collision: count is %i \n", count);
|
||||
printf("%s: count is %i\n", __func__, count);
|
||||
compare = cd9660_compare_filename(iter->isoDirRecord->name,
|
||||
next->isoDirRecord->name);
|
||||
if (compare == 0) {
|
||||
@ -1393,7 +1394,7 @@ cd9660_convert_structure(iso9660_disk *diskStructure, fsnode *root,
|
||||
* Newer, more efficient method, reduces recursion depth
|
||||
*/
|
||||
if (root == NULL) {
|
||||
warnx("%s: root is null\n", __func__);
|
||||
warnx("%s: root is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1629,7 +1630,7 @@ cd9660_compute_full_filename(cd9660node *node, char *buf)
|
||||
len = snprintf(buf, len, "%s/%s/%s", node->node->root,
|
||||
node->node->path, node->node->name);
|
||||
if (len > CD9660MAXPATH)
|
||||
errx(1, "Pathname too long.");
|
||||
errx(EXIT_FAILURE, "Pathname too long.");
|
||||
}
|
||||
|
||||
/* NEW filename conversion method */
|
||||
|
@ -505,7 +505,7 @@ ffs_create_image(const char *image, fsinfo_t *fsopts)
|
||||
bufrem = fsopts->size;
|
||||
if (fsopts->sparse) {
|
||||
if (ftruncate(fsopts->fd, bufrem) == -1) {
|
||||
warn("sparse option disabled.\n");
|
||||
warn("sparse option disabled.");
|
||||
fsopts->sparse = 0;
|
||||
}
|
||||
}
|
||||
|
@ -71,25 +71,26 @@ bread(struct vnode *vp, daddr_t blkno, int size, struct ucred *u1 __unused,
|
||||
assert (bpp != NULL);
|
||||
|
||||
if (debug & DEBUG_BUF_BREAD)
|
||||
printf("bread: blkno %lld size %d\n", (long long)blkno, size);
|
||||
printf("%s: blkno %lld size %d\n", __func__, (long long)blkno,
|
||||
size);
|
||||
*bpp = getblk(vp, blkno, size, 0, 0, 0);
|
||||
offset = (*bpp)->b_blkno * sectorsize; /* XXX */
|
||||
if (debug & DEBUG_BUF_BREAD)
|
||||
printf("bread: blkno %lld offset %lld bcount %ld\n",
|
||||
printf("%s: blkno %lld offset %lld bcount %ld\n", __func__,
|
||||
(long long)(*bpp)->b_blkno, (long long) offset,
|
||||
(*bpp)->b_bcount);
|
||||
if (lseek((*bpp)->b_fd, offset, SEEK_SET) == -1)
|
||||
err(1, "bread: lseek %lld (%lld)",
|
||||
err(1, "%s: lseek %lld (%lld)", __func__,
|
||||
(long long)(*bpp)->b_blkno, (long long)offset);
|
||||
rv = read((*bpp)->b_fd, (*bpp)->b_data, (*bpp)->b_bcount);
|
||||
if (debug & DEBUG_BUF_BREAD)
|
||||
printf("bread: read %ld (%lld) returned %d\n",
|
||||
printf("%s: read %ld (%lld) returned %d\n", __func__,
|
||||
(*bpp)->b_bcount, (long long)offset, (int)rv);
|
||||
if (rv == -1) /* read error */
|
||||
err(1, "bread: read %ld (%lld) returned %d",
|
||||
err(1, "%s: read %ld (%lld) returned %d", __func__,
|
||||
(*bpp)->b_bcount, (long long)offset, (int)rv);
|
||||
else if (rv != (*bpp)->b_bcount) /* short read */
|
||||
err(1, "bread: read %ld (%lld) returned %d",
|
||||
err(1, "%s: read %ld (%lld) returned %d", __func__,
|
||||
(*bpp)->b_bcount, (long long)offset, (int)rv);
|
||||
else
|
||||
return (0);
|
||||
|
@ -778,17 +778,17 @@ ffs_rdfs(daddr_t bno, int size, void *bf, const fsinfo_t *fsopts)
|
||||
offset = bno;
|
||||
offset *= fsopts->sectorsize;
|
||||
if (lseek(fsopts->fd, offset, SEEK_SET) < 0)
|
||||
err(1, "ffs_rdfs: seek error for sector %lld: %s\n",
|
||||
(long long)bno, strerror(errno));
|
||||
err(1, "%s: seek error for sector %lld", __func__,
|
||||
(long long)bno);
|
||||
n = read(fsopts->fd, bf, size);
|
||||
if (n == -1) {
|
||||
abort();
|
||||
err(1, "ffs_rdfs: read error bno %lld size %d", (long long)bno,
|
||||
size);
|
||||
err(1, "%s: read error bno %lld size %d", __func__,
|
||||
(long long)bno, size);
|
||||
}
|
||||
else if (n != size)
|
||||
errx(1, "ffs_rdfs: read error for sector %lld: %s\n",
|
||||
(long long)bno, strerror(errno));
|
||||
errx(1, "%s: read error for sector %lld", __func__,
|
||||
(long long)bno);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -803,15 +803,15 @@ ffs_wtfs(daddr_t bno, int size, void *bf, const fsinfo_t *fsopts)
|
||||
offset = bno;
|
||||
offset *= fsopts->sectorsize;
|
||||
if (lseek(fsopts->fd, offset, SEEK_SET) < 0)
|
||||
err(1, "wtfs: seek error for sector %lld: %s\n",
|
||||
(long long)bno, strerror(errno));
|
||||
err(1, "%s: seek error for sector %lld", __func__,
|
||||
(long long)bno );
|
||||
n = write(fsopts->fd, bf, size);
|
||||
if (n == -1)
|
||||
err(1, "wtfs: write error for sector %lld: %s\n",
|
||||
(long long)bno, strerror(errno));
|
||||
err(1, "%s: write error for sector %lld", __func__,
|
||||
(long long)bno);
|
||||
else if (n != size)
|
||||
errx(1, "wtfs: write error for sector %lld: %s\n",
|
||||
(long long)bno, strerror(errno));
|
||||
errx(1, "%s: write error for sector %lld", __func__,
|
||||
(long long)bno);
|
||||
}
|
||||
|
||||
|
||||
@ -834,5 +834,5 @@ ilog2(int val)
|
||||
for (n = 0; n < sizeof(n) * CHAR_BIT; n++)
|
||||
if (1 << n == val)
|
||||
return (n);
|
||||
errx(1, "ilog2: %d is not a power of 2\n", val);
|
||||
errx(1, "%s: %d is not a power of 2", __func__, val);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user