mirror of
https://codeberg.org/shufflecake/shufflecake-c.git
synced 2026-01-06 19:15:38 -05:00
Define ctor args
This commit is contained in:
parent
07cc5797d9
commit
d9e3745a33
2 changed files with 23 additions and 4 deletions
|
|
@ -21,8 +21,6 @@
|
|||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <linux/delay.h>
|
||||
|
||||
#include "sflc.h"
|
||||
#include "legacy/sflc_legacy.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@
|
|||
* Type-checked polymorphism is achieved by having device and volume methods
|
||||
* take as argument a pointer to a base-class struct, instead of an opaque void
|
||||
* pointer. The pointer is then "down-cast" in the mode-specific method.
|
||||
* The same pattern is followed for the struct representing the constructor
|
||||
* arguments.
|
||||
*/
|
||||
|
||||
#ifndef _SFLC_TYPES_H
|
||||
|
|
@ -116,6 +118,25 @@ struct sflc_volume_base
|
|||
struct sflc_mode_ops *ops;
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for constructor arguments.
|
||||
* Inherited by derived classes for mode-specific arguments.
|
||||
*/
|
||||
struct sflc_ctor_args_base
|
||||
{
|
||||
/* Shufflecake mode: Legacy or Lite */
|
||||
u32 mode;
|
||||
|
||||
/*Shufflecake-unique device ID*/
|
||||
u32 dev_id;
|
||||
|
||||
/* Underlying block device: MAJOR,MINOR */
|
||||
dev_t bdev_devt;
|
||||
|
||||
/* Volume index within the device */
|
||||
u32 vol_idx;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------
|
||||
|
|
@ -125,14 +146,14 @@ struct sflc_volume_base
|
|||
|
||||
/* Device constructor */
|
||||
typedef struct sflc_device_base* (*sflc_mode_dev_ctr_fn) (
|
||||
struct dm_target *ti, int argc, char **argv);
|
||||
struct dm_target *ti, struct sflc_ctor_args_base *args_base);
|
||||
/* Device destructor */
|
||||
typedef void (*sflc_mode_dev_dtr_fn) (struct sflc_device_base* sd_base);
|
||||
|
||||
/* Volume constructor */
|
||||
typedef struct sflc_volume_base* (*sflc_mode_vol_ctr_fn) (
|
||||
struct sflc_device_base *sd_base, struct dm_target *ti,
|
||||
int argc, char **argv);
|
||||
struct sflc_ctor_args_base *args_base);
|
||||
/* Volume destructor */
|
||||
typedef void (*sflc_mode_vol_dtr_fn) (struct sflc_volume_base* sv_base);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue