diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-03-26 06:51:21 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-03-26 10:36:20 -0400 |
commit | 963f0cf6d116d83c558a8efe9045c1c5ad7aed34 (patch) | |
tree | 43937f0d742bfac7dfc1a00bae8f72e98dc87425 /fs/ubifs/sb.c | |
parent | fcabb3479e2b15abfd2d2ef5363295f16e98b2d7 (diff) |
UBIFS: add R/O compatibility
Now UBIFS is supported by u-boot. If we ever decide to change the
media format, then people will have to upgrade their u-boots to
mount new format images. However, very often it is possible to
preserve R/O forward-compatibility, even though the write
forward-compatibility is not preserved.
This patch introduces a new super-block field which stores the
R/O compatibility version.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Acked-by: Adrian Hunter <Adrian.Hunter@nokia.com>
Diffstat (limited to 'fs/ubifs/sb.c')
-rw-r--r-- | fs/ubifs/sb.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c index 0dec47c87c6d..57085e43320f 100644 --- a/fs/ubifs/sb.c +++ b/fs/ubifs/sb.c | |||
@@ -193,6 +193,7 @@ static int create_default_filesystem(struct ubifs_info *c) | |||
193 | if (tmp64 > DEFAULT_MAX_RP_SIZE) | 193 | if (tmp64 > DEFAULT_MAX_RP_SIZE) |
194 | tmp64 = DEFAULT_MAX_RP_SIZE; | 194 | tmp64 = DEFAULT_MAX_RP_SIZE; |
195 | sup->rp_size = cpu_to_le64(tmp64); | 195 | sup->rp_size = cpu_to_le64(tmp64); |
196 | sup->ro_compat_version = cpu_to_le32(UBIFS_RO_COMPAT_VERSION); | ||
196 | 197 | ||
197 | err = ubifs_write_node(c, sup, UBIFS_SB_NODE_SZ, 0, 0, UBI_LONGTERM); | 198 | err = ubifs_write_node(c, sup, UBIFS_SB_NODE_SZ, 0, 0, UBI_LONGTERM); |
198 | kfree(sup); | 199 | kfree(sup); |
@@ -532,17 +533,39 @@ int ubifs_read_superblock(struct ubifs_info *c) | |||
532 | if (IS_ERR(sup)) | 533 | if (IS_ERR(sup)) |
533 | return PTR_ERR(sup); | 534 | return PTR_ERR(sup); |
534 | 535 | ||
536 | c->fmt_version = le32_to_cpu(sup->fmt_version); | ||
537 | c->ro_compat_version = le32_to_cpu(sup->ro_compat_version); | ||
538 | |||
535 | /* | 539 | /* |
536 | * The software supports all previous versions but not future versions, | 540 | * The software supports all previous versions but not future versions, |
537 | * due to the unavailability of time-travelling equipment. | 541 | * due to the unavailability of time-travelling equipment. |
538 | */ | 542 | */ |
539 | c->fmt_version = le32_to_cpu(sup->fmt_version); | ||
540 | if (c->fmt_version > UBIFS_FORMAT_VERSION) { | 543 | if (c->fmt_version > UBIFS_FORMAT_VERSION) { |
541 | ubifs_err("on-flash format version is %d, but software only " | 544 | struct super_block *sb = c->vfs_sb; |
542 | "supports up to version %d", c->fmt_version, | 545 | int mounting_ro = sb->s_flags & MS_RDONLY; |
543 | UBIFS_FORMAT_VERSION); | 546 | |
544 | err = -EINVAL; | 547 | ubifs_assert(!c->ro_media || mounting_ro); |
545 | goto out; | 548 | if (!mounting_ro || |
549 | c->ro_compat_version > UBIFS_RO_COMPAT_VERSION) { | ||
550 | ubifs_err("on-flash format version is w%d/r%d, but " | ||
551 | "software only supports up to version " | ||
552 | "w%d/r%d", c->fmt_version, | ||
553 | c->ro_compat_version, UBIFS_FORMAT_VERSION, | ||
554 | UBIFS_RO_COMPAT_VERSION); | ||
555 | if (c->ro_compat_version <= UBIFS_RO_COMPAT_VERSION) { | ||
556 | ubifs_msg("only R/O mounting is possible"); | ||
557 | err = -EROFS; | ||
558 | } else | ||
559 | err = -EINVAL; | ||
560 | goto out; | ||
561 | } | ||
562 | |||
563 | /* | ||
564 | * The FS is mounted R/O, and the media format is | ||
565 | * R/O-compatible with the UBIFS implementation, so we can | ||
566 | * mount. | ||
567 | */ | ||
568 | c->rw_incompat = 1; | ||
546 | } | 569 | } |
547 | 570 | ||
548 | if (c->fmt_version < 3) { | 571 | if (c->fmt_version < 3) { |