#include "u.h" #include "../port/lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "../port/error.h" #include void readn(Chan *c, void *vp, long n) { char *p; long nn; p = vp; while(n > 0) { nn = devtab[c->type]->read(c, p, n, c->offset); if(nn == 0) error(Eshort); c->offset += nn; p += nn; n -= nn; } } static void setbootcmd(int argc, char *argv[]) { char *buf, *p, *ep; int i; buf = malloc(1024); if(buf == nil) error(Enomem); p = buf; ep = buf + 1024; for(i=0; ipgsize from libmach */ rtext = ROUNDUP(entry + text, 1024*1024) - entry; size = rtext + data; p = malloc(size); if(p == nil) error(Enomem); if(waserror()){ free(p); nexterror(); } memset(p, 0, size); readn(c, p, text); readn(c, p + rtext, data); ksetenv("bootfile", argv[0], 1); setbootcmd(argc-1, argv+1); reboot((void*)entry, p, size); panic("return from reboot!"); }