Merge pull request #19793 from keszybz/tmpfiles-autofs-and-globs
tmpfiles: better handling of autofs and globs
This commit is contained in:
@@ -71,3 +71,22 @@ int glob_extend(char ***strv, const char *path, int flags) {
|
||||
|
||||
return strv_extend_strv(strv, g.gl_pathv, false);
|
||||
}
|
||||
|
||||
int glob_non_glob_prefix(const char *path, char **ret) {
|
||||
/* Return the path of the path that has no glob characters. */
|
||||
|
||||
size_t n = strcspn(path, GLOB_CHARS);
|
||||
|
||||
if (path[n] != '\0')
|
||||
while (n > 0 && path[n-1] != '/')
|
||||
n--;
|
||||
|
||||
if (n == 0)
|
||||
return -ENOENT;
|
||||
|
||||
char *ans = strndup(path, n);
|
||||
if (!ans)
|
||||
return -ENOMEM;
|
||||
*ret = ans;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ int safe_glob(const char *path, int flags, glob_t *pglob);
|
||||
int glob_exists(const char *path);
|
||||
int glob_extend(char ***strv, const char *path, int flags);
|
||||
|
||||
int glob_non_glob_prefix(const char *path, char **ret);
|
||||
|
||||
#define _cleanup_globfree_ _cleanup_(globfree)
|
||||
|
||||
_pure_ static inline bool string_is_glob(const char *p) {
|
||||
|
||||
Reference in New Issue
Block a user