aboutsummaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
Diffstat (limited to 'modutils')
-rw-r--r--modutils/modprobe.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index dcab493f1..94f7b22c2 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -37,9 +37,9 @@ struct dep_t { /* one-way list of dependency rules */
37 37
38struct mod_list_t { /* two-way list of modules to process */ 38struct mod_list_t { /* two-way list of modules to process */
39 /* a module description */ 39 /* a module description */
40 char * m_name; 40 const char * m_name;
41 char * m_path; 41 char * m_path;
42 struct mod_opt_t * m_options; 42 struct mod_opt_t * m_options;
43 43
44 struct mod_list_t * m_prev; 44 struct mod_list_t * m_prev;
45 struct mod_list_t * m_next; 45 struct mod_list_t * m_next;
@@ -577,7 +577,7 @@ done:
577 return ret; 577 return ret;
578} 578}
579 579
580static int mod_process(struct mod_list_t *list, int do_insert) 580static int mod_process(const struct mod_list_t *list, int do_insert)
581{ 581{
582 int rc = 0; 582 int rc = 0;
583 char **argv = NULL; 583 char **argv = NULL;
@@ -603,16 +603,16 @@ static int mod_process(struct mod_list_t *list, int do_insert)
603 argv = xmalloc(6 * sizeof(char*)); 603 argv = xmalloc(6 * sizeof(char*));
604 if (do_insert) { 604 if (do_insert) {
605 if (already_loaded(list->m_name) != 1) { 605 if (already_loaded(list->m_name) != 1) {
606 argv[argc++] = "insmod"; 606 argv[argc++] = (char*)"insmod";
607 if (ENABLE_FEATURE_2_4_MODULES) { 607 if (ENABLE_FEATURE_2_4_MODULES) {
608 if (do_syslog) 608 if (do_syslog)
609 argv[argc++] = "-s"; 609 argv[argc++] = (char*)"-s";
610 if (autoclean) 610 if (autoclean)
611 argv[argc++] = "-k"; 611 argv[argc++] = (char*)"-k";
612 if (quiet) 612 if (quiet)
613 argv[argc++] = "-q"; 613 argv[argc++] = (char*)"-q";
614 else if (verbose) /* verbose and quiet are mutually exclusive */ 614 else if (verbose) /* verbose and quiet are mutually exclusive */
615 argv[argc++] = "-v"; 615 argv[argc++] = (char*)"-v";
616 } 616 }
617 argv[argc++] = list->m_path; 617 argv[argc++] = list->m_path;
618 if (ENABLE_FEATURE_CLEAN_UP) 618 if (ENABLE_FEATURE_CLEAN_UP)
@@ -629,10 +629,10 @@ static int mod_process(struct mod_list_t *list, int do_insert)
629 } else { 629 } else {
630 /* modutils uses short name for removal */ 630 /* modutils uses short name for removal */
631 if (already_loaded(list->m_name) != 0) { 631 if (already_loaded(list->m_name) != 0) {
632 argv[argc++] = "rmmod"; 632 argv[argc++] = (char*)"rmmod";
633 if (do_syslog) 633 if (do_syslog)
634 argv[argc++] = "-s"; 634 argv[argc++] = (char*)"-s";
635 argv[argc++] = list->m_name; 635 argv[argc++] = (char*)list->m_name;
636 if (ENABLE_FEATURE_CLEAN_UP) 636 if (ENABLE_FEATURE_CLEAN_UP)
637 argc_malloc = argc; 637 argc_malloc = argc;
638 } 638 }
@@ -810,13 +810,14 @@ static void check_dep(char *mod, struct mod_list_t **head, struct mod_list_t **t
810 810
811static int mod_insert(char *mod, int argc, char **argv) 811static int mod_insert(char *mod, int argc, char **argv)
812{ 812{
813 struct mod_list_t *tail = 0; 813 struct mod_list_t *tail = NULL;
814 struct mod_list_t *head = 0; 814 struct mod_list_t *head = NULL;
815 int rc; 815 int rc;
816 816
817 // get dep list for module mod 817 // get dep list for module mod
818 check_dep(mod, &head, &tail); 818 check_dep(mod, &head, &tail);
819 819
820 rc = 1;
820 if (head && tail) { 821 if (head && tail) {
821 if (argc) { 822 if (argc) {
822 int i; 823 int i;
@@ -826,7 +827,8 @@ static int mod_insert(char *mod, int argc, char **argv)
826 } 827 }
827 828
828 // process tail ---> head 829 // process tail ---> head
829 if ((rc = mod_process(tail, 1)) != 0) { 830 rc = mod_process(tail, 1);
831 if (rc) {
830 /* 832 /*
831 * In case of using udev, multiple instances of modprobe can be 833 * In case of using udev, multiple instances of modprobe can be
832 * spawned to load the same module (think of two same usb devices, 834 * spawned to load the same module (think of two same usb devices,
@@ -837,31 +839,26 @@ static int mod_insert(char *mod, int argc, char **argv)
837 rc = 0; 839 rc = 0;
838 } 840 }
839 } 841 }
840 else
841 rc = 1;
842
843 return rc; 842 return rc;
844} 843}
845 844
846static int mod_remove(char *mod) 845static int mod_remove(char *mod)
847{ 846{
848 int rc; 847 int rc;
849 static struct mod_list_t rm_a_dummy = { "-a", NULL, NULL, NULL, NULL }; 848 static const struct mod_list_t rm_a_dummy = { "-a", NULL, NULL, NULL, NULL };
850 849
851 struct mod_list_t *head = 0; 850 struct mod_list_t *head = NULL;
852 struct mod_list_t *tail = 0; 851 struct mod_list_t *tail = NULL;
853 852
854 if (mod) 853 if (mod)
855 check_dep(mod, &head, &tail); 854 check_dep(mod, &head, &tail);
856 else // autoclean 855 else // autoclean
857 head = tail = &rm_a_dummy; 856 head = tail = (struct mod_list_t*) &rm_a_dummy;
858 857
858 rc = 1;
859 if (head && tail) 859 if (head && tail)
860 rc = mod_process(head, 0); // process head ---> tail 860 rc = mod_process(head, 0); // process head ---> tail
861 else
862 rc = 1;
863 return rc; 861 return rc;
864
865} 862}
866 863
867int modprobe_main(int argc, char** argv) 864int modprobe_main(int argc, char** argv)