[systemd-devel] [PATCH 02/17] journal: add ability to filter by current user

Lennart Poettering lennart at poettering.net
Mon Jun 10 02:02:22 PDT 2013


On Sat, 08.06.13 00:22, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:

> This is the just the library part.
> 
> SD_JOURNAL_CURRENT_USER flags is added to sd_j_open(), to open
> files from current user.
> 
> SD_JOURNAL_SYSTEM_ONLY is renamed to SD_JOURNAL_SYSTEM,
> and changed to mean to (also) open system files. This way various
> flags can be combined, which gives them nicer semantics, especially
> if other ones are added later.
> 
> Backwards compatibility is kept, because SD_JOURNAL_SYSTEM_ONLY
> is equivalent to SD_JOURNAL_SYSTEM if used alone, and before there
> we no other flags.

Our general approach for doing these compat things is to keep them in
the headers but remove them from the docs in order not to confuse people
and to make sure people don't use this anymore. In the headers they
should carry comments though that clarify that they our obsolete.

>  static int respond_oom_internal(struct MHD_Connection *connection) {
> diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
> index 2bad243..e5b6968 100644
> --- a/src/journal/sd-journal.c
> +++ b/src/journal/sd-journal.c
> @@ -1249,6 +1249,39 @@ static void check_network(sd_journal *j, int fd) {
>                  F_TYPE_CMP(sfs.f_type, SMB_SUPER_MAGIC);
>  }
>  
> +static bool file_has_type_prefix(const char *prefix, const char *filename) {
> +        const char *full = strappend(prefix, ".journal");
> +        const char *tilded = strappenda(full, "~");
> +        const char *atted = strappenda(prefix, "@");

I'd really prefer if we could keep variable declarations and function
calls separate. It don't think it helps readability.

> +static bool file_type_wanted(int flags, const char *filename) {
> +        /* no flags set → every type is OK */
> +        if (!(flags & (SD_JOURNAL_SYSTEM | SD_JOURNAL_CURRENT_USER)))
> +                return true;
> +        // why are file suffixes not checked here?

// comments are not cool either... Looks like something is missing here?

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list