[systemd-devel] [PATCH 1/3] tmpfiles: skip the path entirely if configured as type x

Michal Sekletar msekleta at redhat.com
Thu Nov 7 22:32:31 PST 2013


On Thu, Nov 07, 2013 at 10:39:19PM +0100, Lennart Poettering wrote:
> On Wed, 06.11.13 11:18, Michal Sekletar (msekleta at redhat.com) wrote:
> 
> > Type x in tmpfiles configuration accepts shell style globs instead of normal
> > paths. If user uses normal path he might expect that the path will be left
> > untouched. However this is not the case for directories and content of the
> > directory will be cleaned according to the Age parameter, we should rather skip
> > the path entirely in such case.
> 
Hi Lennart,

> Not sure I follow. dir_cleanup() already skips all items listed in the
> glob hashmap anyway, no? What does your patch add on top of that?

In dir_cleanup() we skip if there is an item configured for the path or it
matches the glob, however we are doing it on the subpaths of currently processed
directory. This won't work in the case mentioned in the commit message. If user
wants to exclude path from cleanup entirely he has to use x /path/*, this way
all subpaths match the glob. In case of x /path/ no subpath matches such glob and
we remove them, hence checking explicitly beforehand.

Hope that makes some sense.

Michal
> 
> > ---
> >  src/tmpfiles/tmpfiles.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
> > index 8051cb3..e4ee99d 100644
> > --- a/src/tmpfiles/tmpfiles.c
> > +++ b/src/tmpfiles/tmpfiles.c
> > @@ -910,6 +910,7 @@ static int clean_item_instance(Item *i, const char* instance) {
> >          bool mountpoint;
> >          int r;
> >          usec_t cutoff, n;
> > +        Item *j = NULL;
> >  
> >          assert(i);
> >  
> > @@ -946,6 +947,10 @@ static int clean_item_instance(Item *i, const char* instance) {
> >                  return -errno;
> >          }
> >  
> > +        j = hashmap_get(globs, j->path);
> > +        if (j && j->type == IGNORE_PATH)
> > +                return 0;
> > +
> >          mountpoint = s.st_dev != ps.st_dev ||
> >                       (s.st_dev == ps.st_dev && s.st_ino == ps.st_ino);
> >  
> 
> 
> Lennart
> 
> -- 
> Lennart Poettering, Red Hat


More information about the systemd-devel mailing list