Define ctor args

This commit is contained in:
toninov 2025-07-22 00:25:03 +02:00
parent 07cc5797d9
commit d9e3745a33
No known key found for this signature in database
2 changed files with 23 additions and 4 deletions

View file

@ -21,8 +21,6 @@
* If not, see <https://www.gnu.org/licenses/>.
*/
#include <linux/delay.h>
#include "sflc.h"
#include "legacy/sflc_legacy.h"

View file

@ -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);