Skip to content

Commit 909e54b

Browse files
authored
Merge pull request #306 from antony-weber/format_sd_fix
Enable formatting not mounted sdcards
2 parents ab9d7c1 + 1f7ca5d commit 909e54b

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/ui/page_storage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static void page_storage_close_status_box() {
104104
* The formatting routine.
105105
*/
106106
static format_codes_t page_storage_format_sd() {
107-
if (!sdcard_mounted()) {
107+
if (!sdcard_inserted()) {
108108
return FMC_ERR_SDCARD_NOT_INSERTED;
109109
}
110110

src/util/sdcard.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "sdcard.h"
22

33
#include <sys/stat.h>
4+
#include <unistd.h>
45

56
bool sdcard_mounted() {
67
struct stat mountpoint;
@@ -15,3 +16,7 @@ bool sdcard_mounted() {
1516

1617
return false;
1718
}
19+
20+
bool sdcard_inserted() {
21+
return access(SD_BLOCK_DEVICE, F_OK) == 0;
22+
}

src/util/sdcard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
#include <stdbool.h>
44

5+
#define SD_BLOCK_DEVICE "/dev/mmcblk0"
6+
57
bool sdcard_mounted();
8+
9+
bool sdcard_inserted();

0 commit comments

Comments
 (0)