summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2011-03-25 11:04:53 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2011-04-11 12:36:07 +0200
commitf1bb89fd9e5c6f3527ebaafcf57346fec19e4d5f (patch)
tree494e54adea9b5a2f9cd0a4a66e2ed5b360b7783a /fs
parent3efa8f7bed53dba8d9252d94233db36aac64b6ce (diff)
downloadbarebox-f1bb89fd9e5c6f3527ebaafcf57346fec19e4d5f.tar.gz
barebox-f1bb89fd9e5c6f3527ebaafcf57346fec19e4d5f.tar.xz
fs: implement flush function
Once we have caching in file functions we need a way to sync the the underlying devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/devfs.c11
-rw-r--r--fs/fs.c20
2 files changed, 31 insertions, 0 deletions
diff --git a/fs/devfs.c b/fs/devfs.c
index ddb3447673..f82fdddbc2 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -169,6 +169,16 @@ static int devfs_close(struct device_d *_dev, FILE *f)
return 0;
}
+static int devfs_flush(struct device_d *_dev, FILE *f)
+{
+ struct cdev *cdev = f->inode;
+
+ if (cdev->ops->flush)
+ return cdev->ops->flush(cdev);
+
+ return 0;
+}
+
static int partition_ioctl(struct cdev *cdev, int request, void *buf)
{
size_t offset;
@@ -287,6 +297,7 @@ static struct fs_driver_d devfs_driver = {
.lseek = devfs_lseek,
.open = devfs_open,
.close = devfs_close,
+ .flush = devfs_flush,
.ioctl = devfs_ioctl,
.opendir = devfs_opendir,
.readdir = devfs_readdir,
diff --git a/fs/fs.c b/fs/fs.c
index f684d45583..059f67a19f 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -536,6 +536,26 @@ ssize_t write(int fd, const void *buf, size_t count)
}
EXPORT_SYMBOL(write);
+int flush(int fd)
+{
+ struct device_d *dev;
+ struct fs_driver_d *fsdrv;
+ FILE *f = &files[fd];
+
+ if (check_fd(fd))
+ return errno;
+
+ dev = f->dev;
+
+ fsdrv = (struct fs_driver_d *)dev->driver->type_data;
+ if (fsdrv->flush)
+ errno = fsdrv->flush(dev, f);
+ else
+ errno = 0;
+
+ return errno;
+}
+
off_t lseek(int fildes, off_t offset, int whence)
{
struct device_d *dev;