-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
is_hdd: update for linux only #4293
Conversation
tests/unit_tests/is_hdd.cpp
Outdated
path = "C:\\"; | ||
EXPECT_TRUE(tools::is_hdd(path.c_str())); | ||
} | ||
TEST(is_hdd, win_os_ssd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to emulate ssd.
This test isn't general and requires environment setup.
It'll be deleted.
src/crypto/CMakeLists.txt
Outdated
@@ -79,6 +79,7 @@ target_link_libraries(cncrypto | |||
epee | |||
${Boost_SYSTEM_LIBRARY} | |||
PRIVATE | |||
sodium |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required for successful build of master branch.
It's not required for is_hdd() implementation itself.
CMakeLists.txt
Outdated
@@ -566,11 +568,13 @@ else() | |||
add_c_flag_if_supported(-Wformat-security C_SECURITY_FLAGS) | |||
add_cxx_flag_if_supported(-Wformat-security CXX_SECURITY_FLAGS) | |||
|
|||
if(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required for successful build of master branch.
It's not required for is_hdd() implementation itself.
It's mentioned here #4290
tests/unit_tests/ringdb.cpp
Outdated
@@ -47,7 +47,7 @@ static crypto::chacha_key generate_chacha_key() | |||
{ | |||
crypto::chacha_key chacha_key; | |||
uint64_t password = crypto::rand<uint64_t>(); | |||
crypto::generate_chacha_key(std::string((const char*)&password, sizeof(password)), chacha_key); | |||
crypto::generate_chacha_key(std::string((const char*)&password, sizeof(password)), chacha_key, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required for successful build of tests of master branch.
It's not required for is_hdd() implementation itself.
It's mentioned here #4272
CMakeLists.txt
Outdated
@@ -814,7 +818,7 @@ endif() | |||
include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) | |||
if(MINGW) | |||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wa,-mbig-obj") | |||
set(EXTRA_LIBRARIES mswsock;ws2_32;iphlpapi) | |||
set(EXTRA_LIBRARIES mswsock;ws2_32;iphlpapi;bcrypt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required for successful build of tests of master branch.
It's not required for is_hdd() implementation itself.
Changed the default random_generator implementation to use
boost::uuid::random_generator is being used only in "tests/functional_tests/transactions_flow_test.cpp" but included in few other places.
Why change this ? Is it somehow better ? |
Welll, the code's substantially smaller anyway, and it works for me, so I guess that's a good enough reason. Why did you take out the Windows part ? |
STORAGE_PROPERTY_QUERY q{
.PropertyId = StorageDeviceSeekPenaltyProperty,
.QueryType = PropertyStandardQuery
};
DEVICE_SEEK_PENALTY_DESCRIPTOR r;
DWORD r_size = 0;
BOOL success = DeviceIoControl(
h,
IOCTL_STORAGE_QUERY_PROPERTY,
&q,
sizeof(q),
&r,
sizeof(r),
&r_size,
nullptr
); Windows part works on windows 7 installed on virtualbox emulator. |
Isn't this better than nothing then ? |
I don't want submit that implementation.
https://support.microsoft.com/en-us/lifecycle/search/?c2=14019 |
src/common/is_hdd.cpp
Outdated
} | ||
std::string attr_path = prefix + "/queue/rotational"; | ||
std::ifstream f(attr_path, std::ios_base::in); | ||
if(not f.is_open()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you start flipping everything to the alternative tokens? I guess a new cpp file means you can slightly dictact new style policies, but this is certainly an interesting choice ... it doesn't bother me all that much (it is still readable) -> @moneromooo-monero what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels odd, but since it's now standard and not confusing, I have no problem with it.
src/common/is_hdd.cpp
Outdated
bool success = qi::parse( | ||
p.cbegin(), | ||
p.cend(), | ||
(qi::lit("\\Device\\") >> qi::raw[*(qi::char_ - "\\")]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch on the missing qi::raw
calling from my last review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see that code in the patch now, and don't recall seeing it before. Is this commenting on an old rev ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I meant to only click the approve button and didn't realize I had unpublished comments.
src/common/is_hdd.cpp
Outdated
} | ||
if(q.value()) | ||
{ | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a comment about whether this is correct behavior in my last review. In particular, if a path is backed by a RAID-0 setup, you want every check to pass. This would be "correct" for RAID-1 or higher, but I think the conservative approach is better since this is merely a warning system and not a forcibly-do-this check.
src/common/is_hdd.cpp
Outdated
std::ifstream f(attr_path, std::ios_base::in); | ||
if(not f.is_open()) | ||
{ | ||
attr_path = prefix + "/../queue/rotational"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this for older kernels? This would be looking for a file at path /sys/dev/block/queue/rotational
. I see no such file on my local systems.
src/common/is_hdd.cpp
Outdated
#include <boost/optional.hpp> | ||
namespace tools | ||
{ | ||
#if defined(__GLIBC__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This /sys
check seems specific to Linux, and not Posix or GNU. Is it possible to have glibc (GNU) outside of Linux? I feel like it is possible, so a check for a Linux macro might be more appropriate.
Sorry, I had unpublished comments apparently. You can just ignore them now ... |
First two commits have been discussed in #4278