public static function checkIfFileSystemIsNFS()
{
$sessionsPath = Session::getSessionsDirectory();
// this command will display details for the filesystem that holds the $sessionsPath
// path, but only if its type is NFS. if not NFS, df will return one or less lines
// and the return code 1. if NFS, it will return 0 and at least 2 lines of text.
$command = "df -T -t nfs \"{$sessionsPath}\" 2>&1";
if (function_exists('exec')) {
// use exec
$output = $returnCode = null;
@exec($command, $output, $returnCode);
// check if filesystem is NFS
if ($returnCode == 0 && count($output) > 1) {
return true;
}
} elseif (function_exists('shell_exec')) {
// use shell_exec
$output = @shell_exec($command);
if ($output) {
$commandFailed = false !== strpos($output, "no file systems processed");
$output = explode("\n", trim($output));
if (!$commandFailed && count($output) > 1) {
// check if filesystem is NFS
return true;
}
}
}
return false;
// not NFS, or we can't run a program to find out
}