Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
8fac9398
Commit
8fac9398
authored
Jul 27, 2016
by
Paul Sokolovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unix/file: Implement MP_STREAM_FLUSH ioctl.
parent
6ead9f6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
11 deletions
+19
-11
unix/file.c
unix/file.c
+19
-11
No files found.
unix/file.c
View file @
8fac9398
...
...
@@ -105,18 +105,26 @@ STATIC mp_uint_t fdfile_write(mp_obj_t o_in, const void *buf, mp_uint_t size, in
STATIC
mp_uint_t
fdfile_ioctl
(
mp_obj_t
o_in
,
mp_uint_t
request
,
uintptr_t
arg
,
int
*
errcode
)
{
mp_obj_fdfile_t
*
o
=
MP_OBJ_TO_PTR
(
o_in
);
if
(
request
==
MP_STREAM_SEEK
)
{
struct
mp_stream_seek_t
*
s
=
(
struct
mp_stream_seek_t
*
)
arg
;
off_t
off
=
lseek
(
o
->
fd
,
s
->
offset
,
s
->
whence
);
if
(
off
==
(
off_t
)
-
1
)
{
*
errcode
=
errno
;
return
MP_STREAM_ERROR
;
switch
(
request
)
{
case
MP_STREAM_SEEK
:
{
struct
mp_stream_seek_t
*
s
=
(
struct
mp_stream_seek_t
*
)
arg
;
off_t
off
=
lseek
(
o
->
fd
,
s
->
offset
,
s
->
whence
);
if
(
off
==
(
off_t
)
-
1
)
{
*
errcode
=
errno
;
return
MP_STREAM_ERROR
;
}
s
->
offset
=
off
;
return
0
;
}
s
->
offset
=
off
;
return
0
;
}
else
{
*
errcode
=
EINVAL
;
return
MP_STREAM_ERROR
;
case
MP_STREAM_FLUSH
:
if
(
fsync
(
o
->
fd
)
<
0
)
{
*
errcode
=
errno
;
return
MP_STREAM_ERROR
;
}
return
0
;
default:
*
errcode
=
EINVAL
;
return
MP_STREAM_ERROR
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment