From 4419f458ee65c8facffc16a5a5d888cefb43e5d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D0=BD=D1=8C=D0=BA=D0=B8=D0=BD=20=D0=90=D0=BB?= =?UTF-8?q?=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Wed, 14 Sep 2022 12:29:44 +0300 Subject: [PATCH] Removed debug messages from squashfs builder, updated readme --- .../SquashFs/Builder/MetadataWriter.cs | 8 +++--- NyaFs/Filesystem/SquashFs/SquashFsBuilder.cs | 26 +++++++++---------- readme.md | 19 +++++++++++--- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/NyaFs/Filesystem/SquashFs/Builder/MetadataWriter.cs b/NyaFs/Filesystem/SquashFs/Builder/MetadataWriter.cs index 68b5cda..9314e7e 100644 --- a/NyaFs/Filesystem/SquashFs/Builder/MetadataWriter.cs +++ b/NyaFs/Filesystem/SquashFs/Builder/MetadataWriter.cs @@ -62,8 +62,8 @@ private void CheckFilled() { var Data = FullBlocks ? TempMetablock.FullData : TempMetablock.Data; var Compressed = CompressBlock(Data); - System.Diagnostics.Debug.WriteLine($"Metadata: {Dst.Count:x06} l {Compressed.Length:x04} ({Compressed.Length}): " + - $"{Compressed[0]:x02} {Compressed[1]:x02} {Compressed[2]:x02} {Compressed[3]:x02} unc:{Data.Length}"); // DEBUG + //System.Diagnostics.Debug.WriteLine($"Metadata: {Dst.Count:x06} l {Compressed.Length:x04} ({Compressed.Length}): " + + // $"{Compressed[0]:x02} {Compressed[1]:x02} {Compressed[2]:x02} {Compressed[3]:x02} unc:{Data.Length}"); // DEBUG Dst.AddRange(Compressed); TestCompressorData(Data, Compressed); @@ -131,8 +131,8 @@ public void Flush() var Data = FullBlocks ? TempMetablock.FullData : TempMetablock.Data; var Compressed = CompressBlock(Data); - System.Diagnostics.Debug.WriteLine($"Metadata Flush: {Dst.Count:x06} l {Compressed.Length:x04} ({Compressed.Length}): " + - $"{Compressed[0]:x02} {Compressed[1]:x02} {Compressed[2]:x02} {Compressed[3]:x02} unc:{Data.Length}"); // DEBUG + //System.Diagnostics.Debug.WriteLine($"Metadata Flush: {Dst.Count:x06} l {Compressed.Length:x04} ({Compressed.Length}): " + + // $"{Compressed[0]:x02} {Compressed[1]:x02} {Compressed[2]:x02} {Compressed[3]:x02} unc:{Data.Length}"); // DEBUG Dst.AddRange(Compressed); TestCompressorData(Data, Compressed); diff --git a/NyaFs/Filesystem/SquashFs/SquashFsBuilder.cs b/NyaFs/Filesystem/SquashFs/SquashFsBuilder.cs index cd1687f..92a3f02 100644 --- a/NyaFs/Filesystem/SquashFs/SquashFsBuilder.cs +++ b/NyaFs/Filesystem/SquashFs/SquashFsBuilder.cs @@ -239,7 +239,7 @@ private void PrepareFragmentTable() private void AppendFragmentTable(List Dst) { - System.Diagnostics.Debug.WriteLine($"AppendFragmentTable data: {Dst.Count:x06}"); + //System.Diagnostics.Debug.WriteLine($"AppendFragmentTable data: {Dst.Count:x06}"); // Write fragment tables list var Writer = new Builder.MetadataWriter(Dst, 0, MetadataBlockSize, Comp); @@ -253,7 +253,7 @@ private void AppendFragmentTable(List Dst) F.Start += FragmentDataStart; var FragmentRef = Writer.Write(F.getPacket()); - System.Diagnostics.Debug.WriteLine($"Fragment {i}: {F.Start:x08} size: {F.Size:x04}"); + //System.Diagnostics.Debug.WriteLine($"Fragment {i}: {F.Start:x08} size: {F.Size:x04}"); uint Pos = Convert.ToUInt32(Dst.Count); if (Pos != LastTable) { @@ -263,7 +263,7 @@ private void AppendFragmentTable(List Dst) } Writer.Flush(); - System.Diagnostics.Debug.WriteLine($"AppendFragmentTable table: {Dst.Count:x06}"); + //System.Diagnostics.Debug.WriteLine($"AppendFragmentTable table: {Dst.Count:x06}"); Superblock.FragmentTableStart = Convert.ToUInt64(Dst.Count); var Temp = new byte[8]; foreach (var T in FragmentTablesList) @@ -275,13 +275,13 @@ private void AppendFragmentTable(List Dst) private void AppendIdTable(List Dst) { - System.Diagnostics.Debug.WriteLine($"AppendIdTable data: {Dst.Count:x06}"); + //System.Diagnostics.Debug.WriteLine($"AppendIdTable data: {Dst.Count:x06}"); uint MdAddress = Convert.ToUInt32(Dst.Count); var Table = new Builder.IdTable(IdTable.ToArray()); Dst.AddRange(Table.Data); - System.Diagnostics.Debug.WriteLine($"AppendIdTable table: {Dst.Count:x06}"); + //System.Diagnostics.Debug.WriteLine($"AppendIdTable table: {Dst.Count:x06}"); Superblock.IdTableStart = Convert.ToUInt64(Dst.Count); byte[] Temp = new byte[8]; Temp.WriteUInt64(0, MdAddress); @@ -291,7 +291,7 @@ private void AppendIdTable(List Dst) private void AppendDirectoryTable(List Dst) { - System.Diagnostics.Debug.WriteLine($"AppendDirectoryTable data: {Dst.Count:x06}"); + //System.Diagnostics.Debug.WriteLine($"AppendDirectoryTable data: {Dst.Count:x06}"); Superblock.DirectoryTableStart = Convert.ToUInt64(Dst.Count); var Temp = new List(); @@ -309,7 +309,7 @@ private void AppendDirectoryTable(List Dst) Writer.Flush(); Dst.AddRange(Temp.ToArray()); - System.Diagnostics.Debug.WriteLine($"AppendDirectoryTable data end: {Dst.Count:x06}"); + //System.Diagnostics.Debug.WriteLine($"AppendDirectoryTable data end: {Dst.Count:x06}"); // Update dirs data refs foreach (var N in Nodes) @@ -324,7 +324,7 @@ private void AppendDirectoryTable(List Dst) DE.DirBlockStart = Convert.ToUInt32(D.EntriesRef.MetadataOffset); DE.BlockOffset = Convert.ToUInt32(D.EntriesRef.UnpackedOffset); - System.Diagnostics.Debug.WriteLine($"Directory node {N.Index} entry data: block={DE.DirBlockStart:x06} offset={DE.BlockOffset:x06}"); + //System.Diagnostics.Debug.WriteLine($"Directory node {N.Index} entry data: block={DE.DirBlockStart:x06} offset={DE.BlockOffset:x06}"); WriteUncompressedMetadata(Dst, Superblock.INodeTableStart, D.Ref, DE.getPacket()); } @@ -351,14 +351,14 @@ private void WriteUncompressedMetadata(List Dst, ulong Start, Builder.Meta private void AppendINodeTable(List Dst) { Superblock.INodeTableStart = Convert.ToUInt64(Dst.Count); - System.Diagnostics.Debug.WriteLine($"AppendINodeTable: {Dst.Count:x06}"); + //System.Diagnostics.Debug.WriteLine($"AppendINodeTable: {Dst.Count:x06}"); var Temp = new List(); Builder.MetadataWriter Writer = new Builder.MetadataWriter(Temp, 0, MetadataBlockSize, null); Writer.FullBlocks = true; for (int b = 0; b < NodesBlocks.Count; b++) { - System.Diagnostics.Debug.WriteLine($"Node block {b}: offset {Temp.Count:x06}"); + //System.Diagnostics.Debug.WriteLine($"Node block {b}: offset {Temp.Count:x06}"); var BNodes = NodesBlocks[b]; for (int i = 0; i < BNodes.Length; i++) { @@ -368,7 +368,7 @@ private void AppendINodeTable(List Dst) var Data = Node.getPacket(); BNodes[i].Ref = Writer.Write(Data); - System.Diagnostics.Debug.WriteLine($"Node {Node.INodeNumber}: offset {BNodes[i].Ref.MetadataOffset} unp: {BNodes[i].Ref.UnpackedOffset}"); + //System.Diagnostics.Debug.WriteLine($"Node {Node.INodeNumber}: offset {BNodes[i].Ref.MetadataOffset} unp: {BNodes[i].Ref.UnpackedOffset}"); } Writer.Flush(); @@ -380,7 +380,7 @@ private void AppendINodeTable(List Dst) private void AppendExportTable(List Dst) { - System.Diagnostics.Debug.WriteLine($"AppendExportTable data: {Dst.Count:x06}"); + //System.Diagnostics.Debug.WriteLine($"AppendExportTable data: {Dst.Count:x06}"); // Add export data [inode table] var Writer = new Builder.MetadataWriter(Dst, 0, 0x8000, Comp); @@ -400,7 +400,7 @@ private void AppendExportTable(List Dst) Writer.Flush(); - System.Diagnostics.Debug.WriteLine($"AppendExportTable table: {Dst.Count:x06}"); + //System.Diagnostics.Debug.WriteLine($"AppendExportTable table: {Dst.Count:x06}"); Superblock.ExportTableStart = Convert.ToUInt64(Dst.Count); byte[] Temp = new byte[8]; diff --git a/readme.md b/readme.md index 00eaa76..6912812 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,7 @@ There is possible to add or update files in ramfs image. Supported at now: 1. CPIO ASCII (RW) 2. EXT2 (RW) -3. SquashFs (R) +3. SquashFs (RW) ## Supported compression types Supported at now: @@ -22,7 +22,7 @@ Supported at now: 4. BZIP2 (RW) 5. XZ (R) 6. LZO (R) -7. ZStd (R) +7. ZStd (RW) LZMA compression is provided by LZMA SDK package. LZ4 compression is provided by FT.LZ4 package. @@ -156,6 +156,11 @@ store ramfs ``` (compression) is "gzip", "lz4", "lzma", "bzip2" +Store fs as squashfs image: +``` +store ramfs squashfs +``` + Store fs as ext2 image: ``` store ramfs ext2 @@ -199,7 +204,13 @@ Update filesystem type: ``` set ramfs filesystem ``` -(fs) is one of 'ext2' or 'cpio'. +(fs) is one of 'ext2', 'squashfs' or 'cpio'. + +Change squash compression type: +``` +set ramfs squashfs.compression +``` +(compression) is one of "gzip", "lzma", "lz4", "zstd" Update target OS for image: ``` @@ -226,7 +237,7 @@ Set compression type (for FIT/legacy): ``` set compression ``` -(compression) is "none", "gzip", "lzma", "lz4", "bzip2" +(compression) is "none", "gzip", "lzma", "lz4", "bzip2", "zstd" Set entry address (for kernel): ```