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
GitLab 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
dcf14c1b
Commit
dcf14c1b
authored
Sep 12, 2016
by
Alex March
Committed by
Damien George
Sep 27, 2016
Browse files
Options
Downloads
Patches
Plain Diff
extmod/vfs_fat: Add fat_vfs_statvfs(), reused from stmhal.
parent
791b65f4
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
extmod/vfs_fat.c
+31
-0
31 additions, 0 deletions
extmod/vfs_fat.c
with
31 additions
and
0 deletions
extmod/vfs_fat.c
+
31
−
0
View file @
dcf14c1b
...
...
@@ -250,6 +250,36 @@ STATIC mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
fat_vfs_stat_obj
,
fat_vfs_stat
);
// Get the status of a VFS.
STATIC
mp_obj_t
fat_vfs_statvfs
(
mp_obj_t
vfs_in
,
mp_obj_t
path_in
)
{
(
void
)
vfs_in
;
const
char
*
path
=
mp_obj_str_get_str
(
path_in
);
FATFS
*
fatfs
;
DWORD
nclst
;
FRESULT
res
=
f_getfree
(
path
,
&
nclst
,
&
fatfs
);
if
(
FR_OK
!=
res
)
{
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_OSError
,
MP_OBJ_NEW_SMALL_INT
(
fresult_to_errno_table
[
res
])));
}
mp_obj_tuple_t
*
t
=
MP_OBJ_TO_PTR
(
mp_obj_new_tuple
(
10
,
NULL
));
t
->
items
[
0
]
=
MP_OBJ_NEW_SMALL_INT
(
fatfs
->
csize
*
fatfs
->
ssize
);
// f_bsize
t
->
items
[
1
]
=
t
->
items
[
0
];
// f_frsize
t
->
items
[
2
]
=
MP_OBJ_NEW_SMALL_INT
((
fatfs
->
n_fatent
-
2
)
*
fatfs
->
csize
);
// f_blocks
t
->
items
[
3
]
=
MP_OBJ_NEW_SMALL_INT
(
nclst
);
// f_bfree
t
->
items
[
4
]
=
t
->
items
[
3
];
// f_bavail
t
->
items
[
5
]
=
MP_OBJ_NEW_SMALL_INT
(
0
);
// f_files
t
->
items
[
6
]
=
MP_OBJ_NEW_SMALL_INT
(
0
);
// f_ffree
t
->
items
[
7
]
=
MP_OBJ_NEW_SMALL_INT
(
0
);
// f_favail
t
->
items
[
8
]
=
MP_OBJ_NEW_SMALL_INT
(
0
);
// f_flags
t
->
items
[
9
]
=
MP_OBJ_NEW_SMALL_INT
(
_MAX_LFN
);
// f_namemax
return
MP_OBJ_FROM_PTR
(
t
);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
fat_vfs_statvfs_obj
,
fat_vfs_statvfs
);
// Unmount the filesystem
STATIC
mp_obj_t
fat_vfs_umount
(
mp_obj_t
vfs_in
)
{
fatfs_umount
(((
fs_user_mount_t
*
)
vfs_in
)
->
readblocks
[
1
]);
...
...
@@ -268,6 +298,7 @@ STATIC const mp_rom_map_elem_t fat_vfs_locals_dict_table[] = {
{
MP_ROM_QSTR
(
MP_QSTR_remove
),
MP_ROM_PTR
(
&
fat_vfs_remove_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_rename
),
MP_ROM_PTR
(
&
fat_vfs_rename_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_stat
),
MP_ROM_PTR
(
&
fat_vfs_stat_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_statvfs
),
MP_ROM_PTR
(
&
fat_vfs_statvfs_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_umount
),
MP_ROM_PTR
(
&
fat_vfs_umount_obj
)
},
};
STATIC
MP_DEFINE_CONST_DICT
(
fat_vfs_locals_dict
,
fat_vfs_locals_dict_table
);
...
...
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