[PATCH] add kexec_load() syscall

maximilian attems max@stro.at
Wed May 23 10:04:00 GMT 2012


Not sure how to add it properly, this is my first glibc touching,
hints howto do it better are appreciated.

Motivation is to axe the syscall maze in kexec-tools itself and
have this syscall supported in glibc.

---
 misc/Makefile                        |    2 +-
 sysdeps/unix/sysv/linux/kexec_load.c |   30 ++++++++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/sys/kexec.h  |   20 ++++++++++++++++++++
 3 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/unix/sysv/linux/kexec_load.c
 create mode 100644 sysdeps/unix/sysv/linux/sys/kexec.h

diff --git a/misc/Makefile b/misc/Makefile
index d1c0a02..4ce78d2 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -41,7 +41,7 @@ routines := brk sbrk sstk ioctl \
 	    getdtsz \
 	    gethostname sethostname getdomain setdomain \
 	    select pselect \
-	    acct chroot fsync sync fdatasync syncfs reboot \
+	    acct chroot fsync sync fdatasync syncfs reboot kexec_load \
 	    gethostid sethostid \
 	    revoke vhangup \
 	    swapon swapoff mktemp mkstemp mkstemp64 mkdtemp \
diff --git a/sysdeps/unix/sysv/linux/kexec_load.c b/sysdeps/unix/sysv/linux/kexec_load.c
new file mode 100644
index 0000000..8a38c03
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/kexec_load.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1996, 1997, 1998, 1999, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/kexec.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* Call kernel with additional two arguments the syscall requires.  */
+long
+kexec_load (void *entry, unsigned long nr_segments,
+		struct kexec_segment *segments, unsigned long flags)
+{
+  return INLINE_SYSCALL (kexec_load, entry, nr_segments, segments, flags);
+}
diff --git a/sysdeps/unix/sysv/linux/sys/kexec.h b/sysdeps/unix/sysv/linux/sys/kexec.h
new file mode 100644
index 0000000..2ccd643
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sys/kexec.h
@@ -0,0 +1,20 @@
+#ifndef _SYS_KEXEC_H
+#define _SYS_KEXEC_H   1
+
+
+struct kexec_segment {
+	const void *buf;
+	size_t bufsz;
+	const void *mem;
+	size_t memsz;
+};
+
+__BEGIN_DECLS
+
+static inline long kexec_load(void *__entry, unsigned long __nr_segments,
+		struct kexec_segment *__segments,
+		unsigned long __flags) __THROW;
+
+__END_DECLS
+
+#endif  /* _SYS_KEXEC_H */
-- 
1.7.10



More information about the Libc-alpha mailing list