summaryrefslogtreecommitdiff
path: root/src/journal/journalctl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-08-09 17:05:29 +0200
committerLennart Poettering <lennart@poettering.net>2012-08-09 17:05:29 +0200
commitb6a345143bf6ffdc87a7149015f75c03be440b10 (patch)
tree01678dafc89ae8d68fe61f86822b23af6689639a /src/journal/journalctl.c
parent5b4c61cd0b7d35f5a905c83a0ee111a1876a7873 (diff)
journalctl: support device node matches as shortcut
Diffstat (limited to 'src/journal/journalctl.c')
-rw-r--r--src/journal/journalctl.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 10959423f6..62bb904dbe 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -305,7 +305,7 @@ static int add_matches(sd_journal *j, char **args) {
if (streq(*i, "+"))
r = sd_journal_add_disjunction(j);
else if (path_is_absolute(*i)) {
- char *p;
+ char *p, *t = NULL;
const char *path;
struct stat st;
@@ -318,24 +318,25 @@ static int add_matches(sd_journal *j, char **args) {
return -errno;
}
- if (S_ISREG(st.st_mode) && (0111 & st.st_mode)) {
- char *t;
-
+ if (S_ISREG(st.st_mode) && (0111 & st.st_mode))
t = strappend("_EXE=", path);
- if (!t) {
- free(p);
- return log_oom();
- }
-
- r = sd_journal_add_match(j, t, 0);
- free(t);
- } else {
+ else if (S_ISCHR(st.st_mode))
+ asprintf(&t, "_KERNEL_DEVICE=c%u:%u", major(st.st_rdev), minor(st.st_rdev));
+ else if (S_ISBLK(st.st_mode))
+ asprintf(&t, "_KERNEL_DEVICE=b%u:%u", major(st.st_rdev), minor(st.st_rdev));
+ else {
free(p);
- log_error("File is not a regular file or is not executable: %s", *i);
+ log_error("File is not a device node, regular file or is not executable: %s", *i);
return -EINVAL;
}
free(p);
+
+ if (!t)
+ return log_oom();
+
+ r = sd_journal_add_match(j, t, 0);
+ free(t);
} else
r = sd_journal_add_match(j, *i, 0);