Skip to content

Commit a2d76bd

Browse files
Paolo 'Blaisorblade' GiarrussoLinus Torvalds
authored andcommitted
[PATCH] uml: implement hostfs syncing
Actually implement the hostfs "sync" method. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Cc: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 30f417c commit a2d76bd

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

‎arch/um/os-Linux/user_syms.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ EXPORT_SYMBOL_PROTO(statfs64);
8383

8484
EXPORT_SYMBOL_PROTO(getuid);
8585

86+
EXPORT_SYMBOL_PROTO(fsync);
87+
EXPORT_SYMBOL_PROTO(fdatasync);
88+
8689
/*
8790
* Overrides for Emacs so that we follow Linus's tabbing style.
8891
* Emacs will notice this stuff at the end of the file and automatically

‎fs/hostfs/hostfs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
6969
extern int write_file(int fd, unsigned long long *offset, const char *buf,
7070
int len);
7171
extern int lseek_file(int fd, long long offset, int whence);
72+
extern int fsync_file(int fd, int datasync);
7273
extern int file_create(char *name, int ur, int uw, int ux, int gr,
7374
int gw, int gx, int or, int ow, int ox);
7475
extern int set_attr(const char *file, struct hostfs_iattr *attrs);

‎fs/hostfs/hostfs_kern.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ int hostfs_file_open(struct inode *ino, struct file *file)
382382

383383
int hostfs_fsync(struct file *file, struct dentry *dentry, int datasync)
384384
{
385-
return(0);
385+
return fsync_file(HOSTFS_I(dentry->d_inode)->fd, datasync);
386386
}
387387

388388
static struct file_operations hostfs_file_fops = {

‎fs/hostfs/hostfs_user.c‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,24 @@ int lseek_file(int fd, long long offset, int whence)
153153
int ret;
154154

155155
ret = lseek64(fd, offset, whence);
156-
if(ret < 0) return(-errno);
156+
if(ret < 0)
157+
return(-errno);
157158
return(0);
158159
}
159160

161+
int fsync_file(int fd, int datasync)
162+
{
163+
int ret;
164+
if (datasync)
165+
ret = fdatasync(fd);
166+
else
167+
ret = fsync(fd);
168+
169+
if (ret < 0)
170+
return -errno;
171+
return 0;
172+
}
173+
160174
void close_file(void *stream)
161175
{
162176
close(*((int *) stream));

0 commit comments

Comments
 (0)