diff options
author | Dan McDonald <danmcd@mnx.io> | 2022-07-17 13:25:22 -0400 |
---|---|---|
committer | Dan McDonald <danmcd@mnx.io> | 2022-07-17 13:25:22 -0400 |
commit | f582f7535aa54ba25d4db1c069e659abe1d57c9a (patch) | |
tree | 29b8d8b833e1e529d24722f3ee0e66d1963c9fd0 /usr/src/cmd | |
parent | fa5dae8ca1047298254a799e4b097ab7321806c5 (diff) | |
parent | b9a2a14b8f156d14859ac7ceeea07ac7194df08d (diff) | |
download | illumos-joyent-f582f7535aa54ba25d4db1c069e659abe1d57c9a.tar.gz |
[illumos-gate merge]
commit b9a2a14b8f156d14859ac7ceeea07ac7194df08d
14181 pcie hotplug trapped in power off loop with no power controller
commit f73c681df5e443d3ae471c59776cbb44eb9eb90a
14779 The function prtconf/prtconf.c:cleanup_path can be replaced by realpath(3C)
Diffstat (limited to 'usr/src/cmd')
-rw-r--r-- | usr/src/cmd/prtconf/prtconf.c | 88 |
1 files changed, 7 insertions, 81 deletions
diff --git a/usr/src/cmd/prtconf/prtconf.c b/usr/src/cmd/prtconf/prtconf.c index 613fcea78c..cf9eb99814 100644 --- a/usr/src/cmd/prtconf/prtconf.c +++ b/usr/src/cmd/prtconf/prtconf.c @@ -23,6 +23,7 @@ * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2011, Joyent, Inc. All rights reserved. * Copyright (c) 2019 Peter Tribble. + * Copyright (c) 2022 Sachidananda Urs <sacchi@gmail.com> */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -78,85 +79,6 @@ indent_to_level(int ilev) (void) printf("%*s", INDENT_LENGTH * ilev, ""); } -static void -cleanup_path(const char *input_path, char *path) -{ - char *ptr, *ptr2; - size_t len; - - if ((input_path == NULL) || (path == NULL)) - return; - - (void) strcpy(path, input_path); - - /*LINTED*/ - while (1) { - len = strlen(path); - if (len == 0) - break; - - /* change substring "//" into "/" */ - if (ptr = strstr(path, "//")) { - len = strlen(ptr + 1); - (void) memmove(ptr, ptr + 1, len + 1); - continue; - } - /* change substring "/./" into "/" */ - if (ptr = strstr(path, "/./")) { - len = strlen(ptr + 2); - (void) memmove(ptr, ptr + 2, len + 1); - continue; - } - - /* change substring "/<foo>/../" into "/" */ - if (ptr = strstr(path, "/../")) { - len = strlen(ptr + 3); - *ptr = '\0'; - ptr2 = strrchr(path, (int)'/'); - if (ptr2 == NULL) { - /* path had a leading "/../" */ - ptr2 = path; - } - (void) memmove(ptr2, ptr + 3, len + 1); - continue; - } - - /* change trailing "/<foo>/.." into "/" */ - if ((len >= 3) && - (path[len - 3] == '/') && - (path[len - 2] == '.') && - (path[len - 1] == '.')) { - path[len - 3] = '\0'; - ptr2 = strrchr(path, (int)'/'); - if (ptr2 != NULL) { - ptr2[1] = '\0'; - } else { - /* path was "/.." */ - path[0] = '/'; - path[1] = '\0'; - } - continue; - } - - /* change trailing "/." into "/" */ - if ((len >= 2) && - (path[len - 2] == '/') && - (path[len - 1] == '.')) { - path[len - 1] = '\0'; - continue; - } - - /* remove trailing "/" unless it's the root */ - if ((len > 1) && (path[len - 1] == '/')) { - path[len - 1] = '\0'; - continue; - } - - break; - } -} - - /* * debug version has two more flags: * -L force load driver @@ -291,8 +213,12 @@ main(int argc, char *argv[]) } else if ((sinfo.st_mode & S_IFMT) == S_IFDIR) { size_t len, plen; - /* clean up the path */ - cleanup_path(path, new_path); + if (realpath(path, new_path) == NULL) { + (void) fprintf(stderr, "%s: invalid device" + " path specified\n", + opts.o_progname); + return (1); + } len = strlen(new_path); plen = strlen("/devices"); |