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