-
Notifications
You must be signed in to change notification settings - Fork 110
/
p_write.c
40 lines (35 loc) · 951 Bytes
/
p_write.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <pal.h>
/**
*
* Copies a block pointed to by 'src' into the memory objecct
* 'mem'.
*
* @param src A pointer to a block of memory
*
* @param nb Number of bytes to copy
*
* @param flags Bitmask field indicating runtime options
*
* ASYNC: Specifies asynchronous (non-blocking) operation.
* The default is blocking
*
* @param mem Reference to a memory object created with p_malloc();
*
* @return Returns 0? if successful. Negative value indicates error.
*
*/
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include "pal_base.h"
#include "pal_base_private.h"
ssize_t p_write(p_mem_t *mem, const void *src, off_t offset, size_t nb,
int flags)
{
struct mem_ops *mem_ops = mem->ops;
if (p_mem_error(mem))
return p_mem_error(mem);
if (!mem_ops || !mem_ops->write)
return -ENOSYS;
return mem_ops->write(mem, src, offset, nb, flags);
}