/* find the physical size of the file or block device */
if (stat(filename, &st) < 0) {
- die(FSCK_ERROR, 1, "stat failed: %s", filename);
+ die(FSCK_ERROR, 1, _("stat failed: %s"), filename);
}
fd = open(filename, O_RDONLY);
if (fd < 0) {
- die(FSCK_ERROR, 1, "open failed: %s", filename);
+ die(FSCK_ERROR, 1, _("open failed: %s"), filename);
}
if (S_ISBLK(st.st_mode)) {
unsigned long long bytes;
if (blkdev_get_size(fd, &bytes)) {
- die(FSCK_ERROR, 1, "ioctl failed: unable to determine device size: %s", filename);
+ die(FSCK_ERROR, 1, _("ioctl failed: unable to determine device size: %s"), filename);
}
*length = bytes;
}
*length = st.st_size;
}
else {
- die(FSCK_ERROR, 0, "not a block device or file: %s", filename);
+ die(FSCK_ERROR, 0, _("not a block device or file: %s"), filename);
}
if (*length < sizeof(struct cramfs_super)) {
- die(FSCK_UNCORRECTED, 0, "file length too short");
+ die(FSCK_UNCORRECTED, 0, _("file length too short"));
}
/* find superblock */
if (read(fd, &super, sizeof(super)) != sizeof(super)) {
- die(FSCK_ERROR, 1, "read failed: %s", filename);
+ die(FSCK_ERROR, 1, _("read failed: %s"), filename);
}
if (super.magic == CRAMFS_MAGIC) {
*start = 0;
else if (*length >= (PAD_SIZE + sizeof(super))) {
lseek(fd, PAD_SIZE, SEEK_SET);
if (read(fd, &super, sizeof(super)) != sizeof(super)) {
- die(FSCK_ERROR, 1, "read failed: %s", filename);
+ die(FSCK_ERROR, 1, _("read failed: %s"), filename);
}
if (super.magic == CRAMFS_MAGIC) {
*start = PAD_SIZE;
/* superblock tests */
if (super.magic != CRAMFS_MAGIC) {
- die(FSCK_UNCORRECTED, 0, "superblock magic not found");
+ die(FSCK_UNCORRECTED, 0, _("superblock magic not found"));
}
if (super.flags & ~CRAMFS_SUPPORTED_FLAGS) {
- die(FSCK_ERROR, 0, "unsupported filesystem features");
+ die(FSCK_ERROR, 0, _("unsupported filesystem features"));
}
if (super.size < page_size) {
- die(FSCK_UNCORRECTED, 0, "superblock size (%d) too small", super.size);
+ die(FSCK_UNCORRECTED, 0, _("superblock size (%d) too small"), super.size);
}
if (super.flags & CRAMFS_FLAG_FSID_VERSION_2) {
if (super.fsid.files == 0) {
- die(FSCK_UNCORRECTED, 0, "zero file count");
+ die(FSCK_UNCORRECTED, 0, _("zero file count"));
}
if (*length < super.size) {
- die(FSCK_UNCORRECTED, 0, "file length too short");
+ die(FSCK_UNCORRECTED, 0, _("file length too short"));
}
else if (*length > super.size) {
- fprintf(stderr, "warning: file extends past end of filesystem\n");
+ fprintf(stderr, _("warning: file extends past end of filesystem\n"));
}
}
else {
- fprintf(stderr, "warning: old cramfs format\n");
+ fprintf(stderr, _("warning: old cramfs format\n"));
}
}
#ifdef INCLUDE_FS_TESTS
return;
#else /* not INCLUDE_FS_TESTS */
- die(FSCK_USAGE, 0, "unable to test CRC: old cramfs format");
+ die(FSCK_USAGE, 0, _("unable to test CRC: old cramfs format"));
#endif /* not INCLUDE_FS_TESTS */
}
if (buf != MAP_FAILED) {
lseek(fd, 0, SEEK_SET);
if (read(fd, buf, super.size) < 0)
- die(FSCK_ERROR, 1, "read failed: %s", filename);
+ die(FSCK_ERROR, 1, _("read failed: %s"), filename);
}
}
if (buf != MAP_FAILED) {
buf = malloc(4096);
if (!buf) {
- die(FSCK_ERROR, 1, "malloc failed");
+ die(FSCK_ERROR, 1, _("malloc failed"));
}
lseek(fd, start, SEEK_SET);
for (;;) {
retval = read(fd, buf, 4096);
if (retval < 0) {
- die(FSCK_ERROR, 1, "read failed: %s", filename);
+ die(FSCK_ERROR, 1, _("read failed: %s"), filename);
}
else if (retval == 0) {
break;
}
if (crc != super.fsid.crc) {
- die(FSCK_UNCORRECTED, 0, "crc error");
+ die(FSCK_UNCORRECTED, 0, _("crc error"));
}
}
struct cramfs_inode *inode = malloc(sizeof(struct cramfs_inode));
if (!inode) {
- die(FSCK_ERROR, 1, "malloc failed");
+ die(FSCK_ERROR, 1, _("malloc failed"));
}
*inode = *i;
return inode;
unsigned long offset = super.root.offset << 2;
if (!S_ISDIR(super.root.mode))
- die(FSCK_UNCORRECTED, 0, "root inode is not directory");
+ die(FSCK_UNCORRECTED, 0, _("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))))
{
- die(FSCK_UNCORRECTED, 0, "bad root offset (%lu)", offset);
+ die(FSCK_UNCORRECTED, 0, _("bad root offset (%lu)"), offset);
}
return cramfs_iget(&super.root);
}
inflateReset(&stream);
if (len > page_size*2) {
- die(FSCK_UNCORRECTED, 0, "data block too large");
+ die(FSCK_UNCORRECTED, 0, _("data block too large"));
}
err = inflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
- die(FSCK_UNCORRECTED, 0, "decompression error %p(%d): %s",
+ die(FSCK_UNCORRECTED, 0, _("decompression error %p(%d): %s"),
zError(err), src, len);
}
return stream.total_out;
offset += 4;
if (curr == next) {
if (opt_verbose > 1) {
- printf(" hole at %ld (%d)\n", curr, page_size);
+ printf(_(" hole at %ld (%d)\n"), curr, page_size);
}
if (size < page_size)
out = size;
}
else {
if (opt_verbose > 1) {
- printf(" uncompressing block at %ld to %ld (%ld)\n", curr, next, next - curr);
+ printf(_(" uncompressing block at %ld to %ld (%ld)\n"), curr, next, next - curr);
}
out = uncompress_block(romfs_read(curr), next - curr);
}
if (size >= page_size) {
if (out != page_size) {
- die(FSCK_UNCORRECTED, 0, "non-block (%ld) bytes", out);
+ die(FSCK_UNCORRECTED, 0, _("non-block (%ld) bytes"), out);
}
} else {
if (out != size) {
- die(FSCK_UNCORRECTED, 0, "non-size (%ld vs %ld) bytes", out, size);
+ die(FSCK_UNCORRECTED, 0, _("non-size (%ld vs %ld) bytes"), out, size);
}
}
size -= out;
if (opt_extract) {
if (write(fd, outbuffer, out) < 0) {
- die(FSCK_ERROR, 1, "write failed: %s", path);
+ die(FSCK_ERROR, 1, _("write failed: %s"), path);
}
}
curr = next;
if (euid == 0) {
if (lchown(path, i->uid, i->gid) < 0) {
- die(FSCK_ERROR, 1, "lchown failed: %s", path);
+ die(FSCK_ERROR, 1, _("lchown failed: %s"), path);
}
if (S_ISLNK(i->mode))
return;
if ((S_ISUID | S_ISGID) & i->mode) {
if (chmod(path, i->mode) < 0) {
- die(FSCK_ERROR, 1, "chown failed: %s", path);
+ die(FSCK_ERROR, 1, _("chown failed: %s"), path);
}
}
}
if (S_ISLNK(i->mode))
return;
if (utime(path, &epoch) < 0) {
- die(FSCK_ERROR, 1, "utime failed: %s", path);
+ die(FSCK_ERROR, 1, _("utime failed: %s"), path);
}
}
char *newpath = malloc(pathlen + 256);
if (!newpath) {
- die(FSCK_ERROR, 1, "malloc failed");
+ die(FSCK_ERROR, 1, _("malloc failed"));
}
if (offset == 0 && count != 0) {
- die(FSCK_UNCORRECTED, 0, "directory inode has zero offset and non-zero size: %s", path);
+ die(FSCK_UNCORRECTED, 0, _("directory inode has zero offset and non-zero size: %s"), path);
}
if (offset != 0 && offset < start_dir) {
start_dir = offset;
}
if (opt_extract) {
if (mkdir(path, i->mode) < 0) {
- die(FSCK_ERROR, 1, "mkdir failed: %s", path);
+ die(FSCK_ERROR, 1, _("mkdir failed: %s"), path);
}
change_file_status(path, i);
}
memcpy(newpath + pathlen, romfs_read(offset), newlen);
newpath[pathlen + newlen] = 0;
if (newlen == 0) {
- die(FSCK_UNCORRECTED, 0, "filename length is zero");
+ die(FSCK_UNCORRECTED, 0, _("filename length is zero"));
}
if ((pathlen + newlen) - strlen(newpath) > 3) {
- die(FSCK_UNCORRECTED, 0, "bad filename length");
+ die(FSCK_UNCORRECTED, 0, _("bad filename length"));
}
expand_fs(newpath, child);
offset += newlen;
if (offset <= start_dir) {
- die(FSCK_UNCORRECTED, 0, "bad inode offset");
+ die(FSCK_UNCORRECTED, 0, _("bad inode offset"));
}
if (offset > end_dir) {
end_dir = offset;
int fd = 0;
if (offset == 0 && i->size != 0) {
- die(FSCK_UNCORRECTED, 0, "file inode has zero offset and non-zero size");
+ die(FSCK_UNCORRECTED, 0, _("file inode has zero offset and non-zero size"));
}
if (i->size == 0 && offset != 0) {
- die(FSCK_UNCORRECTED, 0, "file inode has zero size and non-zero offset");
+ die(FSCK_UNCORRECTED, 0, _("file inode has zero size and non-zero offset"));
}
if (offset != 0 && offset < start_data) {
start_data = offset;
if (opt_extract) {
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, i->mode);
if (fd < 0) {
- die(FSCK_ERROR, 1, "open failed: %s", path);
+ die(FSCK_ERROR, 1, _("open failed: %s"), path);
}
}
if (i->size) {
unsigned long size;
if (offset == 0) {
- die(FSCK_UNCORRECTED, 0, "symbolic link has zero offset");
+ die(FSCK_UNCORRECTED, 0, _("symbolic link has zero offset"));
}
if (i->size == 0) {
- die(FSCK_UNCORRECTED, 0, "symbolic link has zero size");
+ die(FSCK_UNCORRECTED, 0, _("symbolic link has zero size"));
}
if (offset < start_data) {
size = uncompress_block(romfs_read(curr), next - curr);
if (size != i->size) {
- die(FSCK_UNCORRECTED, 0, "size error in symlink: %s", path);
+ die(FSCK_UNCORRECTED, 0, _("size error in symlink: %s"), path);
}
outbuffer[size] = 0;
if (opt_verbose) {
asprintf(&str, "%s -> %s", path, outbuffer);
print_node('l', i, str);
if (opt_verbose > 1) {
- printf(" uncompressing block at %ld to %ld (%ld)\n", curr, next, next - curr);
+ printf(_(" uncompressing block at %ld to %ld (%ld)\n"), curr, next, next - curr);
}
free(str);
}
if (opt_extract) {
if (symlink(outbuffer, path) < 0) {
- die(FSCK_ERROR, 1, "symlink failed: %s", path);
+ die(FSCK_ERROR, 1, _("symlink failed: %s"), path);
}
change_file_status(path, i);
}
char type;
if (i->offset) { /* no need to shift offset */
- die(FSCK_UNCORRECTED, 0, "special file has non-zero offset: %s", path);
+ die(FSCK_UNCORRECTED, 0, _("special file has non-zero offset: %s"), path);
}
if (S_ISCHR(i->mode)) {
devtype = i->size;
}
else if (S_ISFIFO(i->mode)) {
if (i->size != 0) {
- die(FSCK_UNCORRECTED, 0, "fifo has non-zero size: %s", path);
+ die(FSCK_UNCORRECTED, 0, _("fifo has non-zero size: %s"), path);
}
type = 'p';
}
else if (S_ISSOCK(i->mode)) {
if (i->size != 0) {
- die(FSCK_UNCORRECTED, 0, "socket has non-zero size: %s", path);
+ die(FSCK_UNCORRECTED, 0, _("socket has non-zero size: %s"), path);
}
type = 's';
}
else {
- die(FSCK_UNCORRECTED, 0, "bogus mode: %s (%o)", path, i->mode);
+ die(FSCK_UNCORRECTED, 0, _("bogus mode: %s (%o)"), path, i->mode);
return; /* not reached */
}
if (opt_extract) {
if (mknod(path, i->mode, devtype) < 0) {
- die(FSCK_ERROR, 1, "mknod failed: %s", path);
+ die(FSCK_ERROR, 1, _("mknod failed: %s"), path);
}
change_file_status(path, i);
}
inflateEnd(&stream);
if (start_data != ~0UL) {
if (start_data < (sizeof(struct cramfs_super) + start)) {
- die(FSCK_UNCORRECTED, 0, "directory data start (%ld) < sizeof(struct cramfs_super) + start (%ld)", start_data, sizeof(struct cramfs_super) + start);
+ die(FSCK_UNCORRECTED, 0, _("directory data start (%ld) < sizeof(struct cramfs_super) + start (%ld)"), start_data, sizeof(struct cramfs_super) + start);
}
if (end_dir != start_data) {
- die(FSCK_UNCORRECTED, 0, "directory data end (%ld) != file data start (%ld)", end_dir, start_data);
+ die(FSCK_UNCORRECTED, 0, _("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) {
- die(FSCK_UNCORRECTED, 0, "invalid file data offset");
+ die(FSCK_UNCORRECTED, 0, _("invalid file data offset"));
}
}
iput(root); /* free(root) */
int start = 0;
size_t length = 0;
+ setlocale(LC_MESSAGES, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
page_size = getpagesize();
if (argc)
outbuffer = malloc(page_size * 2);
if (!outbuffer)
- die(FSCK_ERROR, 1, "failed to allocate outbuffer");
+ die(FSCK_ERROR, 1, _("failed to allocate outbuffer"));
/* command line options */
while ((c = getopt(argc, argv, "hx:v")) != EOF) {
extract_dir = optarg;
break;
#else /* not INCLUDE_FS_TESTS */
- die(FSCK_USAGE, 0, "compiled without -x support");
+ die(FSCK_USAGE, 0, _("compiled without -x support"));
#endif /* not INCLUDE_FS_TESTS */
case 'v':
opt_verbose++;