-
- if (pid == 0) { /* Child. */
- execl ("/insmod.static", "insmod.static", filename, NULL);
- perror ("insmod: execl");
- _exit (EXIT_FAILURE);
+ struct stat st;
+ if (fstat (fd, &st) == -1) {
+ perror ("insmod: fstat");
+ exit (EXIT_FAILURE);
+ }
+ char buf[st.st_size];
+ long offset = 0;
+ do {
+ long rc = read (fd, buf + offset, st.st_size - offset);
+ if (rc == -1) {
+ perror ("insmod: read");
+ exit (EXIT_FAILURE);
+ }
+ offset += rc;
+ } while (offset < st.st_size);
+ close (fd);
+
+ if (init_module (buf, st.st_size, "") != 0) {
+ fprintf (stderr, "insmod: init_module: %s: %s\n", filename, moderror (errno));
+ /* However ignore the error because this can just happen because
+ * of a missing device.
+ */