--- zzzz-none-000/linux-5.4.213/fs/squashfs/super.c 2022-09-15 10:04:56.000000000 +0000 +++ miami-7690-761/linux-5.4.213/fs/squashfs/super.c 2024-05-29 11:20:02.000000000 +0000 @@ -26,6 +26,9 @@ #include #include #include +#include +#include +#include #include "squashfs_fs.h" #include "squashfs_fs_sb.h" @@ -101,7 +104,8 @@ if (IS_ERR(sblk)) { errorf(fc, "unable to read squashfs_super_block"); - err = PTR_ERR(sblk); + /*--- err = PTR_ERR(sblk); ---*//*--- JZ-27891 mit err = -EIO wird kein anderes FS mehr gemountet ---*/ + err = -EINVAL; sblk = NULL; goto failed_mount; } @@ -130,8 +134,11 @@ block device */ msblk->bytes_used = le64_to_cpu(sblk->bytes_used); if (msblk->bytes_used < 0 || msblk->bytes_used > - i_size_read(sb->s_bdev->bd_inode)) + i_size_read(sb->s_bdev->bd_inode)){ + pr_err("SQFS-Size %llu is to big for given device size %llu. Is mtdram1 too small?\n", + msblk->bytes_used, i_size_read(sb->s_bdev->bd_inode)); goto failed_mount; + } /* Check block size for sanity */ msblk->block_size = le32_to_cpu(sblk->block_size); @@ -343,8 +350,44 @@ return err; } +/* copy from init/do_mounts.h */ +static inline int create_dev(char *name, dev_t dev) +{ + ksys_unlink(name); + return ksys_mknod(name, S_IFBLK|0600, new_encode_dev(dev)); +} + +static void squashfs_mount(struct fs_context *fc) +{ + if (!strncmp(fc->source, "mtd:", 4) || !strncmp(fc->source, "ubi:", 4)) { + struct mtd_info *mtd = get_mtd_device_nm("ubi_rootfs"); + + if (!IS_ERR(mtd)) { + void *bdev; + char *dev; + dev = kmalloc(32, GFP_KERNEL); + + scnprintf(dev, 32, "/dev/mtdblock%d", mtd->index); + bdev = blkdev_get_by_path(dev, FMODE_READ, fc->fs_type); + + if (!IS_ERR(bdev)) { + kfree(fc->source); + fc->source = dev; + } else if (PTR_ERR(bdev) == -ENOENT) { + create_dev(dev, + MKDEV(MTD_BLOCK_MAJOR, mtd->index)); + kfree(fc->source); + fc->source = dev; + } else + kfree(dev); + } + } + +} + static int squashfs_get_tree(struct fs_context *fc) { + squashfs_mount(fc); return get_tree_bdev(fc, squashfs_fill_super); }