43 filesystems =
_free(filesystems);
48 #if defined(HAVE_MNTCTL)
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 defined(RPM_VENDOR_OPENPKG)
115 if (!(strcmp(fsn,
"/proc") == 0)) {
117 if (
Stat(fsn, &sb) < 0) {
130 filesystems[i].
dev = sb.st_dev;
131 filesystems[i].
rdonly = rdonly;
132 #if defined(RPM_VENDOR_OPENPKG)
137 vm = (
struct vmount *)((
char *)vm + vm->vmt_length);
165 # if GETMNTENT_ONE || GETMNTENT_TWO
175 # elif defined(HAVE_GETMNTINFO_R)
177 struct statfs * mounts = NULL;
178 int mntCount = 0, bufSize = 0, flags = MNT_NOWAIT;
181 getmntinfo_r(&mounts, flags, &mntCount, &bufSize);
182 # elif defined(HAVE_GETMNTINFO)
184 #if defined(__NetBSD__)
185 struct statvfs * mounts = NULL;
187 struct statfs * mounts = NULL;
189 int mntCount = 0, flags = MNT_NOWAIT;
193 mntCount = getmntinfo(&mounts, flags);
196 filesystems =
xcalloc((numAlloced + 1),
sizeof(*filesystems));
207 #if defined(MNTOPT_RO)
209 if (hasmntopt(itemptr, MNTOPT_RO) != NULL)
218 # elif defined(HAVE_GETMNTINFO_R)
220 if (nextMount == mntCount)
break;
221 mntdir = mounts[nextMount++].f_mntonname;
222 # elif defined(HAVE_GETMNTINFO)
224 if (nextMount == mntCount)
break;
225 mntdir = mounts[nextMount++].f_mntonname;
228 #if defined(RPM_VENDOR_OPENPKG)
229 if (strcmp(mntdir,
"/proc") == 0)
233 if (
Stat(mntdir, &sb) < 0) {
252 sizeof(*filesystems) * (numAlloced + 1));
268 # if GETMNTENT_ONE || GETMNTENT_TWO
270 # elif defined(HAVE_GETMNTINFO_R)
271 mounts =
_free(mounts);
280 fsnames[i] = filesystems[i].mntPoint;
295 if (listptr) *listptr =
fsnames;
312 const char * sourceDir;
314 dev_t lastDev = (dev_t)-1;
324 sourceDir =
rpmGetPath(
"%{_sourcedir}", NULL);
326 maxLen = strlen(sourceDir);
327 for (i = 0; i < numFiles; i++) {
328 len = strlen(fileList[i]);
329 if (maxLen < len) maxLen = len;
333 lastDir =
alloca(maxLen + 1);
334 dirName =
alloca(maxLen + 1);
338 for (i = 0; i < numFiles; i++) {
339 if (*fileList[i] ==
'/') {
340 strcpy(buf, fileList[i]);
341 chptr = buf + strlen(buf) - 1;
342 while (*chptr !=
'/') chptr--;
349 strcpy(buf, sourceDir);
352 if (strcmp(lastDir, buf)) {
353 strcpy(dirName, buf);
354 chptr = dirName + strlen(dirName) - 1;
355 while (
Stat(dirName, &sb) < 0) {
367 while (*chptr !=
'/') chptr--;
369 if (chptr == dirName)
375 if (lastDev != sb.st_dev) {
377 if (filesystems && filesystems[j].dev == sb.st_dev)
380 if (j == numFilesystems) {
382 _(
"file %s is on an unknown device\n"), buf);
391 strcpy(lastDir, buf);
392 usages[lastfs] += fssizes[i];
397 sourceDir =
_free(sourceDir);
399 if (rc == 0 && usagesPtr)
402 usages =
_free(usages);