Merge branch 'linux-user-disk' into refs/top-bases/linux-zfs-branch

This commit is contained in:
Brian Behlendorf 2010-07-23 10:44:38 -07:00
commit 404931364c
1 changed files with 11 additions and 3 deletions

View File

@ -149,10 +149,16 @@ static int
efi_get_info(int fd, struct dk_cinfo *dki_info)
{
#if defined(__linux__)
char path[PATH_MAX];
char *path;
char *dev_path;
int rval = 0;
memset(dki_info, 0, sizeof(*dki_info));
path = calloc(PATH_MAX, 1);
if (path == NULL)
goto error;
/*
* The simplest way to get the partition number under linux is
* to parse it out of the /dev/<disk><parition> block device name.
@ -166,9 +172,11 @@ efi_get_info(int fd, struct dk_cinfo *dki_info)
* /proc/self/fd/<fd>. Aside from the partition number we collect
* some additional device info.
*/
memset(dki_info, 0, sizeof(*dki_info));
(void) sprintf(path, "/proc/self/fd/%d", fd);
if ((dev_path = realpath(path, NULL)) == NULL)
dev_path = realpath(path, NULL);
free(path);
if (dev_path == NULL)
goto error;
if ((strncmp(dev_path, "/dev/sd", 7) == 0)) {