Esempio n. 1
0
function get_udev_info($device, $udev = NULL, $reload)
{
    global $paths;
    $state = is_file($paths['state']) ? @parse_ini_file($paths['state'], true) : array();
    if ($udev) {
        $state[$device] = $udev;
        save_ini_file($paths['state'], $state);
        return $udev;
    } else {
        if (array_key_exists($device, $state) && !$reload) {
            unassigned_log("Using udev cache for '{$device}'.", "DEBUG");
            return $state[$device];
        } else {
            $state[$device] = parse_ini_string(shell_exec("/sbin/udevadm info --query=property --path \$(/sbin/udevadm info -q path -n {$device} 2>/dev/null) 2>/dev/null"));
            save_ini_file($paths['state'], $state);
            unassigned_log("Not using udev cache for '{$device}'.", "DEBUG");
            return $state[$device];
        }
    }
}
function get_udev_info($device, $udev=NULL) {
  global $paths;
  $state = is_file($paths['state']) ? @parse_ini_file($paths['state'], true) : array();
  if ($udev) {
    $state[$device] = $udev;
    save_ini_file($paths['state'], $state);
    return $udev;
  } else if (array_key_exists($device, $state)) {
    // debug("Using udev cache for '$device'.");
    return $state[$device];
  } else {
    $state[$device] = parse_ini_string(shell_exec("udevadm info --query=property --path $(udevadm info -q path -n $device ) 2>/dev/null"));
    save_ini_file($paths['state'], $state);
    // debug("Not using udev cache for '$device'.");
    return $state[$device];
  }
}