Merge "init/builtins.cpp: Switch to finit_module"

am: b3cf2e0

* commit 'b3cf2e0f3d3b9ba328921cd1c9c3839ea70a1ab1':
  init/builtins.cpp: Switch to finit_module

Change-Id: I23d53bb70856016968c58a417b9299be572392a7
This commit is contained in:
Nick Kralevich 2016-03-30 02:14:09 +00:00 committed by android-build-merger
commit 699b115be3

View file

@ -27,6 +27,7 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -61,19 +62,20 @@
#define UNMOUNT_CHECK_MS 5000 #define UNMOUNT_CHECK_MS 5000
#define UNMOUNT_CHECK_TIMES 10 #define UNMOUNT_CHECK_TIMES 10
// System call provided by bionic but not in any header file.
extern "C" int init_module(void *, unsigned long, const char *);
static const int kTerminateServiceDelayMicroSeconds = 50000; static const int kTerminateServiceDelayMicroSeconds = 50000;
static int insmod(const char *filename, const char *options) { static int insmod(const char *filename, const char *options) {
std::string module; int fd = open(filename, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (!read_file(filename, &module)) { if (fd == -1) {
ERROR("insmod: open(\"%s\") failed: %s", filename, strerror(errno));
return -1; return -1;
} }
int rc = syscall(__NR_finit_module, fd, options, 0);
// TODO: use finit_module for >= 3.8 kernels. if (rc == -1) {
return init_module(&module[0], module.size(), options); ERROR("finit_module for \"%s\" failed: %s", filename, strerror(errno));
}
close(fd);
return rc;
} }
static int __ifupdown(const char *interface, int up) { static int __ifupdown(const char *interface, int up) {