]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/install+setup/install/ide.c
Wir kehren zurueck zu Kudzu, da hwinfo noch mehr Aerger macht.
[people/teissler/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
14/* checkide(). Scans the named drive letter and returns the IDE_??? type. */
15int checkide(char letter)
16{
17 FILE *f = NULL;
18 char filename[STRING_SIZE];
19 char buffer[STRING_SIZE];
20
21 sprintf(filename, "/proc/ide/hd%c/media", letter);
22
23 if (!(f = fopen(filename, "r")))
24 return IDE_EMPTY;
25
26 if (!(fgets(buffer, STRING_SIZE, f)))
27 {
28 printf("Couldn't read from %s\n", filename);
29 fclose(f);
30 return IDE_EMPTY;
31 }
32
33 fclose(f);
34
35 stripnl(buffer);
36
37 if (strcmp(buffer, "cdrom") == 0)
38 return IDE_CDROM;
39 else if (strcmp(buffer, "disk") == 0)
40 return IDE_HD;
41 else
42 return IDE_UNKNOWN;
43}
44
45/* findidetype(). Finds the first ide deveice of the given IDE_?? type. */
46char findidetype(int type)
47{
48 char letter;
49
50 for (letter = 'a'; letter <= 'z'; letter++)
51 {
52 if ((checkide(letter)) == type)
53 {
54 return letter;
55 }
56 }
57 return '\0';
58}
59