return -1;
}
-static int misc_get_minor(char *node)
+static int misc_get_minor(char *device)
{
FILE *fp;
int minor;
char name[64];
+ char *path;
+ char *node;
fp = fopen("/proc/misc", "r");
if (fp == NULL) {
return -1;
}
+ path = strdup(device);
+ node = basename(path);
+
while (fscanf(fp, "%d %64s", &minor, name) == 2) {
if (strcmp(name, node) == 0) {
+ free(path);
fclose(fp);
return minor;
}
}
+ free(path);
fclose(fp);
return -1;
static int mkmisc(char *device)
{
- char *path;
- char *node;
int major;
int minor;
dev_t dev;
return major;
}
- path = strdup(device);
- node = basename(path);
-
- minor = misc_get_minor(node);
+ minor = misc_get_minor(device);
if (minor < 0) {
fprintf(stderr, "Cannot get misc minor for %s\n", device);
- free(path);
return minor;
}
- free(path);
if (verbose)
printf("Creating device: %s, major: %d, minor: %d\n",