]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - hurd/hurdmsg.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / hurd / hurdmsg.c
index 57b6b8dd679578c45a296765e21784d1c1a64441..4249ba104a94137676d630505158e87be658e8ea 100644 (file)
@@ -1,20 +1,19 @@
-/* Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1992-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Library General Public License for more details.
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
 
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <hurd.h>
 #include <hurd/msg_server.h>
@@ -22,6 +21,7 @@ Cambridge, MA 02139, USA.  */
 #include <unistd.h>
 #include <limits.h>
 #include <string.h>
+#include <argz.h>
 
 
 #define AUTHCHECK \
@@ -32,8 +32,8 @@ Cambridge, MA 02139, USA.  */
 /* Snarfing and frobbing the init ports.  */
 
 kern_return_t
-_S_msg_get_init_port (mach_port_t msgport, mach_port_t auth, int which,
-                 mach_port_t *result, mach_msg_type_name_t *result_type)
+  _S_msg_get_init_port (mach_port_t msgport, mach_port_t auth, int which,
+                       mach_port_t *result, mach_msg_type_name_t *result_type)
 {
   AUTHCHECK;
   *result_type = MACH_MSG_TYPE_MOVE_SEND;
@@ -44,7 +44,7 @@ _S_msg_get_init_port (mach_port_t msgport, mach_port_t auth, int which,
 
 kern_return_t
 _S_msg_set_init_port (mach_port_t msgport, mach_port_t auth,
-                 int which, mach_port_t port)
+                     int which, mach_port_t port)
 {
   error_t err;
 
@@ -59,9 +59,9 @@ _S_msg_set_init_port (mach_port_t msgport, mach_port_t auth,
 
 kern_return_t
 _S_msg_get_init_ports (mach_port_t msgport, mach_port_t auth,
-                  mach_port_t **ports,
-                  mach_msg_type_name_t *ports_type,
-                  mach_msg_type_number_t *nports)
+                      mach_port_t **ports,
+                      mach_msg_type_name_t *ports_type,
+                      mach_msg_type_number_t *nports)
 {
   mach_msg_type_number_t i;
   error_t err;
@@ -93,7 +93,7 @@ _S_msg_get_init_ports (mach_port_t msgport, mach_port_t auth,
 
 kern_return_t
 _S_msg_set_init_ports (mach_port_t msgport, mach_port_t auth,
-                  mach_port_t *ports, mach_msg_type_number_t nports)
+                      mach_port_t *ports, mach_msg_type_number_t nports)
 {
   mach_msg_type_number_t i;
   error_t err;
@@ -158,7 +158,7 @@ get_int (int which, int *value)
 
 kern_return_t
 _S_msg_get_init_int (mach_port_t msgport, mach_port_t auth,
-                int which, int *value)
+                    int which, int *value)
 {
   AUTHCHECK;
 
@@ -167,7 +167,7 @@ _S_msg_get_init_int (mach_port_t msgport, mach_port_t auth,
 
 kern_return_t
 _S_msg_get_init_ints (mach_port_t msgport, mach_port_t auth,
-                 int **values, mach_msg_type_number_t *nvalues)
+                     int **values, mach_msg_type_number_t *nvalues)
 {
   error_t err;
   mach_msg_type_number_t i;
@@ -238,6 +238,10 @@ set_int (int which, int value)
          }
        __spin_unlock (&ss->lock);
        return 0;
+
+      case INIT_TRACEMASK:
+       _hurdsig_traced = value;
+       return 0;
       }
     default:
       return EINVAL;
@@ -246,7 +250,7 @@ set_int (int which, int value)
 
 kern_return_t
 _S_msg_set_init_int (mach_port_t msgport, mach_port_t auth,
-                int which, int value)
+                    int which, int value)
 {
   AUTHCHECK;
 
@@ -255,7 +259,7 @@ _S_msg_set_init_int (mach_port_t msgport, mach_port_t auth,
 
 kern_return_t
 _S_msg_set_init_ints (mach_port_t msgport, mach_port_t auth,
-                 int *values, mach_msg_type_number_t nvalues)
+                     int *values, mach_msg_type_number_t nvalues)
 {
   error_t err;
   mach_msg_type_number_t i;
@@ -278,8 +282,8 @@ _S_msg_set_init_ints (mach_port_t msgport, mach_port_t auth,
 \f
 
 kern_return_t
-_S_msg_get_fd (mach_port_t msgport, mach_port_t auth,
-          int which, mach_port_t *result, mach_msg_type_name_t *result_type)
+_S_msg_get_fd (mach_port_t msgport, mach_port_t auth, int which,
+              mach_port_t *result, mach_msg_type_name_t *result_type)
 {
   AUTHCHECK;
 
@@ -295,7 +299,7 @@ _S_msg_get_fd (mach_port_t msgport, mach_port_t auth,
 
 kern_return_t
 _S_msg_set_fd (mach_port_t msgport, mach_port_t auth,
-          int which, mach_port_t port)
+              int which, mach_port_t port)
 {
   AUTHCHECK;
 
@@ -307,26 +311,36 @@ _S_msg_set_fd (mach_port_t msgport, mach_port_t auth,
 
 kern_return_t
 _S_msg_get_env_variable (mach_port_t msgport,
-                    char *variable,
-                    char **data, mach_msg_type_number_t *datalen)
+                        char *variable,
+                        char **data, mach_msg_type_number_t *datalen)
 {
+  error_t err;
+  mach_msg_type_number_t valuelen;
   const char *value = getenv (variable);
 
   if (value == NULL)
     return ENOENT;
 
-  /* XXX this pointer might become invalid */
-  *data = value;
-  *datalen = strlen (value);
+  valuelen = strlen (value);
+  if (valuelen > *datalen)
+    {
+      if (err = __vm_allocate (__mach_task_self (),
+                              (vm_address_t *) data, valuelen, 1))
+       return err;
+    }
+
+  memcpy (*data, value, valuelen);
+  *datalen = valuelen;
+
   return 0;
 }
 
 
 kern_return_t
 _S_msg_set_env_variable (mach_port_t msgport, mach_port_t auth,
-                    char *variable,
-                    char *value,
-                    int replace)
+                        char *variable,
+                        char *value,
+                        int replace)
 {
   AUTHCHECK;
 
@@ -337,7 +351,7 @@ _S_msg_set_env_variable (mach_port_t msgport, mach_port_t auth,
 
 kern_return_t
 _S_msg_get_environment (mach_port_t msgport,
-                   char **data, mach_msg_type_number_t *datalen)
+                       char **data, mach_msg_type_number_t *datalen)
 {
   /* Pack the environment into an array with nulls separating elements.  */
   if (__environ != NULL)
@@ -369,7 +383,7 @@ _S_msg_get_environment (mach_port_t msgport,
 
 kern_return_t
 _S_msg_set_environment (mach_port_t msgport, mach_port_t auth,
-                   char *data, mach_msg_type_number_t datalen)
+                       char *data, mach_msg_type_number_t datalen)
 {
   int _hurd_split_args (char *, mach_msg_type_number_t, char **);
   int envc;
@@ -377,75 +391,29 @@ _S_msg_set_environment (mach_port_t msgport, mach_port_t auth,
 
   AUTHCHECK;
 
-  envc = _hurd_split_args (data, datalen, NULL);
+  envc = __argz_count (data, datalen);
   envp = malloc ((envc + 1) * sizeof (char *));
   if (envp == NULL)
     return errno;
-  _hurd_split_args (data, datalen, envp);
+  __argz_extract (data, datalen, envp);
   __environ = envp;            /* XXX cooperate with loadenv et al */
   return 0;
 }
 \f
-/* Get and frob the exec flags.  */
-
-kern_return_t
-_S_msg_get_exec_flags (mach_port_t process, mach_port_t auth,
-                      int *flags)
-{
-  AUTHCHECK;
-
-  *flags = _hurd_exec_flags;
-  return 0;
-}
-
-kern_return_t
-_S_msg_set_all_exec_flags (mach_port_t process, mach_port_t auth,
-                          int flags)
-{
-  AUTHCHECK;
-
-  _hurd_exec_flags = flags;
-  return 0;
-}
-
-kern_return_t
-_S_msg_set_some_exec_flags (mach_port_t process, mach_port_t auth,
-                           int flags)
-{
-  AUTHCHECK;
-
-  _hurd_exec_flags |= flags;
-  return 0;
-}
-
-kern_return_t
-_S_msg_clear_some_exec_flags (mach_port_t process, mach_port_t auth,
-                             int flags)
-{
-  AUTHCHECK;
-
-  _hurd_exec_flags &= ~flags;
-  return 0;
-}
-\f
 
 /* XXX */
 
 kern_return_t
 _S_msg_get_dtable (mach_port_t process,
-              mach_port_t refport,
-              portarray_t *dtable,
-              mach_msg_type_name_t *dtablePoly,
-              mach_msg_type_number_t *dtableCnt)
+                  mach_port_t refport,
+                  portarray_t *dtable,
+                  mach_msg_type_name_t *dtablePoly,
+                  mach_msg_type_number_t *dtableCnt)
 { return EOPNOTSUPP; }
 
 kern_return_t
 _S_msg_set_dtable (mach_port_t process,
-              mach_port_t refport,
-              portarray_t dtable,
-              mach_msg_type_number_t dtableCnt)
-{ return EOPNOTSUPP; }
-
-kern_return_t
-_S_msg_startup_dosync (mach_port_t process)
+                  mach_port_t refport,
+                  portarray_t dtable,
+                  mach_msg_type_number_t dtableCnt)
 { return EOPNOTSUPP; }