summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--disk-utils/fsck.cramfs.c104
-rw-r--r--disk-utils/mkfs.cramfs.c42
-rw-r--r--disk-utils/mkfs.minix.c62
-rw-r--r--include/exitcodes.h32
4 files changed, 122 insertions, 118 deletions
diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c
index 465e11594..0b34f79e8 100644
--- a/disk-utils/fsck.cramfs.c
+++ b/disk-utils/fsck.cramfs.c
@@ -60,7 +60,7 @@
#include "c.h"
#include "exitcodes.h"
-#define XALLOC_EXIT_CODE FSCK_ERROR
+#define XALLOC_EXIT_CODE FSCK_EX_ERROR
#include "xalloc.h"
static const char *progname = "cramfsck";
@@ -138,42 +138,42 @@ static void test_super(int *start, size_t * length)
/* find the physical size of the file or block device */
if (stat(filename, &st) < 0)
- err(FSCK_ERROR, _("stat failed: %s"), filename);
+ err(FSCK_EX_ERROR, _("stat failed: %s"), filename);
fd = open(filename, O_RDONLY);
if (fd < 0)
- err(FSCK_ERROR, _("open failed: %s"), filename);
+ err(FSCK_EX_ERROR, _("open failed: %s"), filename);
if (S_ISBLK(st.st_mode)) {
unsigned long long bytes;
if (blkdev_get_size(fd, &bytes))
- err(FSCK_ERROR,
+ err(FSCK_EX_ERROR,
_("ioctl failed: unable to determine device size: %s"),
filename);
*length = bytes;
} else if (S_ISREG(st.st_mode))
*length = st.st_size;
else
- errx(FSCK_ERROR, _("not a block device or file: %s"), filename);
+ errx(FSCK_EX_ERROR, _("not a block device or file: %s"), filename);
if (*length < sizeof(struct cramfs_super))
- errx(FSCK_UNCORRECTED, _("file length too short"));
+ errx(FSCK_EX_UNCORRECTED, _("file length too short"));
/* find superblock */
if (read(fd, &super, sizeof(super)) != sizeof(super))
- err(FSCK_ERROR, _("read failed: %s"), filename);
+ err(FSCK_EX_ERROR, _("read failed: %s"), filename);
if (get_superblock_endianness(super.magic) != -1)
*start = 0;
else if (*length >= (PAD_SIZE + sizeof(super))) {
lseek(fd, PAD_SIZE, SEEK_SET);
if (read(fd, &super, sizeof(super)) != sizeof(super))
- err(FSCK_ERROR, _("read failed: %s"), filename);
+ err(FSCK_EX_ERROR, _("read failed: %s"), filename);
if (get_superblock_endianness(super.magic) != -1)
*start = PAD_SIZE;
else
- errx(FSCK_UNCORRECTED, _("superblock magic not found"));
+ errx(FSCK_EX_UNCORRECTED, _("superblock magic not found"));
} else
- errx(FSCK_UNCORRECTED, _("superblock magic not found"));
+ errx(FSCK_EX_UNCORRECTED, _("superblock magic not found"));
if (opt_verbose)
printf(_("cramfs endianness is %s\n"),
@@ -181,17 +181,17 @@ static void test_super(int *start, size_t * length)
super_toggle_endianness(cramfs_is_big_endian, &super);
if (super.flags & ~CRAMFS_SUPPORTED_FLAGS)
- errx(FSCK_ERROR, _("unsupported filesystem features"));
+ errx(FSCK_EX_ERROR, _("unsupported filesystem features"));
if (super.size < page_size)
- errx(FSCK_UNCORRECTED, _("superblock size (%d) too small"),
+ errx(FSCK_EX_UNCORRECTED, _("superblock size (%d) too small"),
super.size);
if (super.flags & CRAMFS_FLAG_FSID_VERSION_2) {
if (super.fsid.files == 0)
- errx(FSCK_UNCORRECTED, _("zero file count"));
+ errx(FSCK_EX_UNCORRECTED, _("zero file count"));
if (*length < super.size)
- errx(FSCK_UNCORRECTED, _("file length too short"));
+ errx(FSCK_EX_UNCORRECTED, _("file length too short"));
else if (*length > super.size)
fprintf(stderr,
_("warning: file extends past end of filesystem\n"));
@@ -208,7 +208,7 @@ static void test_crc(int start)
#ifdef INCLUDE_FS_TESTS
return;
#else
- errx(FSCK_USAGE, _("unable to test CRC: old cramfs format"));
+ errx(FSCK_EX_USAGE, _("unable to test CRC: old cramfs format"));
#endif
}
@@ -223,7 +223,7 @@ static void test_crc(int start)
if (buf != MAP_FAILED) {
lseek(fd, 0, SEEK_SET);
if (read(fd, buf, super.size) < 0)
- err(FSCK_ERROR, _("read failed: %s"), filename);
+ err(FSCK_EX_ERROR, _("read failed: %s"), filename);
}
}
if (buf != MAP_FAILED) {
@@ -240,7 +240,7 @@ static void test_crc(int start)
for (;;) {
retval = read(fd, buf, 4096);
if (retval < 0)
- err(FSCK_ERROR, _("read failed: %s"), filename);
+ err(FSCK_EX_ERROR, _("read failed: %s"), filename);
else if (retval == 0)
break;
if (length == 0)
@@ -259,7 +259,7 @@ static void test_crc(int start)
}
if (crc != super.fsid.crc)
- errx(FSCK_UNCORRECTED, _("crc error"));
+ errx(FSCK_EX_UNCORRECTED, _("crc error"));
}
#ifdef INCLUDE_FS_TESTS
@@ -320,11 +320,11 @@ static struct cramfs_inode *read_super(void)
unsigned long offset = root->offset << 2;
if (!S_ISDIR(root->mode))
- errx(FSCK_UNCORRECTED, _("root inode is not directory"));
+ errx(FSCK_EX_UNCORRECTED, _("root inode is not directory"));
if (!(super.flags & CRAMFS_FLAG_SHIFTED_ROOT_OFFSET) &&
((offset != sizeof(struct cramfs_super)) &&
(offset != PAD_SIZE + sizeof(struct cramfs_super)))) {
- errx(FSCK_UNCORRECTED, _("bad root offset (%lu)"), offset);
+ errx(FSCK_EX_UNCORRECTED, _("bad root offset (%lu)"), offset);
}
return root;
}
@@ -342,11 +342,11 @@ static int uncompress_block(void *src, int len)
inflateReset(&stream);
if (len > page_size * 2)
- errx(FSCK_UNCORRECTED, _("data block too large"));
+ errx(FSCK_EX_UNCORRECTED, _("data block too large"));
err = inflate(&stream, Z_FINISH);
if (err != Z_STREAM_END)
- errx(FSCK_UNCORRECTED, _("decompression error %p(%d): %s"),
+ errx(FSCK_EX_UNCORRECTED, _("decompression error %p(%d): %s"),
zError(err), src, len);
return stream.total_out;
}
@@ -385,18 +385,18 @@ static void do_uncompress(char *path, int fd, unsigned long offset,
}
if (size >= page_size) {
if (out != page_size)
- errx(FSCK_UNCORRECTED,
+ errx(FSCK_EX_UNCORRECTED,
_("non-block (%ld) bytes"), out);
} else {
if (out != size)
- errx(FSCK_UNCORRECTED,
+ errx(FSCK_EX_UNCORRECTED,
_("non-size (%ld vs %ld) bytes"), out,
size);
}
size -= out;
if (opt_extract)
if (write(fd, outbuffer, out) < 0)
- err(FSCK_ERROR, _("write failed: %s"),
+ err(FSCK_EX_ERROR, _("write failed: %s"),
path);
curr = next;
} while (size);
@@ -408,16 +408,16 @@ static void change_file_status(char *path, struct cramfs_inode *i)
if (euid == 0) {
if (lchown(path, i->uid, i->gid) < 0)
- err(FSCK_ERROR, _("lchown failed: %s"), path);
+ err(FSCK_EX_ERROR, _("lchown failed: %s"), path);
if (S_ISLNK(i->mode))
return;
if (((S_ISUID | S_ISGID) & i->mode) && chmod(path, i->mode) < 0)
- err(FSCK_ERROR, _("chown failed: %s"), path);
+ err(FSCK_EX_ERROR, _("chown failed: %s"), path);
}
if (S_ISLNK(i->mode))
return;
if (utime(path, &epoch) < 0)
- err(FSCK_ERROR, _("utime failed: %s"), path);
+ err(FSCK_EX_ERROR, _("utime failed: %s"), path);
}
static void do_directory(char *path, struct cramfs_inode *i)
@@ -428,7 +428,7 @@ static void do_directory(char *path, struct cramfs_inode *i)
char *newpath = xmalloc(pathlen + 256);
if (offset == 0 && count != 0)
- errx(FSCK_UNCORRECTED,
+ errx(FSCK_EX_UNCORRECTED,
_("directory inode has zero offset and non-zero size: %s"),
path);
@@ -444,7 +444,7 @@ static void do_directory(char *path, struct cramfs_inode *i)
if (opt_extract) {
if (mkdir(path, i->mode) < 0)
- err(FSCK_ERROR, _("mkdir failed: %s"), path);
+ err(FSCK_EX_ERROR, _("mkdir failed: %s"), path);
change_file_status(path, i);
}
while (count > 0) {
@@ -460,15 +460,15 @@ static void do_directory(char *path, struct cramfs_inode *i)
memcpy(newpath + pathlen, romfs_read(offset), newlen);
newpath[pathlen + newlen] = 0;
if (newlen == 0)
- errx(FSCK_UNCORRECTED, _("filename length is zero"));
+ errx(FSCK_EX_UNCORRECTED, _("filename length is zero"));
if ((pathlen + newlen) - strlen(newpath) > 3)
- errx(FSCK_UNCORRECTED, _("bad filename length"));
+ errx(FSCK_EX_UNCORRECTED, _("bad filename length"));
expand_fs(newpath, child);
offset += newlen;
if (offset <= start_dir)
- errx(FSCK_UNCORRECTED, _("bad inode offset"));
+ errx(FSCK_EX_UNCORRECTED, _("bad inode offset"));
if (offset > end_dir)
end_dir = offset;
iput(child); /* free(child) */
@@ -482,10 +482,10 @@ static void do_file(char *path, struct cramfs_inode *i)
int fd = 0;
if (offset == 0 && i->size != 0)
- errx(FSCK_UNCORRECTED,
+ errx(FSCK_EX_UNCORRECTED,
_("file inode has zero offset and non-zero size"));
if (i->size == 0 && offset != 0)
- errx(FSCK_UNCORRECTED,
+ errx(FSCK_EX_UNCORRECTED,
_("file inode has zero size and non-zero offset"));
if (offset != 0 && offset < start_data)
start_data = offset;
@@ -494,7 +494,7 @@ static void do_file(char *path, struct cramfs_inode *i)
if (opt_extract) {
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, i->mode);
if (fd < 0)
- err(FSCK_ERROR, _("open failed: %s"), path);
+ err(FSCK_EX_ERROR, _("open failed: %s"), path);
}
if (i->size)
do_uncompress(path, fd, offset, i->size);
@@ -514,9 +514,9 @@ static void do_symlink(char *path, struct cramfs_inode *i)
unsigned long size;
if (offset == 0)
- errx(FSCK_UNCORRECTED, _("symbolic link has zero offset"));
+ errx(FSCK_EX_UNCORRECTED, _("symbolic link has zero offset"));
if (i->size == 0)
- errx(FSCK_UNCORRECTED, _("symbolic link has zero size"));
+ errx(FSCK_EX_UNCORRECTED, _("symbolic link has zero size"));
if (offset < start_data)
start_data = offset;
@@ -525,7 +525,7 @@ static void do_symlink(char *path, struct cramfs_inode *i)
size = uncompress_block(romfs_read(curr), next - curr);
if (size != i->size)
- errx(FSCK_UNCORRECTED, _("size error in symlink: %s"), path);
+ errx(FSCK_EX_UNCORRECTED, _("size error in symlink: %s"), path);
outbuffer[size] = 0;
if (opt_verbose) {
char *str;
@@ -539,7 +539,7 @@ static void do_symlink(char *path, struct cramfs_inode *i)
}
if (opt_extract) {
if (symlink(outbuffer, path) < 0)
- err(FSCK_ERROR, _("symlink failed: %s"), path);
+ err(FSCK_EX_ERROR, _("symlink failed: %s"), path);
change_file_status(path, i);
}
}
@@ -551,7 +551,7 @@ static void do_special_inode(char *path, struct cramfs_inode *i)
if (i->offset)
/* no need to shift offset */
- errx(FSCK_UNCORRECTED,
+ errx(FSCK_EX_UNCORRECTED,
_("special file has non-zero offset: %s"), path);
if (S_ISCHR(i->mode)) {
@@ -562,16 +562,16 @@ static void do_special_inode(char *path, struct cramfs_inode *i)
type = 'b';
} else if (S_ISFIFO(i->mode)) {
if (i->size != 0)
- errx(FSCK_UNCORRECTED, _("fifo has non-zero size: %s"),
+ errx(FSCK_EX_UNCORRECTED, _("fifo has non-zero size: %s"),
path);
type = 'p';
} else if (S_ISSOCK(i->mode)) {
if (i->size != 0)
- errx(FSCK_UNCORRECTED,
+ errx(FSCK_EX_UNCORRECTED,
_("socket has non-zero size: %s"), path);
type = 's';
} else {
- errx(FSCK_UNCORRECTED, _("bogus mode: %s (%o)"), path, i->mode);
+ errx(FSCK_EX_UNCORRECTED, _("bogus mode: %s (%o)"), path, i->mode);
return; /* not reached */
}
@@ -580,7 +580,7 @@ static void do_special_inode(char *path, struct cramfs_inode *i)
if (opt_extract) {
if (mknod(path, i->mode, devtype) < 0)
- err(FSCK_ERROR, _("mknod failed: %s"), path);
+ err(FSCK_EX_ERROR, _("mknod failed: %s"), path);
change_file_status(path, i);
}
}
@@ -611,17 +611,17 @@ static void test_fs(int start)
inflateEnd(&stream);
if (start_data != ~0UL) {
if (start_data < (sizeof(struct cramfs_super) + start))
- errx(FSCK_UNCORRECTED,
+ errx(FSCK_EX_UNCORRECTED,
_("directory data start (%ld) < sizeof(struct cramfs_super) + start (%ld)"),
start_data, sizeof(struct cramfs_super) + start);
if (end_dir != start_data)
- errx(FSCK_UNCORRECTED,
+ errx(FSCK_EX_UNCORRECTED,
_("directory data end (%ld) != file data start (%ld)"),
end_dir, start_data);
}
if (super.flags & CRAMFS_FLAG_FSID_VERSION_2)
if (end_data > super.size)
- errx(FSCK_UNCORRECTED, _("invalid file data offset"));
+ errx(FSCK_EX_UNCORRECTED, _("invalid file data offset"));
iput(root); /* free(root) */
}
@@ -648,7 +648,7 @@ int main(int argc, char **argv)
while ((c = getopt(argc, argv, "hx:v")) != EOF)
switch (c) {
case 'h':
- usage(FSCK_OK);
+ usage(FSCK_EX_OK);
break;
case 'x':
#ifdef INCLUDE_FS_TESTS
@@ -656,7 +656,7 @@ int main(int argc, char **argv)
extract_dir = optarg;
break;
#else
- errx(FSCK_USAGE, _("compiled without -x support"));
+ errx(FSCK_EX_USAGE, _("compiled without -x support"));
#endif
case 'v':
opt_verbose++;
@@ -664,7 +664,7 @@ int main(int argc, char **argv)
}
if ((argc - optind) != 1)
- usage(FSCK_USAGE);
+ usage(FSCK_EX_USAGE);
filename = argv[optind];
test_super(&start, &length);
@@ -676,5 +676,5 @@ int main(int argc, char **argv)
if (opt_verbose)
printf(_("%s: OK\n"), filename);
- exit(FSCK_OK);
+ exit(FSCK_EX_OK);
}
diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index a1e16cea9..9777eaf97 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -44,7 +44,7 @@
#include "nls.h"
#include "exitcodes.h"
#include "strutils.h"
-#define XALLOC_EXIT_CODE MKFS_ERROR
+#define XALLOC_EXIT_CODE MKFS_EX_ERROR
#include "xalloc.h"
/* The kernel only supports PAD_SIZE of 0 and 512. */
@@ -171,7 +171,7 @@ do_mmap(char *path, unsigned int size, unsigned int mode){
start = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
if (-1 == (int) (long) start)
- err(MKFS_ERROR, "mmap");
+ err(MKFS_EX_ERROR, "mmap");
close(fd);
return start;
@@ -295,7 +295,7 @@ static unsigned int parse_directory(struct entry *root_entry, const char *name,
dircount = scandir(name, &dirlist, 0, cramsort);
if (dircount < 0)
- err(MKFS_ERROR, _("could not read directory %s"), name);
+ err(MKFS_EX_ERROR, _("could not read directory %s"), name);
/* process directory */
for (dirindex = 0; dirindex < dircount; dirindex++) {
@@ -319,7 +319,7 @@ static unsigned int parse_directory(struct entry *root_entry, const char *name,
}
namelen = strlen(dirent->d_name);
if (namelen > MAX_INPUT_NAMELEN)
- errx(MKFS_ERROR,
+ errx(MKFS_EX_ERROR,
_("Very long (%zu bytes) filename `%s' found.\n"
" Please increase MAX_INPUT_NAMELEN in "
"mkcramfs.c and recompile. Exiting."),
@@ -442,7 +442,7 @@ static void set_data_offset(struct entry *entry, char *base, unsigned long offse
struct cramfs_inode *inode = (struct cramfs_inode *) (base + entry->dir_offset);
inode_to_host(cramfs_is_big_endian, inode, inode);
if (offset >= (1 << (2 + CRAMFS_OFFSET_WIDTH)))
- errx(MKFS_ERROR, _("filesystem too big. Exiting."));
+ errx(MKFS_EX_ERROR, _("filesystem too big. Exiting."));
inode->offset = (offset >> 2);
inode_from_host(cramfs_is_big_endian, inode, inode);
}
@@ -604,7 +604,7 @@ do_compress(char *base, unsigned int offset, unsigned char const *name,
printf(_("AIEEE: block \"compressed\" to > "
"2*blocklength (%ld)\n"),
len);
- exit(MKFS_ERROR);
+ exit(MKFS_EX_ERROR);
}
*(uint32_t *) (base + offset) = u32_toggle_endianness(cramfs_is_big_endian, curr);
@@ -660,12 +660,12 @@ static unsigned int write_file(char *file, char *base, unsigned int offset)
fd = open(file, O_RDONLY);
if (fd < 0)
- err(MKFS_ERROR, _("cannot open file %s"), file);
+ err(MKFS_EX_ERROR, _("cannot open file %s"), file);
buf = mmap(NULL, image_length, PROT_READ, MAP_PRIVATE, fd, 0);
memcpy(base + offset, buf, image_length);
munmap(buf, image_length);
if (close (fd) < 0)
- err(MKFS_ERROR, _("cannot close file %s"), file);
+ err(MKFS_EX_ERROR, _("cannot close file %s"), file);
/* Pad up the image_length to a 4-byte boundary */
while (image_length & 3) {
*(base + offset + image_length) = '\0';
@@ -723,14 +723,14 @@ int main(int argc, char **argv)
while ((c = getopt(argc, argv, "hb:Ee:i:n:N:psVvz")) != EOF) {
switch (c) {
case 'h':
- usage(MKFS_OK);
+ usage(MKFS_EX_OK);
case 'b':
{
long long tmp = strtoll_or_err(optarg,
_("failed to parse blocksize argument"));
if (tmp <= 0 || UINT_MAX < tmp)
- errx(MKFS_USAGE, _("invalid block size"));
+ errx(MKFS_EX_USAGE, _("invalid block size"));
blksize = tmp;
break;
}
@@ -748,13 +748,13 @@ int main(int argc, char **argv)
else if (strcmp(optarg, "host") == 0)
/* default */ ;
else
- errx(MKFS_USAGE, _("invalid endianness given."
+ errx(MKFS_EX_USAGE, _("invalid endianness given."
" Must be 'big', 'little', or 'host'"));
break;
case 'i':
opt_image = optarg;
if (lstat(opt_image, &st) < 0)
- err(MKFS_USAGE, _("cannot stat %s"), opt_image);
+ err(MKFS_EX_USAGE, _("cannot stat %s"), opt_image);
image_length = st.st_size; /* may be padded later */
fslen_ub += (image_length + 3); /* 3 is for padding */
break;
@@ -771,7 +771,7 @@ int main(int argc, char **argv)
case 'V':
printf(_("%s from %s\n"),
program_invocation_short_name, PACKAGE_STRING);
- exit(MKFS_OK);
+ exit(MKFS_EX_OK);
case 'v':
verbose = 1;
break;
@@ -782,15 +782,15 @@ int main(int argc, char **argv)
}
if ((argc - optind) != 2)
- usage(MKFS_USAGE);
+ usage(MKFS_EX_USAGE);
dirname = argv[optind];
outfile = argv[optind + 1];
if (stat(dirname, &st) < 0)
- err(MKFS_USAGE, _("cannot stat %s"), dirname);
+ err(MKFS_EX_USAGE, _("cannot stat %s"), dirname);
fd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0)
- err(MKFS_USAGE, _("cannot open %s"), outfile);
+ err(MKFS_EX_USAGE, _("cannot open %s"), outfile);
root_entry = xcalloc(1, sizeof(struct entry));
root_entry->mode = st.st_mode;
@@ -832,7 +832,7 @@ int main(int argc, char **argv)
-1, 0);
if (-1 == (int) (long) rom_image)
- err(MKFS_ERROR, _("ROM image map"));
+ err(MKFS_EX_ERROR, _("ROM image map"));
/* Skip the first opt_pad bytes for boot loader code */
offset = opt_pad;
@@ -874,7 +874,7 @@ int main(int argc, char **argv)
/* Check to make sure we allocated enough space. */
if (fslen_ub < offset)
- errx(MKFS_ERROR,
+ errx(MKFS_EX_ERROR,
_("not enough space allocated for ROM image "
"(%lld allocated, %zu used)"),
(long long) fslen_ub, offset);
@@ -882,9 +882,9 @@ int main(int argc, char **argv)
written = write(fd, rom_image, offset);
close(fd);
if (written < 0)
- err(MKFS_ERROR, _("ROM image"));
+ err(MKFS_EX_ERROR, _("ROM image"));
if (offset != written)
- errx(MKFS_ERROR, _("ROM image write failed (%zd %zd)"),
+ errx(MKFS_EX_ERROR, _("ROM image write failed (%zd %zd)"),
written, offset);
/*
@@ -914,7 +914,7 @@ int main(int argc, char **argv)
CRAMFS_OFFSET_WIDTH);
if (opt_errors &&
(warn_namelen|warn_skip|warn_size|warn_uid|warn_gid|warn_dev))
- exit(MKFS_ERROR);
+ exit(MKFS_EX_ERROR);
return EXIT_SUCCESS;
}
diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index 9c926106f..a1ec2960c 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -145,7 +145,7 @@ static char *zone_map;
static void __attribute__((__noreturn__))
usage(void) {
- errx(MKFS_USAGE, _("Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]"),
+ errx(MKFS_EX_USAGE, _("Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]"),
program_name);
}
@@ -167,7 +167,7 @@ static void check_mount(void) {
if (!mnt)
return;
- errx(MKFS_ERROR, _("%s is mounted; will not make a filesystem here!"),
+ errx(MKFS_EX_ERROR, _("%s is mounted; will not make a filesystem here!"),
device_name);
}
@@ -193,32 +193,32 @@ static void write_tables(void) {
super_set_state();
if (lseek(DEV, 0, SEEK_SET))
- err(MKFS_ERROR, _("%s: seek to boot block failed "
+ err(MKFS_EX_ERROR, _("%s: seek to boot block failed "
" in write_tables"), device_name);
if (write_all(DEV, boot_block_buffer, 512))
- err(MKFS_ERROR, _("%s: unable to clear boot sector"), device_name);
+ err(MKFS_EX_ERROR, _("%s: unable to clear boot sector"), device_name);
if (MINIX_BLOCK_SIZE != lseek(DEV, MINIX_BLOCK_SIZE, SEEK_SET))
- err(MKFS_ERROR, _("%s: seek failed in write_tables"), device_name);
+ err(MKFS_EX_ERROR, _("%s: seek failed in write_tables"), device_name);
if (write_all(DEV, super_block_buffer, MINIX_BLOCK_SIZE))
- err(MKFS_ERROR, _("%s: unable to write super-block"), device_name);
+ err(MKFS_EX_ERROR, _("%s: unable to write super-block"), device_name);
if (write_all(DEV, inode_map, imaps * MINIX_BLOCK_SIZE))
- err(MKFS_ERROR, _("%s: unable to write inode map"), device_name);
+ err(MKFS_EX_ERROR, _("%s: unable to write inode map"), device_name);
if (write_all(DEV, zone_map, zmaps * MINIX_BLOCK_SIZE))
- err(MKFS_ERROR, _("%s: unable to write zone map"), device_name);
+ err(MKFS_EX_ERROR, _("%s: unable to write zone map"), device_name);
if (write_all(DEV, inode_buffer, buffsz))
- err(MKFS_ERROR, _("%s: unable to write inodes"), device_name);
+ err(MKFS_EX_ERROR, _("%s: unable to write inodes"), device_name);
}
static void write_block(int blk, char * buffer) {
if (blk*MINIX_BLOCK_SIZE != lseek(DEV, blk*MINIX_BLOCK_SIZE, SEEK_SET))
- errx(MKFS_ERROR, _("%s: seek failed in write_block"), device_name);
+ errx(MKFS_EX_ERROR, _("%s: seek failed in write_block"), device_name);
if (write_all(DEV, buffer, MINIX_BLOCK_SIZE))
- errx(MKFS_ERROR, _("%s: write failed in write_block"), device_name);
+ errx(MKFS_EX_ERROR, _("%s: write failed in write_block"), device_name);
}
static int get_free_block(void) {
@@ -227,7 +227,7 @@ static int get_free_block(void) {
unsigned int first_zone = get_first_zone();
if (used_good_blocks+1 >= MAX_GOOD_BLOCKS)
- errx(MKFS_ERROR, _("%s: too many bad blocks"), device_name);
+ errx(MKFS_EX_ERROR, _("%s: too many bad blocks"), device_name);
if (used_good_blocks)
blk = good_blocks_table[used_good_blocks-1]+1;
else
@@ -235,7 +235,7 @@ static int get_free_block(void) {
while (blk < zones && zone_in_use(blk))
blk++;
if (blk >= zones)
- errx(MKFS_ERROR, _("%s: not enough good blocks"), device_name);
+ errx(MKFS_EX_ERROR, _("%s: not enough good blocks"), device_name);
good_blocks_table[used_good_blocks] = blk;
used_good_blocks++;
return blk;
@@ -302,7 +302,7 @@ static void make_bad_inode_v1(void)
goto end_bad;
}
}
- errx(MKFS_ERROR, _("%s: too many bad blocks"), device_name);
+ errx(MKFS_EX_ERROR, _("%s: too many bad blocks"), device_name);
end_bad:
if (ind)
write_block(ind, (char *) ind_block);
@@ -351,7 +351,7 @@ static void make_bad_inode_v2_v3 (void)
}
}
/* Could make triple indirect block here */
- errx(MKFS_ERROR, _("%s: too many bad blocks"), device_name);
+ errx(MKFS_EX_ERROR, _("%s: too many bad blocks"), device_name);
end_bad:
if (ind)
write_block (ind, (char *) ind_block);
@@ -481,7 +481,7 @@ static void setup_tables(void) {
super_block_buffer = calloc(1, MINIX_BLOCK_SIZE);
if (!super_block_buffer)
- err(MKFS_ERROR, _("%s: unable to alloc buffer for superblock"),
+ err(MKFS_EX_ERROR, _("%s: unable to alloc buffer for superblock"),
device_name);
memset(boot_block_buffer,0,512);
@@ -527,7 +527,7 @@ static void setup_tables(void) {
inode_map = malloc(imaps * MINIX_BLOCK_SIZE);
zone_map = malloc(zmaps * MINIX_BLOCK_SIZE);
if (!inode_map || !zone_map)
- err(MKFS_ERROR, _("%s: unable to allocate buffers for maps"),
+ err(MKFS_EX_ERROR, _("%s: unable to allocate buffers for maps"),
device_name);
memset(inode_map,0xff,imaps * MINIX_BLOCK_SIZE);
memset(zone_map,0xff,zmaps * MINIX_BLOCK_SIZE);
@@ -537,7 +537,7 @@ static void setup_tables(void) {
unmark_inode(i);
inode_buffer = malloc(get_inode_buffer_size());
if (!inode_buffer)
- err(MKFS_ERROR, _("%s: unable to allocate buffer for inodes"),
+ err(MKFS_EX_ERROR, _("%s: unable to allocate buffer for inodes"),
device_name);
memset(inode_buffer,0, get_inode_buffer_size());
printf(_("%lu inodes\n"), inodes);
@@ -557,7 +557,7 @@ static long do_check(char * buffer, int try, unsigned int current_block) {
/* Seek to the correct loc. */
if (lseek(DEV, current_block * MINIX_BLOCK_SIZE, SEEK_SET) !=
current_block * MINIX_BLOCK_SIZE )
- err(MKFS_ERROR, _("%s: seek failed during testing of blocks"),
+ err(MKFS_EX_ERROR, _("%s: seek failed during testing of blocks"),
device_name);
/* Try the read */
@@ -597,7 +597,7 @@ static void check_blocks(void) {
while (currently_testing < zones) {
if (lseek(DEV,currently_testing*MINIX_BLOCK_SIZE,SEEK_SET) !=
currently_testing*MINIX_BLOCK_SIZE)
- errx(MKFS_ERROR, _("%s: seek failed in check_blocks"),
+ errx(MKFS_EX_ERROR, _("%s: seek failed in check_blocks"),
device_name);
try = TEST_BUFFER_BLOCKS;
if (currently_testing + try > zones)
@@ -607,7 +607,7 @@ static void check_blocks(void) {
if (got == try)
continue;
if (currently_testing < first_zone)
- errx(MKFS_ERROR, _("%s: bad blocks before data-area: "
+ errx(MKFS_EX_ERROR, _("%s: bad blocks before data-area: "
"cannot make fs"), device_name);
mark_zone(currently_testing);
badblocks++;
@@ -625,13 +625,13 @@ static void get_list_blocks(char *filename) {
listfile = fopen(filename,"r");
if (listfile == NULL)
- err(MKFS_ERROR, _("%s: can't open file of bad blocks"),
+ err(MKFS_EX_ERROR, _("%s: can't open file of bad blocks"),
device_name);
while (!feof(listfile)) {
if (fscanf(listfile,"%ld\n", &blockno) != 1) {
printf(_("badblock number input error on line %d\n"), badblocks + 1);
- errx(MKFS_ERROR, _("%s: cannot read badblocks file"),
+ errx(MKFS_EX_ERROR, _("%s: cannot read badblocks file"),
device_name);
}
mark_zone(blockno);
@@ -668,9 +668,9 @@ int main(int argc, char ** argv) {
}
if (INODE_SIZE * MINIX_INODES_PER_BLOCK != MINIX_BLOCK_SIZE)
- errx(MKFS_ERROR, _("%s: bad inode size"), device_name);
+ errx(MKFS_EX_ERROR, _("%s: bad inode size"), device_name);
if (INODE2_SIZE * MINIX2_INODES_PER_BLOCK != MINIX_BLOCK_SIZE)
- errx(MKFS_ERROR, _("%s: bad inode size"), device_name);
+ errx(MKFS_EX_ERROR, _("%s: bad inode size"), device_name);
opterr = 0;
while ((i = getopt(argc, argv, "ci:l:n:v123")) != -1)
@@ -750,14 +750,14 @@ int main(int argc, char ** argv) {
strcpy(tmp+2, ".badblocks");
}
if (stat(device_name, &statbuf) < 0)
- err(MKFS_ERROR, _("%s: stat failed"), device_name);
+ err(MKFS_EX_ERROR, _("%s: stat failed"), device_name);
if (S_ISBLK(statbuf.st_mode))
DEV = open(device_name,O_RDWR | O_EXCL);
else
DEV = open(device_name,O_RDWR);
if (DEV<0)
- err(MKFS_ERROR, _("%s: open failed"), device_name);
+ err(MKFS_EX_ERROR, _("%s: open failed"), device_name);
if (S_ISBLK(statbuf.st_mode)) {
int sectorsize;
@@ -769,11 +769,11 @@ int main(int argc, char ** argv) {
warnx(_("%s: device is misaligned"), device_name);
if (MINIX_BLOCK_SIZE < sectorsize)
- errx(MKFS_ERROR, _("block size smaller than physical "
+ errx(MKFS_EX_ERROR, _("block size smaller than physical "
"sector size of %s"), device_name);
if (!BLOCKS) {
if (blkdev_get_size(DEV, &BLOCKS) == -1)
- errx(MKFS_ERROR, _("cannot determine size of %s"),
+ errx(MKFS_EX_ERROR, _("cannot determine size of %s"),
device_name);
BLOCKS /= MINIX_BLOCK_SIZE;
}
@@ -782,9 +782,9 @@ int main(int argc, char ** argv) {
BLOCKS = statbuf.st_size / MINIX_BLOCK_SIZE;
check=0;
} else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
- errx(MKFS_ERROR, _("will not try to make filesystem on '%s'"), device_name);
+ errx(MKFS_EX_ERROR, _("will not try to make filesystem on '%s'"), device_name);
if (BLOCKS < 10)
- errx(MKFS_ERROR, _("%s: number of blocks too small"), device_name);
+ errx(MKFS_EX_ERROR, _("%s: number of blocks too small"), device_name);
if (fs_version == 3)
magic = MINIX3_SUPER_MAGIC;
diff --git a/include/exitcodes.h b/include/exitcodes.h
index ec73aca1f..24ee12364 100644
--- a/include/exitcodes.h
+++ b/include/exitcodes.h
@@ -1,22 +1,28 @@
#ifndef UTIL_LINUX_EXITCODES_H
#define UTIL_LINUX_EXITCODES_H
+/*
+ * BE CAREFUL
+ *
+ * These exit codes are part of the official interface for mount,
+ * fsck, mkfs, etc. wrappers.
+ */
/* Exit codes used by mkfs-type programs */
-#define MKFS_OK 0 /* No errors */
-#define MKFS_ERROR 8 /* Operational error */
-#define MKFS_USAGE 16 /* Usage or syntax error */
+#define MKFS_EX_OK 0 /* No errors */
+#define MKFS_EX_ERROR 8 /* Operational error */
+#define MKFS_EX_USAGE 16 /* Usage or syntax error */
/* Exit codes used by fsck-type programs */
-#define FSCK_OK 0 /* No errors */
-#define FSCK_NONDESTRUCT 1 /* File system errors corrected */
-#define FSCK_REBOOT 2 /* System should be rebooted */
-#define FSCK_DESTRUCT FSCK_REBOOT /* Alias */
-#define FSCK_UNCORRECTED 4 /* File system errors left uncorrected */
-#define FSCK_ERROR 8 /* Operational error */
-#define FSCK_USAGE 16 /* Usage or syntax error */
-#define FSCK_LIBRARY 128 /* Shared library error */
+#define FSCK_EX_OK 0 /* No errors */
+#define FSCK_EX_NONDESTRUCT 1 /* File system errors corrected */
+#define FSCK_EX_REBOOT 2 /* System should be rebooted */
+#define FSCK_EX_DESTRUCT FSCK_EX_REBOOT /* Alias */
+#define FSCK_EX_UNCORRECTED 4 /* File system errors left uncorrected */
+#define FSCK_EX_ERROR 8 /* Operational error */
+#define FSCK_EX_USAGE 16 /* Usage or syntax error */
+#define FSCK_EX_LIBRARY 128 /* Shared library error */
-/* exit status */
+/* Exit codes used by mount-line programs */
#define MOUNT_EX_SUCCESS 0 /* No errors */
#define MOUNT_EX_USAGE 1 /* incorrect invocation or permission */
#define MOUNT_EX_SYSERR 2 /* out of memory, cannot fork, ... */
@@ -26,6 +32,4 @@
#define MOUNT_EX_FAIL 32 /* mount failure */
#define MOUNT_EX_SOMEOK 64 /* some mount succeeded */
-
-
#endif /* UTIL_LINUX_EXITCODES_H */