home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / glibc-1.06 / hurd / hurdfrob.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-30  |  3.2 KB  |  126 lines

  1. /* Copyright (C) 1992 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #include <hurd.h>
  20. #include "msg_server.h"
  21.  
  22. error_t
  23. __get_init_port (mach_port_t msgport, mach_port_t auth,
  24.          int which, mach_port_t *port)
  25. {
  26.   if (task != mach_task_self () &&
  27.       _HURD_PORT_USE (&_hurd_auth, auth != port))
  28.     return EPERM;
  29.  
  30.   switch (which)
  31.     {
  32.     case INIT_PORT_CWDIR:
  33.       *port = get (&_hurd_cwdir);
  34.       return 0;
  35.     case INIT_PORT_CRDIR:
  36.       *port = get (&_hurd_crdir);
  37.       return 0;
  38.     case INIT_PORT_PROC:
  39.       *port = get (&_hurd_proc);
  40.       return 0;
  41.     case INIT_PORT_AUTH:
  42.       *port = get (&_hurd_auth);
  43.       return 0;
  44.     case INIT_PORT_LOGINCOLL:
  45.       return EOPNOTSUPP;    /* XXX */
  46.     case INIT_PORT_BOOTSTRAP:
  47.       return __task_get_special_port (__mach_task_self (),
  48.                       TASK_BOOTSTRAP_PORT,
  49.                       port);
  50.     default:
  51.       return EINVAL;
  52.     }
  53. }
  54.  
  55. error_t
  56. __set_init_port (mach_port_t msgport, task_t task,
  57.          int which, mach_port_t port)
  58. {
  59.   if (task != mach_task_self () &&
  60.       _HURD_PORT_USE (&_hurd_auth, auth != port))
  61.     return EPERM;
  62.  
  63.   switch (which)
  64.     {
  65.     case INIT_PORT_CWDIR:
  66.       set (&_hurd_cwdir);
  67.       return 0;
  68.     case INIT_PORT_CRDIR:
  69.       set (&_hurd_crdir);
  70.       return 0;
  71.     case INIT_PORT_PROC:
  72.       set (&_hurd_proc); /* XXX do more? */
  73.       return 0;
  74.     case INIT_PORT_AUTH:
  75.       __setauth (&_hurd_auth);
  76.       return errno;        /* XXX can't clobber errno */
  77.     case INIT_PORT_LOGINCOLL:
  78.       return EOPNOTSUPP;    /* XXX */
  79.     case INIT_PORT_BOOTSTRAP:
  80.       return __task_set_special_port (__mach_task_self (),
  81.                       TASK_BOOTSTRAP_PORT,
  82.                       port);
  83.     default:
  84.       return EINVAL;
  85.     }
  86. }
  87.  
  88. error_t
  89. __get_init_int (mach_port_t msgport, mach_port_t auth,
  90.         int which, int *value)
  91. {
  92.   if (task != mach_task_self () &&
  93.       _HURD_PORT_USE (&_hurd_auth, auth != port))
  94.     return EPERM;
  95.  
  96.   switch (which)
  97.     {
  98.     case INIT_UMASK:
  99.       *value = _hurd_umask;
  100.       return 0;
  101.     case INIT_SIGMASK:
  102.       {
  103.     struct _hurd_sigstate *ss = _hurd_thread_sigstate (_hurd_sigthread);
  104.     *value = ss->blocked;
  105.     __mutex_unlock (&ss->lock);
  106.     return 0;
  107.       }
  108.     case INIT_SIGMASK:
  109.       {
  110.     struct _hurd_sigstate *ss = _hurd_thread_sigstate (_hurd_sigthread);
  111.     sigset_t ign;
  112.     int sig;
  113.     __sigemptyset (&ign);
  114.     for (sig = 1; sig < NSIG; ++sig)
  115.       if (ss->actions[sig].sa_handler == SIG_IGN)
  116.         __sigaddset (sig, &ign);
  117.     __mutex_unlock (&ss->lock);
  118.     *value = ign
  119.     return 0;
  120.       }
  121.       /* XXX ctty crap */
  122.     default:
  123.       return EINVAL;
  124.     }
  125. }
  126.