LTRData / DiscUtils

Utility libraries to interact with discs, filesystem formats and more
MIT License
111 stars 24 forks source link

Using LZO in `SquashFileSystemReader` #19

Open ww898 opened 1 week ago

ww898 commented 1 week ago

Hi @LTRData, this is the answer on your message https://github.com/DiscUtils/DiscUtils/issues/302#issuecomment-2410665848

I have just tried LTRData.DiscUtils.SquashFs v1.0.47 with lzo.net v0.0.6:

using var fsReader = new SquashFileSystemReader(fsStream, new SquashFileSystemReaderOptions
            {
                GetDecompressor = (kind, options) => kind switch
                {
                SquashFileSystemCompressionKind.Lzo => stream => new SeekableLzoStream(stream, CompressionMode.Decompress),
                _ => null
                }
            });

but unfortunately failed with exception:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
   at DiscUtils.SquashFs.MetablockReader.Read(Span`1 buffer)
   at DiscUtils.SquashFs.Inode.Read(MetablockReader inodeReader)
   at DiscUtils.SquashFs.VfsSquashFileSystemReader..ctor(Stream stream, SquashFileSystemReaderOptions options)
   at DiscUtils.SquashFs.SquashFileSystemReader..ctor(Stream data, SquashFileSystemReaderOptions options)

Could you please help me?

LTRData commented 1 week ago

I am not entire sure. But looking at the tests for this, it looks like it is supposed to be used in a slightly different way: https://github.com/LTRData/DiscUtils/blob/27fc75729dd47925771ec25bc67407053d9f080e/Tests/LibraryTests/SquashFs/SquashFileSystemBuilderTest.cs#L200

ww898 commented 1 week ago

Tried many different variants, but got the same exception. Could you please add test in your fork for LZO compression?

LTRData commented 1 week ago

Yes sure, I'll take a look at it!

LTRData commented 1 week ago

I just built an LZO compressed squashfs file system with one file and tried to decompress it using lzo.net in a similar way as you tested here. I also get some strange exception, but in my case somewhere within lzo.net library. I am not really familiar with that library, but I'll try to see if we somehow feed it with something that it does not expect. I have a bit limited time though, so it could take some time until I could look deeper into this.