diff options
author | Petr Štetiar <ynezz@true.cz> | 2020-01-21 17:11:07 +0100 |
---|---|---|
committer | Petr Štetiar <ynezz@true.cz> | 2020-01-21 17:12:36 +0100 |
commit | deb745f82b93b3bd12273cfb16deb7417fc555ef (patch) | |
tree | 3b7acd24e2f0c91d8622cde89f49ba62c3392e20 | |
parent | f5c7c1813f52e6d7b59ecfb2f9f95e69b05b1980 (diff) | |
download | fstools-deb745f82b93b3bd12273cfb16deb7417fc555ef.tar.gz |
Revert "fstools: Add support to read-only MTD partitions (eg. recovery images)"
This reverts commit f5c7c1813f52e6d7b59ecfb2f9f95e69b05b1980 which needs
more work and testing as it broke at least jffs2 overlays at least on
ath79 platform, marking them as read-only, thus unusable:
jffs2_build_filesystem(): erasing all blocks after the end marker...
jffs2: Erase at 0x009e0000 failed immediately: -EROFS. Is the sector locked?
Ref: http://lists.infradead.org/pipermail/openwrt-devel/2020-January/021344.html
Reported-by: Steve Brown <sbrown@ewol.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
-rw-r--r-- | libfstools/mtd.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/libfstools/mtd.c b/libfstools/mtd.c index aae633e..77c71ee 100644 --- a/libfstools/mtd.c +++ b/libfstools/mtd.c @@ -36,31 +36,20 @@ struct mtd_volume { static struct driver mtd_driver; -static int mtd_open_device(const char *dev) -{ - int ret; - - ret = open(dev, O_RDWR | O_SYNC); - if (ret < 0) - ret = open(dev, O_RDONLY); - - return ret; -} - static int mtd_open(const char *mtd, int block) { FILE *fp; char dev[PATH_MAX]; - int i, ret; + int i, ret, flags = O_RDWR | O_SYNC; if ((fp = fopen("/proc/mtd", "r"))) { while (fgets(dev, sizeof(dev), fp)) { if (sscanf(dev, "mtd%d:", &i) && strstr(dev, mtd)) { snprintf(dev, sizeof(dev), "/dev/mtd%s/%d", (block ? "block" : ""), i); - ret = mtd_open_device(dev); + ret = open(dev, flags); if (ret < 0) { snprintf(dev, sizeof(dev), "/dev/mtd%s%d", (block ? "block" : ""), i); - ret = mtd_open_device(dev); + ret = open(dev, flags); } fclose(fp); return ret; @@ -69,7 +58,7 @@ static int mtd_open(const char *mtd, int block) fclose(fp); } - return mtd_open_device(mtd); + return open(mtd, flags); } static void mtd_volume_close(struct mtd_volume *p) |