]>
git.ipfire.org Git - people/ms/ipfire-2.x.git/blob - src/install+setup/install/usb.c
2 * This file is part of the IPCop Firewall.
4 * IPCop is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * IPCop is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with IPCop; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Copyright 2002: Mark Wormgoor <mark@wormgoor.com>
20 * $Id: usb.c,v 1.9.2.8 2005/12/10 00:18:23 franck78 Exp $
30 int initialize_usb() {
33 modprobe("usb-storage");
48 if (modprobe("ehci-hcd") == 0) ehcihcd
= 1;
49 if (modprobe("usb-ohci") == 0) usbohci
= 1;
50 if (modprobe("usb-uhci") == 0) usbuhci
= 1;
57 int write_usb_modules_conf() {
61 if (!(handle
= fopen("/harddisk/etc/modules.conf", "a")))
64 #if 0 /* we don't do this yet, because one of the drivers has a problem
67 fprintf(handle
,"alias usb-controller");
69 fprintf(handle
,"%d",index
);
70 fprintf(handle
," ehci-hcd\n");
76 fprintf(handle
,"alias usb-controller");
78 fprintf(handle
,"%d",index
);
79 fprintf(handle
," usb-ohci\n");
84 fprintf(handle
,"alias usb-controller");
86 fprintf(handle
,"%d",index
);
87 fprintf(handle
," usb-uhci\n");
96 Scans the named partitions and returns true if USB-removable.
97 a bug? in "cat /proc/partitions" with superfloppy scheme device
98 make them appearing always with four 'false' partitions:
99 sda and sda1 sda2 sda3 sda4.
100 No easy way to decide if /dev/sda1 exists or not.
102 int checkusb(char *partition
)
105 char filename
[STRING_SIZE
];
106 char buffer
[STRING_SIZE
];
107 char *pchar
= &buffer
[0];
108 if (!(f
= fopen("/proc/partitions", "r")))
111 short int major
= 0, minor
= 0;
112 while (fgets(buffer
, STRING_SIZE
, f
)) {
113 /* look for partition*/
114 if (strstr (buffer
, partition
)) {
115 major
= atoi (buffer
);
116 if (major
!= 8) break ; /* not scsi */
118 while (*pchar
!= '8') pchar
++;
119 minor
= atoi (++pchar
);
124 if (major
!= 8) return 0; /* nothing found */
126 //now check for usb-storage-MINOR
127 minor
>>= 4; // get index from minor
128 sprintf (filename
, "/proc/scsi/usb-storage-%d/%d", minor
,minor
);
130 if (!(f
= fopen(filename
, "r")))
133 while (fgets(buffer
, STRING_SIZE
, f
)) {
134 if (strstr(buffer
,"usb-storage")) count
++;
135 if (strstr(buffer
,"SCSI")) count
++;
136 if (strstr(buffer
,"Attached: Yes")) count
++;
140 return (count
==3 ? 1 : 0);