summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats/fsmgr.h
diff options
context:
space:
mode:
author npwoods <npwoods@mess.org>2022-09-19 02:33:50 -0400
committer GitHub <noreply@github.com>2022-09-19 08:33:50 +0200
commit5499683a239d9328a7c54b08135f31e7903ec772 (patch)
treee439ca5174cec47008c571f9c2636a5d4da68d81 /src/lib/formats/fsmgr.h
parente1e30896f5cc3fd736564a9dea25d255241f6777 (diff)
Changed fs::manager_t::enumerate_f() to simplify logic within file system drivers (#10106)
* Changed fs::manager_t::enumerate_f() to simplify logic within file system drivers enumerate_f() used to contain quite a bit of boilerplate logic to determine whether a particular floppy type should be added. This change attempts to move this logic outside the file system drivers to simplify the drivers. The riskiest part of this change is unformatted_image::enumerate_f(). I attempted to replicate the logic that was previously determining with unformatted image types to use, but the logic is tricky and it isn't clear to me that replicating the logic is the correct action - I may be cargo culting. * Fix to floppy_image_device::fs_enum::add_raw() * Updating FS_FAT to reflect this PR * On the advise of Sarayan, I moved the filtering to the fs::manager_t::fs_enum base class. This is actually a less intrusive change than what I originally had because it keeps the unformatted raw image handling closer to what we had previously. Some misgivings about these changes: 1. We now have fs::manager_t::fs_enum::add() being a thin call that invokes a protected method called fs::manager_t::fs_enum::add_format(). Better ideas for names are welcome. 2. It feels odd that we've removed the need to do filtering from the various FS modules, but the unformatted module has to ask the fs_enum() for its internal variables for filtering to perform the same logic. This seems to be the least worst option Feedback is welcome
Diffstat (limited to 'src/lib/formats/fsmgr.h')
-rw-r--r--src/lib/formats/fsmgr.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/lib/formats/fsmgr.h b/src/lib/formats/fsmgr.h
index c75b932cce9..6e3220ad753 100644
--- a/src/lib/formats/fsmgr.h
+++ b/src/lib/formats/fsmgr.h
@@ -288,10 +288,21 @@ class unformatted_floppy_creator;
class manager_t {
public:
struct floppy_enumerator {
+ floppy_enumerator(u32 form_factor, const std::vector<u32> &variants);
virtual ~floppy_enumerator() = default;
- virtual void add(const floppy_image_format_t &type, u32 image_size, const char *name, const char *description) = 0;
+ void add(const floppy_image_format_t &type, u32 form_factor, u32 variant, u32 image_size, const char *name, const char *description);
virtual void add_raw(const char *name, u32 key, const char *description) = 0;
+
+ u32 form_factor() const { return m_form_factor; }
+ const std::vector<u32> &variants() const { return m_variants; }
+
+ protected:
+ virtual void add_format(const floppy_image_format_t &type, u32 image_size, const char *name, const char *description) = 0;
+
+ private:
+ u32 m_form_factor;
+ const std::vector<u32> & m_variants;
};
struct hd_enumerator {
@@ -312,7 +323,7 @@ public:
virtual const char *name() const = 0;
virtual const char *description() const = 0;
- virtual void enumerate_f(floppy_enumerator &fe, u32 form_factor, const std::vector<u32> &variants) const;
+ virtual void enumerate_f(floppy_enumerator &fe) const;
virtual void enumerate_h(hd_enumerator &he) const;
virtual void enumerate_c(cdrom_enumerator &ce) const;
@@ -331,11 +342,11 @@ public:
// Create a filesystem object from a block device
virtual std::unique_ptr<filesystem_t> mount(fsblk_t &blockdev) const = 0;
-protected:
- manager_t() = default;
-
static bool has(u32 form_factor, const std::vector<u32> &variants, u32 ff, u32 variant);
static bool has_variant(const std::vector<u32> &variants, u32 variant);
+
+protected:
+ manager_t() = default;
};
} // namespace fs