system/core
Revision | bfa4c8dee51b84f86f7a768cac553b35011efa28 (tree) |
---|---|
Time | 2019-03-05 14:43:30 |
Author | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
init: expand variables on mount_all command
This allows mount_all to handle fstab.${ro.hardware} instead
of hardcoding the file name.
Change-Id: Ia7fb4e5a84dd50a46afdd4239b9b06204f449cfe
@@ -443,13 +443,18 @@ static Result<int> mount_fstab(const char* fstabfile, int mount_mode) { | ||
443 | 443 | return Error() << "child aborted"; |
444 | 444 | } |
445 | 445 | } else if (pid == 0) { |
446 | + std::string filename_val; | |
447 | + if (!expand_props(fstabfile, &filename_val)) { | |
448 | + PLOG(ERROR) << "mount_all: cannot expand '" << fstabfile << "'"; | |
449 | + _exit(-1); | |
450 | + } | |
446 | 451 | /* child, call fs_mgr_mount_all() */ |
447 | 452 | |
448 | 453 | // So we can always see what fs_mgr_mount_all() does. |
449 | 454 | // Only needed if someone explicitly changes the default log level in their init.rc. |
450 | 455 | android::base::ScopedLogSeverity info(android::base::INFO); |
451 | 456 | |
452 | - struct fstab* fstab = fs_mgr_read_fstab(fstabfile); | |
457 | + struct fstab* fstab = fs_mgr_read_fstab(filename_val.c_str()); | |
453 | 458 | int child_ret = fs_mgr_mount_all(fstab, mount_mode); |
454 | 459 | fs_mgr_free_fstab(fstab); |
455 | 460 | if (child_ret == -1) { |
@@ -540,7 +545,6 @@ static Result<Success> queue_fs_event(int code) { | ||
540 | 545 | * not return. |
541 | 546 | */ |
542 | 547 | static Result<Success> do_mount_all(const BuiltinArguments& args) { |
543 | - std::size_t na = 0; | |
544 | 548 | bool import_rc = true; |
545 | 549 | bool queue_event = true; |
546 | 550 | int mount_mode = MOUNT_MODE_DEFAULT; |
@@ -548,7 +552,7 @@ static Result<Success> do_mount_all(const BuiltinArguments& args) { | ||
548 | 552 | std::size_t path_arg_end = args.size(); |
549 | 553 | const char* prop_post_fix = "default"; |
550 | 554 | |
551 | - for (na = args.size() - 1; na > 1; --na) { | |
555 | + for (std::size_t na = args.size() - 1; na > 1; --na) { | |
552 | 556 | if (args[na] == "--early") { |
553 | 557 | path_arg_end = na; |
554 | 558 | queue_event = false; |