Back to index

glibc  2.9
hurdrlimit.c
Go to the documentation of this file.
00001 /* Resource limits.
00002    Copyright (C) 1994,95,97,2000 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <hurd.h>
00021 #include <cthreads.h>
00022 #include <hurd/resource.h>
00023 
00024 /* This must be given an initializer, or the a.out linking rules will
00025    not include the entire file when this symbol is referenced. */
00026 struct rlimit _hurd_rlimits[RLIM_NLIMITS] = { { 0, }, };
00027 
00028 /* This must be initialized data for the same reason as above, but this is
00029    intentionally initialized to a bogus value to emphasize the point that
00030    mutex_init is still required below just in case of unexec.  */
00031 struct mutex _hurd_rlimit_lock = { SPIN_LOCK_INITIALIZER, };
00032 
00033 static void
00034 init_rlimit (void)
00035 {
00036   int i;
00037 
00038   __mutex_init (&_hurd_rlimit_lock);
00039 
00040   for (i = 0; i < RLIM_NLIMITS; ++i)
00041     {
00042       if (_hurd_rlimits[i].rlim_max == 0)
00043        _hurd_rlimits[i].rlim_max = RLIM_INFINITY;
00044       if (_hurd_rlimits[i].rlim_cur == 0)
00045 #define I(lim, val) case RLIMIT_##lim: _hurd_rlimits[i].rlim_cur = (val); break
00046        switch (i)
00047          {
00048            I (NOFILE, 1024);       /* Linux 2.2.12 uses this initial value.  */
00049 
00050          default:
00051            _hurd_rlimits[i].rlim_cur = _hurd_rlimits[i].rlim_max;
00052            break;
00053          }
00054 #undef I
00055     }
00056 
00057   (void) &init_rlimit;
00058 }
00059 text_set_element (_hurd_preinit_hook, init_rlimit);