mbox series

[0/4] mtd-utils: adding support for lzma in jffs2reader via liblzma

Message ID 20211109081751.480718-1-frederic.germain@gmail.com
Headers show
Series mtd-utils: adding support for lzma in jffs2reader via liblzma | expand

Message

Frederic Germain Nov. 9, 2021, 8:17 a.m. UTC
Hi,

This is my first time sending patch, I probably do some things wrong somewhere.

A while ago I, unfortunately, removed a file from my gl-inet 4g openwrt router.
That file is on a jffs2 partition, with LZMA compression.

LZMA support on OpenWRT is activated via a patch which seems never made it to the mainline : jffs2_make_lzma_available.patch.  There might be a problem with the jffs2 integration of LZMA, if it was not integrated into the kernel? The filesystem support should probably be first integrated in the main kernel before these patch in the user tools...

I think openwrt/LEDE is a big use case for jffs2, with maybe a lot of them with LZMA supports (I'm cannot say how much though...)
So it would be cool to have this integrated so people can recover the files they lost.

There are two opensource LZMA libraries that I found on Ubuntu 20.04...
- The source SDK from https://www.7-zip.org/sdk.html . On ubuntu, it's in the p7zip source package, which provides p7zip & p7zip-full package. p7zip-full provides a library, /usr/lib/p7zip/7z.so, but it's not integrated the Linux/GNU way...
- liblzma: from https://tukaani.org/xz/, which integrates an older version of the LZMA SDK provided by www.7-zip.org, but on a standard Linux/GNU library.

It seems LEDE already has patches for mtd-utils, but it seems they integrate source files from www.7-zip.org in a static way.
https://patchwork.ozlabs.org/project/lede/patch/20180330145639.15824-1-hauke@hauke-m.de/

I have to fiddle around to integrate with liblzma, as the low-level decoder is not exposed, but I got help from the XZ project author  https://sourceforge.net/p/lzmautils/discussion/708858/thread/d02ebb9386/

I pushed the patches on https://github.com/fredericgermain/mtd-utils too, main branch. It might just help some people to recover their file anyway.

---
There is also a problem that jffs2reader selects the earliest version of an inode instead of the latest? I've made a patch to take the latest one with data. But I still needed to patch the mtd dump to remove the DIRENT entry that remove the file from the FS. 

Maybe it would be nice that jffs2reader takes inode/version of the file to dump instead of a path? It's easy to get these parameters with jffs2dump.

Best regards,

Frederic Germain (4):
  .gitignore: add new ubiscan utility
  Fix warning about unaligned pointer in jffs2reader
  jffsX-utils: add lzma support on jffs2reader
  find_raw_inode returns latest version with data of inode

 .gitignore                |  1 +
 Makefile.am               |  4 +++
 configure.ac              | 24 +++++++++++++++
 include/linux/jffs2.h     |  2 ++
 include/mtd/jffs2-user.h  |  1 +
 jffsX-utils/Makemodule.am |  2 +-
 jffsX-utils/jffs2reader.c | 63 ++++++++++++++++++++++++++++++++++-----
 7 files changed, 88 insertions(+), 9 deletions(-)