<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
À<×e†
  ã               @   sr   d dl mZ ddlZddlZddlZd dlT ddlZddl	j
Z
ddlT ddlmZ ejjƒ ZG dd„ dejƒZdS )é   )Úbaseé    N)Ú*)Úcommandsc                   sf   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Ze	j
fdd„Zdd„ Zdd„ Zdd„ Z‡  ZS )ÚSysfsPlugina|  
	`sysfs`::
	
	Sets various `sysfs` settings specified by the plug-in options.
	+
	The syntax is `_name_=_value_`, where
	`_name_` is the `sysfs` path to use and `_value_` is
	the value to write. The `sysfs` path supports the shell-style
	wildcard characters (see `man 7 glob` for additional detail).
	+
	Use this plugin in case you need to change some settings that are
	not covered by other plug-ins. Prefer specific plug-ins if they
	cover the required settings.
	+
	.Ignore corrected errors and associated scans that cause latency spikes
	====
	----
	[sysfs]
	/sys/devices/system/machinecheck/machinecheck*/ignore_ce=1
	----
	====
	c                s$   t t| ƒj||Ž d| _tƒ | _d S )NT)Úsuperr   Ú__init__Z_has_dynamic_optionsr   Ú_cmd)ÚselfÚargsÚkwargs)Ú	__class__© ú"/usr/lib/python3.6/plugin_sysfs.pyr   '   s    zSysfsPlugin.__init__c             C   s4   d|_ d|_tdd„ t|jjƒ ƒD ƒƒ|_i |_d S )NFTc             S   s$   g | ]}t jj|d  ƒ|d f‘qS )r   r   )ÚosÚpathÚnormpath)Ú.0Ú	key_valuer   r   r   ú
<listcomp>0   s    z.SysfsPlugin._instance_init.<locals>.<listcomp>)Z_has_dynamic_tuningZ_has_static_tuningÚdictÚlistZoptionsÚitemsÚ_sysfsÚ_sysfs_original)r
   Úinstancer   r   r   Ú_instance_init,   s    zSysfsPlugin._instance_initc             C   s   d S )Nr   )r
   r   r   r   r   Ú_instance_cleanup3   s    zSysfsPlugin._instance_cleanupc             C   sv   xpt |jjƒ ƒD ]^\}}| jj|ƒ}xHtj|ƒD ]:}| j|ƒr\| j|ƒ|j	|< | j
||ƒ q0tjd| ƒ q0W qW d S )Nz)rejecting write to '%s' (not inside /sys))r   r   r   Ú
_variablesÚexpandÚglobÚiglobÚ_check_sysfsÚ_read_sysfsr   Ú_write_sysfsÚlogÚerror)r
   r   ÚkeyÚvalueÚvÚfr   r   r   Ú_instance_apply_static6   s    
z"SysfsPlugin._instance_apply_staticc       
      C   sp   d}xft |jjƒ ƒD ]T\}}| jj|ƒ}x>tj|ƒD ]0}| j|ƒr4| j|ƒ}	| j	|||	|ƒdkr4d}q4W qW |S )NTF)
r   r   r   r   r   r    r!   r"   r#   Z_verify_value)
r
   r   Zignore_missingZdevicesÚretr'   r(   r)   r*   Zcurr_valr   r   r   Ú_instance_verify_static@   s    

z#SysfsPlugin._instance_verify_staticc             C   s,   x&t |jjƒ ƒD ]\}}| j||ƒ qW d S )N)r   r   r   r$   )r
   r   Zrollbackr'   r(   r   r   r   Ú_instance_unapply_staticK   s    z$SysfsPlugin._instance_unapply_staticc             C   s   t jd|ƒS )Nz^/sys/.*)ÚreÚmatch)r
   Ú
sysfs_filer   r   r   r"   O   s    zSysfsPlugin._check_sysfsc             C   s2   | j j|ƒjƒ }t|ƒdkr*| j j|dƒS d S d S )Nr   F)r	   Z	read_fileÚstripÚlenZget_active_option)r
   r1   Údatar   r   r   r#   R   s    zSysfsPlugin._read_sysfsc             C   s   | j j||ƒS )N)r	   Zwrite_to_file)r
   r1   r(   r   r   r   r$   Y   s    zSysfsPlugin._write_sysfs)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r+   r-   ÚconstsZROLLBACK_SOFTr.   r"   r#   r$   Ú__classcell__r   r   )r   r   r      s   
r   )Ú r   r    r/   Zos.pathr   Z
decoratorsZ
tuned.logsZtunedZtuned.constsr9   Ú
subprocessZtuned.utils.commandsr   ZlogsÚgetr%   ZPluginr   r   r   r   r   Ú<module>   s   

