ublk-org / ublksrv

ublk: userspace block device driver
MIT License
150 stars 53 forks source link

Parameterize /dev/ublk-control #74

Closed mattysweeps closed 1 month ago

mattysweeps commented 1 month ago

ublksrv_cmd.c hard codes the filename of the ublk control device with #define CTRL_DEV "/dev/ublk-control".

While this works for almost all use cases, some users might mount devtmpfs somewhere else, such as /mnt/devtmpfs/. This means the control device is actually /mnt/devtmpfs/ublk-control.

One solution would be to add an optional field to struct ublksrv_dev_data so users who call ublksrv_ctrl_init() can set the appropriate filename.

ming1 commented 1 month ago

The requirement is reasonable.

Are you fine with C macro defined by autoconf with AC_ARG_WITH or AC_ARG_ENABLE for overriding the default name of "/dev/ublk-control" ?

mattysweeps commented 1 month ago

A C macro would work but a runtime configuration option like #75 would be more flexible and open up more opportunities such as:

  1. Adding a flag to configure the control device
  2. Packaging a ublksrv implementation binary for easy distribution (ex: container image)
  3. More creative ideas like a proxy control device, etc.
mattysweeps commented 1 month ago

This morning I realized I need to tweak #75 because there's another C macro in include/ublksrv_priv.h.

/* todo: relace the hardcode name with /dev/char/maj:min */
#define UBLKC_DEV   "/dev/ublkc"

So for now a C macro is probably the better approach, and runtime configuration options can be revisited if/when more flexibility is needed.