This is the Rust library developed by the Stratis project, and I use it in a couple of my projects (blk-archive and thin-provisioning-tools). https://github.com/stratis-storage/devicemapper-rs - Joe On Mon, Mar 10, 2025 at 2:43 PM Zdenek Kabelac <zdenek.kabelac@xxxxxxxxx> wrote: > > Dne 09. 03. 25 v 17:00 Zack Weinberg napsal(a): > > I am developing a device-mapper client library in Rust. The language is > > relevant here because Rust's standard library makes a strong distinction > > between strings that are known to be encoded in UTF-8 and strings whose > > encoding is not known (`str` vs `OsStr`), with the latter being awkward > > to use compared to the former. > > > > The device-mapper ioctls use a lot of strings, and it's not clear > > to me from either the documentation or the kernel's source code > > what expectations the *kernel* has of the character encoding of these > > strings. I don't expect the kernel to care about UTF-8 versus > > ISO-8859-n or whatever, but it is plausible to me that at least some > > of the strings used in device-mapper ioctls can be expected always to > > be ASCII, in which case I can safely use `str` for them on the library > > side and it'll be more ergonomic for end users. > > Hi > > While you could surely interface kernel directly through ioctl(), > you should probably base your tool around libdevmapper as this library > is there to solve version differences or possible kernel or udev > issue that pops up here and there - if you will go your own path, > you will need to reimplement these things within Rust - which > might potentially be problematic - as we are solving i.e. udev trouble > to be working only within our 'small world' across different version of kernel > and udev version installed on the system. > > > > > There are, I think, four different kinds of strings used in device- > > mapper ioctls: target names, device names and UUIDs, table parameters, > > and target messages. For each of these, I would like to ask: > > Device name and UUID are always plain 7bit ASCII. > But there is a catch in udev process - as udev has even further limited char > subset usable for device names - libdevmapper uses name mangling for those. > > Again - you are free to reimplement your Rust version - but eventually this > may lead to a completely different set of udev rules needed for management of > Rust devices - as libdevmapper is free to 'change' DM udev rules as long as > we are 'internally' consistent - as these rules are seen as 'internal' > property for DM world. > > Regards > > Zdenek > >