* [PATCH] UBI: Add ro-mode sysfs attribute
@ 2016-04-28 18:28 Ezequiel Garcia
2016-04-28 18:30 ` Richard Weinberger
0 siblings, 1 reply; 2+ messages in thread
From: Ezequiel Garcia @ 2016-04-28 18:28 UTC (permalink / raw)
To: Richard Weinberger; +Cc: linux-mtd, Ezequiel Garcia
On certain 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: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
---
drivers/mtd/ubi/build.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 22fd19c0c5d3..7091fca0fb44 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -149,6 +149,8 @@ static struct device_attribute dev_bgt_enabled =
__ATTR(bgt_enabled, S_IRUGO, dev_attribute_show, NULL);
static struct device_attribute dev_mtd_num =
__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.
@@ -385,6 +387,8 @@ static ssize_t dev_attribute_show(struct device *dev,
ret = sprintf(buf, "%d\n", ubi->thread_enabled);
else if (attr == &dev_mtd_num)
ret = sprintf(buf, "%d\n", ubi->mtd->index);
+ else if (attr == &dev_ro_mode)
+ ret = sprintf(buf, "%d\n", ubi->ro_mode);
else
ret = -EINVAL;
@@ -404,6 +408,7 @@ static struct attribute *ubi_dev_attrs[] = {
&dev_min_io_size.attr,
&dev_bgt_enabled.attr,
&dev_mtd_num.attr,
+ &dev_ro_mode.attr,
NULL
};
ATTRIBUTE_GROUPS(ubi_dev);
--
2.7.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] UBI: Add ro-mode sysfs attribute
2016-04-28 18:28 [PATCH] UBI: Add ro-mode sysfs attribute Ezequiel Garcia
@ 2016-04-28 18:30 ` Richard Weinberger
0 siblings, 0 replies; 2+ messages in thread
From: Richard Weinberger @ 2016-04-28 18:30 UTC (permalink / raw)
To: Ezequiel Garcia; +Cc: linux-mtd
Am 28.04.2016 um 20:28 schrieb Ezequiel Garcia:
> On certain 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: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Makes sense. Please also document the new attribute in
Documentation/ABI/stable/sysfs-class-ubi,
Thanks,
//richard
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-28 18:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-28 18:28 [PATCH] UBI: Add ro-mode sysfs attribute Ezequiel Garcia
2016-04-28 18:30 ` Richard Weinberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).