diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-06-05 21:57:08 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-06-05 21:57:08 +0200 |
commit | 1613fd9f526dc5a5703bbeb1d84e59980db0845e (patch) | |
tree | d52be266d12694cbb23d01f1dfcc681756a8bc64 | |
parent | bbc35cc01b3632fe345244a5a366dd5e80755265 (diff) | |
download | plan9front-1613fd9f526dc5a5703bbeb1d84e59980db0845e.tar.xz |
disk/edisk: create esp partition in addition to plan9 partition in auto mode
-rw-r--r-- | sys/src/cmd/disk/prep/edisk.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/sys/src/cmd/disk/prep/edisk.c b/sys/src/cmd/disk/prep/edisk.c index cd2800815..907e1f53f 100644 --- a/sys/src/cmd/disk/prep/edisk.c +++ b/sys/src/cmd/disk/prep/edisk.c @@ -90,8 +90,6 @@ static int nparts; static uchar devid[16]; static uchar zeros[16]; -static Type *type9; - /* RFC4122, but in little endian format */ #define UU(a,b,c,d,e) { \ (a)&255,((a)>>8)&255,((a)>>16)&255,((a)>>24)&255, \ @@ -256,8 +254,6 @@ main(int argc, char **argv) initcrc32(); - type9 = gettype(nil, "plan9"); - secsize = 0; ARGBEGIN{ case 'a': @@ -895,18 +891,20 @@ newpart(Edit *edit, Gptpart *p, vlong start, vlong end, Type *type, uvlong attr) } static void -autopart(Edit *edit) +autopart1(Edit *edit, Type *type, uvlong attr, vlong maxsize) { vlong start, bigstart, bigsize; Gptpart *p; int i; + maxsize /= edit->disk->secsize; + bigsize = 0; bigstart = 0; start = partoff; for(i=0; i<edit->npart; i++){ p = (Gptpart*)edit->part[i]; - if(p->type == type9) + if(p->type == type) return; if(p->start > start && (p->start - start) > bigsize){ bigsize = p->start - start; @@ -922,14 +920,23 @@ autopart(Edit *edit) fprint(2, "couldn't find space for plan 9 partition\n"); return; } + if(maxsize && bigsize > maxsize) + bigsize = maxsize; for(i=0; i<nparts; i++){ p = &parts[i]; if(p->type == nil){ - newpart(edit, p, bigstart, bigstart+bigsize, type9, 0); + newpart(edit, p, bigstart, bigstart+bigsize, type, attr); return; } } - fprint(2, "couldn't find free slot for plan 9 partition\n"); + fprint(2, "couldn't find free slot for %s partition\n", type->name); +} + +static void +autopart(Edit *edit) +{ + autopart1(edit, gettype(nil, "esp"), 4, 550*MB); + autopart1(edit, gettype(nil, "plan9"), 0, 0); } typedef struct Name Name; @@ -1072,7 +1079,7 @@ cmdadd(Edit *edit, char *name, vlong start, vlong end) slot = atoi(name+1)-1; if(slot < 0 || slot >= nparts) return "partition number out of range"; - return newpart(edit, &parts[slot], start, end, type9, 0); + return newpart(edit, &parts[slot], start, end, gettype(nil, "plan9"), 0); } static char* |