From: notaz Date: Sat, 31 Jul 2010 15:45:37 +0000 (+0300) Subject: only remove module if we inserted it X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c682a397f4a09a7e9e29fee12ec5101a4284d452;p=warm.git only remove module if we inserted it something may need to keep it loaded, like it is in ginge project. --- diff --git a/warm.c b/warm.c index 5dad50d..c79c63e 100644 --- a/warm.c +++ b/warm.c @@ -50,6 +50,7 @@ extern long delete_module(const char *, unsigned int); static int warm_fd = -1; static int kernel_version; +static int module_inserted; static void sys_cacheflush(void *start, void *end) { @@ -145,6 +146,8 @@ int warm_init(void) fprintf(stderr, PFX "manual insmod also failed: %d\n", ret); } } + if (ret == 0) + module_inserted = 1; warm_fd = open("/proc/warm", O_RDWR); if (warm_fd >= 0) @@ -166,20 +169,22 @@ void warm_finish(void) close(warm_fd); warm_fd = -1; - if (kernel_version < 0x26) { - struct utsname unm; - memset(&unm, 0, sizeof(unm)); - uname(&unm); - snprintf(name, sizeof(name), "warm_%s", unm.release); - } - else - strcpy(name, "warm"); - - snprintf(cmd, sizeof(cmd), "/sbin/rmmod %s", name); - ret = system(cmd); - if (ret != 0) { - fprintf(stderr, PFX "system/rmmod failed: %d %d\n", ret, errno); - manual_rmmod(name); + if (module_inserted) { + if (kernel_version < 0x26) { + struct utsname unm; + memset(&unm, 0, sizeof(unm)); + uname(&unm); + snprintf(name, sizeof(name), "warm_%s", unm.release); + } + else + strcpy(name, "warm"); + + snprintf(cmd, sizeof(cmd), "/sbin/rmmod %s", name); + ret = system(cmd); + if (ret != 0) { + fprintf(stderr, PFX "system/rmmod failed: %d %d\n", ret, errno); + manual_rmmod(name); + } } }