From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58770) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqr5E-0004pB-IM for guix-patches@gnu.org; Tue, 27 Feb 2018 21:03:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqr5D-0008W2-1d for guix-patches@gnu.org; Tue, 27 Feb 2018 21:03:04 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:56628) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqr5C-0008Vo-Th for guix-patches@gnu.org; Tue, 27 Feb 2018 21:03:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eqr5C-0004mh-GE for guix-patches@gnu.org; Tue, 27 Feb 2018 21:03:02 -0500 Subject: [bug#30629] Device mapper modalias Resent-Message-ID: Date: Wed, 28 Feb 2018 04:03:00 +0100 From: Danny Milosavljevic Message-ID: <20180228040227.4299790b@scratchpost.org> In-Reply-To: <87tvu2w2vg.fsf@gnu.org> References: <20180227141720.12513-1-ludo@gnu.org> <20180227222632.42bcf52c@scratchpost.org> <87tvu2w2vg.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 30629@debbugs.gnu.org Hi Ludo, On Tue, 27 Feb 2018 22:15:31 +0100 ludo@gnu.org (Ludovic Court=C3=A8s) wrote: > >> 1. =E2=80=98device-module-aliases=E2=80=99 returns the empty list fo= r /dev/dm-0, which > >> is a LUKS device on my laptop. I=E2=80=99m not sure what it woul= d take to > >> have it return =E2=80=9Cdm-crypt=E2=80=9D, etc. Same for RAID de= vices. =20 > > > > Hmm... I don't know either. =20 >=20 > I browsed kmod in search of code that does that but couldn=E2=80=99t find= it. > Do you know of another source for such things? The device mapper for logical devices (/dev/mapper/control) provides ioctls. scheme@(guile-user)> (device-module-aliases "/dev/mapper/control") $2 =3D () Sigh... Also, Linux dm.c lazily modprobes "dm-%s", target_type. To get target_type as root (warning: getting the table status loads the mod= ule): #include #include #include #include #include #include #include #include #include #include #include static void xdm_init(struct dm_ioctl* header, unsigned dev, off_t datastart= , size_t allsize, unsigned flags) { memset(header, 0, sizeof(header)); header->version[0] =3D 4; header->version[1] =3D 0; header->version[2] =3D 0; header->data_size =3D allsize; header->data_start =3D datastart; header->flags =3D flags; header->dev =3D dev; } struct xdm_devicelist { struct dm_ioctl header; struct dm_name_list items[100]; }; struct xdm_tablestatus { struct dm_ioctl header; struct dm_target_spec items[100]; }; int main() { int controlfd; controlfd =3D open("/dev/mapper/control", O_RDWR); // Retrieve dev major/minor struct xdm_devicelist devicelist; xdm_init(&devicelist.header, 0, offsetof(struct xdm_devicelist, ite= ms), sizeof(devicelist), 0); if (ioctl(controlfd, DM_LIST_DEVICES, &devicelist) =3D=3D -1) abort(); printf("devicelist %s %u\n", devicelist.items[0].name, (unsigned) d= evicelist.items[0].dev); // Get target_type of that device struct xdm_tablestatus tablestatus; xdm_init(&tablestatus.header, devicelist.items[0].dev, offsetof(str= uct xdm_tablestatus, items), sizeof(tablestatus), DM_STATUS_TABLE_FLAG); tablestatus.header.dev =3D devicelist.items[0].dev; if (ioctl(controlfd, DM_TABLE_STATUS, &tablestatus) =3D=3D -1) { perror("b"); abort(); } assert(tablestatus.header.target_count =3D=3D 1); printf("target_type %s\n", tablestatus.items[0].target_type); // pr= ints "crypto", hence we should modprobe "dm-crypto". printf("XXX %u\n", makedev(253, 0)); // The same return 0; } Alternatively, there's even a dm-uevent.c for sysfs AND we have enabled it = AND it's supposed to report DM_TARGET - but I can't see it. Maybe it only does that for even= ts and not for state. Alternatively, there's also this: $ udevadm info -q all /dev/dm-0 ... which has quite a lot of the info, but not the module name.