/* * Get a list of all mntids in mnt_ns_id. If it returns MAXMOUNTS * mounts, then go again until we get everything.
*/ do {
count = listmount(LSMT_ROOT, mnt_ns_id, last_mnt_id, mntid, MAXMOUNTS, 0); if (count < 0 || count > MAXMOUNTS) {
errno = count < 0 ? errno : count;
perror("listmount"); return 1;
}
/* Walk the returned mntids and print info about each */ for (i = 0; i < count; ++i) { int ret = dump_mountinfo(mntid[i], mnt_ns_id);
if (ret != 0) return ret;
} /* Set up last_mnt_id to pick up where we left off */
last_mnt_id = mntid[count - 1];
} while (count == MAXMOUNTS); return 0;
}
staticvoid usage(constchar * const prog)
{
printf("Usage:\n");
printf("%s [-e] [-p pid] [-r] [-h]\n", prog);
printf(" -e: extended format\n");
printf(" -h: print usage message\n");
printf(" -p: get mount namespace from given pid\n");
printf(" -r: recursively print all mounts in all child namespaces\n");
}
/* Get a pidfd for pid */
pidfd = syscall(__NR_pidfd_open, pid, 0); if (pidfd < 0) {
perror("pidfd_open"); return 1;
}
/* Get the mnt namespace for pidfd */
mntns = ioctl(pidfd, PIDFD_GET_MNT_NAMESPACE, NULL); if (mntns < 0) {
perror("PIDFD_GET_MNT_NAMESPACE"); return 1;
}
close(pidfd);
/* get info about mntns. In particular, the mnt_ns_id */
ret = ioctl(mntns, NS_MNT_GET_INFO, &mni); if (ret < 0) {
perror("NS_MNT_GET_INFO"); return 1;
}
do { int ret;
ret = dump_mounts(mni.mnt_ns_id); if (ret) return ret;
if (!recursive) break;
/* get the next mntns (and overwrite the old mount ns info) */
ret = ioctl(mntns, NS_MNT_GET_NEXT, &mni);
close(mntns);
mntns = ret;
} while (mntns >= 0);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.