From f7fa9d5e34401070f57e50469498d2993de5585c Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 17 Dec 2022 17:06:14 +0300 Subject: [PATCH] Fix SCSI device cache type check --- src/disk_tool_utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/disk_tool_utils.cpp b/src/disk_tool_utils.cpp index c1a7731d..d9c7bff7 100644 --- a/src/disk_tool_utils.cpp +++ b/src/disk_tool_utils.cpp @@ -145,10 +145,10 @@ int disable_cache(std::string dev) closedir(dir); // Check cache_type scsi_disk += "/cache_type"; - std::string cache_type = read_file(scsi_disk); + std::string cache_type = trim(read_file(scsi_disk)); if (cache_type == "") return 1; - if (cache_type == "write back") + if (cache_type != "write through") { int fd = open(scsi_disk.c_str(), O_WRONLY); if (fd < 0 || write_blocking(fd, (void*)"write through", strlen("write through")) != strlen("write through"))