Backport of squashfs-2.6.29+ (squashfs-4.0) to kernel 2.6.27



Below are two diffs for squashfs-4 (as found in 2.6.29
and 2.6.30 kernels) to kernel 2.6.27.

In order to build, grab fs/squashfs directory from 2.6.29 or
2.6.30 (or maybe later version), copy it to fs/squashfs in
2.6.27 tree, and apply 2 provided patches.

First (squashfs-2.6.29-to-.27-backport.diff) changes squashfs
itself to be compatible with kernel 2.6.27 API (namely, adding
magic number definition and implementing d_obtain_alias() which
is missing in 2.6.27.

And second changes 2.6.27 build infrastructure to actually
include squashfs filesystem -- init/do_mounts_rd.c, fs/Kconfig
and fs/Makefile.

JFYI, in case it will be useful to someone.

What I use it for is -- since 2.6.29+ does not work with version
3 of the filesystem layout, and 2.6.28- only recognizes v.3, and
since I'm tired updating kernels on all supported machines, I want
to stop for some time, relying on 2.6.27.y stable series. But we
also use squashfs and some machines requires more modern kernel
features. So I thought about updating squashfs to v4 on all.
So here it goes.

Thanks.

/mjt --- linux-2.6.29/fs/squashfs/export.c 2009-06-10 07:05:27 +0400
+++ linux-2.6.27/fs/squashfs/export.c 2009-06-19 18:07:55 +0400
@@ -76,14 +76,30 @@ static struct dentry *squashfs_export_ig
unsigned int ino_num)
{
long long ino;
- struct dentry *dentry = ERR_PTR(-ENOENT);
+ struct dentry *dentry;
+ struct inode *i;

TRACE("Entered squashfs_export_iget\n");

ino = squashfs_inode_lookup(sb, ino_num);
- if (ino >= 0)
- dentry = d_obtain_alias(squashfs_iget(sb, ino, ino_num));
+ if (ino < 0) {
+ dentry = ERR_PTR(-ENOENT);
+ goto failure;
+ }
+
+ i = squashfs_iget(sb, ino, ino_num);
+ if (i == NULL) {
+ dentry = ERR_PTR(-EACCES);
+ goto failure;
+ }
+
+ dentry = d_alloc_anon(i);
+ if (dentry == NULL) {
+ iput(i);
+ dentry = ERR_PTR(-ENOMEM);
+ }

+failure:
return dentry;
}

--- linux-2.6.29/fs/squashfs/squashfs_fs.h 2009-06-10 07:05:27 +0400
+++ linux-2.6.27/fs/squashfs/squashfs_fs.h 2009-06-19 18:07:55 +0400
@@ -23,6 +23,8 @@
* squashfs_fs.h
*/

+#define SQUASHFS_MAGIC 0x73717368
+
#define SQUASHFS_CACHED_FRAGMENTS CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE
#define SQUASHFS_MAJOR 4
#define SQUASHFS_MINOR 0
--- linux-2.6.27.orig/fs/Kconfig 2008-10-10 02:13:53 +0400
+++ linux-2.6.27.squash/fs/Kconfig 2009-06-19 17:57:16 +0400
@@ -1350,2 +1350,4 @@ config CRAMFS

+source "fs/squashfs/Kconfig"
+
config VXFS_FS
--- linux-2.6.27.orig/fs/Makefile 2008-10-10 02:13:53 +0400
+++ linux-2.6.27.squash/fs/Makefile 2009-06-19 17:56:02 +0400
@@ -76,2 +76,3 @@ obj-$(CONFIG_EXT2_FS) += ext2/
obj-$(CONFIG_CRAMFS) += cramfs/
+obj-$(CONFIG_SQUASHFS) += squashfs/
obj-y += ramfs/
--- linux-2.6.27.orig/init/do_mounts_rd.c 2008-10-10 02:13:53 +0400
+++ linux-2.6.27.squash/init/do_mounts_rd.c 2009-06-19 17:53:22 +0400
@@ -11,2 +11,3 @@
#include "do_mounts.h"
+#include "../fs/squashfs/squashfs_fs.h"

@@ -43,2 +44,3 @@ static int __init crd_load(int in_fd, in
* cramfs
+ * squashfs
* gzip
@@ -53,2 +55,3 @@ identify_ramdisk_image(int fd, int start
struct cramfs_super *cramfsb;
+ struct squashfs_super_block *squashfsb;
int nblocks = -1;
@@ -64,2 +67,3 @@ identify_ramdisk_image(int fd, int start
cramfsb = (struct cramfs_super *) buf;
+ squashfsb = (struct squashfs_super_block *) buf;
memset(buf, 0xe5, size);
@@ -101,2 +105,12 @@ identify_ramdisk_image(int fd, int start

+ /* squashfs is at block zero too */
+ if (le32_to_cpu(squashfsb->s_magic) == SQUASHFS_MAGIC) {
+ printk(KERN_NOTICE
+ "RAMDISK: squashfs filesystem found at block %d\n",
+ start_block);
+ nblocks = (le64_to_cpu(squashfsb->bytes_used) + BLOCK_SIZE - 1)
+ >> BLOCK_SIZE_BITS;
+ goto done;
+ }
+
/*


Relevant Pages

  • squashfs + devfs root device problem
    ... In an earlier post some days ago I mentioned that I had a compressed ext2 image which I used as an initrd root disk, and which I'd like to convert so that it is a SquashFS image. ... So I've patched my kernel to include SquashFS and I've built the tool to generate the image and link it into my kernel in the same way. ... it does not work and I cannot figure out whether the problem is being caused by devfs or squashfs. ...
    (comp.os.linux.embedded)
  • Re: [PATCH][2/2] SquashFS
    ... Sorry but I'm not calling Squashfs "limited" and I don't think it is. ... If you wanted to nit-pick many of the current filesystems in the kernel ... Your comment about not wanting more than one compressed filesystem in ... As for your comment about "proving good incentive to make those limits ...
    (Linux-Kernel)
  • Re: [ANN] Squashfs 3.3 released
    ... With the rate of new kernel releases this wasn't really acceptable because the January release was stuck with a patch for kernels no newer than 2.6.20. ... Some of you may be aware that I started work at Canonical, and this left almost no spare-time to work on Squashfs for 9 months. ... Unfortunately the move to fixed little endian filesystem will involve another filesystem layout change. ... The current filesystem layout still uses packed bitfield structures, and it is impossible to swap these using the standard kernel swap macros. ...
    (Linux-Kernel)
  • Re: [ANN] Squashfs 3.3 released
    ... Linux kernel again. ... I don't know of any major distro that doesn't ship Squashfs either ... along the lines of "my Fedora 7 kernel can't unpack squashfs images ...
    (Linux-Kernel)
  • Re: [Announce] Squashfs 2.1 released (compressed filesystem)
    ... >>I'm pleased to announce the release of Squashfs 2.1. ... > Are you going to submit this fs for inclusion in the main kernel tree? ... > I'm getting tired of maintaining it as part of the Gentoo kernel patch ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)