Skip to content

Commit

Permalink
libefi: efi_get_devname: don't allocate procfs path
Browse files Browse the repository at this point in the history
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Matthew Ahrens <[email protected]>
Reviewed-by: John Kennedy <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes openzfs#12048
  • Loading branch information
nabijaczleweli authored and tonyhutter committed Nov 12, 2021
1 parent 32b9e7e commit 73fcaed
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/libefi/rdwr_efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,22 +218,15 @@ read_disk_info(int fd, diskaddr_t *capacity, uint_t *lbsize)
static char *
efi_get_devname(int fd)
{
char *path;
char *dev_name;

path = calloc(1, PATH_MAX);
if (path == NULL)
return (NULL);
char path[32];

/*
* 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
* name from /proc/self/fd/<fd>.
*/
(void) sprintf(path, "/proc/self/fd/%d", fd);
dev_name = realpath(path, NULL);
free(path);
return (dev_name);
(void) snprintf(path, sizeof (path), "/proc/self/fd/%d", fd);
return (realpath(path, NULL));
}

static int
Expand Down

0 comments on commit 73fcaed

Please sign in to comment.