From 981b80b797bbd8076ae280d7dd2e3dfda3ad76ec Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 13 Nov 2008 15:37:22 +0100 Subject: [PATCH] fdisk: read /proc/partitions in more robust way Signed-off-by: Karel Zak --- fdisk/fdisk.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index ff7ac672..84e1860f 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -2049,7 +2049,7 @@ add_partition(int n, int sys) { do { temp = start; for (i = 0; i < partitions; i++) { - unsigned int lastplusoff; + unsigned long long lastplusoff; if (start == ptes[i].offset) start += sector_offset; @@ -2065,7 +2065,7 @@ add_partition(int n, int sys) { read = 0; } if (!read && start == temp) { - unsigned int i = start; + unsigned long long i = start; start = read_int(cround(i), cround(i), cround(limit), 0, mesg); @@ -2551,7 +2551,8 @@ static void tryprocpt(void) { FILE *procpt; char line[100], ptname[100], devname[120]; - int ma, mi, sz; + int ma, mi; + unsigned long long sz; procpt = fopen(PROC_PARTITIONS, "r"); if (procpt == NULL) { @@ -2560,7 +2561,7 @@ tryprocpt(void) { } while (fgets(line, sizeof(line), procpt)) { - if (sscanf (line, " %d %d %d %[^\n ]", + if (sscanf (line, " %d %d %llu %100[^\n ]", &ma, &mi, &sz, ptname) != 4) continue; snprintf(devname, sizeof(devname), "/dev/%s", ptname); -- 2.39.5