summaryrefslogtreecommitdiffstats
path: root/fdisk
diff options
context:
space:
mode:
authorKarel Zak2008-11-13 15:37:22 +0100
committerKarel Zak2008-11-13 15:37:22 +0100
commit981b80b797bbd8076ae280d7dd2e3dfda3ad76ec (patch)
treef334aeaea922bd5b72b3f51b107543bf5f7b5d9a /fdisk
parentfdisk: cannot create partition with starting beyond 1 TB (diff)
downloadkernel-qcow2-util-linux-981b80b797bbd8076ae280d7dd2e3dfda3ad76ec.tar.gz
kernel-qcow2-util-linux-981b80b797bbd8076ae280d7dd2e3dfda3ad76ec.tar.xz
kernel-qcow2-util-linux-981b80b797bbd8076ae280d7dd2e3dfda3ad76ec.zip
fdisk: read /proc/partitions in more robust way
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisk')
-rw-r--r--fdisk/fdisk.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index ff7ac6728..84e1860f2 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);