Skip to content

Commit

Permalink
Merge pull request #306 from antony-weber/format_sd_fix
Browse files Browse the repository at this point in the history
Enable formatting not mounted sdcards
  • Loading branch information
ligenxxxx authored Aug 3, 2023
2 parents ab9d7c1 + 1f7ca5d commit 909e54b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ui/page_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void page_storage_close_status_box() {
* The formatting routine.
*/
static format_codes_t page_storage_format_sd() {
if (!sdcard_mounted()) {
if (!sdcard_inserted()) {
return FMC_ERR_SDCARD_NOT_INSERTED;
}

Expand Down
5 changes: 5 additions & 0 deletions src/util/sdcard.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "sdcard.h"

#include <sys/stat.h>
#include <unistd.h>

bool sdcard_mounted() {
struct stat mountpoint;
Expand All @@ -15,3 +16,7 @@ bool sdcard_mounted() {

return false;
}

bool sdcard_inserted() {
return access(SD_BLOCK_DEVICE, F_OK) == 0;
}
4 changes: 4 additions & 0 deletions src/util/sdcard.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

#include <stdbool.h>

#define SD_BLOCK_DEVICE "/dev/mmcblk0"

bool sdcard_mounted();

bool sdcard_inserted();

0 comments on commit 909e54b

Please sign in to comment.