mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 00:32:45 +00:00 
			
		
		
		
	UserspaceEmulator: Pass arguments through to emulated process
Ultimately we'll want to support passing some options to the emulator as well, but for now just pass all arguments (except argv[0] of course) through to the emulated process. This is still not perfect, but slightly better than what we had before.
This commit is contained in:
		
							parent
							
								
									3d42b85969
								
							
						
					
					
						commit
						27c1690504
					
				
					 3 changed files with 28 additions and 18 deletions
				
			
		|  | @ -30,14 +30,17 @@ | |||
| #include <AK/MappedFile.h> | ||||
| #include <LibCore/ArgsParser.h> | ||||
| #include <LibELF/Loader.h> | ||||
| #include <getopt.h> | ||||
| 
 | ||||
| int main(int argc, char** argv) | ||||
| { | ||||
|     const char* executable_path = nullptr; | ||||
|     if (argc == 1) { | ||||
|         out() << "usage: UserspaceEmulator <command>"; | ||||
|         return 0; | ||||
|     } | ||||
| 
 | ||||
|     Core::ArgsParser args_parser; | ||||
|     args_parser.add_positional_argument(executable_path, "Executable path", "executable"); | ||||
|     args_parser.parse(argc, argv); | ||||
|     // FIXME: Allow specifying any command in $PATH instead of requiring a full executable path.
 | ||||
|     const char* executable_path = argv[1]; | ||||
| 
 | ||||
|     MappedFile mapped_file(executable_path); | ||||
|     if (!mapped_file.is_valid()) { | ||||
|  | @ -47,7 +50,12 @@ int main(int argc, char** argv) | |||
| 
 | ||||
|     auto elf = ELF::Loader::create((const u8*)mapped_file.data(), mapped_file.size()); | ||||
| 
 | ||||
|     UserspaceEmulator::Emulator emulator(executable_path, move(elf)); | ||||
|     Vector<String> arguments; | ||||
|     for (int i = 1; i < argc; ++i) { | ||||
|         arguments.append(argv[i]); | ||||
|     } | ||||
| 
 | ||||
|     UserspaceEmulator::Emulator emulator(arguments, move(elf)); | ||||
|     if (!emulator.load_elf()) | ||||
|         return 1; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling