8
8
#include <stdio.h>
9
9
#include <stdint.h>
10
10
11
+ #include <zephyr/posix/fcntl.h>
11
12
#include <zephyr/posix/poll.h>
12
13
#include <zephyr/posix/unistd.h>
13
14
#include <zephyr/posix/sys/select.h>
16
17
int zvfs_close (int fd );
17
18
FILE * zvfs_fdopen (int fd , const char * mode );
18
19
int zvfs_fileno (FILE * file );
19
- int zvfs_open (const char * name , int flags );
20
+ int zvfs_open (const char * name , int flags , int mode );
20
21
ssize_t zvfs_read (int fd , void * buf , size_t sz , size_t * from_offset );
21
22
ssize_t zvfs_write (int fd , const void * buf , size_t sz , size_t * from_offset );
22
23
23
24
void FD_CLR (int fd , struct zvfs_fd_set * fdset )
24
25
{
25
- return ZVFS_FD_CLR (fd , ( struct zvfs_fd_set * ) fdset );
26
+ return ZVFS_FD_CLR (fd , fdset );
26
27
}
27
28
28
29
int FD_ISSET (int fd , struct zvfs_fd_set * fdset )
29
30
{
30
- return ZVFS_FD_ISSET (fd , ( struct zvfs_fd_set * ) fdset );
31
+ return ZVFS_FD_ISSET (fd , fdset );
31
32
}
32
33
33
34
void FD_SET (int fd , struct zvfs_fd_set * fdset )
34
35
{
35
- ZVFS_FD_SET (fd , ( struct zvfs_fd_set * ) fdset );
36
+ ZVFS_FD_SET (fd , fdset );
36
37
}
37
38
38
39
void FD_ZERO (fd_set * fdset )
39
40
{
40
- ZVFS_FD_ZERO (( struct zvfs_fd_set * ) fdset );
41
+ ZVFS_FD_ZERO (fdset );
41
42
}
42
43
43
44
int close (int fd )
@@ -60,8 +61,16 @@ int fileno(FILE *file)
60
61
61
62
int open (const char * name , int flags , ...)
62
63
{
63
- /* FIXME: necessarily need to check for O_CREAT and unpack ... if set */
64
- return zvfs_open (name , flags );
64
+ int mode = 0 ;
65
+ va_list args ;
66
+
67
+ if ((flags & O_CREAT ) != 0 ) {
68
+ va_start (args , flags );
69
+ mode = va_arg (args , int );
70
+ va_end (args );
71
+ }
72
+
73
+ return zvfs_open (name , flags , mode );
65
74
}
66
75
#ifdef CONFIG_POSIX_DEVICE_IO_ALIAS_OPEN
67
76
FUNC_ALIAS (open , _open , int );
0 commit comments