chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
journal: when watching directories actually watch the directories asked for
[elogind.git]
/
src
/
journal
/
sd-journal.c
diff --git
a/src/journal/sd-journal.c
b/src/journal/sd-journal.c
index c3f19ca697a4396150c8c43d99b5dd4ee00822a0..672896d57ceb913af96ec91505add9ce37008b68 100644
(file)
--- a/
src/journal/sd-journal.c
+++ b/
src/journal/sd-journal.c
@@
-1329,7
+1329,7
@@
static int add_root_directory(sd_journal *j, const char *p) {
if (r < 0)
log_debug("Failed to add file %s/%s: %s", m->path, de->d_name, strerror(-r));
if (r < 0)
log_debug("Failed to add file %s/%s: %s", m->path, de->d_name, strerror(-r));
- } else if ((de->d_type == DT_DIR || de->d_type == DT_UNKNOWN) &&
+ } else if ((de->d_type == DT_DIR || de->d_type == DT_
LNK || de->d_type == DT_
UNKNOWN) &&
sd_id128_from_string(de->d_name, &id) >= 0) {
r = add_directory(j, m->path, de->d_name);
sd_id128_from_string(de->d_name, &id) >= 0) {
r = add_directory(j, m->path, de->d_name);
@@
-1402,7
+1402,7
@@
static int allocate_inotify(sd_journal *j) {
return 0;
}
return 0;
}
-static sd_journal *journal_new(int flags) {
+static sd_journal *journal_new(int flags
, const char *path
) {
sd_journal *j;
j = new0(sd_journal, 1);
sd_journal *j;
j = new0(sd_journal, 1);
@@
-1412,8
+1412,17
@@
static sd_journal *journal_new(int flags) {
j->inotify_fd = -1;
j->flags = flags;
j->inotify_fd = -1;
j->flags = flags;
+ if (path) {
+ j->path = strdup(path);
+ if (!j->path) {
+ free(j);
+ return NULL;
+ }
+ }
+
j->files = hashmap_new(string_hash_func, string_compare_func);
if (!j->files) {
j->files = hashmap_new(string_hash_func, string_compare_func);
if (!j->files) {
+ free(j->path);
free(j);
return NULL;
}
free(j);
return NULL;
}
@@
-1421,6
+1430,7
@@
static sd_journal *journal_new(int flags) {
j->directories_by_path = hashmap_new(string_hash_func, string_compare_func);
if (!j->directories_by_path) {
hashmap_free(j->files);
j->directories_by_path = hashmap_new(string_hash_func, string_compare_func);
if (!j->directories_by_path) {
hashmap_free(j->files);
+ free(j->path);
free(j);
return NULL;
}
free(j);
return NULL;
}
@@
-1440,7
+1450,7
@@
_public_ int sd_journal_open(sd_journal **ret, int flags) {
SD_JOURNAL_SYSTEM_ONLY))
return -EINVAL;
SD_JOURNAL_SYSTEM_ONLY))
return -EINVAL;
- j = journal_new(flags);
+ j = journal_new(flags
, NULL
);
if (!j)
return -ENOMEM;
if (!j)
return -ENOMEM;
@@
-1470,7
+1480,7
@@
_public_ int sd_journal_open_directory(sd_journal **ret, const char *path, int f
if (flags != 0)
return -EINVAL;
if (flags != 0)
return -EINVAL;
- j = journal_new(flags);
+ j = journal_new(flags
, path
);
if (!j)
return -ENOMEM;
if (!j)
return -ENOMEM;
@@
-1513,6
+1523,7
@@
_public_ void sd_journal_close(sd_journal *j) {
sd_journal_flush_matches(j);
sd_journal_flush_matches(j);
+ free(j->path);
free(j);
}
free(j);
}
@@
-1790,7
+1801,10
@@
_public_ int sd_journal_get_fd(sd_journal *j) {
/* Iterate through all dirs again, to add them to the
* inotify */
/* Iterate through all dirs again, to add them to the
* inotify */
- r = add_search_paths(j);
+ if (j->path)
+ r = add_root_directory(j, j->path);
+ else
+ r = add_search_paths(j);
if (r < 0)
return r;
if (r < 0)
return r;