46 struct mntent *fs;
47
48 fp = setmntent(filename, "r"); /* только для чтения */
49 if (fp == NULL) {
50 fprintf(stderr, "%s: %s: could not open: %s\n",
51 myname, filename, strerror(errno));
52 exit(1);
53 }
54
55 while ((fs = getmntent(fp)) != NULL)
56 do_statvfs(fs);
57
58 endmntent(fp);
59 }
Строки 1–59 в сущности те же самые, как и для ch08-mounted.c. main() обрабатывает командную стоку, a process() просматривает в цикле каждую смонтированную файловую систему. do_statvfs() осуществляет действительную работу, выводя для каждой интересующей файловой системы struct statvfs.
61 /* do_statvfs --- Использовать statvfs и вывести сведения */
62
63 void do_statvfs(const struct mntent *fs)
64 {
65 struct statvfs vfs;
66
67 if (fs->mnt_fsname[0] != '/') /* пропустить ненастоящие файловые системы */
68 return;
69
70 if (statvfs(fs->mnt_dir, &vfs) != 0) {
71 fprintf(stderr, "%s: %s: statvfs failed: %s\n",
72 myname, fs->mnt_dir, strerror(errno));
73 errors++;
74 return;
75 }