public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 1/2] MTD: add fsync capability
@ 2009-02-05 21:25 Corentin Chary
  2009-02-05 21:25 ` [PATCH 2/2] UBI: " Corentin Chary
  2009-02-05 22:00 ` [PATCH 1/2] MTD: " Mike Frysinger
  0 siblings, 2 replies; 7+ messages in thread
From: Corentin Chary @ 2009-02-05 21:25 UTC (permalink / raw)
  To: linux-mtd; +Cc: Corentin Chary

Now, we can call fsync() on an mtd device.

Signed-off-by: Corentin Chary <corentincj@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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-02-06  8:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-05 21:25 [PATCH 1/2] MTD: add fsync capability Corentin Chary
2009-02-05 21:25 ` [PATCH 2/2] UBI: " Corentin Chary
2009-02-06  8:01   ` Artem Bityutskiy
2009-02-05 22:00 ` [PATCH 1/2] MTD: " Mike Frysinger
2009-02-06  7:34   ` Artem Bityutskiy
2009-02-06  8:06     ` Corentin Chary
2009-02-06  8:10       ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox