r955: Update debian package rules... builds now
[samba.git] / source4 / lib / module.c
index ffd6a38c77098dd071835203a88e3a89aa01aae1..f03e19d92482c09fc94c8985fdc2fc1fd428a906 100644 (file)
@@ -2,7 +2,7 @@
    Unix SMB/CIFS implementation.
    module loading system
 
-   Copyright (C) Jelmer Vernooij 2002-2003
+   Copyright (C) Jelmer Vernooij 2002-2004
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -125,9 +125,19 @@ struct subsystem {
 
 static struct subsystem *subsystems = NULL;
 
-void register_subsystem(const char *name, register_backend_function callback) 
+NTSTATUS register_subsystem(const char *name, register_backend_function callback) 
 {
        struct subsystem *s;
+       struct subsystem *t = subsystems;
+
+       while(t) {
+               if(!strcmp(name, t->name)) {
+                       /* its already registered! */
+                       DEBUG(0,("Subsystem '%s' already registered\n", name));
+                       return NT_STATUS_OBJECT_NAME_COLLISION;
+               }
+               t = t->next;
+       }
 
        s = smb_xmalloc(sizeof(struct subsystem));
 
@@ -136,6 +146,8 @@ void register_subsystem(const char *name, register_backend_function callback)
        s->prev = s->next = NULL;
 
        DLIST_ADD(subsystems, s);
+
+       return NT_STATUS_OK;
 }
 
 NTSTATUS register_backend(const char *subsystem, void *args)