Skip to content

Commit

Permalink
7941 cannot use crypto lofi on a block/character device
Browse files Browse the repository at this point in the history
Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk>
Approved by: Dan McDonald <danmcd@joyent.com>
  • Loading branch information
tsoome authored and Dan McDonald committed May 14, 2018
1 parent 3e8bfa7 commit 35f80dc
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion usr/src/cmd/lofiadm/main.c
Expand Up @@ -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>
Expand Down Expand Up @@ -302,8 +303,22 @@ name_to_minor(const char *devicename)
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);
Expand Down

0 comments on commit 35f80dc

Please sign in to comment.