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);
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) {
+ free(j->path);
free(j);
return NULL;
}
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;
}
SD_JOURNAL_SYSTEM_ONLY))
return -EINVAL;
- j = journal_new(flags);
+ j = journal_new(flags, NULL);
if (!j)
return -ENOMEM;
if (flags != 0)
return -EINVAL;
- j = journal_new(flags);
+ j = journal_new(flags, path);
if (!j)
return -ENOMEM;
sd_journal_flush_matches(j);
+ free(j->path);
free(j);
}
/* 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;