int get_mdp_major(void) { static int mdp_major = -1; FILE *fl; char *w; int have_block = 0; int have_devices = 0; int last_num = -1; if (mdp_major != -1) return mdp_major; fl = fopen("/proc/devices", "r"); if (!fl) return -1; while ((w = conf_word(fl, 1))) { if (have_block && strcmp(w, "devices:")==0) have_devices = 1; have_block = (strcmp(w, "Block")==0); if (isdigit(w[0])) last_num = atoi(w); if (have_devices && strcmp(w, "mdp")==0) mdp_major = last_num; free(w); } fclose(fl); return mdp_major; }
char *conf_line(FILE *file) { char *w; char *list; w = conf_word(file, 1); if (w == NULL) return NULL; list = dl_strdup(w); free(w); dl_init(list); while ((w = conf_word(file,0))){ char *w2 = dl_strdup(w); free(w); dl_add(list, w2); } /* printf("got a line\n");*/ return list; }