svn commit: r256985 - projects/vps/usr.sbin/vpsctl
Will Andrews
will at FreeBSD.org
Wed Oct 23 16:58:05 UTC 2013
Author: will
Date: Wed Oct 23 16:58:04 2013
New Revision: 256985
URL: http://svnweb.freebsd.org/changeset/base/256985
Log:
Sync with svn.7he.at/vps/trunk r187.
r187 | klaus | 2013-07-09 06:44:15 -0600 (Tue, 09 Jul 2013) | 3 lines
Wrote a shellscript instead of mkprivlist.c for cross-compiling.
Submitted by: Klaus P. Ohrhallinger <k at 7he.at>
Added:
projects/vps/usr.sbin/vpsctl/mkprivlist.sh
Modified:
projects/vps/usr.sbin/vpsctl/Makefile
Modified: projects/vps/usr.sbin/vpsctl/Makefile
==============================================================================
--- projects/vps/usr.sbin/vpsctl/Makefile Wed Oct 23 16:56:44 2013 (r256984)
+++ projects/vps/usr.sbin/vpsctl/Makefile Wed Oct 23 16:58:04 2013 (r256985)
@@ -16,11 +16,17 @@ clean:
vpsctl.8.ps vps.conf.5.ps vps.4.ps vps.9.ps mount_vpsfs.8.ps \
vpsctl.8.pdf vps.conf.5.pdf vps.4.pdf vps.9.pdf mount_vpsfs.8.pdf
+#mkprivlist:
+# cc -Wall -g -o ./mkprivlist ${.CURDIR}/mkprivlist.c
+#
+#priv_ston.c priv_ntos.c: mkprivlist
+# ./mkprivlist ${.CURDIR}/../../sys/sys/priv.h
+
mkprivlist:
- cc -Wall -g -o ./mkprivlist ${.CURDIR}/mkprivlist.c
+ true
priv_ston.c priv_ntos.c: mkprivlist
- ./mkprivlist ${.CURDIR}/../../sys/sys/priv.h
+ ./mkprivlist.sh ${.CURDIR}/../../sys/sys/priv.h
vpsctl: priv_ston.c priv_ntos.c
cc -Wall -g -I../../sys -I/usr/include -o vpsctl \
Added: projects/vps/usr.sbin/vpsctl/mkprivlist.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/vps/usr.sbin/vpsctl/mkprivlist.sh Wed Oct 23 16:58:04 2013 (r256985)
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+set -e
+
+if [ "_$1" = "_" ]
+then
+ echo "requires argument: path/to/sys/priv.h"
+ exit 1
+fi
+
+SYS_PRIV_H=$1
+
+ECHO="printf"
+
+FILE_NTOS=priv_ntos.c
+FILE_STON=priv_ston.c
+
+rm -f $FILE_NTOS
+rm -f $FILE_STON
+
+${ECHO} "/* AUTOMATICALLY GENERATED FILE */\n" >> $FILE_NTOS
+${ECHO} "\n" >> $FILE_NTOS
+${ECHO} "#include <sys/priv.h>\n" >> $FILE_NTOS
+${ECHO} "\n" >> $FILE_NTOS
+${ECHO} "const char * priv_ntos(int priv);\n" >> $FILE_NTOS
+${ECHO} "\n" >> $FILE_NTOS
+${ECHO} "const char *\n" >> $FILE_NTOS
+${ECHO} "priv_ntos(int priv)\n" >> $FILE_NTOS
+${ECHO} "{\n" >> $FILE_NTOS
+${ECHO} "\n" >> $FILE_NTOS
+${ECHO} " switch (priv) {\n" >> $FILE_NTOS
+
+${ECHO} "/* AUTOMATICALLY GENERATED FILE */\n" >> $FILE_STON
+${ECHO} "\n" >> $FILE_STON
+${ECHO} "#include <sys/priv.h>\n" >> $FILE_STON
+${ECHO} "#include <string.h>\n" >> $FILE_STON
+${ECHO} "\n" >> $FILE_STON
+${ECHO} "int priv_ston(const char *str);\n" >> $FILE_STON
+${ECHO} "\n" >> $FILE_STON
+${ECHO} "int\n" >> $FILE_STON
+${ECHO} "priv_ston(const char *str)\n" >> $FILE_STON
+${ECHO} "{\n" >> $FILE_STON
+${ECHO} "\n" >> $FILE_STON
+
+
+###
+
+PRIVLIST=$( \
+ grep -E '^#define\W+PRIV_.*\W+[0-9]+' ${SYS_PRIV_H} | \
+ sed 's/\/\*.*//' | \
+ sed -r 's/[ ]+/;/g')
+
+for PRIV in $PRIVLIST
+do
+ NAME=$(echo ${PRIV} | sed -r 's/[^;]*;([^;]*);([^;]*).*/\1/')
+ NUMBER=$(echo ${PRIV} | sed -r 's/[^;]*;([^;]*);([^;]*).*/\2/')
+
+ #echo "NAME=[${NAME}] NUMBER=[${NUMBER}]"
+
+ printf " case %s: return (\"%s\");\n" ${NUMBER} ${NAME} \
+ >> $FILE_NTOS
+
+ printf " if (strcmp(str, \"%s\") == 0) return (%s);\n" \
+ ${NAME} ${NUMBER} >> $FILE_STON
+done
+
+###
+
+${ECHO} " default: return (\"unknown\");\n" >> $FILE_NTOS
+${ECHO} " }\n" >> $FILE_NTOS
+${ECHO} "}\n" >> $FILE_NTOS
+
+${ECHO} " return (0);\n" >> $FILE_STON
+${ECHO} "}\n" >> $FILE_STON
+
+exit 0
+
+# EOF
More information about the svn-src-projects
mailing list