Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
zenox
firmware
Commits
3b436505
Commit
3b436505
authored
Jan 24, 2020
by
schneider
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'schneider/fat-locking' into 'master'
FS locking and FD counting See merge request
card10/firmware!370
parents
2b12800d
9b411213
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
99 additions
and
7 deletions
+99
-7
epicardium/ble/ble.c
epicardium/ble/ble.c
+1
-1
epicardium/ble/ble_main.c
epicardium/ble/ble_main.c
+1
-1
epicardium/fs/filesystem_fat.c
epicardium/fs/filesystem_fat.c
+1
-0
epicardium/fs/fs_util.c
epicardium/fs/fs_util.c
+92
-0
epicardium/fs/fs_util.h
epicardium/fs/fs_util.h
+0
-0
epicardium/meson.build
epicardium/meson.build
+1
-0
epicardium/modules/config.c
epicardium/modules/config.c
+3
-3
lib/ff13/meson.build
lib/ff13/meson.build
+0
-2
No files found.
epicardium/ble/ble.c
View file @
3b436505
#include "epicardium.h"
#include "modules/log.h"
#include "fs_util.h"
#include "fs
/fs
_util.h"
#include "wsf_types.h"
#include "wsf_buf.h"
#include "wsf_trace.h"
...
...
epicardium/ble/ble_main.c
View file @
3b436505
...
...
@@ -17,7 +17,7 @@
#include <string.h>
#include "wsf_types.h"
#include "util/bstream.h"
#include "fs_util.h"
#include "fs
/fs
_util.h"
#include "wsf_msg.h"
#include "wsf_trace.h"
#include "hci_api.h"
...
...
epicardium/fs/filesystem_fat.c
View file @
3b436505
...
...
@@ -285,6 +285,7 @@ efs_get_new(EpicFileSystem *fs, uint32_t *idx, struct FatObject **obj, int *rc)
}
*
obj
=
&
fs
->
pool
[
index
];
*
idx
=
index
;
return
true
;
}
...
...
lib/ff13/util
/fs_util.c
→
epicardium/fs
/fs_util.c
View file @
3b436505
#include "fs_util.h"
#include "ff.h"
#include "epicardium.h"
#include <stdint.h>
#include <string.h>
FATFS
FatFs
;
/* File system object for logical drive */
FS_USAGE
FsUsage
;
int
fs_read_file
(
char
*
filename
,
void
*
data
,
int
len
)
{
int
fd
=
epic_file_open
(
filename
,
"r"
);
if
(
fd
<
0
)
{
return
fd
;
}
int
res
=
epic_file_read
(
fd
,
data
,
len
);
epic_file_close
(
fd
);
return
res
;
}
int
fs_read_text_file
(
char
*
filename
,
char
*
data
,
int
len
)
{
int
readbytes
;
if
(
len
<
1
)
return
-
1
;
readbytes
=
fs_read_file
(
filename
,
data
,
len
-
1
);
if
(
readbytes
<
0
)
{
data
[
0
]
=
0
;
return
readbytes
;
};
data
[
readbytes
]
=
0
;
while
(
readbytes
>
0
&&
data
[
readbytes
-
1
]
<
0x20
)
{
data
[
--
readbytes
]
=
0
;
};
return
readbytes
;
}
int
fs_write_file
(
char
*
filename
,
const
void
*
data
,
int
len
)
{
int
fd
=
epic_file_open
(
filename
,
"w"
);
if
(
fd
<
0
)
{
return
fd
;
}
int
res
=
epic_file_write
(
fd
,
data
,
len
);
epic_file_close
(
fd
);
return
res
;
}
int
fs_get_file_size
(
char
*
filename
)
{
struct
epic_stat
stat
;
int
res
=
epic_file_stat
(
filename
,
&
stat
);
return
res
<
0
?
res
:
(
int
)
stat
.
size
;
}
#if 0
#include "ff.h"
FATFS FatFs; /* File system object for logical drive */
FS_USAGE FsUsage;
/* TODO: Port functions from r0ket/rad10 libs */
int fs_info(FATFS *fs)
{
memcpy(fs, &FatFs, sizeof(FATFS));
...
...
@@ -35,72 +89,4 @@ int fs_usage(FATFS *fs, FS_USAGE *fs_usage)
return
0
;
}
int
fs_read_file
(
char
*
filename
,
void
*
data
,
int
len
){
FIL
file
;
UINT
readbytes
;
int
res
;
res
=
f_open
(
&
file
,
filename
,
FA_OPEN_EXISTING
|
FA_READ
);
if
(
res
){
return
-
1
;
};
res
=
f_read
(
&
file
,
data
,
len
,
&
readbytes
);
if
(
res
){
return
-
1
;
};
f_close
(
&
file
);
return
readbytes
;
}
int
fs_read_text_file
(
char
*
filename
,
char
*
data
,
int
len
){
int
readbytes
;
if
(
len
<
1
)
return
-
1
;
readbytes
=
fs_read_file
(
filename
,
data
,
len
-
1
);
if
(
readbytes
<
0
){
data
[
0
]
=
0
;
return
readbytes
;
};
data
[
readbytes
]
=
0
;
while
(
readbytes
>
0
&&
data
[
readbytes
-
1
]
<
0x20
){
data
[
--
readbytes
]
=
0
;
};
return
readbytes
;
}
int
fs_write_file
(
char
*
filename
,
const
void
*
data
,
int
len
){
FIL
file
;
UINT
writebytes
;
int
res
;
res
=
f_open
(
&
file
,
filename
,
FA_CREATE_ALWAYS
|
FA_WRITE
);
if
(
res
){
return
-
res
;
};
res
=
f_write
(
&
file
,
data
,
len
,
&
writebytes
);
if
(
res
){
return
-
res
;
};
f_close
(
&
file
);
return
writebytes
;
}
int
fs_get_file_size
(
char
*
filename
){
FILINFO
finfo
;
int
res
;
/// XXX: Untested
res
=
f_stat
(
filename
,
&
finfo
);
if
(
res
){
return
-
1
;
}
return
finfo
.
fsize
;
}
#endif
lib/ff13/util
/fs_util.h
→
epicardium/fs
/fs_util.h
View file @
3b436505
File moved
epicardium/meson.build
View file @
3b436505
...
...
@@ -86,6 +86,7 @@ elf = executable(
'main.c',
'support.c',
'fs/filesystem_fat.c',
'fs/fs_util.c',
module_sources,
l0der_sources,
ble_sources,
...
...
epicardium/modules/config.c
View file @
3b436505
...
...
@@ -272,10 +272,10 @@ void load_config(void)
char
newline
;
rc
=
epic_file_read
(
fd
,
&
newline
,
1
);
if
(
rc
<
0
||
(
newline
!=
'\n'
&&
newline
!=
'\r'
))
{
LOG_ERR
(
"card10.cfg"
,
"
seek
failed, aborting"
);
LOG_ERR
(
"card10.cfg"
,
"
read
failed, aborting"
);
LOG_DEBUG
(
"card10.cfg"
,
"
seek
failed at read-back of newline: rc: %d read: %d"
,
"
read
failed at read-back of newline: rc: %d read: %d"
,
rc
,
(
int
)
newline
);
...
...
@@ -305,7 +305,7 @@ static size_t read_config_offset(size_t seek_offset, char *buf, size_t buf_len)
int
rc
=
epic_file_seek
(
fd
,
seek_offset
,
SEEK_SET
);
if
(
rc
<
0
)
{
LOG_ERR
(
"card10.cfg"
,
"seek failed, aborting"
);
LOG_ERR
(
"card10.cfg"
,
"seek
2
failed
(%d)
, aborting"
,
rc
);
return
0
;
}
...
...
lib/ff13/meson.build
View file @
3b436505
includes = include_directories(
'./Source/',
'./util/',
)
sources = files(
...
...
@@ -8,7 +7,6 @@ sources = files(
'./Source/ff.c',
'./Source/ffsystem.c',
'./Source/ffunicode.c',
'./util/fs_util.c',
)
lib = static_library(
...
...
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