Skip to content

fs: Add FileSystem::get_block_device #4886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions features/filesystem/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ int FileSystem::mkdir(const char *path, mode_t mode)
return -ENOSYS;
}

BlockDevice *FileSystem::get_block_device() const
{
return NULL;
}

int FileSystem::file_sync(fs_file_t file)
{
return 0;
Expand Down
7 changes: 7 additions & 0 deletions features/filesystem/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ class FileSystem : public FileSystemLike {
*/
virtual int mkdir(const char *path, mode_t mode);

/** Get the underlying block device
*
* @return The underlying block device, or NULL if no block
* device has been mounted
*/
virtual BlockDevice *get_block_device() const;

protected:
friend class File;
friend class Dir;
Expand Down
9 changes: 9 additions & 0 deletions features/filesystem/fat/FATFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ int FATFileSystem::unmount()
return fat_error_remap(res);
}

BlockDevice *FATFileSystem::get_block_device() const
{
if (_id != -1) {
return _ffs[_id];
} else {
return NULL;
}
}

/* See http://elm-chan.org/fsw/ff/en/mkfs.html for details of f_mkfs() and
* associated arguments. */
int FATFileSystem::format(BlockDevice *bd, int allocation_unit) {
Expand Down
7 changes: 7 additions & 0 deletions features/filesystem/fat/FATFileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ class FATFileSystem : public FileSystem {
*/
virtual int mkdir(const char *path, mode_t mode);

/** Get the underlying block device
*
* @return The underlying block device, or NULL if no block
* device has been mounted
*/
virtual BlockDevice *get_block_device() const;

protected:
/** Open a file on the filesystem
*
Expand Down