VULN_CHECK_I913V6 GiddlmZddlmZddlddlmZmZddlZ ddl m Z ddl Z e jjZe ZGddej"Zy) N)base)*)PopenPIPE)commandsczeZdZdZedZdZedZdZdZ dZ dZ d Z d Z ed d dZy) MountsPlugina= Enables or disables barriers for mounts according to the value of the boolean option [option]`disable_barriers`. The option additionally allows the special value `force`, which disables barriers even on mountpoints with write back caches. NOTE: Only extended file systems (ext) are supported by this plug-in. ci}d}tgdttddj\}}|jDcgc]}|j c}D]}t |dkr|dd\}}} t |dkDr|dnd} t |dkDr|dnd} |dk(r| }M|dk(s|d vrW| | d k(r_|j | t| | d || d j|||_ ycc}w) z Gets the information about disks, partitions and mountpoints. Stores information about used filesystem and creates a list of all underlying devices (in case of LVM) for each mountpoint. N)lsblkz-rnozTYPE,RM,KNAME,FSTYPE,MOUNTPOINTT)stdoutstderr close_fdsuniversal_newlinesdisk1)partlvmz[SWAP])disks device_name filesystemr) rr communicate splitlinessplitlen setdefaultsetadd_mountpoint_topology) clsmountpoint_topology current_diskr rlinecolumns device_typedevice_removablerr mountpoints @/usr/lib/python3.12/site-packages/tuned/plugins/plugin_mounts.py_generate_mountpoint_topologyz*MountsPlugin._generate_mountpoint_topologys) ,'  +{}&&,2+<+<+>?+>4$**,+>?g 'lQ 07 -; +!'lQ. D:!'lQ. D:VL #O!C J(2 !!*kis.tuz"7+// ='@*1#+@sC:c|jd|_t|jj |_t|_y)NT)r+_devices_supportedrr!keys _free_devices_assigned_devicesselfs r* _init_deviceszMountsPlugin._init_devices:s<$$& $44499;<$5$c ddiS)Ndisable_barriersr1s r*_get_config_optionsz MountsPlugin._get_config_options@st r4c d|_d|_y)NFT)_has_dynamic_tuning_has_static_tuningr2instances r*_instance_initzMountsPlugin._instance_initFs!&( $(r4cy)Nr7r<s r*_instance_cleanupzMountsPlugin._instance_cleanupJsr4ctjd|z}|D]&}tj|jcSy)zV Get device cache type. This will work only for devices on SCSI kernel subsystem. z+/sys/block/%s/device/scsi_disk/*/cache_typeN)globcmd read_filestrip)r2devicesource_filenamessource_filenames r*_get_device_cache_typez#MountsPlugin._get_device_cache_typeMs>YYLvUV)o -- ( . . 00* r4c^|j|dD]}|j|dk(syy)zr Checks if the device has 'write back' cache. If the cache type cannot be determined, asume some other cache. rz write backTF)r!rI)r2r)rFs r*_mountpoint_has_writeback_cachez,MountsPlugin._mountpoint_has_writeback_cacheVs9))*5g>f !!&)\9 ? r4cHtd5}|D]-}|j}|dddk7r|d|k(s(|d}n  dddy dddjd}|D]/}|jd\}} } |d k(s |d k(r| d k(ry |d k(s/y y #1swYOxYw)zP Checks if a given mountpoint is mounted with barriers enabled or disabled. z /proc/mountsr/rrN,= nobarrierbarrier0FT)openr partition) r2r) mounts_filer%r& option_listoptionsoptionnamesepvalues r*_mountpoint_has_barriersz%MountsPlugin._mountpoint_has_barriers_s N{tjjlGqz!} qzZ1:[      c "'f((-D#u kdi/ESL    /s*B BB!c@d|dd|zg}tj|y)z Remounts partition. z/usr/bin/mountz-oz remount,%sN)rCexecute)r2rTrWremount_commands r*_remount_partitionzMountsPlugin._remount_partition|s#&y$ w8NO/++or4r6T) per_devicec|jd|}t|jdk(}|xs|j|}|r|syd} |j|dj dsd} n|s|j |rd} np|j|} | d} nZ| d k(r,|r'tjtj|zy d } n)|r'tjtj|zy | tjd |d | dy|jj| tjd|z|j!|dy|ry|jj#|} | ytjd|z|j!|d|jj%|y)Nr6) command_namerforcerextzfilesystem not supportedzdevice uses write back cachezunknown current settingFTzbarriers already disabledznot disabling barriers on 'z' ()zdisabling barriers on '%s'z barrier=0zenabling barriers on '%s'z barrier=1) _storage_keystrlower _option_boolr! startswithrKr\loginfoconstsSTR_VERIFY_PROFILE_OKerrorSTR_VERIFY_PROFILE_FAIL_storagerr`getunset) r2startr[r)verifyignore_missingr= storage_keyrd reject_reasonoriginal_values r*_disable_barrierszMountsPlugin._disable_barrierss!!%"+ e*    '%  +4$$U+%  =  # #J / = H H O.M d:::F2M22:>N.] 5  hhv++j89 1m YYv-- :; HHj- PQ ==[.188 (: 56:{3  MM%%k2> 88 '* 45:{3=={# r4N)__name__ __module__ __qualname____doc__ classmethodr+r3r8r>r@rIrKr\r`command_customr{r7r4r*r r so!1!1F!  %:#5161r4r ) tuned.constsrnr decorators subprocessrr tuned.logstunedtuned.utils.commandsrrBlogsrsrlrCPluginr r7r4r*rsC!)  jjnnji4;;ir4