* we consider the device not mounted. */
mounted = false;
} else {
+ char *sanitized = sstrdup(path);
+ if (strlen(sanitized) > 1 && sanitized[strlen(sanitized) - 1] == '/')
+ sanitized[strlen(sanitized) - 1] = '\0';
FILE *mntentfile = setmntent("/etc/mtab", "r");
struct mntent *m;
while ((m = getmntent(mntentfile)) != NULL) {
- if (strcmp(m->mnt_dir, path) == 0) {
+ if (strcmp(m->mnt_dir, sanitized) == 0) {
mounted = true;
break;
}
}
endmntent(mntentfile);
+ free(sanitized);
}
#endif