// Parse line and return a newly allocated string containing the mount point if // the line contains a matching filesystem and the mount point is accessible by // the current user. // sscanf, using %m, will return malloced memory. Need raw ::free, not os::free.
if (sscanf(line, "%*u %*u %*u:%*u %*s %ms %*[^-]- %ms", &line_mountpoint, &line_filesystem) != 2 ||
strcmp(line_filesystem, filesystem) != 0 ||
access(line_mountpoint, R_OK|W_OK|X_OK) != 0) { // Not a matching or accessible filesystem
ALLOW_C_FUNCTION(::free, ::free(line_mountpoint);)
line_mountpoint = NULL;
}
char* ZMountPoint::find_preferred_mountpoint(const char* filesystem,
ZArray<char*>* mountpoints, const char** preferred_mountpoints) const { // Find preferred mount point
ZArrayIterator<char*> iter1(mountpoints);
for (char* mountpoint; iter1.next(&mountpoint);) {
for (const char** preferred = preferred_mountpoints; *preferred != NULL; preferred++) {
if (!strcmp(mountpoint, *preferred)) { // Preferred mount point found return os::strdup(mountpoint, mtGC);
}
}
}
// Preferred mount point not found
log_error_p(gc)("More than one %s filesystem found:", filesystem);
ZArrayIterator<char*> iter2(mountpoints);
for (char* mountpoint; iter2.next(&mountpoint);) {
log_error_p(gc)(" %s", mountpoint);
}
if (mountpoints.length() == 0) { // No mount point found
log_error_p(gc)("Failed to find an accessible %s filesystem", filesystem);
} else if (mountpoints.length() == 1) { // One mount point found
path = os::strdup(mountpoints.at(0), mtGC);
} else { // More than one mount point found
path = find_preferred_mountpoint(filesystem, &mountpoints, preferred_mountpoints);
}
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.