exec-startup-get-data.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* -*-comment-start: "//";comment-end:""-*-
  2. * GNU Mes --- Maxwell Equations of Software
  3. * Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  4. *
  5. * This file is part of GNU Mes.
  6. *
  7. * GNU Mes is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * GNU Mes is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <gnu/syscall.h>
  21. static void
  22. mach_startup_info2hurd_startup_data (struct mach_msg_startup_info *info,
  23. struct hurd_startup_data *data)
  24. {
  25. data->flags = info->flags;
  26. data->dtable = info->dtable;
  27. data->dtable_count = info->dtableType.msgtl_number;
  28. data->argp = info->argv;
  29. data->arg_size = info->argvType.msgtl_number;
  30. data->envp = info->envp;
  31. data->env_size = info->envpType.msgtl_number;
  32. data->portarray = info->portarray;
  33. data->portarray_count = info->portarrayType.msgtl_number;
  34. data->intarray = info->intarray;
  35. data->intarray_count = info->intarrayType.msgtl_number;
  36. data->stack_base = info->stack_base;
  37. data->stack_count = info->stack_size;
  38. data->phdr = info->phdr;
  39. data->phdr_count = info->phdr_size;
  40. data->user_entry = info->user_entry;
  41. }
  42. kern_return_t
  43. __exec_startup_get_data (mach_port_t bootstrap, struct hurd_startup_data *data)
  44. {
  45. union message
  46. {
  47. mach_msg_header_t header;
  48. struct mach_msg_startup_info info;
  49. };
  50. union message message;
  51. message.header.msgh_size = sizeof (struct mach_msg);
  52. kern_return_t result = __syscall_get (bootstrap, SYS__exec_startup_get_info,
  53. &message.header, sizeof (message));
  54. mach_startup_info2hurd_startup_data (&message.info, data);
  55. return result;
  56. }