mirror of
https://github.com/systemd/systemd.git
synced 2024-10-31 07:51:21 +03:00
udev-util: introduce udev_replace_ifname()
This commit is contained in:
parent
5a3586db9a
commit
e1ecfef16f
@ -18,6 +18,7 @@
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "signal-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "string-table.h"
|
||||
#include "string-util.h"
|
||||
#include "strxcpyx.h"
|
||||
@ -436,6 +437,22 @@ size_t udev_replace_whitespace(const char *str, char *to, size_t len) {
|
||||
return j;
|
||||
}
|
||||
|
||||
size_t udev_replace_ifname(char *str) {
|
||||
size_t replaced = 0;
|
||||
|
||||
assert(str);
|
||||
|
||||
/* See ifname_valid_full(). */
|
||||
|
||||
for (char *p = str; *p != '\0'; p++)
|
||||
if (!ifname_valid_char(*p)) {
|
||||
*p = '_';
|
||||
replaced++;
|
||||
}
|
||||
|
||||
return replaced;
|
||||
}
|
||||
|
||||
size_t udev_replace_chars(char *str, const char *allow) {
|
||||
size_t i = 0, replaced = 0;
|
||||
|
||||
|
@ -46,6 +46,7 @@ void log_device_uevent(sd_device *device, const char *str);
|
||||
|
||||
int udev_rule_parse_value(char *str, char **ret_value, char **ret_endpos);
|
||||
size_t udev_replace_whitespace(const char *str, char *to, size_t len);
|
||||
size_t udev_replace_ifname(char *str);
|
||||
size_t udev_replace_chars(char *str, const char *allow);
|
||||
int udev_resolve_subsys_kernel(const char *string, char *result, size_t maxsize, bool read_value);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user