From: Stefan Metzmacher Date: Fri, 11 Jun 2021 19:07:03 +0000 (+0000) Subject: vfs_preopen: introduce support for "preopen:posix-basic-regex = yes" X-Git-Tag: tevent-0.11.0~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ade3b16490e9afdf909a761828a38d80d6596fd1;p=thirdparty%2Fsamba.git vfs_preopen: introduce support for "preopen:posix-basic-regex = yes" This will allow the usage of patterns as 'POSIX Basic Regular Expression' vfs objects = preopen preopen:posix-basic-regex = yes preopen:names = /Re7599Ex\([0-9]\).*\.txt/test\([0-9]*\)\.dat/ The key is that exactly one 'subexpression' starting with '\(' and ending with '\)' is specified in order to select the position where the digits are searched. E.g. given a file name 'Re7599Ex01234.txt' will actually preopen: Re7599Ex01234.txt Re7599Ex11234.txt Re7599Ex21234.txt Re7599Ex31234.txt Re7599Ex41234.txt As '\([0-9]\)' will only match the first digit after 'Re7599Ex'. It also means it's now possible to have digits in the fixed part of the filename, which was the actual motivation for this patchset. Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- diff --git a/docs-xml/manpages/vfs_preopen.8.xml b/docs-xml/manpages/vfs_preopen.8.xml index 3c799b62190..d1a90710f1e 100644 --- a/docs-xml/manpages/vfs_preopen.8.xml +++ b/docs-xml/manpages/vfs_preopen.8.xml @@ -48,6 +48,17 @@ + + preopen:posix-basic-regex = BOOL (default: no) + + + preopen:posix-basic-regex = yes changes + the meaning of the preopen:names option. + Further details are described there. + + + + preopen:names = /pattern1/pattern2/ @@ -57,9 +68,23 @@ the files are numbered incrementally. So if your file names are numbered FRAME00000.frm FRAME00001.frm and so on you would list them as preopen:names=/FRAME*.frm/. - The current algorithm uses the first (at least 3) digits it finds + The default algorithm uses the first (at least 3) digits it finds in order to calculate the name of the next frames. + + preopen:posix-basic-regex = yes changes + the meaning of the preopen:names option. + It means 'POSIX Basic Regular Expression' strings are used + as patterns. The key is each pattern requires exactly one + 'subexpression' starting with '\(' and ending with '\)' in + order to specify the position of the digits representing + the incrementing frame numbers. Given a file names like + Movie7599Frame0v1234.txt, Movie7599Frame1v1234.txt, Movie7599Frame2v1234.txt + up to Movie7599Frame9v1234.txt you can use preopen:names = /.*Frame\([0-9]\).*\.txt/ + in order to match just a single digits, this might not be a real world example, + but it shows the flexiblity that is possible here. + + diff --git a/source3/modules/vfs_preopen.c b/source3/modules/vfs_preopen.c index 6ee3c059a07..4dc5ba30b1d 100644 --- a/source3/modules/vfs_preopen.c +++ b/source3/modules/vfs_preopen.c @@ -338,10 +338,16 @@ static struct preopen_state *preopen_state_get(vfs_handle_struct *handle) return NULL; } - status = samba_path_matching_mswild_create(state, - true, /* case_sensitive */ - namelist, - &state->preopen_names); + if (lp_parm_bool(SNUM(handle->conn), "preopen", "posix-basic-regex", false)) { + status = samba_path_matching_regex_sub1_create(state, + namelist, + &state->preopen_names); + } else { + status = samba_path_matching_mswild_create(state, + true, /* case_sensitive */ + namelist, + &state->preopen_names); + } if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(state); return NULL;