Discussion:
[linux-lvm] lvm filter regex format
Thanos Makatos
2017-12-18 17:16:14 UTC
Permalink
I'm trying to be very specific in the global_filter of lvm.conf and
ignore devices under /dev/mapper of the format
'^/dev/mapper/[a-z0-9]{14}$', however the repetition count '{14}' does
not seem to be honored?

Currently I have to repeat '[a-z0-9]' fourteen times, which works but
it's a bit ugly.

Does the filter use some standarized regex format?
--
Thanos Makatos
Joe Thornber
2017-12-18 17:49:15 UTC
Permalink
Post by Thanos Makatos
I'm trying to be very specific in the global_filter of lvm.conf and
ignore devices under /dev/mapper of the format
'^/dev/mapper/[a-z0-9]{14}$', however the repetition count '{14}' does
not seem to be honored?
Currently I have to repeat '[a-z0-9]' fourteen times, which works but
it's a bit ugly.
Does the filter use some standarized regex format?
It's a custom engine that I wrote which matches all the regexs in the
filters at the same time (so is pretty fast). Looking at the header here:

https://github.com/jthornber/lvm2-ejt/blob/master/libdm/regex/parse_rx.h

It seems to support just catenation, |, *, +, ?, [<charset>], ^ and $

Out of interest why are you using the length of the device name as a discriminator?

- Joe
Thanos Makatos
2017-12-19 09:36:51 UTC
Permalink
Post by Joe Thornber
Out of interest why are you using the length of the device name as a discriminator?
In my case I am the one who creates these devices so I fully control
the naming scheme, however there are other components in our product
that might create device mapper targets and I shouldn't filter them
out.

matthew patton
2017-12-18 18:53:06 UTC
Permalink
  https://github.com/jthornber/lvm2-ejt/blob/master/libdm/regex/parse_rx.h
not to be ungrateful but why on earth would one NOT use the glibc standard regex library? Nobody cares about pointless optimization. Surprises like "well, we only implemented most of the spec" are what drives people nuts!

I agree this particular length-based match is rather odd but there are plenty of useful examples I am sure that could benefit from {x,y} notation.
Zdenek Kabelac
2017-12-18 22:43:57 UTC
Permalink
Post by matthew patton
  https://github.com/jthornber/lvm2-ejt/blob/master/libdm/regex/parse_rx.h
not to be ungrateful but why on earth would one NOT use the glibc standard regex library? Nobody cares about pointless optimization. Surprises like "well, we only implemented most of the spec" are what drives people nuts!
I agree this particular length-based match is rather odd but there are plenty of useful examples I am sure that could benefit from {x,y} notation.
Such code was actually written long time ago - but since the syntax of
standard glibc regex accepts slightly different strings - it would be an
incompatible change - so it's been considered now worth breaking the
compatibility at that time...


Regards

Zdenek
Joe Thornber
2017-12-19 08:51:47 UTC
Permalink
Post by matthew patton
  https://github.com/jthornber/lvm2-ejt/blob/master/libdm/regex/parse_rx.h
not to be ungrateful but why on earth would one NOT use the glibc standard regex library? Nobody cares about pointless optimization. Surprises like "well, we only implemented most of the spec" are what drives people nuts!
It was written about 17 years ago, and the optimisation was not pointless at that time.

- Joe
Loading...