diff options
author | Sidney Amani <seed@uffs.org> | 2009-01-27 04:11:46 -0500 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-01-27 09:54:41 -0500 |
commit | 766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2 (patch) | |
tree | a7041e919ca5f6d5460b7d7ecfb27e08b9119236 /drivers/mtd/ubi/cdev.c | |
parent | 36b477d005fbda29e7581c3cef7ee31a59d8970b (diff) |
UBI: allow direct user-space I/O
Introduce a new ioctl UBI_IOCSETPROP to set properties
on a volume. Also add the first property:
UBI_PROP_DIRECT_WRITE, this property is used to set the
ability to use direct writes in userspace
Signed-off-by: Sidney Amani <seed@uffs.org>
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/cdev.c')
-rw-r--r-- | drivers/mtd/ubi/cdev.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index f9631eb3fef3..e63c8fc3df3a 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c | |||
@@ -259,12 +259,9 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count, | |||
259 | return err ? err : count_save - count; | 259 | return err ? err : count_save - count; |
260 | } | 260 | } |
261 | 261 | ||
262 | #ifdef CONFIG_MTD_UBI_DEBUG_USERSPACE_IO | ||
263 | |||
264 | /* | 262 | /* |
265 | * This function allows to directly write to dynamic UBI volumes, without | 263 | * This function allows to directly write to dynamic UBI volumes, without |
266 | * issuing the volume update operation. Available only as a debugging feature. | 264 | * issuing the volume update operation. |
267 | * Very useful for testing UBI. | ||
268 | */ | 265 | */ |
269 | static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, | 266 | static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, |
270 | size_t count, loff_t *offp) | 267 | size_t count, loff_t *offp) |
@@ -276,6 +273,9 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, | |||
276 | size_t count_save = count; | 273 | size_t count_save = count; |
277 | char *tbuf; | 274 | char *tbuf; |
278 | 275 | ||
276 | if (!vol->direct_writes) | ||
277 | return -EPERM; | ||
278 | |||
279 | dbg_gen("requested: write %zd bytes to offset %lld of volume %u", | 279 | dbg_gen("requested: write %zd bytes to offset %lld of volume %u", |
280 | count, *offp, vol->vol_id); | 280 | count, *offp, vol->vol_id); |
281 | 281 | ||
@@ -339,10 +339,6 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, | |||
339 | return err ? err : count_save - count; | 339 | return err ? err : count_save - count; |
340 | } | 340 | } |
341 | 341 | ||
342 | #else | ||
343 | #define vol_cdev_direct_write(file, buf, count, offp) (-EPERM) | ||
344 | #endif /* CONFIG_MTD_UBI_DEBUG_USERSPACE_IO */ | ||
345 | |||
346 | static ssize_t vol_cdev_write(struct file *file, const char __user *buf, | 342 | static ssize_t vol_cdev_write(struct file *file, const char __user *buf, |
347 | size_t count, loff_t *offp) | 343 | size_t count, loff_t *offp) |
348 | { | 344 | { |
@@ -552,6 +548,30 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd, | |||
552 | break; | 548 | break; |
553 | } | 549 | } |
554 | 550 | ||
551 | /* Set volume property command*/ | ||
552 | case UBI_IOCSETPROP: | ||
553 | { | ||
554 | struct ubi_set_prop_req req; | ||
555 | |||
556 | err = copy_from_user(&req, argp, | ||
557 | sizeof(struct ubi_set_prop_req)); | ||
558 | if (err) { | ||
559 | err = -EFAULT; | ||
560 | break; | ||
561 | } | ||
562 | switch (req.property) { | ||
563 | case UBI_PROP_DIRECT_WRITE: | ||
564 | mutex_lock(&ubi->volumes_mutex); | ||
565 | desc->vol->direct_writes = !!req.value; | ||
566 | mutex_unlock(&ubi->volumes_mutex); | ||
567 | break; | ||
568 | default: | ||
569 | err = -EINVAL; | ||
570 | break; | ||
571 | } | ||
572 | break; | ||
573 | } | ||
574 | |||
555 | default: | 575 | default: |
556 | err = -ENOTTY; | 576 | err = -ENOTTY; |
557 | break; | 577 | break; |