f = fopen("/etc/mtab", "r");
if (f) {
- while (fgets(tmp, sizeof(MTAB_LINE), f)) {
- dev = strtok(tmp, " ");
- mntpt = strtok(NULL, " ");
- df_path(mntpt);
+ while (fgets(tmp, MTAB_LINE, f)) {
+ dev = strtok(tmp, " ");
+ mntpt = strtok(NULL, " ");
+ if (mntpt)
+ df_path(mntpt);
}
fclose(f);
- }else{
+ } else {
fprintf(stderr, "df: cannot open /etc/mtab: %s\n", strerror(errno));
}
}
continue;
if (fstat.st_rdev != devno)
continue;
+ closedir(dp);
return namebuf;
}
}
+ closedir(dp);
sprintf(namebuf, "%d", devno);
return namebuf;