summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Lilleengen <lulf@pvv.ntnu.no>2008-09-03 09:35:58 +0200
committerUlf Lilleengen <lulf@pvv.ntnu.no>2008-09-03 09:35:58 +0200
commitc1ac6a3f5e69b75a922385d78e380c209fd2911c (patch)
tree596680508a480e1538ff83d569f9af6de0767690
parent5f83ed096a8f0e19cd4658258c07630d17c4b488 (diff)
- Implement flush and fsync.
-rw-r--r--TODO4
-rwxr-xr-xsrc/mfs_vnops.c17
2 files changed, 18 insertions, 3 deletions
diff --git a/TODO b/TODO
index 533ae4e..a600f5e 100644
--- a/TODO
+++ b/TODO
@@ -5,10 +5,12 @@ v. 0.1
* Better interface (the new .config is pretty good, but needs
improvement)
-* We should implement flush and similar calls we don't currently implement.
+* [FIXED] We should implement flush and similar calls we don't currently implement.
Under some circumstances, high load can force the closing of files or
something in a similar manner, and we should handle this properly, or else the
media player will probably stop playback.
+ * flush and fsync have been implemented, but is not required to do anything
+ since we have reading only currently, so we will have to extend them later.
- [FIXED] BUG: what to do with songs without tags?
* This has been improved to check if the string is actually empty,
diff --git a/src/mfs_vnops.c b/src/mfs_vnops.c
index 4e1915e..549ebb1 100755
--- a/src/mfs_vnops.c
+++ b/src/mfs_vnops.c
@@ -238,19 +238,31 @@ static int mfs_truncate(const char *path, off_t size)
static int mfs_flush(const char *path, struct fuse_file_info *fi)
{
+ int fd;
+
DEBUG("flushing path %s\n", path);
if (strcmp(path, "/.config") == 0) {
return (0);
}
- return (-1);
+ fd = (int)fi->fh;
+ /* Fd is not valid, return flush error. */
+ if (fd < 0)
+ return (-ENOENT);
+ return (0);
}
static int mfs_fsync(const char *path, int datasync,
struct fuse_file_info *fi)
{
+ int fd;
+
DEBUG("fsync path %s\n", path);
- return (0);
+ fd = (int)fi->fh;
+ /* Fd is not valid, return fsync error. */
+ if (fd < 0)
+ return (-ENOENT);
+ return (fsync(fd));
}
static int mfs_release(const char *path, struct fuse_file_info *fi)
@@ -330,6 +342,7 @@ static struct fuse_operations mfs_ops = {
.mknod = mfs_mknod,
.create = mfs_create,
.truncate = mfs_truncate,
+ .flush = mfs_flush,
.fsync = mfs_fsync,
.chmod = mfs_chmod,
.release = mfs_release,