[PATCH] fs/devfs.c: disallow write and erase if a partition is read-only

Jan Luebbe jlu at pengutronix.de
Mon Jun 25 08:03:27 EDT 2012


Signed-off-by: Jan Luebbe <jlu at pengutronix.de>
---
 fs/devfs.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/devfs.c b/fs/devfs.c
index ae48451..074bb34 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -49,6 +49,9 @@ static int devfs_write(struct device_d *_dev, FILE *f, const void *buf, size_t s
 {
 	struct cdev *cdev = f->inode;
 
+	if (cdev->flags & DEVFS_PARTITION_READONLY)
+		return -EPERM;
+
 	return cdev_write(cdev, buf, size, f->pos, f->flags);
 }
 
@@ -70,6 +73,9 @@ static int devfs_erase(struct device_d *_dev, FILE *f, size_t count, unsigned lo
 {
 	struct cdev *cdev = f->inode;
 
+	if (cdev->flags & DEVFS_PARTITION_READONLY)
+		return -EPERM;
+
 	if (!cdev->ops->erase)
 		return -ENOSYS;
 
-- 
1.7.10




More information about the barebox mailing list