SCSI Dump Usability Enhancements & Cleanup#1026
Conversation
akuker
commented
Dec 8, 2022
- Fix for weird corner case - when executing the arm binary on an x86_64 host, PiSCSI will throw an exception while trying to initialize the GPIO bus. This isn't a valid use case, so just handling the exception and aborting execution. (TIL - Ubuntu 22 on x86_64 will still execute an ARM binary. It seems to spin up Qemu in the background to try to run the executable)
- Rename RasDump to ScsiDump
- Add total time and transfer rate to the output of scsidump
- Create a .properties file when backing up a drive. This can be used to more closely emulate the original drive.
- Added examples to man page + some cleanup/clarification
…/RASCSI into feature_scsidump_usability
|
|
||
| int run(const vector<char *> &); | ||
|
|
||
| struct inquiry_info_struct { |
There was a problem hiding this comment.
Does this struct have to be public instead of being private?
There was a problem hiding this comment.
Its used in the test procedure. Suggestions for a better way to make it accessible to the test procedure?
There was a problem hiding this comment.
In this case (tests also using it) there might be no alternative. In general an implementation should not have weak points just because of unit tests. If datat structures are/should be private from the implementation perspective (like in this case) tests should be coded in a way that they do not need to access these private structures. This is best practices as far as I know, and it makes sense. Otherwise you end up with a lot of data being public just because of the tests, which is defeating the idea of encapsulation.
There was a problem hiding this comment.
Just one anecdotal note on this, because I just remembered: In a job interview I had a long time ago, how to deal with a similar issue was a topic. It was essentially a private constant string that was part of the implementation. The string content was also required in a unit test. The preferred solution was to have a copy of the string (duplication) in the test, so that the original string could stay private.
In this particular case using a copy has also another benefit: If you use the same public string for your test, if somebody changes the string declaration your code may be wrong, but the test still passes. You will miss the code modification. With a copy for the test it would have been revealed that something in the code had been changed,.
There was a problem hiding this comment.
In this case its a struct, not data. Another solution would be to move it out of the class definition completely.
There was a problem hiding this comment.
I don't object keeping the code as it is if there is no convenient alternative.
|
|
||
| // TODO Replace old-fashinoned C I/O by C++ streams I/O. | ||
| // This also avoids potential issues with data type sizes and there is no need for c_str(). | ||
| void CreateTempFileWithData(const string& filename, vector<uint8_t> &data) |
There was a problem hiding this comment.
I would appreciate if we were not reverting C++-style conventions for pointers and references back to C-style. We have C++ style almost everywhere now, and it's not just Bjarne Stroustrup who says:
A typical C programmer writes int *p; and explains it *p is what is the int emphasizing syntax, and may point to the C (and C++) declaration grammar to argue for the correctness of the style. Indeed, the * binds to the name p in the grammar.
A typical C++ programmer writes int* p; and explains it p is a pointer to an int emphasizing type. Indeed the type of p is int*. I clearly prefer that emphasis and see it as important for using the more advanced parts of C++ well.
but also IBM, cpppreference.com, ...
There was a problem hiding this comment.
Are you saying that you prefer this:
void CreateTempFileWithData(const string& filename, vector<uint8_t>& data)
over this?
void CreateTempFileWithData(const string &filename, vector<uint8_t> &data)
Currently, its the clang formatting configuration that is doing this, so I'll need to investigate. But, I wanted to double check I'm understanding the comment first.
There was a problem hiding this comment.
Yes, that's what I (and others like Stroustrup) are saying for pointers (*) and references (&) in C++. (If you google for it you will find several hits.) When using "&" as address operator it's different, but for "&" denoting a reference it should directly follow the type.
There was a problem hiding this comment.
Sounds good. I'll work on updating that configuration.
There was a problem hiding this comment.
Should now be updated. See changes in .clang-format. This change will be applicable to pointers and references
cpp/test/test_shared.cpp
Outdated
| string ReadTempFileToString(const string &filename) | ||
| { | ||
| path temp_file = test_data_temp_path / path(filename); | ||
| std::ifstream in_fs(temp_file); |
There was a problem hiding this comment.
Since we usually declare namespace std to be used we should omit std:: for simplicity and readability sake.
cpp/scsidump/scsidump_core.h
Outdated
|
|
||
| bool restore = false; | ||
|
|
||
| const string divider_str = "----------------------------------------"; |
There was a problem hiding this comment.
Can this string be static?
doc/scsidump.1
Outdated
| .TP | ||
| .BR \-r\fI | ||
| Run in restore mode. | ||
| Run in restore mode. Defaults to download mode if not specified. |
There was a problem hiding this comment.
I don't think "download" is a good term. The common terms are dump/restore, just as the names of the respective UNIX commands. Downloading is quite specific for the file downloads in the internet.
doc/scsidump_man_page.txt
Outdated
| scsidump has two modes of operation: download and restore. These can be used with physical storage media, including hard drives and magneto optical drives. Download mode can be used with read-only media such as CD/DVD drives. | ||
|
|
||
| Set its own ID with the BID option. Defaults to 7 if ommitted. | ||
| When operating in download mode, scsidump will copy all data from a remote SCSI drive to an image on the local filesystem. Additionally, it will generate a .properties file that can be used to more closely emulate the source drive. |
There was a problem hiding this comment.
Is the creation of the .properties file mandatory? It should not be because not everybody (not just not me) would want unexpected and potentially invisible (dot) files to be created.
Making the file creation optional and the filename configurable would IMO be best. One should also consider not to overwrite existing files.
There was a problem hiding this comment.
Now requires '-p' argument in order to enable this feature.
uweseimet
left a comment
There was a problem hiding this comment.
Please see my comments.
|
A general remark, not specific to this PR, but also concerning this PR: For functional extensions like in this case (property file) it might be good to have a ticket first because:
Just my two cents. |
|
@akuker Thank you four addressing my comments. |
|
@uweseimet - Thank you for reviewing!! I'll try to do a better job of writing up issues before implementing things |