mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/vfs: provide vfs_fsync()
This commit is contained in:
parent
4e007d3f3e
commit
aac538ba7f
@ -440,6 +440,17 @@ struct vfs_file_ops {
|
|||||||
* @return <0 on error
|
* @return <0 on error
|
||||||
*/
|
*/
|
||||||
ssize_t (*write) (vfs_file_t *filp, const void *src, size_t nbytes);
|
ssize_t (*write) (vfs_file_t *filp, const void *src, size_t nbytes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Synchronize a file on storage
|
||||||
|
* Any pending writes are written out to storage.
|
||||||
|
*
|
||||||
|
* @param[in] filp pointer to open file
|
||||||
|
*
|
||||||
|
* @return 0 on success
|
||||||
|
* @return <0 on error
|
||||||
|
*/
|
||||||
|
int (*fsync) (vfs_file_t *filp);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -739,6 +750,17 @@ ssize_t vfs_read(int fd, void *dest, size_t count);
|
|||||||
*/
|
*/
|
||||||
ssize_t vfs_write(int fd, const void *src, size_t count);
|
ssize_t vfs_write(int fd, const void *src, size_t count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Synchronize a file on storage
|
||||||
|
* Any pending writes are written out to storage.
|
||||||
|
*
|
||||||
|
* @param[in] fd fd number obtained from vfs_open
|
||||||
|
*
|
||||||
|
* @return 0 on success
|
||||||
|
* @return <0 on error
|
||||||
|
*/
|
||||||
|
int vfs_fsync(int fd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Open a directory for reading with readdir
|
* @brief Open a directory for reading with readdir
|
||||||
*
|
*
|
||||||
|
@ -333,6 +333,25 @@ ssize_t vfs_write(int fd, const void *src, size_t count)
|
|||||||
return filp->f_op->write(filp, src, count);
|
return filp->f_op->write(filp, src, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int vfs_fsync(int fd)
|
||||||
|
{
|
||||||
|
DEBUG_NOT_STDOUT(fd, "vfs_fsync: %d\n", fd);
|
||||||
|
int res = _fd_is_valid(fd);
|
||||||
|
if (res < 0) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
vfs_file_t *filp = &_vfs_open_files[fd];
|
||||||
|
if (((filp->flags & O_ACCMODE) != O_WRONLY) & ((filp->flags & O_ACCMODE) != O_RDWR)) {
|
||||||
|
/* File not open for writing */
|
||||||
|
return -EBADF;
|
||||||
|
}
|
||||||
|
if (filp->f_op->fsync == NULL) {
|
||||||
|
/* driver does not implement fsync() */
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
return filp->f_op->fsync(filp);
|
||||||
|
}
|
||||||
|
|
||||||
int vfs_opendir(vfs_DIR *dirp, const char *dirname)
|
int vfs_opendir(vfs_DIR *dirp, const char *dirname)
|
||||||
{
|
{
|
||||||
DEBUG("vfs_opendir: %p, \"%s\"\n", (void *)dirp, dirname);
|
DEBUG("vfs_opendir: %p, \"%s\"\n", (void *)dirp, dirname);
|
||||||
|
Loading…
Reference in New Issue
Block a user