]> git.sur5r.net Git - u-boot/blobdiff - fs/ubifs/super.c
Merge branch 'u-boot-samsung/master' into 'u-boot-arm/master'
[u-boot] / fs / ubifs / super.c
index 95f2a412508ec2e02b1c5ba8b57c7f02ee7774cc..9acf243eeff42bf88f56a23ef8d7258ac1f4692f 100644 (file)
@@ -727,8 +727,9 @@ static int mount_ubifs(struct ubifs_info *c)
        x = (long long)c->log_lebs * c->leb_size + c->max_bud_bytes;
        ubifs_msg("journal size:       %lld bytes (%lld KiB, %lld MiB, %d "
                  "LEBs)", x, x >> 10, x >> 20, c->log_lebs + c->max_bud_cnt);
-       ubifs_msg("media format:       %d (latest is %d)",
-                 c->fmt_version, UBIFS_FORMAT_VERSION);
+       ubifs_msg("media format:       w%d/r%d (latest is w%d/r%d)",
+                 c->fmt_version, c->ro_compat_version,
+                 UBIFS_FORMAT_VERSION, UBIFS_RO_COMPAT_VERSION);
        ubifs_msg("default compressor: %s", ubifs_compr_name(c->default_compr));
        ubifs_msg("reserved for root:  %llu bytes (%llu KiB)",
                c->report_rp_size, c->report_rp_size >> 10);
@@ -823,7 +824,7 @@ out_free:
  * through mounting (error path cleanup function). So it has to make sure the
  * resource was actually allocated before freeing it.
  */
-static void ubifs_umount(struct ubifs_info *c)
+void ubifs_umount(struct ubifs_info *c)
 {
        dbg_gen("un-mounting UBI device %d, volume %d", c->vi.ubi_num,
                c->vi.vol_id);
@@ -847,8 +848,10 @@ static void ubifs_umount(struct ubifs_info *c)
        ubifs_debugging_exit(c);
 
        /* Finally free U-Boot's global copy of superblock */
-       free(ubifs_sb->s_fs_info);
-       free(ubifs_sb);
+       if (ubifs_sb != NULL) {
+               free(ubifs_sb->s_fs_info);
+               free(ubifs_sb);
+       }
 }
 
 /**
@@ -967,6 +970,15 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
        if (c->max_inode_sz > MAX_LFS_FILESIZE)
                sb->s_maxbytes = c->max_inode_sz = MAX_LFS_FILESIZE;
 
+       if (c->rw_incompat) {
+               ubifs_err("the file-system is not R/W-compatible");
+               ubifs_msg("on-flash format version is w%d/r%d, but software "
+                         "only supports up to version w%d/r%d", c->fmt_version,
+                         c->ro_compat_version, UBIFS_FORMAT_VERSION,
+                         UBIFS_RO_COMPAT_VERSION);
+               return -EROFS;
+       }
+
        mutex_lock(&c->umount_mutex);
        err = mount_ubifs(c);
        if (err) {
@@ -1152,10 +1164,9 @@ static struct file_system_type ubifs_fs_type = {
        .get_sb  = ubifs_get_sb,
 };
 
-int ubifs_mount(char *vol_name)
+int ubifs_mount(char *name)
 {
        int flags;
-       char name[80] = "ubi:";
        void *data;
        struct vfsmount *mnt;
        int ret;
@@ -1168,17 +1179,17 @@ int ubifs_mount(char *vol_name)
                ubifs_umount(ubifs_sb->s_fs_info);
 
        INIT_LIST_HEAD(&ubifs_infos);
+       INIT_LIST_HEAD(&ubifs_fs_type.fs_supers);
 
        /*
         * Mount in read-only mode
         */
        flags = MS_RDONLY;
-       strcat(name, vol_name);
        data = NULL;
        mnt = NULL;
        ret = ubifs_get_sb(&ubifs_fs_type, flags, name, data, mnt);
        if (ret) {
-               printf("Error reading superblock on volume '%s'!\n", name);
+               ubifs_err("Error reading superblock on volume '%s' errno=%d!\n", name, ret);
                return -1;
        }