Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Show more breadcrumbs
flow3r
flow3r firmware
Commits
f5164f31
Commit
f5164f31
authored
1 year ago
by
q3k
Browse files
Options
Downloads
Patches
Plain Diff
st3m: reformat vfs
Whoops.
parent
796e6d94
No related branches found
No related tags found
No related merge requests found
Pipeline
#5889
passed
1 year ago
Stage: check
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
components/st3m/st3m_fs.c
+68
-56
68 additions, 56 deletions
components/st3m/st3m_fs.c
main/fs.c
+1
-1
1 addition, 1 deletion
main/fs.c
with
69 additions
and
57 deletions
components/st3m/st3m_fs.c
+
68
−
56
View file @
f5164f31
...
...
@@ -15,22 +15,34 @@ static const char *TAG = "st3m-fs";
// Entries for root filesystem. Ideally this wouldn't be static but would
// consult the ESP-IDF VFS registry.
static
struct
dirent
_root_dirents
[
4
]
=
{
{
.
d_ino
=
1
,
.
d_name
=
"."
,
.
d_type
=
DT_DIR
,
},
{
.
d_ino
=
2
,
.
d_name
=
"flash"
,
.
d_type
=
DT_DIR
,
},
{
.
d_ino
=
3
,
.
d_name
=
"sd"
,
.
d_type
=
DT_DIR
,
},
{
.
d_ino
=
4
,
.
d_name
=
"console"
,
.
d_type
=
DT_DIR
,
},
{
.
d_ino
=
1
,
.
d_name
=
"."
,
.
d_type
=
DT_DIR
,
},
{
.
d_ino
=
2
,
.
d_name
=
"flash"
,
.
d_type
=
DT_DIR
,
},
{
.
d_ino
=
3
,
.
d_name
=
"sd"
,
.
d_type
=
DT_DIR
,
},
{
.
d_ino
=
4
,
.
d_name
=
"console"
,
.
d_type
=
DT_DIR
,
},
};
// Handle of the wear levelling library instance
static
wl_handle_t
s_wl_handle
=
WL_INVALID_HANDLE
;
static
int
_root_vfs_close
(
int
fd
)
{
return
0
;
}
static
int
_root_vfs_close
(
int
fd
)
{
return
0
;
}
static
int
_root_vfs_fcntl
(
int
fd
,
int
cmd
,
int
arg
)
{
return
0
;
}
static
int
_root_vfs_fcntl
(
int
fd
,
int
cmd
,
int
arg
)
{
return
0
;
}
static
int
_root_vfs_fstat
(
int
fd
,
struct
stat
*
st
)
{
st
->
st_mode
=
S_IFDIR
;
...
...
@@ -38,77 +50,77 @@ static int _root_vfs_fstat(int fd, struct stat *st) {
}
static
int
_root_vfs_open
(
const
char
*
path
,
int
flags
,
int
mode
)
{
if
(
strcmp
(
path
,
"/"
)
==
0
)
{
if
(
flags
==
0
)
{
return
0
;
}
errno
=
EISDIR
;
}
else
{
errno
=
ENOENT
;
}
return
-
1
;
if
(
strcmp
(
path
,
"/"
)
==
0
)
{
if
(
flags
==
0
)
{
return
0
;
}
errno
=
EISDIR
;
}
else
{
errno
=
ENOENT
;
}
return
-
1
;
}
static
ssize_t
_root_vfs_read
(
int
fd
,
void
*
data
,
size_t
size
)
{
errno
=
EISDIR
;
return
-
1
;
errno
=
EISDIR
;
return
-
1
;
}
static
ssize_t
_root_vfs_write
(
int
fd
,
const
void
*
data
,
size_t
size
)
{
errno
=
EISDIR
;
return
-
1
;
errno
=
EISDIR
;
return
-
1
;
}
typedef
struct
{
DIR
_inner
;
size_t
ix
;
DIR
_inner
;
size_t
ix
;
}
st3m_rootfs_dir_t
;
static
DIR
*
_root_vfs_opendir
(
const
char
*
name
)
{
if
(
strcmp
(
name
,
"/"
)
!=
0
)
{
errno
=
ENOENT
;
return
NULL
;
}
st3m_rootfs_dir_t
*
dir
=
calloc
(
1
,
sizeof
(
st3m_rootfs_dir_t
));
assert
(
dir
!=
NULL
);
return
(
DIR
*
)
dir
;
if
(
strcmp
(
name
,
"/"
)
!=
0
)
{
errno
=
ENOENT
;
return
NULL
;
}
st3m_rootfs_dir_t
*
dir
=
calloc
(
1
,
sizeof
(
st3m_rootfs_dir_t
));
assert
(
dir
!=
NULL
);
return
(
DIR
*
)
dir
;
}
static
struct
dirent
*
_root_vfs_readdir
(
DIR
*
pdir
)
{
st3m_rootfs_dir_t
*
dir
=
pdir
;
if
(
dir
->
ix
>=
(
sizeof
(
_root_dirents
)
/
sizeof
(
struct
dirent
)))
{
return
NULL
;
}
return
&
_root_dirents
[
dir
->
ix
++
];
st3m_rootfs_dir_t
*
dir
=
(
st3m_rootfs_dir_t
*
)
pdir
;
if
(
dir
->
ix
>=
(
sizeof
(
_root_dirents
)
/
sizeof
(
struct
dirent
)))
{
return
NULL
;
}
return
&
_root_dirents
[
dir
->
ix
++
];
}
static
int
_root_vfs_closedir
(
DIR
*
pdir
)
{
free
(
pdir
);
return
0
;
free
(
pdir
);
return
0
;
}
// Root filesystem implementation, because otherwise os.listdir("/") fails...
static
esp_vfs_t
_root_vfs
=
{
.
flags
=
ESP_VFS_FLAG_DEFAULT
,
.
close
=
&
_root_vfs_close
,
.
fcntl
=
&
_root_vfs_fcntl
,
.
fstat
=
&
_root_vfs_fstat
,
.
open
=
&
_root_vfs_open
,
.
read
=
&
_root_vfs_read
,
.
write
=
&
_root_vfs_write
,
.
opendir
=
&
_root_vfs_opendir
,
.
readdir
=
&
_root_vfs_readdir
,
.
closedir
=
&
_root_vfs_closedir
,
.
flags
=
ESP_VFS_FLAG_DEFAULT
,
.
close
=
&
_root_vfs_close
,
.
fcntl
=
&
_root_vfs_fcntl
,
.
fstat
=
&
_root_vfs_fstat
,
.
open
=
&
_root_vfs_open
,
.
read
=
&
_root_vfs_read
,
.
write
=
&
_root_vfs_write
,
.
opendir
=
&
_root_vfs_opendir
,
.
readdir
=
&
_root_vfs_readdir
,
.
closedir
=
&
_root_vfs_closedir
,
};
void
st3m_fs_init
(
void
)
{
esp_err_t
err
;
esp_err_t
err
;
if
((
err
=
esp_vfs_register
(
""
,
&
_root_vfs
,
NULL
))
!=
ESP_OK
)
{
ESP_LOGE
(
TAG
,
"Failed to mount root VFS: %s"
,
esp_err_to_name
(
err
));
return
;
}
if
((
err
=
esp_vfs_register
(
""
,
&
_root_vfs
,
NULL
))
!=
ESP_OK
)
{
ESP_LOGE
(
TAG
,
"Failed to mount root VFS: %s"
,
esp_err_to_name
(
err
));
return
;
}
const
esp_vfs_fat_mount_config_t
mount_config
=
{
.
max_files
=
4
,
...
...
@@ -117,7 +129,7 @@ void st3m_fs_init(void) {
};
err
=
esp_vfs_fat_spiflash_mount
(
"/flash"
,
"vfs"
,
&
mount_config
,
&
s_wl_handle
);
&
s_wl_handle
);
if
(
err
!=
ESP_OK
)
{
ESP_LOGE
(
TAG
,
"Failed to mount FAT FS: %s"
,
esp_err_to_name
(
err
));
return
;
...
...
This diff is collapsed.
Click to expand it.
main/fs.c
+
1
−
1
View file @
f5164f31
#include
"fs.h"
#include
"st3m_fs.h"
#include
"st3m_mode.h"
#include
"st3m_sys_data.h"
#include
"st3m_tar.h"
#include
"st3m_fs.h"
#include
"esp_system.h"
#include
"esp_vfs.h"
...
...
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