summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
3292bd2)
The use of basename() is a detail about how we find the minor number, so
let's keep it private.
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
-static int misc_get_minor(char *node)
+static int misc_get_minor(char *device)
{
FILE *fp;
int minor;
char name[64];
{
FILE *fp;
int minor;
char name[64];
+ char *path;
+ char *node;
fp = fopen("/proc/misc", "r");
if (fp == NULL) {
fp = fopen("/proc/misc", "r");
if (fp == NULL) {
+ path = strdup(device);
+ node = basename(path);
+
while (fscanf(fp, "%d %64s", &minor, name) == 2) {
if (strcmp(name, node) == 0) {
while (fscanf(fp, "%d %64s", &minor, name) == 2) {
if (strcmp(name, node) == 0) {
fclose(fp);
return minor;
}
}
fclose(fp);
return minor;
}
}
static int mkmisc(char *device)
{
static int mkmisc(char *device)
{
- char *path;
- char *node;
int major;
int minor;
dev_t dev;
int major;
int minor;
dev_t dev;
- 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);
if (minor < 0) {
fprintf(stderr, "Cannot get misc minor for %s\n", device);
if (verbose)
printf("Creating device: %s, major: %d, minor: %d\n",
if (verbose)
printf("Creating device: %s, major: %d, minor: %d\n",