summaryrefslogtreecommitdiff
path: root/package/system
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-11-14 19:38:54 +0000
committerFelix Fietkau <nbd@openwrt.org>2013-11-14 19:38:54 +0000
commitff17114ba17f8e7c8b256f6f3a04640062a6d797 (patch)
treeab8f9f8d43c486022319ba32d821ecba29e71d15 /package/system
parent9aca892304c49523c620ed964f2c0b3468a57667 (diff)
downloadmtk-20170518-ff17114ba17f8e7c8b256f6f3a04640062a6d797.zip
mtk-20170518-ff17114ba17f8e7c8b256f6f3a04640062a6d797.tar.gz
mtk-20170518-ff17114ba17f8e7c8b256f6f3a04640062a6d797.tar.bz2
ar71xx: Unifi AP Pro sysupgrade patch
The current implementation of mtd will not append the backup file created by sysupgrade to the correct partition, as mtd will append the data to first jffs2 partition it finds. As the kernel is also stored on a jffs2 partition (which resides before the overlay partition), the data will be appended to this partition. To fix this problem, a new option -s <number> skip the first n bytes when appending data to the jffs2 partiton, defaults to "0" is added to mtd. Signed-off-by: Peter Wagner <tripolar@gmx.at> SVN-Revision: 38807
Diffstat (limited to 'package/system')
-rw-r--r--package/system/mtd/src/mtd.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/package/system/mtd/src/mtd.c b/package/system/mtd/src/mtd.c
index a660486..2ec02a8 100644
--- a/package/system/mtd/src/mtd.c
+++ b/package/system/mtd/src/mtd.c
@@ -55,6 +55,7 @@ int quiet;
int no_erase;
int mtdsize = 0;
int erasesize = 0;
+int jffs2_skip_bytes=0;
int mtd_open(const char *mtd, bool block)
{
@@ -339,7 +340,6 @@ resume:
fprintf(stderr, "Could not open mtd device: %s\n", mtd);
exit(1);
}
-
if (part_offset > 0) {
fprintf(stderr, "Seeking on mtd device '%s' to: %u\n", mtd, part_offset);
lseek(fd, part_offset, SEEK_SET);
@@ -379,7 +379,7 @@ resume:
continue;
}
- if (jffs2file) {
+ if (jffs2file && w >= jffs2_skip_bytes) {
if (memcmp(buf, JFFS2_EOF, sizeof(JFFS2_EOF) - 1) == 0) {
if (!quiet)
fprintf(stderr, "\b\b\b ");
@@ -503,6 +503,7 @@ static void usage(void)
" -e <device> erase <device> before executing the command\n"
" -d <name> directory for jffs2write, defaults to \"tmp\"\n"
" -j <name> integrate <file> into jffs2 data when writing an image\n"
+ " -s <number> skip the first n bytes when appending data to the jffs2 partiton, defaults to \"0\"\n"
" -p write beginning at partition offset\n");
if (mtd_fixtrx) {
fprintf(stderr,
@@ -560,7 +561,7 @@ int main (int argc, char **argv)
#ifdef FIS_SUPPORT
"F:"
#endif
- "frnqe:d:j:p:o:")) != -1)
+ "frnqe:d:s:j:p:o:")) != -1)
switch (ch) {
case 'f':
force = 1;
@@ -574,6 +575,14 @@ int main (int argc, char **argv)
case 'j':
jffs2file = optarg;
break;
+ case 's':
+ errno = 0;
+ jffs2_skip_bytes = strtoul(optarg, 0, 0);
+ if (errno) {
+ fprintf(stderr, "-s: illegal numeric string\n");
+ usage();
+ }
+ break;
case 'q':
quiet++;
break;