summaryrefslogtreecommitdiffstats
path: root/loader2
diff options
context:
space:
mode:
authorJán ONDREJ <ondrejj@salstar.sk>2008-06-04 06:38:02 +0000
committerJán ONDREJ <ondrejj@salstar.sk>2008-06-04 06:38:02 +0000
commit96d7f3e7e678a8ac9919ce628c2f792d4cb57955 (patch)
tree71d6ba7f9e48f87f90a8f8d5c8937c229913d6c5 /loader2
parente772036e9972589c7808428c9fd00b90b2089a66 (diff)
downloadanaconda-96d7f3e7e678a8ac9919ce628c2f792d4cb57955.tar.gz
anaconda-96d7f3e7e678a8ac9919ce628c2f792d4cb57955.tar.xz
anaconda-96d7f3e7e678a8ac9919ce628c2f792d4cb57955.zip
2008-06-04 Ján ONDREJ <ondrejj@salstar.sk> (via ondrejj@fedoraproject.org)
* po/sk.po: Typo fix.
Diffstat (limited to 'loader2')
-rw-r--r--loader2/init.c74
-rw-r--r--loader2/loader.c48
-rw-r--r--loader2/loader.h1
-rw-r--r--loader2/method.c1
-rw-r--r--loader2/method.h1
-rw-r--r--loader2/urlinstall.c3
6 files changed, 56 insertions, 72 deletions
diff --git a/loader2/init.c b/loader2/init.c
index 158a3cf18..ce4cff50f 100644
--- a/loader2/init.c
+++ b/loader2/init.c
@@ -78,24 +78,6 @@
#define ENV_MALLOC_CHECK 7
#define ENV_MALLOC_PERTURB 8
-/*
- * Snakes On A Plane...
- *
- * Define this macro if you want init to launch /bin/bash instead of loader.
- * You will want to populate initrd.img with bash, libraries, other commands
- * like strace or something, and whatever else you want. This is purely for
- * debugging loader. Things you will likely want in a debugging initrd:
- * /lib/libc.so.6
- * /lib/libtermcap.so.2
- * /lib/ld-linux.so.2
- * /lib/libdl.so.2
- * /bin/bash
- * /bin/strace
- * You get the idea. Be creative. Be imaginative. Be bold.
- */
-#undef SNAKES_ON_A_PLANE
-/* #define SNAKES_ON_A_PLANE 1 */
-
char * env[] = {
"PATH=/usr/bin:/bin:/sbin:/usr/sbin:/mnt/sysimage/bin:"
"/mnt/sysimage/usr/bin:/mnt/sysimage/usr/sbin:/mnt/sysimage/sbin:"
@@ -135,28 +117,6 @@ void shutDown(int noKill, int doReboot, int doPowerOff);
static int getNoKill(void);
struct termios ts;
-static int mystrstr(char *str1, char *str2) {
- char *p;
- int rc=0;
-
- for (p=str1; *p; p++) {
- if (*p == *str2) {
- char *s, *t;
-
- rc = 1;
- for (s=p, t=str2; *s && *t; s++, t++)
- if (*s != *t) {
- rc = 0;
- p++;
- }
-
- if (rc)
- return rc;
- }
- }
- return rc;
-}
-
static void printstr(char * string) {
int ret;
ret = write(1, string, strlen(string));
@@ -364,7 +324,7 @@ static int setupTerminal(int fd) {
if ((fdn = open("/proc/cmdline", O_RDONLY, 0)) != -1) {
len = read(fdn, buf, sizeof(buf) - 1);
close(fdn);
- if (len > 0 && mystrstr(buf, "utf8"))
+ if ((len > 0) && strstr(buf, "utf8"))
env[ENV_TERM] = "TERM=vt100";
}
@@ -449,7 +409,7 @@ static int getNoKill(void) {
if ((fd = open("/proc/cmdline", O_RDONLY,0)) > 0) {
len = read(fd, buf, sizeof(buf) - 1);
close(fd);
- if (len > 0 && mystrstr(buf, "nokill"))
+ if ((len > 0) && strstr(buf, "nokill"))
return 1;
}
return 0;
@@ -674,14 +634,10 @@ int main(int argc, char **argv) {
#endif
/* disable Ctrl+Z, Ctrl+C, etc ... but not in rescue mode */
-#ifdef SNAKES_ON_A_PLANE
- disable_keys = 0;
-#else
disable_keys = 1;
if (argc > 1)
- if (mystrstr(argv[1], "rescue"))
+ if (strstr(argv[1], "rescue"))
disable_keys = 0;
-#endif
if (disable_keys) {
tcgetattr(0, &ts);
@@ -752,32 +708,8 @@ int main(int argc, char **argv) {
setsid();
-#ifdef SNAKES_ON_A_PLANE
- printf("> Snakes on a Plane <\n");
-
- /* hack to load core modules for debugging mode */
- char * modvc[15];
- char ** modvp = modvc;
- *modvp++ = "/bin/modprobe";
- *modvp++ = "ehci-hcd";
- *modvp++ = "uhci-hcd";
- *modvp++ = "ohci-hcd";
- *modvp++ = NULL;
- pid_t blah = fork();
- int qux;
- if (blah == 0) {
- printf("loading core debugging modules...\n");
- execve(modvc[0], modvc, env);
- } else {
- waitpid(blah, &qux, WNOHANG);
- }
-#endif
-
if (!(installpid = fork())) {
/* child */
-#ifdef SNAKES_ON_A_PLANE
- *argvp++ = "/bin/strace";
-#endif
*argvp++ = "/sbin/loader";
if (isSerial == 3) {
diff --git a/loader2/loader.c b/loader2/loader.c
index 0be05db2c..56b227db2 100644
--- a/loader2/loader.c
+++ b/loader2/loader.c
@@ -147,6 +147,49 @@ void doShell(void) {
newtResume();
}
+void doGdbserver(struct loaderData_s *loaderData) {
+ int child, rc, fd;
+ char *pid;
+ struct networkDeviceConfig netCfg;
+
+ /* If gdbserver is found, go ahead and run it on the loader process now
+ * before anything bad happens.
+ */
+ if (loaderData->gdbServer && !access("/usr/bin/gdbserver", X_OK)) {
+ pid_t loaderPid = getpid();
+
+ if (kickstartNetworkUp(loaderData, &netCfg)) {
+ logMessage(ERROR, "can't run gdbserver due to no network");
+ return;
+ }
+
+ rc = asprintf(&pid, "%d", loaderPid);
+
+ if (!(child = fork())) {
+ logMessage(INFO, "starting gdbserver: %s %s %s %s",
+ "/usr/bin/gdbserver", "--attach", loaderData->gdbServer,
+ pid);
+
+ fd = open("/dev/null", O_RDONLY);
+ close(STDIN_FILENO);
+ dup2(fd, STDIN_FILENO);
+ close(fd);
+ fd = open("/dev/null", O_WRONLY);
+ close(STDOUT_FILENO);
+ dup2(fd, STDOUT_FILENO);
+ close(STDERR_FILENO);
+ dup2(fd, STDERR_FILENO);
+ close(fd);
+
+ if (execl("/usr/bin/gdbserver", "/usr/bin/gdbserver", "--attach",
+ loaderData->gdbServer, pid, NULL) == -1)
+ logMessage(ERROR, "error running gdbserver: %s", strerror(errno));
+
+ _exit(1);
+ }
+ }
+}
+
void startNewt(void) {
if (!newtRunning) {
char *buf;
@@ -904,6 +947,8 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData,
flags &= ~LOADER_FLAGS_SELINUX;
else if (!strncasecmp(argv[i], "selinux", 7))
flags |= LOADER_FLAGS_SELINUX;
+ else if (!strncasecmp(argv[i], "gdb=", 4))
+ loaderData->gdbServer = strdup(argv[i] + 4);
else if (numExtraArgs < (MAX_EXTRA_ARGS - 1)) {
/* go through and append args we just want to pass on to */
/* the anaconda script, but don't want to represent as a */
@@ -1712,6 +1757,9 @@ int main(int argc, char ** argv) {
busProbe(FL_NOPROBE(flags));
+ /* can't run gdbserver until after network modules are loaded */
+ doGdbserver(&loaderData);
+
/* JKFIXME: we'd really like to do this before the busprobe, but then
* we won't have network devices available (and that's the only thing
* we support with this right now */
diff --git a/loader2/loader.h b/loader2/loader.h
index 8bd9e5f92..1c6d2730b 100644
--- a/loader2/loader.h
+++ b/loader2/loader.h
@@ -134,6 +134,7 @@ struct loaderData_s {
char * logLevel;
char * updatessrc;
char * dogtailurl;
+ char * gdbServer;
pid_t fw_loader_pid;
char *fw_search_pathz;
diff --git a/loader2/method.c b/loader2/method.c
index 26f360ccb..bd5426f8a 100644
--- a/loader2/method.c
+++ b/loader2/method.c
@@ -582,7 +582,6 @@ int copyFileAndLoopbackMount(int fd, char * dest,
/* JKFIXME: this used to be fatal, but that seems unfriendly */
logMessage(ERROR, "Error mounting %s on %s (%s)", device,
mntpoint, strerror(errno));
- unlink(dest);
return 1;
}
diff --git a/loader2/method.h b/loader2/method.h
index a29828c2b..03fc529ee 100644
--- a/loader2/method.h
+++ b/loader2/method.h
@@ -54,6 +54,7 @@ int mountStage2(char *stage2path, char *imageDir);
int copyFileAndLoopbackMount(int fd, char *dest, char *device, char *mntpoint);
int getFileFromBlockDevice(char *device, char *path, char * dest);
+int unpackCpioBall(char * ballPath, char * rootDir);
void copyUpdatesImg(char * path);
void copyProductImg(char * path);
diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c
index fd942fec4..55b7c3dad 100644
--- a/loader2/urlinstall.c
+++ b/loader2/urlinstall.c
@@ -133,6 +133,9 @@ static int loadUrlImages(struct iurlinfo * ui) {
umountLoopback("/tmp/update-disk", "/dev/loop7");
unlink("/tmp/updates-disk.img");
unlink("/tmp/update-disk");
+ } else if (!access("/tmp/updates-disk.img", R_OK)) {
+ unpackCpioBall("/tmp/updates-disk.img", "/tmp/updates");
+ unlink("/tmp/updates-disk.img");
}
free(buf);