Skip to content
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

Merged
merged 1 commit into from
Sep 10, 2018
Merged

is_hdd: update for linux only #4293

merged 1 commit into from
Sep 10, 2018

Conversation

p8p
Copy link
Contributor

@p8p p8p commented Aug 22, 2018

First two commits have been discussed in #4278

path = "C:\\";
EXPECT_TRUE(tools::is_hdd(path.c_str()));
}
TEST(is_hdd, win_os_ssd)
Copy link
Contributor Author

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.

@@ -79,6 +79,7 @@ target_link_libraries(cncrypto
epee
${Boost_SYSTEM_LIBRARY}
PRIVATE
sodium
Copy link
Contributor Author

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)
Copy link
Contributor Author

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

@@ -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);
Copy link
Contributor Author

@p8p p8p Aug 22, 2018

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)
Copy link
Contributor Author

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.

@p8p p8p changed the title is_hdd: update for linux and windows is_hdd: update for linux only Aug 25, 2018
@p8p p8p closed this Aug 25, 2018
@p8p p8p reopened this Aug 25, 2018
@moneromooo-monero
Copy link
Collaborator

Why change this ? Is it somehow better ?

@moneromooo-monero
Copy link
Collaborator

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 ?

@p8p
Copy link
Contributor Author

p8p commented Aug 26, 2018

@moneromooo-monero,

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.
But it fails with GetLastError() == 31 on windows 10 and windows 8.1 installed on virtualbox emulator.
I don't have any other implementation for windows.

@moneromooo-monero
Copy link
Collaborator

moneromooo-monero commented Aug 27, 2018

Isn't this better than nothing then ?
Or is window 7 really old ?

@p8p
Copy link
Contributor Author

p8p commented Aug 27, 2018

I don't want submit that implementation.
Windows 7 is still supported.

Products Released Lifecycle Start Date Mainstream Support End Date Extended Support End Date Service Pack Support End Date Notes
Windows 7 Service Pack 1 2/22/2011 1/13/2015 1/14/2020 -- --

https://support.microsoft.com/en-us/lifecycle/search/?c2=14019

}
std::string attr_path = prefix + "/queue/rotational";
std::ifstream f(attr_path, std::ios_base::in);
if(not f.is_open())
Copy link
Contributor

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?

Copy link
Collaborator

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.

bool success = qi::parse(
p.cbegin(),
p.cend(),
(qi::lit("\\Device\\") >> qi::raw[*(qi::char_ - "\\")]),
Copy link
Contributor

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.

Copy link
Collaborator

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 ?

Copy link
Contributor

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.

}
if(q.value())
{
return true;
Copy link
Contributor

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.

std::ifstream f(attr_path, std::ios_base::in);
if(not f.is_open())
{
attr_path = prefix + "/../queue/rotational";
Copy link
Contributor

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.

#include <boost/optional.hpp>
namespace tools
{
#if defined(__GLIBC__)
Copy link
Contributor

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.

@vtnerd
Copy link
Contributor

vtnerd commented Sep 3, 2018

Sorry, I had unpublished comments apparently. You can just ignore them now ...

@luigi1111 luigi1111 merged commit 9d65399 into monero-project:master Sep 10, 2018
luigi1111 added a commit that referenced this pull request Sep 10, 2018
9d65399 is_hdd update (p8p)
@p8p p8p deleted the is_hdd branch September 11, 2018 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants