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