initial checkin
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Fri, 6 Feb 2004 14:47:18 +0000 (14:47 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Fri, 6 Feb 2004 14:47:18 +0000 (14:47 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@814 94cd875c-1c1d-0410-91d2-eb244daf1a30

31 files changed:
util-vserver/ensc_vector/Makefile-files [new file with mode: 0644]
util-vserver/ensc_vector/vector-clear.c [new file with mode: 0644]
util-vserver/ensc_vector/vector-free.c [new file with mode: 0644]
util-vserver/ensc_vector/vector-init.c [new file with mode: 0644]
util-vserver/ensc_vector/vector-insert.c [new file with mode: 0644]
util-vserver/ensc_vector/vector-internal.h [new file with mode: 0644]
util-vserver/ensc_vector/vector-popback.c [new file with mode: 0644]
util-vserver/ensc_vector/vector-pushback.c [new file with mode: 0644]
util-vserver/ensc_vector/vector-resize.c [new file with mode: 0644]
util-vserver/ensc_vector/vector-resizeinternal.hc [new file with mode: 0644]
util-vserver/ensc_vector/vector-search.c [new file with mode: 0644]
util-vserver/ensc_vector/vector-sort.c [new file with mode: 0644]
util-vserver/ensc_vector/vector-unique.c [new file with mode: 0644]
util-vserver/ensc_vector/vector.h [new file with mode: 0644]
util-vserver/ensc_vector/vector.hc [new file with mode: 0644]
util-vserver/ensc_wrappers/Makefile-files [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers-clone.hc [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers-dirent.hc [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers-fcntl.hc [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers-io.hc [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers-ioctl.hc [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers-iosock.hc [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers-mount.hc [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers-pivot.hc [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers-resource.hc [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers-stdlib.hc [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers-unistd.hc [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers-vserver.hc [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers-wait.hc [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers.h [new file with mode: 0644]
util-vserver/ensc_wrappers/wrappers_handler.hc [new file with mode: 0644]

diff --git a/util-vserver/ensc_vector/Makefile-files b/util-vserver/ensc_vector/Makefile-files
new file mode 100644 (file)
index 0000000..cb62743
--- /dev/null
@@ -0,0 +1,36 @@
+## $Id$                --*- makefile -*--
+
+## Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+##  
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; version 2 of the License.
+##  
+## This program 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 General Public License for more details.
+##  
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ENSC_VECTOR_SRCS =             ensc_vector/vector-clear.c \
+                               ensc_vector/vector-free.c \
+                               ensc_vector/vector-init.c \
+                               ensc_vector/vector-insert.c \
+                               ensc_vector/vector-popback.c \
+                               ensc_vector/vector-pushback.c \
+                               ensc_vector/vector-resize.c \
+                               ensc_vector/vector-search.c \
+                               ensc_vector/vector-sort.c \
+                               ensc_vector/vector-unique.c
+
+ENSC_VECTOR_HDRS =             ensc_vector/vector.h \
+                               ensc_vector/vector.hc
+
+ENSC_VECTOR_XHDRS =            ensc_vector/vector-resizeinternal.hc \
+                               ensc_vector/vector-internal.h
+
+ENSC_VECTOR_LIBS =             libensc_vector.a
+libensc_vector_a_SOURCES =     $(ENSC_VECTOR_SRCS)
diff --git a/util-vserver/ensc_vector/vector-clear.c b/util-vserver/ensc_vector/vector-clear.c
new file mode 100644 (file)
index 0000000..0df7ad1
--- /dev/null
@@ -0,0 +1,31 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "vector.h"
+#include <assert.h>
+
+void
+Vector_clear(struct Vector *vec)
+{
+  assert(vec!=0);
+  vec->count = 0;
+}
diff --git a/util-vserver/ensc_vector/vector-free.c b/util-vserver/ensc_vector/vector-free.c
new file mode 100644 (file)
index 0000000..f88822d
--- /dev/null
@@ -0,0 +1,38 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "vector.h"
+#include <assert.h>
+
+void
+Vector_free(struct Vector *vec)
+{
+  assert(vec!=0);
+  free(vec->data);
+
+#ifndef NDEBUG  
+  vec->count     = 0xdeadbeef;
+  vec->allocated = 0xdeadbeef;
+  vec->elem_size = 0xdeadbeef;
+  vec->data      = (void *)(0xdeadbeef);
+#endif
+}
diff --git a/util-vserver/ensc_vector/vector-init.c b/util-vserver/ensc_vector/vector-init.c
new file mode 100644 (file)
index 0000000..c83961e
--- /dev/null
@@ -0,0 +1,36 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "vector.h"
+#include <assert.h>
+
+void
+Vector_init(struct Vector *vec, size_t elem_size)
+{
+  assert(vec!=0);
+  assert(elem_size!=0);
+
+  vec->elem_size = elem_size;
+  vec->data      = 0;
+  vec->count     = 0;
+  vec->allocated = 0;
+}
diff --git a/util-vserver/ensc_vector/vector-insert.c b/util-vserver/ensc_vector/vector-insert.c
new file mode 100644 (file)
index 0000000..ab91b5e
--- /dev/null
@@ -0,0 +1,42 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "vector.h"
+#include <string.h>
+
+void *
+Vector_insert(struct Vector *vec, void const *key,
+             int (*compare)(const void *, const void *))
+{
+  char *       data;
+  char *       end_ptr = Vector_pushback(vec);
+
+  for (data=vec->data; data<end_ptr; data += vec->elem_size) {
+    if (compare(key, data)>0) {
+      memmove(data, data+vec->elem_size,
+             (char *)(end_ptr) - (char *)(data));
+      return data;
+    }
+  }
+
+  return end_ptr;
+}
diff --git a/util-vserver/ensc_vector/vector-internal.h b/util-vserver/ensc_vector/vector-internal.h
new file mode 100644 (file)
index 0000000..6bcf5f0
--- /dev/null
@@ -0,0 +1,32 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef H_UTIL_VSERVER_SRC_VECTOR_VECTOR_INTERNAL_H
+#define H_UTIL_VSERVER_SRC_VECTOR_VECTOR_INTERNAL_H
+
+#ifndef VECTOR_SET_THRESHOLD
+#  define VECTOR_SET_THRESHOLD         20/16
+#endif
+
+#ifndef VECTOR_DEC_THRESHOLD
+#  define VECTOR_DEC_THRESHOLD         24/16
+#endif
+
+
+
+#endif //  H_UTIL_VSERVER_SRC_VECTOR_VECTOR_INTERNAL_H
diff --git a/util-vserver/ensc_vector/vector-popback.c b/util-vserver/ensc_vector/vector-popback.c
new file mode 100644 (file)
index 0000000..93d2184
--- /dev/null
@@ -0,0 +1,32 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "vector.h"
+#include <assert.h>
+
+void
+Vector_popback(struct Vector *vec)
+{
+  assert(vec->count>0);
+
+  if (vec->count>0) --vec->count;
+}
diff --git a/util-vserver/ensc_vector/vector-pushback.c b/util-vserver/ensc_vector/vector-pushback.c
new file mode 100644 (file)
index 0000000..d13867e
--- /dev/null
@@ -0,0 +1,34 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "vector.h"
+#include "vector-resizeinternal.hc"
+
+void *
+Vector_pushback(struct Vector *vec)
+{
+  ++vec->count;
+  if (vec->allocated<vec->count)
+    Vector_resizeInternal(vec);
+
+  return (char *)(vec->data) + ((vec->count-1) * vec->elem_size);
+}
diff --git a/util-vserver/ensc_vector/vector-resize.c b/util-vserver/ensc_vector/vector-resize.c
new file mode 100644 (file)
index 0000000..89295ca
--- /dev/null
@@ -0,0 +1,31 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "vector.h"
+#include "vector-resizeinternal.hc"
+
+void
+Vector_resize(struct Vector *vec)
+{
+  if (vec->allocated * VECTOR_DEC_THRESHOLD > vec->count+1)
+    Vector_resizeInternal(vec);
+}
diff --git a/util-vserver/ensc_vector/vector-resizeinternal.hc b/util-vserver/ensc_vector/vector-resizeinternal.hc
new file mode 100644 (file)
index 0000000..cefafa7
--- /dev/null
@@ -0,0 +1,39 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "vector-internal.h"
+#include <assert.h>
+
+#define ENSC_WRAPPERS_STDLIB 1
+#include <wrappers.h>
+
+static void
+Vector_resizeInternal(struct Vector *vec)
+{
+  vec->allocated = vec->count * VECTOR_SET_THRESHOLD;
+  ++vec->allocated;
+
+  assert(vec->allocated >= vec->count);
+    
+  vec->data = Erealloc(vec->data, vec->allocated * vec->elem_size);
+  assert(vec->data!=0);
+}
diff --git a/util-vserver/ensc_vector/vector-search.c b/util-vserver/ensc_vector/vector-search.c
new file mode 100644 (file)
index 0000000..05fe7cc
--- /dev/null
@@ -0,0 +1,37 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "vector.h"
+
+#include <stdlib.h>
+#include <assert.h>
+
+
+void *
+Vector_search(struct Vector *vec, void const *key,
+             int (*compare)(const void *, const void *))
+{
+  if (vec->count==0) return 0;
+  assert(vec->data!=0);
+  
+  return bsearch(key, vec->data, vec->count, vec->elem_size, compare);
+}
diff --git a/util-vserver/ensc_vector/vector-sort.c b/util-vserver/ensc_vector/vector-sort.c
new file mode 100644 (file)
index 0000000..84047cd
--- /dev/null
@@ -0,0 +1,34 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "vector.h"
+
+#include <stdlib.h>
+#include <assert.h>
+
+void
+Vector_sort(struct Vector *vec, int (*compare)(const void *, const void *))
+{
+  if (vec->count==0) return;
+
+  qsort(vec->data, vec->count, vec->elem_size, compare);
+}
diff --git a/util-vserver/ensc_vector/vector-unique.c b/util-vserver/ensc_vector/vector-unique.c
new file mode 100644 (file)
index 0000000..a9119f9
--- /dev/null
@@ -0,0 +1,57 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "vector.h"
+
+#include <assert.h>
+#include <string.h>
+
+  // TODO: do not iterate from begin to end but in the reverse direction. This should be more
+  // effective.
+void
+Vector_unique(struct Vector *vec, int (*compare)(const void *, const void *))
+{
+  size_t               idx;
+  
+  if (vec->count<2) return;
+
+  for (idx=0; idx+1<vec->count; ++idx) {
+    char       *ptr      = (char *)(vec->data) + idx*vec->elem_size;
+    char       *next_ptr = ptr + vec->elem_size;
+    size_t     next_idx  = idx + 1;
+
+    while (next_idx<vec->count &&
+          compare(ptr, next_ptr)==0) {
+      ++next_idx;
+      next_ptr += vec->elem_size;
+    }
+
+    if (next_idx==vec->count)
+      vec->count = idx+1;
+    else if (next_idx-idx > 1) {
+      memmove(ptr + vec->elem_size,
+             next_ptr, (vec->count - next_idx)*vec->elem_size);
+      vec->count -= (next_idx-idx-1);
+    }
+  }
+}
+
diff --git a/util-vserver/ensc_vector/vector.h b/util-vserver/ensc_vector/vector.h
new file mode 100644 (file)
index 0000000..ff8c24d
--- /dev/null
@@ -0,0 +1,52 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2002,2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//  
+
+#ifndef H_UTILVSERVER_VECTOR_VECTOR_H
+#define H_UTILVSERVER_VECTOR_VECTOR_H
+
+#include <stdlib.h>
+
+struct Vector
+{
+    void       *data;
+    size_t     count;
+    size_t     allocated;
+
+    size_t     elem_size;
+};
+
+void   Vector_init(struct Vector *, size_t elem_size);
+void   Vector_free(struct Vector *);
+void * Vector_search(struct Vector *, void const *key, int (*compar)(const void *, const void *));
+void   Vector_sort(struct Vector *, int (*compar)(const void *, const void *));
+void   Vector_unique(struct Vector *, int (*compar)(const void *, const void *));
+void * Vector_pushback(struct Vector *);
+void * Vector_insert(struct Vector *, void const *key, int (*compar)(const void *, const void *));
+void   Vector_popback(struct Vector *);
+void   Vector_resize(struct Vector *vec);
+void   Vector_clear(struct Vector *vec);
+static void const *    Vector_search_const(struct Vector const *, void const *key, int (*compar)(const void *, const void *));
+static void *          Vector_begin(struct Vector *);
+static void *          Vector_end(struct Vector *);
+static void const *    Vector_begin_const(struct Vector const *);
+static void const *    Vector_end_const(struct Vector const *);
+static size_t          Vector_count(struct Vector const *vec);
+
+#include "vector.hc"
+
+#endif //  H_UTILVSERVER_VECTOR_VECTOR_H
diff --git a/util-vserver/ensc_vector/vector.hc b/util-vserver/ensc_vector/vector.hc
new file mode 100644 (file)
index 0000000..071138e
--- /dev/null
@@ -0,0 +1,53 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2002,2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//  
+
+static inline UNUSED void *
+Vector_begin(struct Vector *vec)
+{
+  return vec->data;
+}
+
+static inline UNUSED void *
+Vector_end(struct Vector *vec)
+{
+  return (char *)(vec->data) + (vec->count * vec->elem_size);
+}
+
+static inline UNUSED void const *
+Vector_begin_const(struct Vector const *vec)
+{
+  return vec->data;
+}
+
+static inline UNUSED void const *
+Vector_end_const(struct Vector const *vec)
+{
+  return (char *)(vec->data) + (vec->count * vec->elem_size);
+}
+
+static inline UNUSED size_t
+Vector_count(struct Vector const *vec)
+{
+  return vec->count;
+}
+
+static inline UNUSED void const *
+Vector_search_const(struct Vector const *vec, void const *key, int (*compar)(const void *, const void *))
+{
+  return Vector_search((struct Vector *)(vec), key, compar);
+}
diff --git a/util-vserver/ensc_wrappers/Makefile-files b/util-vserver/ensc_wrappers/Makefile-files
new file mode 100644 (file)
index 0000000..f2e277f
--- /dev/null
@@ -0,0 +1,32 @@
+## $Id$                --*- makefile -*--
+
+## Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+##  
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; version 2 of the License.
+##  
+## This program 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 General Public License for more details.
+##  
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ENSC_WRAPPERS_HDRS =           ensc_wrappers/wrappers-clone.hc \
+                               ensc_wrappers/wrappers-dirent.hc \
+                               ensc_wrappers/wrappers-fcntl.hc \
+                               ensc_wrappers/wrappers-io.hc \
+                               ensc_wrappers/wrappers-ioctl.hc \
+                               ensc_wrappers/wrappers-iosock.hc \
+                               ensc_wrappers/wrappers-mount.hc \
+                               ensc_wrappers/wrappers-pivot.hc \
+                               ensc_wrappers/wrappers-resource.hc \
+                               ensc_wrappers/wrappers-stdlib.hc \
+                               ensc_wrappers/wrappers-unistd.hc \
+                               ensc_wrappers/wrappers-vserver.hc \
+                               ensc_wrappers/wrappers-wait.hc \
+                               ensc_wrappers/wrappers.h \
+                               ensc_wrappers/wrappers_handler.hc
diff --git a/util-vserver/ensc_wrappers/wrappers-clone.hc b/util-vserver/ensc_wrappers/wrappers-clone.hc
new file mode 100644 (file)
index 0000000..943514f
--- /dev/null
@@ -0,0 +1,34 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef H_ENSC_IN_WRAPPERS_H
+#  error wrappers_handler.hc can not be used in this way
+#endif
+
+inline static WRAPPER_DECL pid_t
+Eclone(int (*fn)(void *), void *child_stack, int flags, void *arg)
+{
+  pid_t                res;
+#ifndef __dietlibc__
+  res = clone(fn, child_stack, flags, arg);
+#else
+  res = clone((void*(*)(void*))(fn), child_stack, flags, arg);
+#endif
+  FatalErrnoError(res==-1, "clone()");
+  return res;
+}
diff --git a/util-vserver/ensc_wrappers/wrappers-dirent.hc b/util-vserver/ensc_wrappers/wrappers-dirent.hc
new file mode 100644 (file)
index 0000000..d7fe433
--- /dev/null
@@ -0,0 +1,57 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef H_ENSC_IN_WRAPPERS_H
+#  error wrappers_handler.hc can not be used in this way
+#endif
+
+inline static WRAPPER_DECL DIR *
+Eopendir(const char *name)
+{
+  DIR *                res = opendir(name);
+
+  FatalErrnoError(res==0, "opendir()");
+  return res;
+}
+
+inline static WRAPPER_DECL struct dirent *
+Ereaddir(DIR *dir)
+{
+  struct dirent        *res;
+
+  errno = 0;
+  res   = readdir(dir);
+  
+  FatalErrnoError(res==0 && errno!=0, "readdir()");
+  return res;
+}
+
+#ifndef __dietlibc__
+inline static WRAPPER_DECL void
+Ereaddir_r(DIR *dir, struct dirent *entry, struct dirent **result)
+{
+  errno = 0;
+  FatalErrnoError(readdir_r(dir, entry, result)==0 && errno!=0, "readdir_r()");
+}
+#endif
+
+inline static WRAPPER_DECL void
+Eclosedir(DIR *dir)
+{
+  FatalErrnoError(closedir(dir)==-1, "closedir()");
+}
diff --git a/util-vserver/ensc_wrappers/wrappers-fcntl.hc b/util-vserver/ensc_wrappers/wrappers-fcntl.hc
new file mode 100644 (file)
index 0000000..10e9508
--- /dev/null
@@ -0,0 +1,35 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef H_ENSC_IN_WRAPPERS_H
+#  error wrappers_handler.hc can not be used in this way
+#endif
+
+inline static WRAPPER_DECL int
+Eopen(char const *fname, int flags, mode_t mode)
+{
+  int  res = open(fname, flags, mode);
+  FatalErrnoError(res==-1, "open()");
+
+  return res;
+}
+
+inline static WRAPPER_DECL void
+Emkdir(const char *pathname, mode_t mode)
+{
+  FatalErrnoError(mkdir(pathname,mode)==-1, "mkdir()");
+}
diff --git a/util-vserver/ensc_wrappers/wrappers-io.hc b/util-vserver/ensc_wrappers/wrappers-io.hc
new file mode 100644 (file)
index 0000000..ddfa392
--- /dev/null
@@ -0,0 +1,96 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef H_ENSC_IN_WRAPPERS_H
+#  error wrappers_handler.hc can not be used in this way
+#endif
+
+#include <stdbool.h>
+
+inline static UNUSED bool
+WwriteAll(int fd, void const *ptr_v, size_t len)
+{
+  register char const  *ptr = ptr_v;
+
+  while (len>0) {
+    size_t     res = TEMP_FAILURE_RETRY(write(fd, ptr, len));
+    if (res==(size_t)-1) {
+      perror("write()");
+      return false;
+    }
+
+    if (res==0) return false;
+
+    ptr += res;
+    len -= res;
+  }
+  return true;
+}
+
+inline static UNUSED void
+EwriteAll(int fd, void const *ptr_v, size_t len)
+{
+  register char const  *ptr = ptr_v;
+
+  while (len>0) {
+    size_t     res = TEMP_FAILURE_RETRY(write(fd, ptr, len));
+    FatalErrnoError(res==(size_t)-1, "write()");
+
+    ptr += res;
+    len -= res;
+  }
+}
+
+
+inline static UNUSED bool
+WreadAll(int fd, void *ptr_v, size_t len)
+{
+  register char        *ptr = ptr_v;
+  
+  while (len>0) {
+    size_t     res = TEMP_FAILURE_RETRY(read(fd, ptr, len));
+    if (res==(size_t)-1) {
+      perror("read()");
+      return false;
+    }
+
+    if (res==0) return false;
+
+    ptr += res;
+    len -= res;
+  }
+  return true;
+}
+
+inline static UNUSED bool
+EreadAll(int fd, void *ptr_v, size_t len)
+{
+  register char        *ptr = ptr_v;
+  
+  while (len>0) {
+    size_t     res = TEMP_FAILURE_RETRY(read(fd, ptr, len));
+    FatalErrnoError(res==(size_t)-1, "read()");
+
+    if (res==0) return false;
+
+    ptr += res;
+    len -= res;
+  }
+
+  return true;
+}
diff --git a/util-vserver/ensc_wrappers/wrappers-ioctl.hc b/util-vserver/ensc_wrappers/wrappers-ioctl.hc
new file mode 100644 (file)
index 0000000..7656bf1
--- /dev/null
@@ -0,0 +1,29 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef H_ENSC_IN_WRAPPERS_H
+#  error wrappers_handler.hc can not be used in this way
+#endif
+
+inline static WRAPPER_DECL void
+Eioctl(int fd, int request, void *p)
+{
+  int   res = ioctl(fd, request, p);
+  FatalErrnoError(res<0, "ioctl()");
+}
+
diff --git a/util-vserver/ensc_wrappers/wrappers-iosock.hc b/util-vserver/ensc_wrappers/wrappers-iosock.hc
new file mode 100644 (file)
index 0000000..0da40c9
--- /dev/null
@@ -0,0 +1,96 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef H_ENSC_IN_WRAPPERS_H
+#  error wrappers_handler.hc can not be used in this way
+#endif
+
+#include <stdbool.h>
+
+inline static UNUSED bool
+WsendAll(int fd, void const *ptr_v, size_t len)
+{
+  register char const  *ptr = ptr_v;
+
+  while (len>0) {
+    size_t     res = TEMP_FAILURE_RETRY(send(fd, ptr, len, MSG_NOSIGNAL));
+    if (res==(size_t)-1) {
+      perror("send()");
+      return false;
+    }
+
+    if (res==0) return false;
+
+    ptr += res;
+    len -= res;
+  }
+  return true;
+}
+
+inline static UNUSED void
+EsendAll(int fd, void const *ptr_v, size_t len)
+{
+  register char const  *ptr = ptr_v;
+
+  while (len>0) {
+    size_t     res = TEMP_FAILURE_RETRY(send(fd, ptr, len, MSG_NOSIGNAL));
+    FatalErrnoError(res==(size_t)-1, "send()");
+
+    ptr += res;
+    len -= res;
+  }
+}
+
+
+inline static UNUSED bool
+WrecvAll(int fd, void *ptr_v, size_t len)
+{
+  register char        *ptr = ptr_v;
+  
+  while (len>0) {
+    size_t     res = TEMP_FAILURE_RETRY(recv(fd, ptr, len, MSG_NOSIGNAL));
+    if (res==(size_t)-1) {
+      perror("recv()");
+      return false;
+    }
+
+    if (res==0) return false;
+
+    ptr += res;
+    len -= res;
+  }
+  return true;
+}
+
+inline static UNUSED bool
+ErecvAll(int fd, void *ptr_v, size_t len)
+{
+  register char        *ptr = ptr_v;
+  
+  while (len>0) {
+    size_t     res = TEMP_FAILURE_RETRY(recv(fd, ptr, len, MSG_NOSIGNAL));
+    FatalErrnoError(res==(size_t)-1, "recv()");
+
+    if (res==0) return false;
+
+    ptr += res;
+    len -= res;
+  }
+
+  return true;
+}
diff --git a/util-vserver/ensc_wrappers/wrappers-mount.hc b/util-vserver/ensc_wrappers/wrappers-mount.hc
new file mode 100644 (file)
index 0000000..d4f3c54
--- /dev/null
@@ -0,0 +1,35 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef H_ENSC_IN_WRAPPERS_H
+#  error wrappers_handler.hc can not be used in this way
+#endif
+
+inline static WRAPPER_DECL void
+Eumount2(char const *path, int flag)
+{
+  FatalErrnoError(umount2(path,flag)==-1, "umount2()");
+}
+
+inline static WRAPPER_DECL void
+Emount(const char *source, const char *target,
+       const char *filesystemtype, unsigned long mountflags,
+       const void *data)
+{
+  FatalErrnoError(mount(source, target, filesystemtype,
+                       mountflags, data)==-1, "mount()");
+}
diff --git a/util-vserver/ensc_wrappers/wrappers-pivot.hc b/util-vserver/ensc_wrappers/wrappers-pivot.hc
new file mode 100644 (file)
index 0000000..dc4cd90
--- /dev/null
@@ -0,0 +1,27 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef H_ENSC_IN_WRAPPERS_H
+#  error wrappers_handler.hc can not be used in this way
+#endif
+
+inline static WRAPPER_DECL void
+Epivot_root(const char *new_root, const char *put_old)
+{
+  FatalErrnoError(pivot_root(new_root, put_old)==-1, "pivot_root()");
+}
diff --git a/util-vserver/ensc_wrappers/wrappers-resource.hc b/util-vserver/ensc_wrappers/wrappers-resource.hc
new file mode 100644 (file)
index 0000000..b7a4b57
--- /dev/null
@@ -0,0 +1,32 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef H_ENSC_IN_WRAPPERS_H
+#  error wrappers_handler.hc can not be used in this way
+#endif
+
+inline static WRAPPER_DECL void
+Egetrlimit(int resource, struct rlimit *rlim)
+{
+  FatalErrnoError(getrlimit(resource, rlim)==-1, "getrlimit()");
+}
+
+inline static WRAPPER_DECL void
+Esetrlimit(int resource, struct rlimit const *rlim)
+{
+  FatalErrnoError(setrlimit(resource, rlim)==-1, "setrlimit()");
+}
diff --git a/util-vserver/ensc_wrappers/wrappers-stdlib.hc b/util-vserver/ensc_wrappers/wrappers-stdlib.hc
new file mode 100644 (file)
index 0000000..4e0abb7
--- /dev/null
@@ -0,0 +1,41 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef H_ENSC_IN_WRAPPERS_H
+#  error wrappers_handler.hc can not be used in this way
+#endif
+
+inline static WRAPPER_DECL void *
+Emalloc(size_t size)
+{
+  register void               *res = malloc(size);
+  FatalErrnoError(res==0 && size!=0, "malloc()");
+  return res;
+}
+
+/*@unused@*/
+inline static WRAPPER_DECL /*@null@*//*@only@*/ void *
+Erealloc(/*@only@*//*@out@*//*@null@*/ void *ptr,
+         size_t new_size)
+    /*@ensures maxSet(result) == new_size@*/
+    /*@modifies *ptr@*/
+{
+  register void         *res = realloc(ptr, new_size);
+  FatalErrnoError(res==0 && new_size!=0, "realloc()");
+
+  return res;
+}
diff --git a/util-vserver/ensc_wrappers/wrappers-unistd.hc b/util-vserver/ensc_wrappers/wrappers-unistd.hc
new file mode 100644 (file)
index 0000000..2aa6ff7
--- /dev/null
@@ -0,0 +1,155 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef H_ENSC_IN_WRAPPERS_H
+#  error wrappers_handler.hc can not be used in this way
+#endif
+
+inline static WRAPPER_DECL void
+Eclose(int s)
+{
+  FatalErrnoError(close(s)==-1, "close()");
+}
+
+inline static WRAPPER_DECL void
+Echdir(char const path[])
+{
+  FatalErrnoError(chdir(path)==-1, "chdir()");
+}
+
+inline static WRAPPER_DECL void
+Efchdir(int fd)
+{
+  FatalErrnoError(fchdir(fd)==-1, "fchdir()");
+}
+
+inline static WRAPPER_DECL void
+Echroot(char const path[])
+{
+  FatalErrnoError(chroot(path)==-1, "chroot()");
+}
+
+inline static WRAPPER_DECL void
+Eexecv(char const *path, char *argv[])
+{
+  FatalErrnoError(execv(path,argv)==-1, "execv()");
+}
+
+inline static WRAPPER_DECL void
+Epipe(int filedes[2])
+{
+  FatalErrnoError(pipe(filedes)==-1, "pipe()");
+}
+
+inline static WRAPPER_DECL pid_t
+Efork()
+{
+  pid_t                res;
+  res = fork();
+  FatalErrnoError(res==-1, "fork()");
+  return res;
+}
+
+inline static WRAPPER_DECL size_t
+Eread(int fd, void *ptr, size_t len)
+{
+  size_t       res = read(fd, ptr, len);
+  FatalErrnoError((ssize_t)(res)==-1, "read()");
+
+  return res;
+}
+
+inline static WRAPPER_DECL size_t
+Ewrite(int fd, void const *ptr, size_t len)
+{
+  size_t       res = write(fd, ptr, len);
+  FatalErrnoError((ssize_t)(res)==-1, "write()");
+
+  return res;
+}
+
+inline static WRAPPER_DECL void
+Ereadlink(const char *path, char *buf, size_t bufsiz)
+{
+  FatalErrnoError(readlink(path, buf, bufsiz)==-1, "readlink()");
+}
+
+inline static WRAPPER_DECL void
+Esymlink(const char *oldpath, const char *newpath)
+{
+  FatalErrnoError(symlink(oldpath, newpath)==-1, "symlink()");
+}
+
+inline static WRAPPER_DECL void
+Eunlink(char const *pathname)
+{
+  FatalErrnoError(unlink(pathname)==-1, "unlink()");
+}
+
+inline static void
+Esetuid(uid_t uid)
+{
+  FatalErrnoError(setuid(uid)==-1, "setuid()");
+}
+
+inline static void
+Esetgid(gid_t gid)
+{
+  FatalErrnoError(setgid(gid)==-1, "setgid()");
+}
+
+#if defined(_GRP_H) && (defined(__USE_BSD) || defined(__dietlibc__))
+inline static void
+Esetgroups(size_t size, const gid_t *list)
+{
+  FatalErrnoError(setgroups(size, list)==-1, "setgroups()");
+}
+#endif
+
+inline static WRAPPER_DECL int
+Edup2(int oldfd, int newfd)
+{
+  register int          res = dup2(oldfd, newfd);
+  FatalErrnoError(res==-1, "dup2()");
+
+  return res;
+}
+
+inline static WRAPPER_DECL pid_t
+Esetsid()
+{
+  register pid_t const  res = setsid();
+  FatalErrnoError(res==-1, "setsid()");
+
+  return res;
+}
+
+inline static WRAPPER_DECL int
+Emkstemp(char *template)
+{
+  int          res = mkstemp(template);
+  FatalErrnoError(res==-1, "mkstemp()");
+  return res;
+}
+
+inline static WRAPPER_DECL off_t
+Elseek(int fildes, off_t offset, int whence)
+{
+  off_t         res = lseek(fildes, offset, whence);
+  FatalErrnoError(res==(off_t)-1, "lseek()");
+  return res;
+}
diff --git a/util-vserver/ensc_wrappers/wrappers-vserver.hc b/util-vserver/ensc_wrappers/wrappers-vserver.hc
new file mode 100644 (file)
index 0000000..280a114
--- /dev/null
@@ -0,0 +1,39 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef H_ENSC_IN_WRAPPERS_H
+#  error wrappers_handler.hc can not be used in this way
+#endif
+
+#include <vserver.h>
+
+inline static UNUSED xid_t
+Evc_new_s_context(xid_t ctx, unsigned int remove_cap, unsigned int flags)
+{
+  register xid_t       res = vc_new_s_context(ctx,remove_cap,flags);
+  FatalErrnoError(res==VC_NOCTX, "vc_new_s_context()");
+  return res;
+}
+
+inline static UNUSED xid_t
+Evc_get_task_xid(pid_t pid)
+{
+  register xid_t       res = vc_get_task_xid(pid);
+  FatalErrnoError(res==VC_NOCTX, "vc_get_task_xid()");
+  return res;
+}
diff --git a/util-vserver/ensc_wrappers/wrappers-wait.hc b/util-vserver/ensc_wrappers/wrappers-wait.hc
new file mode 100644 (file)
index 0000000..4391a24
--- /dev/null
@@ -0,0 +1,31 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef H_ENSC_IN_WRAPPERS_H
+#  error wrappers_handler.hc can not be used in this way
+#endif
+
+inline static WRAPPER_DECL pid_t
+Ewait4(pid_t pid, int *status, int options,
+       struct rusage *rusage)
+{
+  pid_t                res;
+  res = wait4(pid, status, options, rusage);
+  FatalErrnoError(res==-1, "wait4()");
+  return res;
+}
diff --git a/util-vserver/ensc_wrappers/wrappers.h b/util-vserver/ensc_wrappers/wrappers.h
new file mode 100644 (file)
index 0000000..d662051
--- /dev/null
@@ -0,0 +1,78 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2003,2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef H_UTIL_VSERVER_SRC_WRAPPERS_H
+#define H_UTIL_VSERVER_SRC_WRAPPERS_H
+
+#define WRAPPER_DECL           UNUSED ALWAYSINLINE
+#define H_ENSC_IN_WRAPPERS_H   1
+
+#include "wrappers_handler.hc"
+
+#ifdef ENSC_WRAPPERS_UNISTD
+#  include "wrappers-unistd.hc"
+#endif
+
+#ifdef ENSC_WRAPPERS_FCNTL
+#  include "wrappers-fcntl.hc"
+#endif
+
+#ifdef ENSC_WRAPPERS_MOUNT
+#  include "wrappers-mount.hc"
+#endif
+
+#ifdef ENSC_WRAPPERS_RESOURCE
+#  include "wrappers-resource.hc"
+#endif
+
+#ifdef ENSC_WRAPPERS_IOCTL
+#  include "wrappers-ioctl.hc"
+#endif
+
+#ifdef ENSC_WRAPPERS_WAIT
+#  include "wrappers-wait.hc"
+#endif
+
+#ifdef ENSC_WRAPPERS_VSERVER
+#  include "wrappers-vserver.hc"
+#endif
+
+#ifdef ENSC_WRAPPERS_IO
+#  include "wrappers-io.hc"
+#endif
+
+#ifdef ENSC_WRAPPERS_IOSOCK
+#  include "wrappers-iosock.hc"
+#endif
+
+#ifdef ENSC_WRAPPERS_DIRENT
+#  include "wrappers-dirent.hc"
+#endif
+
+#ifdef ENSC_WRAPPERS_CLONE
+#  include "wrappers-clone.hc"
+#endif
+
+#ifdef ENSC_WRAPPERS_STDLIB
+#  include "wrappers-stdlib.hc"
+#endif
+
+#undef H_ENSC_IN_WRAPPERS_H
+#undef WRAPPER_DECL
+
+#endif //  H_UTIL_VSERVER_SRC_WRAPPERS_H
diff --git a/util-vserver/ensc_wrappers/wrappers_handler.hc b/util-vserver/ensc_wrappers/wrappers_handler.hc
new file mode 100644 (file)
index 0000000..7f7ca44
--- /dev/null
@@ -0,0 +1,36 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//  
+// This program 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 General Public License for more details.
+//  
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef H_ENSC_IN_WRAPPERS_H
+#  error wrappers_handler.hc can not be used in this way
+#endif
+
+#include <stdlib.h>
+#include <stdbool.h>
+#include <stdio.h>
+
+static UNUSED void 
+FatalErrnoError(bool condition, char const msg[]) /*@*/
+{
+  extern int   wrapper_exit_code;
+
+  if (!condition)       return;
+  perror(msg);
+
+  exit(wrapper_exit_code);
+}