
#include <inc/lib.h>

void
umain(void)
{
	int fd, n, r;
	char buf[512+1];

        printf("exectest startup: envid=%lx\n", env->env_id);
        
	printf("exectest: open /motd\n");
	if ((fd = open("/motd", O_RDONLY)) < 0)
		panic("exectest: open /motd: %e", fd);

	printf("exectest: read /motd\n");
	while ((n = read(fd, buf, sizeof buf-1)) > 0){
		buf[n] = 0;
		sys_cputs(buf);
	}

	printf("exectest: close /motd\n");
	close(fd);

	printf("exectest: spawn /init\n");
	if ((r = execl("/init", "init", "initarg1", "initarg2", (char*)0)) < 0)
		panic("exectest: execl /init: %e", r);

	printf("exectest: shouldn't reach this point\n");
}
