return get_mount_entries("/etc/fstab", &is_user_mountable);
}
-int is_in_array(char **names, char *devname)
+int is_in_array(char **array, char *str)
{
int i;
- if(!names || !devname)
+ if(!array || !str)
return 0;
- for(i=0; names[i]; ++i)
- if(!strcmp(devname, names[i]))
+ for(i=0; array[i]; ++i)
+ if(!strcmp(str, array[i]))
return 1;
return 0;
}
-void free_device_names(char **names)
+void free_string_array(char **array)
{
int i;
- if(!names)
+ if(!array)
return;
- for(i=0; names[i]; ++i)
- free(names[i]);
- free(names);
+ for(i=0; array[i]; ++i)
+ free(array[i]);
+ free(array);
}
int is_removable(char *devpath)
char linkbuf[256];
strcpy(ptr, "/subsystem");
len = readlink(fnbuf, linkbuf, sizeof(linkbuf)-1);
- *ptr = 0;
if(len!=-1)
{
- int i;
linkbuf[len] = 0;
for(; (len>0 && linkbuf[len-1]!='/'); --len) ;
if(verbosity>=2)
+ {
+ *ptr = 0;
printf(" Subsystem of %s is %s\n", fnbuf, linkbuf+len);
- for(i=0; buses[i]; ++i)
- if(strcmp(linkbuf+len, buses[i])==0)
- return 1;
+ }
+ if(is_in_array(buses, linkbuf+len))
+ return 1;
}
}
}
free(nodes);
- free_device_names(mounted);
+ free_string_array(mounted);
if(devices)
{