return COQUET_RET_OK;
}
+static int posix_sync(void * vfs_data, int which_file, bool_t data_only) {
+ struct posix_data * pd = (struct posix_data *)vfs_data;
+ int *fd, r;
+
+ fd = file_fd(pd,which_file);
+ if(fd == NULL || *fd == -1) {
+ set_error(pd,"file not open",0);
+ return COQUET_RET_VFSERR;
+ }
+
+ if(data_only) {
+ r = fdatasync(*fd);
+ } else {
+ r = fsync(*fd);
+ }
+ if(r == -1) {
+ set_error(pd,"fsync failed",1);
+ return COQUET_RET_VFSERR;
+ }
+
+ return COQUET_RET_OK;
+}
vfs_t vfs_posix = {
.make = posix_make,
.write = posix_write,
.read = posix_read,
.finish = posix_finish,
- .delete = posix_delete
+ .delete = posix_delete,
+ .sync = posix_sync
};
*/
int (*open)(void * vfs_data, int which_file, bool_t allow_create);
+ /* Sync given file to disk. */
+ int (*sync)(void * vfs_data, int which_file, bool_t data_only);
+
/* Close the given file. Which_file is drawn from COQUET_FILE_*. The
* file is guaranteed to be open when this function is called. If file
* is COQUET_FILE_MAIN, all locks must be dropped.
/* Finish VFS layer. Release OS resources (files etc), and free the
* passed vfs_data.
*/
- int (*finish)(void *vfs_data);
+ int (*finish)(void * vfs_data);
/* Delete the given file. File will be closed.
*/
- int (*delete)(void *vfs_data, int which_file);
+ int (*delete)(void * vfs_data, int which_file);
} vfs_t;