diff options
author | Steven Barth <steven@midlink.org> | 2008-09-18 16:44:49 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-09-18 16:44:49 +0000 |
commit | 8509b6a83f5545f06b47505c9856411b2c053d66 (patch) | |
tree | f3e6fae3b016b245df048ae5d53dc38d6ae3319c /libs/sys | |
parent | d87d01a24bb5dba7755d054e400ea861ae95a96c (diff) |
More mtdow fixes
Diffstat (limited to 'libs/sys')
-rw-r--r-- | libs/sys/luasrc/sys/mtdow.lua | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/libs/sys/luasrc/sys/mtdow.lua b/libs/sys/luasrc/sys/mtdow.lua index ffe3e42292..bfa2e9e937 100644 --- a/libs/sys/luasrc/sys/mtdow.lua +++ b/libs/sys/luasrc/sys/mtdow.lua @@ -63,7 +63,7 @@ CFEWriter.blocks = { image = { magic = {"4844", "5735"}, device = "linux", - write = WRITE_COMBINED + write = WRITE_IMAGE } } @@ -181,11 +181,22 @@ function Writer._write_emulated(self, devicename, imagestream, appendfile) end function Writer._write_memory(self, devicename, imagestream) - local devicestream = ltn12.sink.file(io.open(devicename, "w")) - local stat, err = ltn12.pump.all(imagestream, devicestream) - if stat then - return os.execute("sync") + local imageproc = posix.fork() + assert(imageproc ~= -1, ERROR_RESOURCE) + if imageproc == 0 then + fs.unlink(self.IMAGEFIFO) + assert(posix.mkfifo(self.IMAGEFIFO), ERROR_RESOURCE) + local imagefifo = io.open(self.IMAGEFIFO, "w") + assert(imagefifo, ERROR_RESOURCE) + ltn12.pump.all(imagestream, ltn12.sink.file(imagefifo)) + os.exit(0) end + + return os.execute( + "%s write '%s' '%s'" % { + self.MTD, self.IMAGEFIFO, devicename + } + ) end function Writer._write_combined(self, devicename, imagestream, appendfile) |