diff options
author | Jaeyoon Jung <jaeyoon.jung@lge.com> | 2024-08-07 03:44:37 +0900 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-08-08 14:28:49 +0100 |
commit | 454fcf36c7ad9bde5a0a9e3993874c19e407ee93 (patch) | |
tree | b171d94dbdbf55a74d3f8fd1934e3e119d03b1bd /meta | |
parent | 0043986334e587dd09887b81535644ae437b2893 (diff) | |
download | poky-454fcf36c7ad9bde5a0a9e3993874c19e407ee93.tar.gz |
makedevs: Fix issue when rootdir of / is given
Treating rootdir "/" as "" leads an error in parse_devtable(). Preserve
it as it is given and use a separate variable for path name prepending.
Another minor fix is to add a return statement at the end of
convert2guid() to avoid an error with -Werror=return-type.
(From OE-Core rev: 4d52e6276c687a8950bde21850072ddf14893fb2)
Signed-off-by: Jaeyoon Jung <jaeyoon.jung@lge.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/recipes-devtools/makedevs/makedevs/makedevs.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/meta/recipes-devtools/makedevs/makedevs/makedevs.c b/meta/recipes-devtools/makedevs/makedevs/makedevs.c index df2e3cfad5..2254b54891 100644 --- a/meta/recipes-devtools/makedevs/makedevs/makedevs.c +++ b/meta/recipes-devtools/makedevs/makedevs/makedevs.c | |||
@@ -36,6 +36,7 @@ static const char *const app_name = "makedevs"; | |||
36 | static const char *const memory_exhausted = "memory exhausted"; | 36 | static const char *const memory_exhausted = "memory exhausted"; |
37 | static char default_rootdir[]="."; | 37 | static char default_rootdir[]="."; |
38 | static char *rootdir = default_rootdir; | 38 | static char *rootdir = default_rootdir; |
39 | static char *rootdir_prepend = default_rootdir; | ||
39 | static int trace = 0; | 40 | static int trace = 0; |
40 | 41 | ||
41 | struct name_id { | 42 | struct name_id { |
@@ -217,6 +218,9 @@ static unsigned long convert2guid(char *id_buf, struct name_id *search_list) | |||
217 | } | 218 | } |
218 | error_msg_and_die("No entry for %s in search list", id_buf); | 219 | error_msg_and_die("No entry for %s in search list", id_buf); |
219 | } | 220 | } |
221 | |||
222 | // Unreachable, but avoid an error with -Werror=return-type | ||
223 | return 0; | ||
220 | } | 224 | } |
221 | 225 | ||
222 | static void free_list(struct name_id *list) | 226 | static void free_list(struct name_id *list) |
@@ -379,8 +383,8 @@ static int interpret_table_entry(char *line) | |||
379 | error_msg_and_die("Device table entries require absolute paths"); | 383 | error_msg_and_die("Device table entries require absolute paths"); |
380 | } | 384 | } |
381 | name = xstrdup(path + 1); | 385 | name = xstrdup(path + 1); |
382 | /* prefix path with rootdir */ | 386 | /* prefix path with rootdir_prepend */ |
383 | sprintf(path, "%s/%s", rootdir, name); | 387 | sprintf(path, "%s/%s", rootdir_prepend, name); |
384 | 388 | ||
385 | /* XXX Why is name passed into all of the add_new_*() routines? */ | 389 | /* XXX Why is name passed into all of the add_new_*() routines? */ |
386 | switch (type) { | 390 | switch (type) { |
@@ -406,11 +410,11 @@ static int interpret_table_entry(char *line) | |||
406 | 410 | ||
407 | for (i = start; i < start + count; i++) { | 411 | for (i = start; i < start + count; i++) { |
408 | sprintf(buf, "%s%d", name, i); | 412 | sprintf(buf, "%s%d", name, i); |
409 | sprintf(path, "%s/%s%d", rootdir, name, i); | 413 | sprintf(path, "%s/%s%d", rootdir_prepend, name, i); |
410 | /* FIXME: MKDEV uses illicit insider knowledge of kernel | 414 | /* FIXME: MKDEV uses illicit insider knowledge of kernel |
411 | * major/minor representation... */ | 415 | * major/minor representation... */ |
412 | rdev = MKDEV(major, minor + (i - start) * increment); | 416 | rdev = MKDEV(major, minor + (i - start) * increment); |
413 | sprintf(path, "%s/%s\0", rootdir, buf); | 417 | sprintf(path, "%s/%s\0", rootdir_prepend, buf); |
414 | add_new_device(buf, path, uid, gid, mode, rdev); | 418 | add_new_device(buf, path, uid, gid, mode, rdev); |
415 | } | 419 | } |
416 | } else { | 420 | } else { |
@@ -541,12 +545,11 @@ int main(int argc, char **argv) | |||
541 | } else { | 545 | } else { |
542 | closedir(dir); | 546 | closedir(dir); |
543 | } | 547 | } |
544 | /* If "/" is specified, use "" because rootdir is always prepended to a | 548 | rootdir = xstrdup(optarg); |
545 | * string that starts with "/" */ | 549 | if (0 == strcmp(rootdir, "/")) |
546 | if (0 == strcmp(optarg, "/")) | 550 | rootdir_prepend = xstrdup(""); |
547 | rootdir = xstrdup(""); | ||
548 | else | 551 | else |
549 | rootdir = xstrdup(optarg); | 552 | rootdir_prepend = xstrdup(rootdir); |
550 | break; | 553 | break; |
551 | 554 | ||
552 | case 't': | 555 | case 't': |