7 find a list of drive names on this machine
8 return the number of drives found, return the names as
9 a string array in **names
11 static int find_drive_names(char ***names)
17 dir = opendir("/proc/ide");
25 while ((de = (readdir(dir)))) {
26 /* /proc/ide contains more than just a list of drives. We need
27 to select only those bits that match 'hd*' */
28 if (strncmp(de->d_name, "hd", 2) == 0) {
30 (*names) = realloc(*names, sizeof(char *) * (count+2));
32 fprintf(stderr,"Out of memory in find_drive_names\n");
35 asprintf(&(*names)[count],"/dev/%s", de->d_name);
41 (*names)[count] = NULL;
53 n = find_drive_names(&names);
56 printf("%s\n", names[i]);