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

Commit 525bab71 authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Richard Weinberger
Browse files

UBI: Add ro-mode sysfs attribute



On serious situations, UBI may detect serious device corruption,
and switch to read-only mode to protect the data and allow debugging.
This commit exposes this ro-mode on sysfs, so it can be obtained
by userspace tools.

Signed-off-by: default avatarEzequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 04974df8
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -107,6 +107,15 @@ Contact: Artem Bityutskiy <dedekind@infradead.org>
Description:
Description:
		Number of physical eraseblocks reserved for bad block handling.
		Number of physical eraseblocks reserved for bad block handling.


What:		/sys/class/ubi/ubiX/ro_mode
Date:		April 2016
KernelVersion:	4.7
Contact:	linux-mtd@lists.infradead.org
Description:
		Contains ASCII "1\n" if the read-only flag is set on this
		device, and "0\n" if it is cleared. UBI devices mark themselves
		as read-only when they detect an unrecoverable error.

What:		/sys/class/ubi/ubiX/total_eraseblocks
What:		/sys/class/ubi/ubiX/total_eraseblocks
Date:		July 2006
Date:		July 2006
KernelVersion:	2.6.22
KernelVersion:	2.6.22
+5 −0
Original line number Original line Diff line number Diff line
@@ -149,6 +149,8 @@ static struct device_attribute dev_bgt_enabled =
	__ATTR(bgt_enabled, S_IRUGO, dev_attribute_show, NULL);
	__ATTR(bgt_enabled, S_IRUGO, dev_attribute_show, NULL);
static struct device_attribute dev_mtd_num =
static struct device_attribute dev_mtd_num =
	__ATTR(mtd_num, S_IRUGO, dev_attribute_show, NULL);
	__ATTR(mtd_num, S_IRUGO, dev_attribute_show, NULL);
static struct device_attribute dev_ro_mode =
	__ATTR(ro_mode, S_IRUGO, dev_attribute_show, NULL);


/**
/**
 * ubi_volume_notify - send a volume change notification.
 * ubi_volume_notify - send a volume change notification.
@@ -385,6 +387,8 @@ static ssize_t dev_attribute_show(struct device *dev,
		ret = sprintf(buf, "%d\n", ubi->thread_enabled);
		ret = sprintf(buf, "%d\n", ubi->thread_enabled);
	else if (attr == &dev_mtd_num)
	else if (attr == &dev_mtd_num)
		ret = sprintf(buf, "%d\n", ubi->mtd->index);
		ret = sprintf(buf, "%d\n", ubi->mtd->index);
	else if (attr == &dev_ro_mode)
		ret = sprintf(buf, "%d\n", ubi->ro_mode);
	else
	else
		ret = -EINVAL;
		ret = -EINVAL;


@@ -404,6 +408,7 @@ static struct attribute *ubi_dev_attrs[] = {
	&dev_min_io_size.attr,
	&dev_min_io_size.attr,
	&dev_bgt_enabled.attr,
	&dev_bgt_enabled.attr,
	&dev_mtd_num.attr,
	&dev_mtd_num.attr,
	&dev_ro_mode.attr,
	NULL
	NULL
};
};
ATTRIBUTE_GROUPS(ubi_dev);
ATTRIBUTE_GROUPS(ubi_dev);