void *t = malloc(size);
if (t == NULL) {
perror(NULL);
- exit(8); /* out of memory */
+ exit(MKFS_ERROR); /* out of memory */
}
return t;
}
start = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
if (-1 == (int) (long) start) {
perror("mmap");
- exit(8);
+ exit(MKFS_ERROR);
}
close(fd);
if (dircount < 0) {
perror(name);
- exit(8);
+ exit(MKFS_ERROR);
}
/* process directory */
" Please increase MAX_INPUT_NAMELEN in "
"mkcramfs.c and recompile. Exiting.\n"),
namelen, dirent->d_name);
- exit(8);
+ exit(MKFS_ERROR);
}
memcpy(endpath, dirent->d_name, namelen + 1);
entry = calloc(1, sizeof(struct entry));
if (!entry) {
perror(NULL);
- exit(8);
+ exit(MKFS_ERROR);
}
entry->name = (unsigned char *)strdup(dirent->d_name);
if (!entry->name) {
perror(NULL);
- exit(8);
+ exit(MKFS_ERROR);
}
if (namelen > 255) {
/* Can't happen when reading from ext2fs. */
inode_to_host(cramfs_is_big_endian, inode, inode);
if (offset >= (1 << (2 + CRAMFS_OFFSET_WIDTH))) {
fprintf(stderr, _("filesystem too big. Exiting.\n"));
- exit(8);
+ exit(MKFS_ERROR);
}
inode->offset = (offset >> 2);
inode_from_host(cramfs_is_big_endian, inode, inode);
entry_stack = realloc(entry_stack, stack_size * sizeof(struct entry *));
if (!entry_stack) {
perror(NULL);
- exit(8); /* out of memory */
+ exit(MKFS_ERROR); /* out of memory */
}
}
entry_stack[stack_entries] = entry;
printf(_("AIEEE: block \"compressed\" to > "
"2*blocklength (%ld)\n"),
len);
- exit(8);
+ exit(MKFS_ERROR);
}
*(u32 *) (base + offset) = u32_toggle_endianness(cramfs_is_big_endian, curr);
fd = open(file, O_RDONLY);
if (fd < 0) {
perror(file);
- exit(8);
+ exit(MKFS_ERROR);
}
buf = mmap(NULL, image_length, PROT_READ, MAP_PRIVATE, fd, 0);
memcpy(base + offset, buf, image_length);
else if (strcmp(optarg, "host") == 0); /* default */
else {
perror("invalid endianness given. Must be 'big', 'little', or 'host'");
- exit(16);
+ exit(MKFS_USAGE);
}
break;
opt_image = optarg;
if (lstat(opt_image, &st) < 0) {
perror(opt_image);
- exit(16);
+ exit(MKFS_USAGE);
}
image_length = st.st_size; /* may be padded later */
fslen_ub += (image_length + 3); /* 3 is for padding */
case 'V':
printf(_("%s (%s)\n"),
progname, PACKAGE_STRING);
- exit(0);
+ exit(MKFS_OK);
case 'v':
verbose = 1;
break;
if (stat(dirname, &st) < 0) {
perror(dirname);
- exit(16);
+ exit(MKFS_USAGE);
}
fd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
root_entry = calloc(1, sizeof(struct entry));
if (!root_entry) {
perror(NULL);
- exit(8);
+ exit(MKFS_ERROR);
}
root_entry->mode = st.st_mode;
root_entry->uid = st.st_uid;
if (-1 == (int) (long) rom_image) {
perror(_("ROM image map"));
- exit(8);
+ exit(MKFS_ERROR);
}
/* Skip the first opt_pad bytes for boot loader code */
_("not enough space allocated for ROM image "
"(%lld allocated, %zu used)\n"),
(long long) fslen_ub, offset);
- exit(8);
+ exit(MKFS_ERROR);
}
written = write(fd, rom_image, offset);
if (written < 0) {
perror(_("ROM image"));
- exit(8);
+ exit(MKFS_ERROR);
}
if (offset != written) {
fprintf(stderr, _("ROM image write failed (%zd %zd)\n"),
written, offset);
- exit(8);
+ exit(MKFS_ERROR);
}
/* (These warnings used to come at the start, but they scroll off the
CRAMFS_OFFSET_WIDTH);
if (opt_errors &&
(warn_namelen|warn_skip|warn_size|warn_uid|warn_gid|warn_dev))
- exit(8);
+ exit(MKFS_ERROR);
return 0;
}