diff options
author | Colin Cross <ccross@android.com> | 2013-07-22 15:45:42 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-07-22 15:45:42 -0700 |
commit | 776751ad79b878e98017039bad87ca27a1c86ad0 (patch) | |
tree | 01c26faca2a7943f028e75b71db0f484acff9f4a /init | |
parent | 70cdc26dfcb04676d981afb62be038440296bf94 (diff) | |
parent | 8c4b153911e399f00fdf0ed4e39782d0d49396d6 (diff) | |
download | system_core-776751ad79b878e98017039bad87ca27a1c86ad0.zip system_core-776751ad79b878e98017039bad87ca27a1c86ad0.tar.gz system_core-776751ad79b878e98017039bad87ca27a1c86ad0.tar.bz2 |
am 8c4b1539: am f9873987: am 5954ecb8: Merge "Allow more characters in partition name links"
* commit '8c4b153911e399f00fdf0ed4e39782d0d49396d6':
Allow more characters in partition name links
Diffstat (limited to 'init')
-rw-r--r-- | init/devices.c | 2 | ||||
-rw-r--r-- | init/util.c | 19 |
2 files changed, 18 insertions, 3 deletions
diff --git a/init/devices.c b/init/devices.c index de27a7a..1893642 100644 --- a/init/devices.c +++ b/init/devices.c @@ -451,6 +451,8 @@ static char **parse_platform_block_device(struct uevent *uevent) if (uevent->partition_name) { p = strdup(uevent->partition_name); sanitize(p); + if (strcmp(uevent->partition_name, p)) + NOTICE("Linking partition '%s' as '%s'\n", uevent->partition_name, p); if (asprintf(&links[link_num], "%s/by-name/%s", link_path, p) > 0) link_num++; else diff --git a/init/util.c b/init/util.c index fffc8a4..1908b3a 100644 --- a/init/util.c +++ b/init/util.c @@ -306,14 +306,27 @@ int mkdir_recursive(const char *pathname, mode_t mode) return 0; } +/* + * replaces any unacceptable characters with '_', the + * length of the resulting string is equal to the input string + */ void sanitize(char *s) { + const char* accept = + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789" + "_-."; + if (!s) return; - while (isalnum(*s)) - s++; - *s = 0; + + for (; *s; s++) { + s += strspn(s, accept); + if (*s) *s = '_'; + } } + void make_link(const char *oldpath, const char *newpath) { int ret; |