summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Heim <phreak@gentoo.org>2005-09-28 11:20:01 +0000
committerChristian Heim <phreak@gentoo.org>2005-09-28 11:20:01 +0000
commit2d2518706a218e9e06eeb9a7d64c3600034ef683 (patch)
tree5de761f9853677d0991b9f3ead88a5808f0f1e0b /src
parentUpdating ChangeLog (diff)
downloadbaselayout-vserver-2d2518706a218e9e06eeb9a7d64c3600034ef683.tar.gz
baselayout-vserver-2d2518706a218e9e06eeb9a7d64c3600034ef683.tar.bz2
baselayout-vserver-2d2518706a218e9e06eeb9a7d64c3600034ef683.zip
Adding kir's mount-utility; should save us from util-linux and it's dependencies
svn path=/baselayout-vserver/trunk/; revision=46
Diffstat (limited to 'src')
-rw-r--r--src/utils/Makefile39
-rw-r--r--src/utils/mount.c24
2 files changed, 63 insertions, 0 deletions
diff --git a/src/utils/Makefile b/src/utils/Makefile
new file mode 100644
index 0000000..84305c8
--- /dev/null
+++ b/src/utils/Makefile
@@ -0,0 +1,39 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header$
+
+CC = gcc
+LD = gcc
+
+CFLAGS = -Wall -O2
+DESTDIR =
+LIBDIR = lib
+
+BIN_TARGETS =
+SBIN_TARGETS = mount
+SYS_WHITELIST =
+
+TARGET = $(BIN_TARGETS) $(SBIN_TARGETS)
+
+OS = Linux
+ifeq ($(OS),Linux)
+LDFLAGS_RS = -ldl
+endif
+ifeq ($(OS),BSD)
+LDFLAGS_SSD = -lkvm
+endif
+
+override CFLAGS += -DLIBDIR=\"$(LIBDIR)\"
+
+all: $(TARGET)
+
+mount: mount.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDFLAGS_SSD)
+
+install: $(TARGET)
+ install -m 0755 -d $(DESTDIR)/sbin
+ install -m 0755 $(SBIN_TARGETS) $(DESTDIR)/sbin
+
+clean:
+ rm -f $(TARGET)
+ rm -f *.o *~
diff --git a/src/utils/mount.c b/src/utils/mount.c
new file mode 100644
index 0000000..a5ed3c8
--- /dev/null
+++ b/src/utils/mount.c
@@ -0,0 +1,24 @@
+/* Simple prog to mount /proc inside a VPS.
+ * Can be statically compiled with dietlibc:
+ * diet -Os gcc -static -s -o mount.proc mount.proc.c
+ *
+ * By Kir Kolyshkin <kir-at-sw-dot-ru>.
+ * Licensed under GNU GPL version 2.
+ */
+
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+/* Taken from /usr/src/linux/include/fs.h */
+#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
+#define MS_ACTIVE (1<<30)
+#define MS_NOUSER (1<<31)
+
+int main(void)
+{
+ mkdir("/proc", 0555);
+ /* "Normal" mount uses the same flags, so should we... */
+ return mount("proc", "/proc", "proc",
+ MS_POSIXACL|MS_ACTIVE|MS_NOUSER|0xec0000, 0);
+}