Mercurial > unleashed > prev-conversion
changeset 18832:365f79a66849
cannot use crypto lofi on a block/character device
illumos issue #7941
author | Toomas Soome <tsoome@me.com> |
---|---|
date | Sat, 24 Mar 2018 18:13:39 +0200 |
parents | 9406d2a9566f |
children | f69311ba75b3 |
files | usr/src/cmd/lofiadm/main.c |
diffstat | 1 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/lofiadm/main.c Tue Mar 13 10:06:12 2018 +0200 +++ b/usr/src/cmd/lofiadm/main.c Sat Mar 24 18:13:39 2018 +0200 @@ -40,6 +40,7 @@ #include <sys/lofi.h> #include <sys/stat.h> #include <sys/sysmacros.h> +#include <sys/modctl.h> #include <netinet/in.h> #include <stdio.h> #include <fcntl.h> @@ -302,8 +303,22 @@ return (0); } + /* + * For disk devices we use modctl(MODGETNAME) to read driver name + * for major device. + */ if (st.st_mode & S_IFCHR || st.st_mode & S_IFBLK) { - return (LOFI_MINOR2ID(minor(st.st_rdev))); + major_t maj; + char mname[MODMAXNAMELEN]; + + maj = major(st.st_rdev); + + if (modctl(MODGETNAME, mname, MODMAXNAMELEN, &maj) == 0) { + if (strncmp(mname, LOFI_DRIVER_NAME, + sizeof (LOFI_DRIVER_NAME)) == 0) { + return (LOFI_MINOR2ID(minor(st.st_rdev))); + } + } } return (0);