-function EmulatedWriter.write_block(self, name, imagestream, appendpattern)
- if appendpattern then
- os.execute("grep rootfs /proc/mtd >/dev/null || "
- .. "{ echo /dev/hda2,65536,rootfs > "
- .. "/sys/module/block2mtd/parameters/block2mtd }")
+-- Auto Detect
+function native_writer()
+ local w = Writer()
+
+ -- Detect amd64 / x86
+ local x86 = {"x86_64", "i386", "i486", "i586", "i686"}
+ if util.contains(x86, posix.uname("%m")) then
+ return EmulatedWriter()
+ end
+
+ -- Detect CFE
+ if w:_find_mtdblock("cfe") and w:_find_mtdblock("linux") then
+ return CFEWriter()
+ end
+
+ -- Detect Redboot
+ if w:_find_mtdblock("RedBoot") and w:_find_mtdblock("vmlinux.bin.l7") then
+ return RedWriter()
+ end
+
+ -- Detect MagicBox
+ if fs.readfile("/proc/cpuinfo"):find("MagicBox") then
+ return CommonWriter()