Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2b9df3f authored by Artem Bityutskiy's avatar Artem Bityutskiy
Browse files

UBIFS: return sensible error codes



When mounting/re-mounting, UBIFS returns EINVAL even if the ENOSPC
or EROFS codes are are much better, just because we have not found
references to ENOSPC/EROFS in mount (2) man pages. This patch
changes this behaviour and makes UBIFS return real error code,
because:

1. It is just less confusing and more logical
2. mount is not described in SuSv3, so it seems to be not really
   well-standartized
3. we do not cover all cases, and any random undocumented in man
   pages error code may be returned anyway

Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
parent b466f17d
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -354,7 +354,7 @@ int ubifs_write_master(struct ubifs_info *c)
	int err, lnum, offs, len;
	int err, lnum, offs, len;


	if (c->ro_media)
	if (c->ro_media)
		return -EINVAL;
		return -EROFS;


	lnum = UBIFS_MST_LNUM;
	lnum = UBIFS_MST_LNUM;
	offs = c->mst_offs + c->mst_node_alsz;
	offs = c->mst_offs + c->mst_node_alsz;
+3 −8
Original line number Original line Diff line number Diff line
@@ -1085,12 +1085,7 @@ static int check_free_space(struct ubifs_info *c)
		ubifs_err("insufficient free space to mount in read/write mode");
		ubifs_err("insufficient free space to mount in read/write mode");
		dbg_dump_budg(c);
		dbg_dump_budg(c);
		dbg_dump_lprops(c);
		dbg_dump_lprops(c);
		/*
		return -ENOSPC;
		 * We return %-EINVAL instead of %-ENOSPC because it seems to
		 * be the closest error code mentioned in the mount function
		 * documentation.
		 */
		return -EINVAL;
	}
	}
	return 0;
	return 0;
}
}
@@ -1790,7 +1785,7 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data)
	if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
	if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
		if (c->ro_media) {
		if (c->ro_media) {
			ubifs_msg("cannot re-mount due to prior errors");
			ubifs_msg("cannot re-mount due to prior errors");
			return -EINVAL;
			return -EROFS;
		}
		}
		err = ubifs_remount_rw(c);
		err = ubifs_remount_rw(c);
		if (err)
		if (err)
@@ -1798,7 +1793,7 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data)
	} else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) {
	} else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) {
		if (c->ro_media) {
		if (c->ro_media) {
			ubifs_msg("cannot re-mount due to prior errors");
			ubifs_msg("cannot re-mount due to prior errors");
			return -EINVAL;
			return -EROFS;
		}
		}
		ubifs_remount_ro(c);
		ubifs_remount_ro(c);
	}
	}