1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/vfs: add vfs_write_iol()

This commit is contained in:
Benjamin Valentin 2022-05-02 22:56:12 +02:00
parent 501ca7e34d
commit 42e5d0d402
2 changed files with 28 additions and 0 deletions

View File

@ -68,6 +68,7 @@
#include "sched.h"
#include "clist.h"
#include "iolist.h"
#include "mtd.h"
#include "xfa.h"
@ -809,6 +810,17 @@ ssize_t vfs_read(int fd, void *dest, size_t count);
*/
ssize_t vfs_write(int fd, const void *src, size_t count);
/**
* @brief Write bytes from an iolist to an open file
*
* @param[in] fd fd number obtained from vfs_open
* @param[in] iolist iolist to read from
*
* @return number of bytes written on success
* @return <0 on error
*/
ssize_t vfs_write_iol(int fd, const iolist_t *iolist);
/**
* @brief Synchronize a file on storage
* Any pending writes are written out to storage.

View File

@ -355,6 +355,22 @@ ssize_t vfs_write(int fd, const void *src, size_t count)
return filp->f_op->write(filp, src, count);
}
ssize_t vfs_write_iol(int fd, const iolist_t *snips)
{
int res, sum = 0;
while (snips) {
res = vfs_write(fd, snips->iol_base, snips->iol_len);
if (res < 0) {
return res;
}
sum += res;
snips = snips->iol_next;
}
return sum;
}
int vfs_fsync(int fd)
{
DEBUG_NOT_STDOUT(fd, "vfs_fsync: %d\n", fd);