Skip to content

Commit

Permalink
Embed romfs support to all tools
Browse files Browse the repository at this point in the history
  • Loading branch information
teplofizik committed Sep 19, 2022
1 parent 316ef58 commit dd1cb1e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
3 changes: 2 additions & 1 deletion NyaFs/ImageFormat/Elements/Fs/FilesystemDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public static Types.FsType DetectFs(byte[] Raw)
if (Magic == 0x2d726f6du) // romfs magic
return Types.FsType.RomFs;


if (IsExt4(Raw))
return Types.FsType.Ext2;

Expand All @@ -51,6 +50,8 @@ public static string GetFilesystemType(Types.FsType Type)
case Types.FsType.Cpio: return "CPIO (ASCII)";
case Types.FsType.Ext2: return "Ext2";
case Types.FsType.SquashFs: return "SquashFs";
case Types.FsType.CramFs: return "CramFs";
case Types.FsType.RomFs: return "RomFs";
default: return "Unknown";
}
}
Expand Down
4 changes: 4 additions & 0 deletions NyaFs/ImageFormat/Elements/Fs/Writer/Writer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ internal static bool IsFilesystemSupported(Types.FsType Type)
{
case Types.FsType.Cpio:
case Types.FsType.Ext2:
case Types.FsType.SquashFs:
case Types.FsType.CramFs:
case Types.FsType.RomFs:
return true;
default:
return false;
Expand All @@ -45,6 +48,7 @@ internal static Writer GetRawFilesystemWriter(LinuxFilesystem Fs)
case Types.FsType.Ext2: return new Ext2FsWriter(DetectFixDiskSize(Fs, 0x800000));
case Types.FsType.SquashFs: return new SquashFsWriter(Fs.SquashFsCompression);
case Types.FsType.CramFs: return new CramFsWriter();
case Types.FsType.RomFs: return new RomFsWriter();

default: throw new InvalidOperationException($"Unsupported filesystem: {Fs.FilesystemType}");
}
Expand Down
2 changes: 2 additions & 0 deletions NyaFs/ImageFormat/Helper/FitHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static string GetFilesystemType(Types.FsType Fs)
case Types.FsType.Ext2: return "ext2";
case Types.FsType.SquashFs: return "squashfs";
case Types.FsType.CramFs: return "cramfs";
case Types.FsType.RomFs: return "romfs";
case Types.FsType.Unknown:
default:
return "unknown";
Expand All @@ -30,6 +31,7 @@ public static Types.FsType GetFilesystemType(string Fs)
case "ext2": return Types.FsType.Ext2;
case "squashfs": return Types.FsType.SquashFs;
case "cramfs": return Types.FsType.CramFs;
case "romfs": return Types.FsType.RomFs;
default: return Types.FsType.Unknown;
}
}
Expand Down
10 changes: 10 additions & 0 deletions NyaFs/Processor/Scripting/Commands/Set.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ public override ScriptStepResult Exec(ImageProcessor Processor)
Fs.FilesystemType = ImageFormat.Types.FsType.SquashFs;
return new ScriptStepResult(ScriptStepStatus.Ok, $"Set filesystem type ok: squashfs!");
}
else if (Value == "cramfs")
{
Fs.FilesystemType = ImageFormat.Types.FsType.CramFs;
return new ScriptStepResult(ScriptStepStatus.Ok, $"Set filesystem type ok: cramfs!");
}
else if (Value == "romfs")
{
Fs.FilesystemType = ImageFormat.Types.FsType.RomFs;
return new ScriptStepResult(ScriptStepStatus.Ok, $"Set filesystem type ok: romfs!");
}
else
return new ScriptStepResult(ScriptStepStatus.Error, $"Unsupported filesystem type: {Value}");
}
Expand Down
16 changes: 13 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ There is possible to add or update files in ramfs image.

## Supported image formats
1. Kernel: compressed raw, fit, android, raw, legacy
2. Ramfs: cpio, ext2, squashfs, cramfs, compressed cpio or ext2, legacy, fit, android image
2. Ramfs: cpio, ext2, squashfs, cramfs, romfs, compressed cpio or ext2, legacy, fit, android image
3. Device tree: dtb, fit

## Supported filesystems
Expand All @@ -14,6 +14,7 @@ Supported at now:
2. EXT2 (RW)
3. SquashFs (RW)
4. CramFs (RW)
5. RomFs (RW)

## Supported compression types
Supported at now:
Expand Down Expand Up @@ -111,7 +112,11 @@ load <filename.sqfs> ramfs squashfs
```
Load fs from cramfs image:
```
load <filename.sqfs> ramfs cramfs
load <filename.cramfs> ramfs cramfs
```
Load fs from romfs image:
```
load <filename.romfs> ramfs romfs
```

### Kernel image
Expand Down Expand Up @@ -161,6 +166,11 @@ store <filename.fs.ct> ramfs <compression>
```
(compression) is "gzip", "lz4", "lzma", "bzip2"

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

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

Change squash compression type:
```
Expand Down

0 comments on commit dd1cb1e

Please sign in to comment.