[systemd-devel] [PATCH] journald: ignore failure to watch hostname_fd on older kernels

Dave Reisner d at falconindy.com
Fri Feb 21 09:48:59 PST 2014


On Fri, Feb 21, 2014 at 06:00:46PM +0100, Zbigniew Jędrzejewski-Szmek wrote:
> On Fri, Feb 21, 2014 at 11:22:50AM -0500, Dave Reisner wrote:
> > Prior to 3.2, /proc/sys/kernel/hostname isn't a pollable file and
> > sd_event_add_io will return EPERM. Ignore this failure, since it isn't
> > critical to journald operation.
> > ---
> > Reported and tested by user sraue on IRC.
> This should probably go above "---", to give credit in the changelog.
>  
> >  src/journal/journald-server.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
> > index 5872e91..add6cf5 100644
> > --- a/src/journal/journald-server.c
> > +++ b/src/journal/journald-server.c
> > @@ -1430,6 +1430,14 @@ static int server_open_hostname(Server *s) {
> >  
> >          r = sd_event_add_io(s->event, &s->hostname_event_source, s->hostname_fd, 0, dispatch_hostname_change, s);
> >          if (r < 0) {
> > +                /* kernels prior to 3.2 don't support polling this file.
> > +                 * quietly ignore the failure. */
> > +                if (r == -EPERM) {
> > +                        close_nointr_nofail(s->hostname_fd);
> > +                        s->hostname_fd = -1;
> > +                        return 0;
> > +                }
> Critical not, but certainly worth a warning.
> 
> Zbyszek

Thanks, I'll push with these 2 changes.


More information about the systemd-devel mailing list