libefi: efi_get_devname: don't allocate procfs path
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: John Kennedy <john.kennedy@delphix.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12048
This commit is contained in:
parent
1a4030b1b5
commit
dec1ea4dbc
|
@ -218,22 +218,15 @@ read_disk_info(int fd, diskaddr_t *capacity, uint_t *lbsize)
|
||||||
static char *
|
static char *
|
||||||
efi_get_devname(int fd)
|
efi_get_devname(int fd)
|
||||||
{
|
{
|
||||||
char *path;
|
char path[32];
|
||||||
char *dev_name;
|
|
||||||
|
|
||||||
path = calloc(1, PATH_MAX);
|
|
||||||
if (path == NULL)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The libefi API only provides the open fd and not the file path.
|
* The libefi API only provides the open fd and not the file path.
|
||||||
* To handle this realpath(3) is used to resolve the block device
|
* To handle this realpath(3) is used to resolve the block device
|
||||||
* name from /proc/self/fd/<fd>.
|
* name from /proc/self/fd/<fd>.
|
||||||
*/
|
*/
|
||||||
(void) sprintf(path, "/proc/self/fd/%d", fd);
|
(void) snprintf(path, sizeof (path), "/proc/self/fd/%d", fd);
|
||||||
dev_name = realpath(path, NULL);
|
return (realpath(path, NULL));
|
||||||
free(path);
|
|
||||||
return (dev_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in New Issue