summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-10-16 04:40:18 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-10-16 04:40:18 +0200
commitd7ad36942d5baf99d21ee2e182f2139b043c0fff (patch)
treee4c439a69b6d50bdd33d923b92280c7110da0665
parentebdc47dad61a1dd0f9fde65532727ff5cbf384f2 (diff)
parent87e187b09cac8096194024ae7fa8cc1923a78d34 (diff)
downloadplan9front-d7ad36942d5baf99d21ee2e182f2139b043c0fff.tar.xz
merge
-rw-r--r--sys/src/cmd/disk/prep/fdisk.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/sys/src/cmd/disk/prep/fdisk.c b/sys/src/cmd/disk/prep/fdisk.c
index cfafcda2b..2ec44f2f4 100644
--- a/sys/src/cmd/disk/prep/fdisk.c
+++ b/sys/src/cmd/disk/prep/fdisk.c
@@ -246,6 +246,8 @@ enum {
Toffset = 446, /* offset of partition table in sector */
Magic0 = 0x55,
Magic1 = 0xAA,
+
+ Tablesize = NTentry*sizeof(Tentry) + 2,
};
struct Table {
@@ -454,7 +456,7 @@ recover(Edit *edit)
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 @@ rdpart(Edit *edit, uvlong xbase, uvlong ebrstart, int ebrtype)
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 @@ findmbr(Edit *edit)
{
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,14 +1024,14 @@ wrextend(Edit *edit, int i, vlong xbase, vlong startlba, vlong *endlba)
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++)
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 @@ wrextend(Edit *edit, int i, vlong xbase, vlong startlba, vlong *endlba)
}
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 @@ wrextend(Edit *edit, int i, vlong xbase, vlong startlba, vlong *endlba)
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 @@ wrpart(Edit *edit)
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 @@ wrpart(Edit *edit)
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 */