]> git.ozlabs.org Git - petitboot/commitdiff
Use pb_log in the udev-helper.
authorJeremy Kerr <jk@ozlabs.org>
Thu, 5 Apr 2007 08:58:07 +0000 (18:58 +1000)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 5 Apr 2007 08:58:07 +0000 (18:58 +1000)
Rather than printf(), as stdout gets lost in the ether.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
devices/kboot-parser.c
devices/udev-helper.c
devices/yaboot-parser.c

index ef1f247b8b39ffd5ce879220d314933ca7ebf5d2..ba4fbf5f26bad3b6b43e49f8229aa3d18e967400 100644 (file)
@@ -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;
index f0b80b3a0c330a344ca8a21a215dc44326d812e4..fdb128eaab28d9596f4ff9943925c5a789003d55 100644 (file)
@@ -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;
 
index f457abd7dca06682741a19dc7829f305023bb8e7..23249509cdd04b18329f36bf590fd0ff29fb02cf 100644 (file)
@@ -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;