properly remove the partition number and separator

merge-requests/7/head
Richard Acayan 2 years ago
parent 50ef0328af
commit c1f24adfb6
  1. 10
      gpt-utils.cpp

@ -317,6 +317,7 @@ static int get_dev_path_from_partition_name(const char *partname, char *buf,
{ {
struct stat st; struct stat st;
char path[PATH_MAX] = { 0 }; char path[PATH_MAX] = { 0 };
int i;
(void)st; (void)st;
@ -334,7 +335,14 @@ static int get_dev_path_from_partition_name(const char *partname, char *buf,
if (!buf) { if (!buf) {
return -1; return -1;
} else { } else {
buf[PATH_TRUNCATE_LOC] = '\0'; for (i = strlen(buf); i > 0; i--)
if (!isdigit(buf[i - 1]))
break;
if (i >= 2 && buf[i - 1] == 'p' && isdigit(buf[i - 2]))
i--;
buf[i] = 0;
} }
return 0; return 0;
} }

Loading…
Cancel
Save