mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-12 00:10:58 +00:00
core/embed/unix: fix sdcard_init behaviour
This commit is contained in:
parent
68a3094b0a
commit
58a865dd05
@ -35,20 +35,23 @@
|
|||||||
|
|
||||||
#define SDCARD_SIZE (64 * 1024 * 1024)
|
#define SDCARD_SIZE (64 * 1024 * 1024)
|
||||||
|
|
||||||
static uint8_t *sdcard_buffer;
|
static uint8_t *sdcard_buffer = NULL;
|
||||||
static secbool sdcard_powered;
|
static secbool sdcard_powered = secfalse;
|
||||||
|
|
||||||
static void sdcard_exit(void) {
|
static void sdcard_exit(void) {
|
||||||
int r = munmap(sdcard_buffer, SDCARD_SIZE);
|
int r = munmap(sdcard_buffer, SDCARD_SIZE);
|
||||||
ensure(sectrue * (r == 0), "munmap failed");
|
ensure(sectrue * (r == 0), "munmap failed");
|
||||||
|
sdcard_buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdcard_init(void) {
|
void sdcard_init(void) {
|
||||||
int r;
|
if (sdcard_buffer != NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// check whether the file exists and it has the correct size
|
// check whether the file exists and it has the correct size
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
r = stat(SDCARD_FILE, &sb);
|
int r = stat(SDCARD_FILE, &sb);
|
||||||
|
|
||||||
// (re)create if non existant or wrong size
|
// (re)create if non existant or wrong size
|
||||||
if (r != 0 || sb.st_size != SDCARD_SIZE) {
|
if (r != 0 || sb.st_size != SDCARD_SIZE) {
|
||||||
|
Loading…
Reference in New Issue
Block a user