summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2007-04-05 18:58:07 +1000
committerJeremy Kerr <jk@ozlabs.org>2007-04-05 18:58:07 +1000
commitbdb389592338a2f69af98d763a39c617374c1233 (patch)
tree68bb408ab50c1a4deea6bc869e9612365bffb06c
parent678dbd282f917c68c4fd6badfc14fcf464796f5d (diff)
downloadtalos-petitboot-bdb389592338a2f69af98d763a39c617374c1233.tar.gz
talos-petitboot-bdb389592338a2f69af98d763a39c617374c1233.zip
Use pb_log in the udev-helper.
Rather than printf(), as stdout gets lost in the ether. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r--devices/kboot-parser.c4
-rw-r--r--devices/udev-helper.c22
-rw-r--r--devices/yaboot-parser.c6
3 files changed, 17 insertions, 15 deletions
diff --git a/devices/kboot-parser.c b/devices/kboot-parser.c
index ef1f247..ba4fbf5 100644
--- a/devices/kboot-parser.c
+++ b/devices/kboot-parser.c
@@ -147,7 +147,7 @@ static int parse_option(struct boot_option *opt, char *config)
cmdline = tmp;
}
- printf("kboot cmdline: %s", cmdline);
+ pb_log("kboot cmdline: %s", cmdline);
opt->boot_args = cmdline;
asprintf(&opt->description, "%s %s", config, cmdline);
@@ -165,7 +165,7 @@ static void parse_buf(struct device *dev, char *buf)
pos = get_param_pair(pos, &name, &value, '\n');
- printf("kboot param: '%s' = '%s'\n", name, value);
+ pb_log("kboot param: '%s' = '%s'\n", name, value);
if (name == NULL || param_is_ignored(name))
continue;
diff --git a/devices/udev-helper.c b/devices/udev-helper.c
index f0b80b3..fdb128e 100644
--- a/devices/udev-helper.c
+++ b/devices/udev-helper.c
@@ -323,7 +323,7 @@ static int is_removable_device(const char *sysfs_path)
sprintf(full_path, "/sys/%s/removable", sysfs_path);
fd = open(full_path, O_RDONLY);
- printf(" -> removable check on %s, fd=%d\n", full_path, fd);
+ pb_log(" -> removable check on %s, fd=%d\n", full_path, fd);
if (fd < 0)
return 0;
buf_len = read(fd, buf, 79);
@@ -394,35 +394,35 @@ static int poll_device_plug(const char *dev_path,
/* Polling loop for optical drive */
for (; (*optical) != 0; ) {
- printf("poll for optical drive insertion ...\n");
+ pb_log("poll for optical drive insertion ...\n");
fd = open(dev_path, O_RDONLY|O_NONBLOCK);
if (fd < 0)
return EXIT_FAILURE;
rc = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
close(fd);
if (rc == -1) {
- printf("not an optical drive, fallback...\n");
+ pb_log("not an optical drive, fallback...\n");
break;
}
*optical = 1;
if (rc == CDS_DISC_OK)
return EXIT_SUCCESS;
- printf("no... waiting\n");
+ pb_log("no... waiting\n");
detach_and_sleep(REMOVABLE_SLEEP_DELAY);
}
/* Fall back to bare open() */
*optical = 0;
for (;;) {
- printf("poll for non-optical drive insertion ...\n");
+ pb_log("poll for non-optical drive insertion ...\n");
fd = open(dev_path, O_RDONLY);
if (fd < 0 && errno != ENOMEDIUM)
return EXIT_FAILURE;
close(fd);
if (fd >= 0)
return EXIT_SUCCESS;
- printf("no... waiting\n");
+ pb_log("no... waiting\n");
detach_and_sleep(REMOVABLE_SLEEP_DELAY);
}
}
@@ -432,7 +432,7 @@ static int poll_device_unplug(const char *dev_path, int optical)
int rc, fd;
for (;optical;) {
- printf("poll for optical drive removal ...\n");
+ pb_log("poll for optical drive removal ...\n");
fd = open(dev_path, O_RDONLY|O_NONBLOCK);
if (fd < 0)
return EXIT_FAILURE;
@@ -440,20 +440,20 @@ static int poll_device_unplug(const char *dev_path, int optical)
close(fd);
if (rc != CDS_DISC_OK)
return EXIT_SUCCESS;
- printf("no... waiting\n");
+ pb_log("no... waiting\n");
detach_and_sleep(REMOVABLE_SLEEP_DELAY);
}
/* Fall back to bare open() */
for (;;) {
- printf("poll for non-optical drive removal ...\n");
+ pb_log("poll for non-optical drive removal ...\n");
fd = open(dev_path, O_RDONLY);
if (fd < 0 && errno != ENOMEDIUM)
return EXIT_FAILURE;
close(fd);
if (fd < 0)
return EXIT_SUCCESS;
- printf("no... waiting\n");
+ pb_log("no... waiting\n");
detach_and_sleep(REMOVABLE_SLEEP_DELAY);
}
}
@@ -489,6 +489,8 @@ int main(int argc, char **argv)
action = getenv("ACTION");
logf = fopen("/var/tmp/petitboot-udev-helpers.log", "a");
+ if (!logf)
+ logf = stdout;
pb_log("%d started\n", getpid());
rc = EXIT_SUCCESS;
diff --git a/devices/yaboot-parser.c b/devices/yaboot-parser.c
index f457abd..2324950 100644
--- a/devices/yaboot-parser.c
+++ b/devices/yaboot-parser.c
@@ -105,7 +105,7 @@ void process_image(char *label)
cfgopt = cfg_get_strg(label, "image");
opt.boot_image_file = join_paths(mountpoint, cfgopt);
if (cfgopt == defimage)
- printf("This one is default. What do we do about it?\n");
+ pb_log("This one is default. What do we do about it?\n");
cfgopt = cfg_get_strg(label, "initrd");
if (cfgopt)
@@ -164,7 +164,7 @@ static int yaboot_parse(const char *devicepath, const char *_mountpoint)
close(fd);
if (cfg_parse(filepath, conf_file, conf_len)) {
- printf("Error parsing yaboot.conf\n");
+ pb_log("Error parsing yaboot.conf\n");
return 0;
}
@@ -207,7 +207,7 @@ static int yaboot_parse(const char *devicepath, const char *_mountpoint)
yet. And on removal, unmount_device() only unmounts
it once, while in fact it may be mounted twice. */
if (mount_device(new_dev, partition_mntpoint)) {
- printf("Error mounting image partition\n");
+ pb_log("Error mounting image partition\n");
return 0;
}
mountpoint = partition_mntpoint;
OpenPOWER on IntegriCloud