]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/install+setup/install/ide.c
Die IDE/SCSI/SATA/USB-Erkennung erstellt nun schoene Ramdisks :D
[people/pmueller/ipfire-2.x.git] / src / install+setup / install / ide.c
CommitLineData
d6aaa55d
MT
1/* SmoothWall install program.
2 *
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
5 *
6 * (c) Lawrence Manning, 2001
7 * Contains some functs for scanning /proc for ide info on CDROMS and
8 * harddisks.
9 *
d6aaa55d
MT
10 */
11
12#include "install.h"
13
ee78a5ef
MT
14int initialize_ide() {
15 mysystem("/sbin/modprobe ide-generic");
16 mysystem("/sbin/modprobe generic");
17 mysystem("/sbin/modprobe ide-cd");
18 mysystem("/sbin/modprobe ide-disk");
19
20 return 0;
21}
22
d6aaa55d
MT
23/* checkide(). Scans the named drive letter and returns the IDE_??? type. */
24int checkide(char letter)
25{
26 FILE *f = NULL;
27 char filename[STRING_SIZE];
28 char buffer[STRING_SIZE];
29
30 sprintf(filename, "/proc/ide/hd%c/media", letter);
31
32 if (!(f = fopen(filename, "r")))
33 return IDE_EMPTY;
34
35 if (!(fgets(buffer, STRING_SIZE, f)))
36 {
37 printf("Couldn't read from %s\n", filename);
38 fclose(f);
39 return IDE_EMPTY;
40 }
41
42 fclose(f);
43
44 stripnl(buffer);
45
46 if (strcmp(buffer, "cdrom") == 0)
47 return IDE_CDROM;
48 else if (strcmp(buffer, "disk") == 0)
49 return IDE_HD;
50 else
51 return IDE_UNKNOWN;
52}
53
54/* findidetype(). Finds the first ide deveice of the given IDE_?? type. */
55char findidetype(int type)
56{
57 char letter;
58
59 for (letter = 'a'; letter <= 'z'; letter++)
60 {
61 if ((checkide(letter)) == type)
62 {
63 return letter;
64 }
65 }
66 return '\0';
67}
68