Преглед на файлове

Kernel: Disallow loading a module twice without explicitly unloading it

This ensures that a module has the chance to run its cleanup functions
before it's taken out of service.
Conrad Pankoff преди 5 години
родител
ревизия
9a8032b479
променени са 1 файла, в които са добавени 5 реда и са изтрити 0 реда
  1. 5 0
      Kernel/Process.cpp

+ 5 - 0
Kernel/Process.cpp

@@ -3699,6 +3699,11 @@ int Process::sys$module_load(const char* path, size_t path_length)
     if (!module->module_init)
         return -EINVAL;
 
+    if (g_modules->contains(module->name)) {
+        dbg() << "a module with the name " << module->name << " is already loaded; please unload it first";
+        return -EEXIST;
+    }
+
     module->module_init();
 
     auto name = module->name;