1 /* Simple backwards compat code to exec old version */
3 #ifndef CONFIG_NO_BACKWARDS_COMPAT
12 #include <asm/unistd.h>
14 extern long create_module(const char *, size_t);
18 static void exec_old(const char *progname
, char *argv
[])
23 char pathname
[strlen(argv
[0])+1];
24 char oldname
[strlen(progname
) + strlen(argv
[0]) + sizeof(".old")];
26 memset(pathname
, 0, strlen(argv
[0])+1);
27 sep
= strrchr(argv
[0], '/');
29 memcpy(pathname
, argv
[0], sep
- argv
[0]+1);
30 sprintf(oldname
, "%s%s.old", pathname
, progname
);
32 /* Recursion detection: we need an env var since we can't
33 change argv[0] (as older modutils uses it to determine
34 behavior). We *can* recurse in the case of old-style
35 pre-install etc. commands, so make sure pid is exactly the
38 snprintf(ascii_pid
, sizeof(ascii_pid
), "%lu", (unsigned long)pid
);
39 if (strcmp(getenv("MODULE_RECURSE") ?: "", ascii_pid
) == 0) {
40 fprintf(stderr
, "WARNING: %s: I am not the old version!\n",
44 setenv("MODULE_RECURSE", ascii_pid
, 1);
46 execvp(oldname
, argv
);
48 "Kernel requires old %s, but couldn't run %s: %s\n",
49 progname
, oldname
, strerror(errno
));
53 static void try_old_version(const char *progname
, char *argv
[])
56 if (create_module(NULL
, 0) >= 0 /* Uh oh, what have I just done? */
58 exec_old(progname
, argv
);
60 #else /* CONFIG_NO_BACKWARDS_COMPAT */
61 static inline void try_old_version(const char *progname
, char *argv
[])
64 #endif /* !CONFIG_NO_BACKWARDS_COMPAT */