Added mount/unmount to FATFileSystem

Added virtual mount()/unmount() methods to FATFileSystem to allow users
to swap removable disks.
pull/421/head
neilt6 2014-07-30 10:22:23 -06:00
parent 48daa3c4a5
commit 979bc3e2d5
2 changed files with 14 additions and 0 deletions

View File

@ -130,3 +130,15 @@ int FATFileSystem::mkdir(const char *name, mode_t mode) {
FRESULT res = f_mkdir(name);
return res == 0 ? 0 : -1;
}
int FATFileSystem::mount() {
FRESULT res = f_mount(_fsid, &_fs);
return res == 0 ? 0 : -1;
}
int FATFileSystem::unmount() {
if (disk_sync())
return -1;
FRESULT res = f_mount(_fsid, NULL);
return res == 0 ? 0 : -1;
}

View File

@ -44,6 +44,8 @@ public:
virtual int format();
virtual DirHandle *opendir(const char *name);
virtual int mkdir(const char *name, mode_t mode);
virtual int mount();
virtual int unmount();
virtual int disk_initialize() { return 0; }
virtual int disk_status() { return 0; }