Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
39a380b6
Commit
39a380b6
authored
9 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
unix/modos: Android Bionic lacks statvfs(), has BSD statfs().
parent
e0f5df57
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unix/modos.c
+28
-8
28 additions, 8 deletions
unix/modos.c
with
28 additions
and
8 deletions
unix/modos.c
+
28
−
8
View file @
39a380b6
...
...
@@ -31,14 +31,15 @@
#include
<errno.h>
#include
<stdlib.h>
#include
"py/mpconfig.h"
#if MICROPY_PY_OS_STATVFS
#include
<sys/statvfs.h>
#endif
#include
"py/nlr.h"
#include
"py/runtime.h"
#include
"py/objtuple.h"
#ifdef __ANDROID__
#define USE_STATFS 1
#endif
#define RAISE_ERRNO(err_flag, error_val) \
{ if (err_flag == -1) \
{ nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(error_val))); } }
...
...
@@ -67,12 +68,31 @@ STATIC mp_obj_t mod_os_stat(mp_obj_t path_in) {
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
mod_os_stat_obj
,
mod_os_stat
);
#if MICROPY_PY_OS_STATVFS
#if MICROPY_PY_OS_STATVFS
#if USE_STATFS
#include
<sys/vfs.h>
#define STRUCT_STATVFS struct statfs
#define STATVFS statfs
#define F_FAVAIL sb.f_ffree
#define F_NAMEMAX sb.f_namelen
#define F_FLAG sb.f_flags
#else
#include
<sys/statvfs.h>
#define STRUCT_STATVFS struct statvfs
#define STATVFS statvfs
#define F_FAVAIL sb.f_favail
#define F_NAMEMAX sb.f_namemax
#define F_FLAG sb.f_flag
#endif
#endif
STATIC
mp_obj_t
mod_os_statvfs
(
mp_obj_t
path_in
)
{
struct
statvfs
sb
;
STRUCT_STATVFS
sb
;
mp_uint_t
len
;
const
char
*
path
=
mp_obj_str_get_data
(
path_in
,
&
len
);
int
res
=
statvfs
(
path
,
&
sb
);
int
res
=
STATVFS
(
path
,
&
sb
);
RAISE_ERRNO
(
res
,
errno
);
mp_obj_tuple_t
*
t
=
mp_obj_new_tuple
(
10
,
NULL
);
...
...
@@ -83,9 +103,9 @@ STATIC mp_obj_t mod_os_statvfs(mp_obj_t path_in) {
t
->
items
[
4
]
=
MP_OBJ_NEW_SMALL_INT
(
sb
.
f_bavail
);
t
->
items
[
5
]
=
MP_OBJ_NEW_SMALL_INT
(
sb
.
f_files
);
t
->
items
[
6
]
=
MP_OBJ_NEW_SMALL_INT
(
sb
.
f_ffree
);
t
->
items
[
7
]
=
MP_OBJ_NEW_SMALL_INT
(
sb
.
f_favail
);
t
->
items
[
8
]
=
MP_OBJ_NEW_SMALL_INT
(
sb
.
f_flag
);
t
->
items
[
9
]
=
MP_OBJ_NEW_SMALL_INT
(
sb
.
f_namemax
);
t
->
items
[
7
]
=
MP_OBJ_NEW_SMALL_INT
(
F_FAVAIL
);
t
->
items
[
8
]
=
MP_OBJ_NEW_SMALL_INT
(
F_FLAG
);
t
->
items
[
9
]
=
MP_OBJ_NEW_SMALL_INT
(
F_NAMEMAX
);
return
t
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
mod_os_statvfs_obj
,
mod_os_statvfs
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment