Skip to content

Commit

Permalink
Removed debug messages from squashfs builder, updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
teplofizik committed Sep 14, 2022
1 parent 3dc7d12 commit 4419f45
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
8 changes: 4 additions & 4 deletions NyaFs/Filesystem/SquashFs/Builder/MetadataWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
26 changes: 13 additions & 13 deletions NyaFs/Filesystem/SquashFs/SquashFsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private void PrepareFragmentTable()

private void AppendFragmentTable(List<byte> 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);
Expand All @@ -253,7 +253,7 @@ private void AppendFragmentTable(List<byte> 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)
{
Expand All @@ -263,7 +263,7 @@ private void AppendFragmentTable(List<byte> 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)
Expand All @@ -275,13 +275,13 @@ private void AppendFragmentTable(List<byte> Dst)

private void AppendIdTable(List<byte> 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);
Expand All @@ -291,7 +291,7 @@ private void AppendIdTable(List<byte> Dst)

private void AppendDirectoryTable(List<byte> 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<byte>();
Expand All @@ -309,7 +309,7 @@ private void AppendDirectoryTable(List<byte> 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)
Expand All @@ -324,7 +324,7 @@ private void AppendDirectoryTable(List<byte> 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());
}
Expand All @@ -351,14 +351,14 @@ private void WriteUncompressedMetadata(List<byte> Dst, ulong Start, Builder.Meta
private void AppendINodeTable(List<byte> 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<byte>();
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++)
{
Expand All @@ -368,7 +368,7 @@ private void AppendINodeTable(List<byte> 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();
Expand All @@ -380,7 +380,7 @@ private void AppendINodeTable(List<byte> Dst)

private void AppendExportTable(List<byte> 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);
Expand All @@ -400,7 +400,7 @@ private void AppendExportTable(List<byte> 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];
Expand Down
19 changes: 15 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand Down Expand Up @@ -156,6 +156,11 @@ store <filename.fs.ct> ramfs <compression>
```
(compression) is "gzip", "lz4", "lzma", "bzip2"

Store fs as squashfs image:
```
store <filename.cpio> ramfs squashfs
```

Store fs as ext2 image:
```
store <filename.ext2> ramfs ext2
Expand Down Expand Up @@ -199,7 +204,13 @@ Update filesystem type:
```
set ramfs filesystem <fs>
```
(fs) is one of 'ext2' or 'cpio'.
(fs) is one of 'ext2', 'squashfs' or 'cpio'.

Change squash compression type:
```
set ramfs squashfs.compression <compression>
```
(compression) is one of "gzip", "lzma", "lz4", "zstd"

Update target OS for image:
```
Expand All @@ -226,7 +237,7 @@ Set compression type (for FIT/legacy):
```
set <imagetype> compression <compression>
```
(compression) is "none", "gzip", "lzma", "lz4", "bzip2"
(compression) is "none", "gzip", "lzma", "lz4", "bzip2", "zstd"

Set entry address (for kernel):
```
Expand Down

0 comments on commit 4419f45

Please sign in to comment.