L4Re/departure

servers/process_server.cc

610:b6288af98f93
9 months ago Paul Boddie Fixed mapping to permit the inclusion of undefined/invalid capabilities without terminating the mapping operation.
     1 /*     2  * A process server providing a way of creating new 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 <l4/sys/debugger.h>    23 #include <l4/sys/err.h>    24     25 #include <fsclient/client.h>    26 #include <ipc/thread.h>    27     28 #include <stdio.h>    29 #include <stdlib.h>    30     31 #include <exec/process_creator_resource.h>    32 #include <resource/resource_server.h>    33 #include <systypes/env.h>    34 #include <systypes/fcntl.h>    35     36     37     38 /* Server program. */    39     40 int main(int argc, char *argv[])    41 {    42   l4_debugger_set_object_name(l4re_env()->main_thread, "process_server");    43     44   if (argc < 2)    45   {    46     printf("Need a region mapper.\n");    47     return 1;    48   }    49     50   char *rm_filename = argv[1];    51   const char *server_name = (argc > 2) ? argv[2] : ENV_PROCESS_SERVER_NAME;    52   long err;    53     54   /* Introduce concurrency control. */    55     56   err = ipc_thread_init();    57     58   if (err)    59   {    60     printf("Initialisation error: %s\n", l4sys_errtostr(err));    61     return 1;    62   }    63     64   file_t *rm_file = client_open(rm_filename, O_RDONLY);    65     66   if (!client_opened(rm_file))    67   {    68     err = (rm_file == NULL) ? -L4_ENOMEM : rm_file->error;    69     printf("Could not open region mapper file: %s\n", l4sys_errtostr(err));    70     return 1;    71   }    72     73   ProcessCreatorResource creator(rm_filename, rm_file);    74     75   /* Register a server associating it with the given object. */    76     77   ResourceServer server(&creator);    78   err = server.bind(server_name);    79     80   if (err)    81   {    82     printf("Could not bind server: %s\n", l4sys_errtostr(err));    83     return 1;    84   }    85     86   printf("Starting server...\n");    87   server.start();    88   return 0;    89 }    90     91 /* vim: tabstop=2 expandtab shiftwidth=2    92 */