Skip to content

Commit d7fe4ff

Browse files
committed
fatfs: Fixed initialization of block device in mount/unmount functions
At some point the "mount" parameter for "f_mount" was name "force". This led to a bit of confusion that ended with the default mount function never calling block device init. This is fine, since the block device can be manually initialized, but a better user experience is where the filesystem initializes the block device for the user. This is backwards compatible due to the repeatability of the block device init functions.
1 parent 35999be commit d7fe4ff

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

features/filesystem/fat/FATFileSystem.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ FATFileSystem::~FATFileSystem()
247247

248248
int FATFileSystem::mount(BlockDevice *bd) {
249249
// requires duplicate definition to allow virtual overload to work
250-
return mount(bd, false);
250+
return mount(bd, true);
251251
}
252252

253-
int FATFileSystem::mount(BlockDevice *bd, bool force) {
253+
int FATFileSystem::mount(BlockDevice *bd, bool mount) {
254254
lock();
255255
if (_id != -1) {
256256
unlock();
@@ -265,7 +265,7 @@ int FATFileSystem::mount(BlockDevice *bd, bool force) {
265265
_fsid[1] = ':';
266266
_fsid[2] = '\0';
267267
debug_if(FFS_DBG, "Mounting [%s] on ffs drive [%s]\n", getName(), _fsid);
268-
FRESULT res = f_mount(&_fs, _fsid, force);
268+
FRESULT res = f_mount(&_fs, _fsid, mount);
269269
unlock();
270270
return fat_error_remap(res);
271271
}

features/filesystem/fat/FATFileSystem.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,6 @@ class FATFileSystem : public FileSystem {
6969
*/
7070
virtual int mount(BlockDevice *bd);
7171

72-
/** Mounts a filesystem to a block device
73-
*
74-
* @param bd BlockDevice to mount to
75-
* @param force Flag to force the underlying filesystem to force mounting the filesystem
76-
* @return 0 on success, negative error code on failure
77-
*/
78-
virtual int mount(BlockDevice *bd, bool force);
79-
8072
/** Unmounts a filesystem from the underlying block device
8173
*
8274
* @return 0 on success, negative error code on failure
@@ -235,6 +227,7 @@ class FATFileSystem : public FileSystem {
235227
protected:
236228
virtual void lock();
237229
virtual void unlock();
230+
virtual int mount(BlockDevice *bd, bool mount);
238231
};
239232

240233
#endif

0 commit comments

Comments
 (0)