ref: d7ad36942d5baf99d21ee2e182f2139b043c0fff
parent: ebdc47dad61a1dd0f9fde65532727ff5cbf384f2
parent: 87e187b09cac8096194024ae7fa8cc1923a78d34
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Wed Oct 16 00:40:18 EDT 2013
merge
--- a/sys/src/cmd/disk/prep/fdisk.c
+++ b/sys/src/cmd/disk/prep/fdisk.c
@@ -246,6 +246,8 @@
Toffset = 446, /* offset of partition table in sector */
Magic0 = 0x55,
Magic1 = 0xAA,
+
+ Tablesize = NTentry*sizeof(Tentry) + 2,
};
struct Table {@@ -454,7 +456,7 @@
err = 0;
for(i=0; i<nrtab; i++)
- if(diskwrite(edit->disk, &rtab[i].table, sizeof(Table), rtab[i].lba, Toffset) < 0)
+ if(diskwrite(edit->disk, &rtab[i].table, Tablesize, rtab[i].lba, Toffset) < 0)
err = 1;
if(err) {fprint(2, "warning: some writes failed during restoration of old partition tables\n");
@@ -499,7 +501,7 @@
if(xbase == 0)
xbase = ebrstart;
- diskread(edit->disk, &table, sizeof table, ebrstart, Toffset);
+ diskread(edit->disk, &table, Tablesize, ebrstart, Toffset);
addrecover(table, ebrstart);
if(table.magic[0] != Magic0 || table.magic[1] != Magic1)
return;
@@ -533,7 +535,7 @@
{Table table;
- diskread(edit->disk, &table, sizeof(Table), 0, Toffset);
+ diskread(edit->disk, &table, Tablesize, 0, Toffset);
if(table.magic[0] != Magic0 || table.magic[1] != Magic1)
sysfatal("did not find master boot record");}
@@ -1022,7 +1024,7 @@
Finish:
if(startlba < *endlba){disk = edit->disk;
- diskread(disk, &table, sizeof table, startlba, Toffset);
+ diskread(disk, &table, Tablesize, startlba, Toffset);
tp = table.entry;
ep = tp+NTentry;
for(; tp<ep; tp++)
@@ -1029,7 +1031,7 @@
memset(tp, 0, sizeof *tp);
table.magic[0] = Magic0;
table.magic[1] = Magic1;
- if(diskwrite(edit->disk, &table, sizeof table, startlba, Toffset) < 0)
+ if(diskwrite(edit->disk, &table, Tablesize, startlba, Toffset) < 0)
recover(edit);
}
return i;
@@ -1041,7 +1043,7 @@
}
disk = edit->disk;
- diskread(disk, &table, sizeof table, startlba, Toffset);
+ diskread(disk, &table, Tablesize, startlba, Toffset);
tp = table.entry;
ep = tp+NTentry;
@@ -1077,7 +1079,7 @@
table.magic[0] = Magic0;
table.magic[1] = Magic1;
- if(diskwrite(edit->disk, &table, sizeof table, startlba, Toffset) < 0)
+ if(diskwrite(edit->disk, &table, Tablesize, startlba, Toffset) < 0)
recover(edit);
return ni;
}
@@ -1094,7 +1096,7 @@
disk = edit->disk;
- diskread(disk, &table, sizeof table, 0, Toffset);
+ diskread(disk, &table, Tablesize, 0, Toffset);
tp = table.entry;
ep = tp+NTentry;
@@ -1119,7 +1121,7 @@
if(i != edit->npart)
sysfatal("cannot happen #1");- if(diskwrite(disk, &table, sizeof table, 0, Toffset) < 0)
+ if(diskwrite(disk, &table, Tablesize, 0, Toffset) < 0)
recover(edit);
/* bring parts up to date */
--
⑨