Ejemplo n.º 1
0
/*
 * Return the offset of the root directory,
 * or 0 if none.
 */
static struct cramfs_inode *read_super(void)
{
	unsigned long offset;

	offset = super->root.offset << 2;
	if (super->magic != CRAMFS_MAGIC)
		return NULL;
	if (memcmp(super->signature, CRAMFS_SIGNATURE, sizeof(super->signature)) != 0)
		return NULL;
	if (offset < sizeof(super))
		return NULL;
	return cramfs_iget(&super->root);
}
Ejemplo n.º 2
0
/*
 * Return the offset of the root directory
 */
static struct cramfs_inode *read_super(void)
{
	struct cramfs_inode *root = cramfs_iget(&super.root);
	unsigned long offset = root->offset << 2;

	if (!S_ISDIR(root->mode))
		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_EX_UNCORRECTED, _("bad root offset (%lu)"), offset);
	}
	return root;
}
Ejemplo n.º 3
0
/*
 * Return the offset of the root directory
 */
static struct cramfs_inode *read_super(void)
{
	unsigned long offset = super.root.offset << 2;

	if (!S_ISDIR(super.root.mode))
		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);
	}
	return cramfs_iget(&super.root);
}
static void test_fs(int start)
{
    struct cramfs_inode *root;
    unsigned long root_offset;

    root = cramfs_iget(&super.root);
    root_offset = root->offset << 2;
    if (!S_ISDIR(root->mode))
        die(FSCK_UNCORRECTED, 0, "root inode is not directory");
    if (!(super.flags & CRAMFS_FLAG_SHIFTED_ROOT_OFFSET) &&
            ((root_offset != sizeof(struct cramfs_super)) &&
             (root_offset != PAD_SIZE + sizeof(struct cramfs_super))))
    {
        die(FSCK_UNCORRECTED, 0, "bad root offset (%lu)", root_offset);
    }
    umask(0);
    euid = geteuid();
    stream.next_in = NULL;
    stream.avail_in = 0;
    inflateInit(&stream);
    expand_fs(extract_dir, root);
    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);
        }
        if (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");
        }
    }
    iput(root);		/* free(root) */
}
Ejemplo n.º 5
0
static struct cramfs_inode *iget(unsigned int ino)
{
	return cramfs_iget(romfs_read(ino));
}