NOTE: shared_cpu_list file directory example, "/sys/devices/system/cpu/cpu0/cache/index0/shared_cpu_list".
(cache_level: CacheLevel)
| 174 | /// NOTE: shared_cpu_list file directory example, |
| 175 | /// "/sys/devices/system/cpu/cpu0/cache/index0/shared_cpu_list". |
| 176 | pub fn get_cache_shared(cache_level: CacheLevel) -> bool { |
| 177 | let mut file_directory: String = "/sys/devices/system/cpu/cpu0/cache".to_string(); |
| 178 | let mut result = true; |
| 179 | |
| 180 | match cache_level { |
| 181 | CacheLevel::L1D | CacheLevel::L1I => result = false, |
| 182 | CacheLevel::L2 => file_directory += "/index2/shared_cpu_list", |
| 183 | CacheLevel::L3 => file_directory += "/index3/shared_cpu_list", |
| 184 | } |
| 185 | |
| 186 | if !result { |
| 187 | return false; |
| 188 | } |
| 189 | |
| 190 | let file_path = Path::new(&file_directory); |
| 191 | if file_path.exists() { |
| 192 | let src = fs::read_to_string(file_directory).expect("File not exists or file corrupted."); |
| 193 | let src = src.trim(); |
| 194 | if src.is_empty() { |
| 195 | result = false; |
| 196 | } else { |
| 197 | result = src.contains('-') || src.contains(','); |
| 198 | } |
| 199 | } else { |
| 200 | result = false; |
| 201 | } |
| 202 | |
| 203 | result |
| 204 | } |
| 205 | |
| 206 | /// Creates the flattened device tree for this aarch64 VM. |
| 207 | #[allow(clippy::too_many_arguments)] |
no test coverage detected