Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
lib: Get lpj= from /var/log/boot.msg (thanks Olaf Hering).
  • Loading branch information
rwmjones committed Nov 25, 2012
1 parent d751736 commit d2c75dd
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/lpj.c
Expand Up @@ -49,6 +49,7 @@
gl_lock_define_initialized (static, lpj_lock);
static int lpj = 0;
static int read_lpj_from_var_log_dmesg (guestfs_h *g);
static int read_lpj_from_var_log_boot_msg (guestfs_h *g);
static int read_lpj_from_dmesg (guestfs_h *g);
static int read_lpj_common (guestfs_h *g, const char *func, const char *command);

Expand All @@ -65,13 +66,19 @@ guestfs___get_lpj (guestfs_h *g)
* - /proc/cpuinfo [in future]
* - dmesg
* - /var/log/dmesg
* - /var/log/boot.msg
*/
r = read_lpj_from_dmesg (g);
if (r > 0) {
lpj = r;
goto out;
}
lpj = read_lpj_from_var_log_dmesg (g);
r = read_lpj_from_var_log_dmesg (g);
if (r > 0) {
lpj = r;
goto out;
}
lpj = read_lpj_from_var_log_boot_msg (g);

out:
gl_lock_unlock (lpj_lock);
Expand All @@ -92,6 +99,13 @@ read_lpj_from_var_log_dmesg (guestfs_h *g)
"grep -Eo 'lpj=[[:digit:]]+' /var/log/dmesg");
}

static int
read_lpj_from_var_log_boot_msg (guestfs_h *g)
{
return read_lpj_common (g, __func__,
"grep -Eo 'lpj=[[:digit:]]+' /var/log/boot.msg");
}

static void
read_all (guestfs_h *g, void *retv, const char *buf, size_t len)
{
Expand Down

0 comments on commit d2c75dd

Please sign in to comment.