1 Index: kexec-boot-loader/main.c
2 ===================================================================
3 --- kexec-boot-loader.orig/main.c 2006-07-25 10:37:59.000000000 -0600
4 +++ kexec-boot-loader/main.c 2006-07-25 11:10:34.000000000 -0600
6 print("no %s, %s\n", err, what);
10 +static int xreadlink(const char *base, const char *file, char *result,
15 + char *f = alloca(strlen(base) + strlen(file) + 5);
18 + sprintf(f, "%s/.%s", base, file);
20 + sprintf(f, "%s/%s", base, file);
25 + if (S_ISLNK(s.st_mode)) {
26 + buf = alloca(len + 1);
27 + memset(buf, 0, len);
29 + if (readlink(f, buf, len) == -1)
32 + return xreadlink(base, buf, result, len);
35 + strncpy(result, f, len);
40 int stat_file(char *file)
43 int main (int argc, char *argv[])
46 + char *kernel, *cmd = NULL, *init = NULL;
49 - char *kernel = argv[1], *cmd = argv[2], *init = argv[3];
51 + no("few", "arguments");
61 - printf("argc is %d, argv[1] %s, argv[2] %s, argv[3] %s\n", argc, argv[1], argv[2], argv[3]);
62 + if (xreadlink(dirname(kernel), kernel, rkernel, sizeof(rkernel)))
63 + no("readlink", kernel);
65 - if (stat_file(kernel))
66 - no("kernel", kernel);
67 + if (stat_file(rkernel))
68 + no("kernel", rkernel);
70 - ret = my_load(cmd, kernel, init);
71 + ret = my_load(cmd, rkernel, init);