package/mtd: write remaining data after adding file to the jffs2 partition
SVN-Revision: 22881
This commit is contained in:
parent
6734c999af
commit
2a541325d3
3 changed files with 32 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (C) 2006-2009 OpenWrt.org
|
# Copyright (C) 2006-2010 OpenWrt.org
|
||||||
#
|
#
|
||||||
# This is free software, licensed under the GNU General Public License v2.
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
# See /LICENSE for more information.
|
# See /LICENSE for more information.
|
||||||
|
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||||
include $(INCLUDE_DIR)/kernel.mk
|
include $(INCLUDE_DIR)/kernel.mk
|
||||||
|
|
||||||
PKG_NAME:=mtd
|
PKG_NAME:=mtd
|
||||||
PKG_RELEASE:=13
|
PKG_RELEASE:=14
|
||||||
|
|
||||||
PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME)
|
PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME)
|
||||||
STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)
|
STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)
|
||||||
|
|
|
@ -247,7 +247,7 @@ int mtd_replace_jffs2(const char *mtd, int fd, int ofs, const char *filename)
|
||||||
#ifdef target_brcm
|
#ifdef target_brcm
|
||||||
trx_fixup(outfd, mtd);
|
trx_fixup(outfd, mtd);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return (mtdofs - ofs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mtd_parse_jffs2data(const char *buf, const char *dir)
|
void mtd_parse_jffs2data(const char *buf, const char *dir)
|
||||||
|
|
|
@ -367,6 +367,16 @@ mtd_refresh(const char *mtd)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
indicate_writing(const char *mtd)
|
||||||
|
{
|
||||||
|
if (quiet < 2)
|
||||||
|
fprintf(stderr, "\nWriting from %s to %s ... ", imagefile, mtd);
|
||||||
|
|
||||||
|
if (!quiet)
|
||||||
|
fprintf(stderr, " [ ]");
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mtd_write(int imagefd, const char *mtd, char *fis_layout)
|
mtd_write(int imagefd, const char *mtd, char *fis_layout)
|
||||||
{
|
{
|
||||||
|
@ -374,6 +384,7 @@ mtd_write(int imagefd, const char *mtd, char *fis_layout)
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
int fd, result;
|
int fd, result;
|
||||||
ssize_t r, w, e;
|
ssize_t r, w, e;
|
||||||
|
ssize_t skip = 0;
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
|
|
||||||
#ifdef FIS_SUPPORT
|
#ifdef FIS_SUPPORT
|
||||||
|
@ -451,13 +462,9 @@ resume:
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quiet < 2)
|
indicate_writing(mtd);
|
||||||
fprintf(stderr, "Writing from %s to %s ... ", imagefile, mtd);
|
|
||||||
|
|
||||||
w = e = 0;
|
w = e = 0;
|
||||||
if (!quiet)
|
|
||||||
fprintf(stderr, " [ ]");
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* buffer may contain data already (from trx check or last mtd partition write attempt) */
|
/* buffer may contain data already (from trx check or last mtd partition write attempt) */
|
||||||
while (buflen < erasesize) {
|
while (buflen < erasesize) {
|
||||||
|
@ -480,6 +487,15 @@ resume:
|
||||||
if (buflen == 0)
|
if (buflen == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (skip > 0) {
|
||||||
|
skip -= buflen;
|
||||||
|
buflen = 0;
|
||||||
|
if (skip <= 0)
|
||||||
|
indicate_writing(mtd);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (jffs2file) {
|
if (jffs2file) {
|
||||||
if (memcmp(buf, JFFS2_EOF, sizeof(JFFS2_EOF) - 1) == 0) {
|
if (memcmp(buf, JFFS2_EOF, sizeof(JFFS2_EOF) - 1) == 0) {
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
|
@ -487,8 +503,14 @@ resume:
|
||||||
if (quiet < 2)
|
if (quiet < 2)
|
||||||
fprintf(stderr, "\nAppending jffs2 data from %s to %s...", jffs2file, mtd);
|
fprintf(stderr, "\nAppending jffs2 data from %s to %s...", jffs2file, mtd);
|
||||||
/* got an EOF marker - this is the place to add some jffs2 data */
|
/* got an EOF marker - this is the place to add some jffs2 data */
|
||||||
mtd_replace_jffs2(mtd, fd, e, jffs2file);
|
skip = mtd_replace_jffs2(mtd, fd, e, jffs2file);
|
||||||
goto done;
|
|
||||||
|
w += skip;
|
||||||
|
e += skip;
|
||||||
|
skip -= buflen;
|
||||||
|
buflen = 0;
|
||||||
|
offset = 0;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
/* no EOF marker, make sure we figure out the last inode number
|
/* no EOF marker, make sure we figure out the last inode number
|
||||||
* before appending some data */
|
* before appending some data */
|
||||||
|
|
Loading…
Reference in a new issue