1 /* 2 * A resource offering support for creating processes. 3 * 4 * Copyright (C) 2023 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #include <systypes/fcntl.h> 23 24 #include "process_creating.h" 25 #include "process_creator_resource.h" 26 27 #include "notifier_client.h" 28 #include "process_creator_server.h" 29 30 31 32 /* Support for creating processes. */ 33 34 ProcessCreatorResource::ProcessCreatorResource(const char *rm_filename) 35 : _creating(rm_filename) 36 { 37 } 38 39 ProcessCreatorResource::~ProcessCreatorResource() 40 { 41 } 42 43 ipc_server_default_config_type ProcessCreatorResource::config() 44 { 45 return config_ProcessCreator; 46 } 47 48 49 50 /* ProcessCreator interface methods. */ 51 52 long ProcessCreatorResource::start(l4_cap_idx_t program, l4_cap_idx_t *process) 53 { 54 file_t file; 55 56 file_init(&file); 57 file.ref = program; 58 59 /* Obtain a distinct and usable file object. */ 60 61 file_t *program_file = client_reopen(&file, O_RDONLY); 62 63 /* NOTE: To be replaced with the actual arguments, perhaps involving a 64 context object. */ 65 66 const char *argv[] = {"<program>"}; 67 68 long err = _creating.start(program_file, 1, argv); 69 70 if (err) 71 return err; 72 73 /* Obtain a reference to the pager to interact with the process. */ 74 75 *process = _creating.get_pager(); 76 77 return L4_EOK; 78 } 79 80 // vim: tabstop=4 expandtab shiftwidth=4