Skip to content

Commit

Permalink
Merge pull request #296 from rickgaiser/fatfs_fixes
Browse files Browse the repository at this point in the history
Fatfs fixes
  • Loading branch information
rickgaiser authored Jun 28, 2022
2 parents 4cae487 + ae8706c commit 0eb238b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions iop/fs/bdmfs_fatfs/src/fs_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "module_debug.h"

FATFS fatfs;
struct block_device *mounted_bd;
struct block_device *mounted_bd = NULL;

void *malloc(int size);
void free(void *ptr);
Expand Down Expand Up @@ -472,7 +472,7 @@ int fs_ioctl2(iop_file_t *fd, int cmd, void *data, unsigned int datalen, void *r
int ret = 0;
FIL *file = ((FIL *)(fd->privdata));

if (file == NULL)
if ((file == NULL) || (mounted_bd == NULL))
return -ENXIO;

_fs_lock();
Expand All @@ -494,7 +494,7 @@ int fs_ioctl2(iop_file_t *fd, int cmd, void *data, unsigned int datalen, void *r
ret = *(int *)(mounted_bd->name);
break;
case USBMASS_IOCTL_CHECK_CHAIN:
ret = (file->obj.n_frag < 2);
ret = get_frag_list(file, NULL, 0) == 1 ? 1 : 0;
break;
case USBMASS_IOCTL_GET_FRAGLIST:
ret = get_frag_list(file, rdata, rdatalen);
Expand Down Expand Up @@ -535,7 +535,7 @@ static int fs_devctl(iop_file_t *fd, const char *name, int cmd, void *arg, unsig
int ret;
FIL *file = ((FIL *)(fd->privdata));

if (file == NULL)
if ((file == NULL) || (mounted_bd == NULL))
return -ENXIO;

_fs_lock();
Expand Down

0 comments on commit 0eb238b

Please sign in to comment.