Rely on POSIX.1-2008 realpath() semantics in mountpoint resolution

Now that we can, etc.  No functional changes.
This commit is contained in:
Panu Matilainen 2022-05-06 11:08:54 +03:00
parent b1bc46e56a
commit dcf46f9e60
1 changed files with 4 additions and 6 deletions

View File

@ -67,16 +67,13 @@ struct diskspaceInfo_s {
static char *getMntPoint(const char *dirName, dev_t dev)
{
char mntPoint[PATH_MAX];
char *resolved_path = realpath(dirName, mntPoint);
char *mntPoint = realpath(dirName, NULL);
char *end = NULL;
struct stat sb;
char *res = NULL;
if (!resolved_path) {
strncpy(mntPoint, dirName, PATH_MAX);
mntPoint[PATH_MAX-1] = '\0';
}
if (!mntPoint)
mntPoint = xstrdup(dirName);
while (end != mntPoint) {
end = strrchr(mntPoint, '/');
@ -101,6 +98,7 @@ static char *getMntPoint(const char *dirName, dev_t dev)
break;
}
}
free(mntPoint);
return res;
}