From: Evgeniy Dushistov Date: Sun, 25 Jun 2006 12:47:30 +0000 (-0700) Subject: [PATCH] ufs: fsync implementation X-Git-Tag: v2.6.18-rc1~1012 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=577a82752f95a5680d7c14569ffd3fd630d9fb22;p=linux-2.6 [PATCH] ufs: fsync implementation Presently ufs doesn't support "fsync", this make some applications unhappy, for example vim. This patch fixes this situation. Signed-off-by: Evgeniy Dushistov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/ufs/file.c b/fs/ufs/file.c index 312fd3f863..0e5001512a 100644 --- a/fs/ufs/file.c +++ b/fs/ufs/file.c @@ -25,6 +25,26 @@ #include #include +#include /* for sync_mapping_buffers() */ + +static int ufs_sync_file(struct file *file, struct dentry *dentry, int datasync) +{ + struct inode *inode = dentry->d_inode; + int err; + int ret; + + ret = sync_mapping_buffers(inode->i_mapping); + if (!(inode->i_state & I_DIRTY)) + return ret; + if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) + return ret; + + err = ufs_sync_inode(inode); + if (ret == 0) + ret = err; + return ret; +} + /* * We have mostly NULL's here: the current defaults are ok for @@ -37,6 +57,7 @@ const struct file_operations ufs_file_operations = { .write = generic_file_write, .mmap = generic_file_mmap, .open = generic_file_open, + .fsync = ufs_sync_file, .sendfile = generic_file_sendfile, };