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
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
Show more breadcrumbs
dos
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
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
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";
...
@@ -15,22 +15,34 @@ static const char *TAG = "st3m-fs";
// Entries for root filesystem. Ideally this wouldn't be static but would
// Entries for root filesystem. Ideally this wouldn't be static but would
// consult the ESP-IDF VFS registry.
// consult the ESP-IDF VFS registry.
static
struct
dirent
_root_dirents
[
4
]
=
{
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
=
1
,
{
.
d_ino
=
3
,
.
d_name
=
"sd"
,
.
d_type
=
DT_DIR
,
},
.
d_name
=
"."
,
{
.
d_ino
=
4
,
.
d_name
=
"console"
,
.
d_type
=
DT_DIR
,
},
.
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
// Handle of the wear levelling library instance
static
wl_handle_t
s_wl_handle
=
WL_INVALID_HANDLE
;
static
wl_handle_t
s_wl_handle
=
WL_INVALID_HANDLE
;
static
int
_root_vfs_close
(
int
fd
)
{
static
int
_root_vfs_close
(
int
fd
)
{
return
0
;
}
return
0
;
}
static
int
_root_vfs_fcntl
(
int
fd
,
int
cmd
,
int
arg
)
{
static
int
_root_vfs_fcntl
(
int
fd
,
int
cmd
,
int
arg
)
{
return
0
;
}
return
0
;
}
static
int
_root_vfs_fstat
(
int
fd
,
struct
stat
*
st
)
{
static
int
_root_vfs_fstat
(
int
fd
,
struct
stat
*
st
)
{
st
->
st_mode
=
S_IFDIR
;
st
->
st_mode
=
S_IFDIR
;
...
@@ -38,77 +50,77 @@ static int _root_vfs_fstat(int fd, struct stat *st) {
...
@@ -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
)
{
static
int
_root_vfs_open
(
const
char
*
path
,
int
flags
,
int
mode
)
{
if
(
strcmp
(
path
,
"/"
)
==
0
)
{
if
(
strcmp
(
path
,
"/"
)
==
0
)
{
if
(
flags
==
0
)
{
if
(
flags
==
0
)
{
return
0
;
return
0
;
}
}
errno
=
EISDIR
;
errno
=
EISDIR
;
}
else
{
}
else
{
errno
=
ENOENT
;
errno
=
ENOENT
;
}
}
return
-
1
;
return
-
1
;
}
}
static
ssize_t
_root_vfs_read
(
int
fd
,
void
*
data
,
size_t
size
)
{
static
ssize_t
_root_vfs_read
(
int
fd
,
void
*
data
,
size_t
size
)
{
errno
=
EISDIR
;
errno
=
EISDIR
;
return
-
1
;
return
-
1
;
}
}
static
ssize_t
_root_vfs_write
(
int
fd
,
const
void
*
data
,
size_t
size
)
{
static
ssize_t
_root_vfs_write
(
int
fd
,
const
void
*
data
,
size_t
size
)
{
errno
=
EISDIR
;
errno
=
EISDIR
;
return
-
1
;
return
-
1
;
}
}
typedef
struct
{
typedef
struct
{
DIR
_inner
;
DIR
_inner
;
size_t
ix
;
size_t
ix
;
}
st3m_rootfs_dir_t
;
}
st3m_rootfs_dir_t
;
static
DIR
*
_root_vfs_opendir
(
const
char
*
name
)
{
static
DIR
*
_root_vfs_opendir
(
const
char
*
name
)
{
if
(
strcmp
(
name
,
"/"
)
!=
0
)
{
if
(
strcmp
(
name
,
"/"
)
!=
0
)
{
errno
=
ENOENT
;
errno
=
ENOENT
;
return
NULL
;
return
NULL
;
}
}
st3m_rootfs_dir_t
*
dir
=
calloc
(
1
,
sizeof
(
st3m_rootfs_dir_t
));
st3m_rootfs_dir_t
*
dir
=
calloc
(
1
,
sizeof
(
st3m_rootfs_dir_t
));
assert
(
dir
!=
NULL
);
assert
(
dir
!=
NULL
);
return
(
DIR
*
)
dir
;
return
(
DIR
*
)
dir
;
}
}
static
struct
dirent
*
_root_vfs_readdir
(
DIR
*
pdir
)
{
static
struct
dirent
*
_root_vfs_readdir
(
DIR
*
pdir
)
{
st3m_rootfs_dir_t
*
dir
=
pdir
;
st3m_rootfs_dir_t
*
dir
=
(
st3m_rootfs_dir_t
*
)
pdir
;
if
(
dir
->
ix
>=
(
sizeof
(
_root_dirents
)
/
sizeof
(
struct
dirent
)))
{
if
(
dir
->
ix
>=
(
sizeof
(
_root_dirents
)
/
sizeof
(
struct
dirent
)))
{
return
NULL
;
return
NULL
;
}
}
return
&
_root_dirents
[
dir
->
ix
++
];
return
&
_root_dirents
[
dir
->
ix
++
];
}
}
static
int
_root_vfs_closedir
(
DIR
*
pdir
)
{
static
int
_root_vfs_closedir
(
DIR
*
pdir
)
{
free
(
pdir
);
free
(
pdir
);
return
0
;
return
0
;
}
}
// Root filesystem implementation, because otherwise os.listdir("/") fails...
// Root filesystem implementation, because otherwise os.listdir("/") fails...
static
esp_vfs_t
_root_vfs
=
{
static
esp_vfs_t
_root_vfs
=
{
.
flags
=
ESP_VFS_FLAG_DEFAULT
,
.
flags
=
ESP_VFS_FLAG_DEFAULT
,
.
close
=
&
_root_vfs_close
,
.
close
=
&
_root_vfs_close
,
.
fcntl
=
&
_root_vfs_fcntl
,
.
fcntl
=
&
_root_vfs_fcntl
,
.
fstat
=
&
_root_vfs_fstat
,
.
fstat
=
&
_root_vfs_fstat
,
.
open
=
&
_root_vfs_open
,
.
open
=
&
_root_vfs_open
,
.
read
=
&
_root_vfs_read
,
.
read
=
&
_root_vfs_read
,
.
write
=
&
_root_vfs_write
,
.
write
=
&
_root_vfs_write
,
.
opendir
=
&
_root_vfs_opendir
,
.
opendir
=
&
_root_vfs_opendir
,
.
readdir
=
&
_root_vfs_readdir
,
.
readdir
=
&
_root_vfs_readdir
,
.
closedir
=
&
_root_vfs_closedir
,
.
closedir
=
&
_root_vfs_closedir
,
};
};
void
st3m_fs_init
(
void
)
{
void
st3m_fs_init
(
void
)
{
esp_err_t
err
;
esp_err_t
err
;
if
((
err
=
esp_vfs_register
(
""
,
&
_root_vfs
,
NULL
))
!=
ESP_OK
)
{
if
((
err
=
esp_vfs_register
(
""
,
&
_root_vfs
,
NULL
))
!=
ESP_OK
)
{
ESP_LOGE
(
TAG
,
"Failed to mount root VFS: %s"
,
esp_err_to_name
(
err
));
ESP_LOGE
(
TAG
,
"Failed to mount root VFS: %s"
,
esp_err_to_name
(
err
));
return
;
return
;
}
}
const
esp_vfs_fat_mount_config_t
mount_config
=
{
const
esp_vfs_fat_mount_config_t
mount_config
=
{
.
max_files
=
4
,
.
max_files
=
4
,
...
@@ -117,7 +129,7 @@ void st3m_fs_init(void) {
...
@@ -117,7 +129,7 @@ void st3m_fs_init(void) {
};
};
err
=
esp_vfs_fat_spiflash_mount
(
"/flash"
,
"vfs"
,
&
mount_config
,
err
=
esp_vfs_fat_spiflash_mount
(
"/flash"
,
"vfs"
,
&
mount_config
,
&
s_wl_handle
);
&
s_wl_handle
);
if
(
err
!=
ESP_OK
)
{
if
(
err
!=
ESP_OK
)
{
ESP_LOGE
(
TAG
,
"Failed to mount FAT FS: %s"
,
esp_err_to_name
(
err
));
ESP_LOGE
(
TAG
,
"Failed to mount FAT FS: %s"
,
esp_err_to_name
(
err
));
return
;
return
;
...
...
This diff is collapsed.
Click to expand it.
main/fs.c
+
1
−
1
View file @
f5164f31
#include
"fs.h"
#include
"fs.h"
#include
"st3m_fs.h"
#include
"st3m_mode.h"
#include
"st3m_mode.h"
#include
"st3m_sys_data.h"
#include
"st3m_sys_data.h"
#include
"st3m_tar.h"
#include
"st3m_tar.h"
#include
"st3m_fs.h"
#include
"esp_system.h"
#include
"esp_system.h"
#include
"esp_vfs.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