[PATCH 1/2] MTD: add fsync capability
Corentin Chary
corentincj at iksaif.net
Thu Feb 5 16:25:51 EST 2009
Now, we can call fsync() on an mtd device.
Signed-off-by: Corentin Chary <corentincj at iksaif.net>
---
drivers/mtd/mtdchar.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index e9ec59e..5f095bb 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -154,6 +154,20 @@ static int mtd_close(struct inode *inode, struct file *file)
return 0;
} /* mtd_close */
+static int mtd_fsync(struct file *file, struct dentry *dentry, int datasync)
+{
+ struct mtd_file_info *mfi = file->private_data;
+ struct mtd_info *mtd = mfi->mtd;
+
+ DEBUG(MTD_DEBUG_LEVEL0, "MTD_fsync\n");
+
+ /* Only sync if opened RW */
+ if ((file->f_mode & FMODE_WRITE) && mtd->sync)
+ mtd->sync(mtd);
+
+ return 0;
+} /* mtd_fsync */
+
/* FIXME: This _really_ needs to die. In 2.5, we should lock the
userspace buffer down and use it directly with readv/writev.
*/
@@ -787,6 +801,7 @@ static const struct file_operations mtd_fops = {
.read = mtd_read,
.write = mtd_write,
.ioctl = mtd_ioctl,
+ .fsync = mtd_fsync,
.open = mtd_open,
.release = mtd_close,
};
--
1.6.1.1
More information about the linux-mtd
mailing list