43 filesystems =
_free(filesystems);
52 #include <sys/mntctl.h>
53 #include <sys/vmount.h>
59 int mntctl(
int command,
int size,
char *buffer);
78 num = mntctl(MCTL_QUERY,
sizeof(size), (
char *) &size);
93 num = mntctl(MCTL_QUERY, size, buf);
105 for (vm = buf, i = 0; i < num; i++) {
107 fsnameLength = vm->vmt_data[VMT_STUB].vmt_size;
108 fsn =
xmalloc(fsnameLength + 1);
109 strncpy(fsn, (
char *)vm + vm->vmt_data[VMT_STUB].vmt_off,
114 if (stat(filesystems[i].mntPoint, &sb)) {
122 filesystems[i].
dev = sb.st_dev;
123 filesystems[i].
rdonly = rdonly;
126 vm = (
struct vmount *)((
char *)vm + vm->vmt_length);
154 # if GETMNTENT_ONE || GETMNTENT_TWO
164 # elif HAVE_GETMNTINFO_R
166 struct statfs * mounts = NULL;
167 int mntCount = 0, bufSize = 0, flags = MNT_NOWAIT;
170 getmntinfo_r(&mounts, flags, &mntCount, &bufSize);
171 # elif HAVE_GETMNTINFO
173 struct statfs * mounts = NULL;
174 int mntCount = 0, flags = MNT_NOWAIT;
178 mntCount = getmntinfo(&mounts, flags);
181 filesystems =
xcalloc((numAlloced + 1),
sizeof(*filesystems));
194 #if defined(MNTOPT_RO)
196 if (hasmntopt(itemptr, MNTOPT_RO) != NULL)
205 # elif HAVE_GETMNTINFO_R
207 if (nextMount == mntCount)
break;
208 mntdir = mounts[nextMount++].f_mntonname;
209 # elif HAVE_GETMNTINFO
211 if (nextMount == mntCount)
break;
212 mntdir = mounts[nextMount++].f_mntonname;
215 if (stat(mntdir, &sb)) {
233 sizeof(*filesystems) * (numAlloced + 1));
249 # if GETMNTENT_ONE || GETMNTENT_TWO
251 # elif HAVE_GETMNTINFO_R
252 mounts =
_free(mounts);
262 fsnames[i] = filesystems[i].mntPoint;
279 if (listptr) *listptr =
fsnames;
287 uint_64 ** usagesPtr,
int flags)
295 const char * sourceDir;
306 sourceDir =
rpmGetPath(
"%{_sourcedir}", NULL);
308 maxLen = strlen(sourceDir);
310 for (i = 0; i < numFiles; i++) {
311 len = strlen(fileList[i]);
312 if (maxLen < len) maxLen = len;
318 lastDir =
alloca(maxLen + 1);
319 dirName =
alloca(maxLen + 1);
323 for (i = 0; i < numFiles; i++) {
324 if (*fileList[i] ==
'/') {
325 strcpy(buf, fileList[i]);
326 chptr = buf + strlen(buf) - 1;
327 while (*chptr !=
'/') chptr--;
334 strcpy(buf, sourceDir);
337 if (strcmp(lastDir, buf)) {
338 strcpy(dirName, buf);
339 chptr = dirName + strlen(dirName) - 1;
340 while (stat(dirName, &sb)) {
341 if (
errno != ENOENT) {
344 sourceDir =
_free(sourceDir);
345 usages =
_free(usages);
350 while (*chptr !=
'/') chptr--;
352 if (chptr == dirName)
358 if (lastDev != sb.st_dev) {
360 if (filesystems && filesystems[j].dev == sb.st_dev)
363 if (j == numFilesystems) {
365 _(
"file %s is on an unknown device\n"), buf);
366 sourceDir =
_free(sourceDir);
367 usages =
_free(usages);
376 strcpy(lastDir, buf);
377 usages[lastfs] += fssizes[i];
381 sourceDir =
_free(sourceDir);
388 usages =
_free(usages);