353 Commits
v0.28 ... v0.33

Author SHA1 Message Date
PartialVolume
1d67d9e0d3 Merge pull request #411 from PartialVolume/Bump_to_0.33
Bump to v0.33
2022-03-20 14:15:05 +00:00
PartialVolume
f63862d042 Bump to v0.33
Updated:
CHANGELOG.md
configure.ac
man/nwipe.1
src/version.c
2022-03-20 14:11:46 +00:00
PartialVolume
65bc03da9a Merge pull request #410 from PartialVolume/fix_segfault_when_logfile_cannot_be_created_due_to_permissions
Fix obscure segfault when --logfile option used with a non writable directory.
2022-03-15 23:07:16 +00:00
PartialVolume
949f2b25e5 Bump version 2022-03-15 23:05:02 +00:00
PartialVolume
62e7876c74 Fix obscure segfault when --logfile option used.
If you use the --logfile option but specify a filename
that will be created in a directory that is not writable,
for instance, a system directory such as /proc/sys/ or
your current directory happens to be a system directory
that you are running nwipe from while not specifying a
writable path for the log file then nwipe would exit with
a segfault.

This is now fixed and if the logfile cannot be created
or opened then an appropriate message is displayed and
nwipe is aborted.
2022-03-15 19:58:13 +00:00
PartialVolume
648cad7645 Merge pull request #409 from PartialVolume/fix_nwipe_not_exiting_when_konsole_exited_before_nwipe_during_wipe
Fix_nwipe_not_exiting_when_using_konsole
2022-03-03 20:06:13 +00:00
PartialVolume
791c6f3975 Fix_nwipe_not_exiting_when_using_konsole
This fixes a issue related to konsole and terminals based on Konsole,
like cool retro terminal. If you exit the terminal before exiting nwipe,
nwipe will then continue running in the background but detached from any
terminals input/output. This causes a call to halfdelay()/getch() to
return immediately, thus removing the delay and causing the thread to
run at full speed causing 100% CPU in a core. This requires nwipe to
then be killed manually. This patch is related to the last patch in
that both patches do much the same thing but the previous patch fixes
the problem when nwipe is sitting at the drive selection screen, while
this patch fixes the problem during a wipe.

This problem would only be seen in specific KDE konsole related
terminals and only if you do not exit nwipe by using nwipe's control c
to abort or use the space bar on completion of the wipe.

Much like the same check we perform in the nwipe_gui_select() function,
here we check that we are not looping any faster than as defined by the
halfdelay() function, typically this loop runs at 10 times a second.
This check makes sure that if the loop runs faster than double this
value i.e 20 times a second then the program exits. This check is
therefore determining whether the getch() function is returning
immediately rather than blocking for the defined period of 100ms.
Why is this necessary? Some terminals (konsole & deriviatives) that are
exited while nwipe is still running fail to terminate nwipe this causes
the halfdelay()/getch() functions to immediately fail causing the loop
frequency to drastically increase. We detect that speed increase here
and therefore close down nwipe. This doesn't affect the use of the tmux
terminal by which you can detach and reattach to running nwipe
processes. The tmux terminal will still work correctly when a nwipe
session is detached.
2022-03-03 19:48:44 +00:00
PartialVolume
3f3ea5e04b Merge pull request #408 from PartialVolume/Fix_100%CPU_when_konsole_closed
Fixes a 100% CPU usage on Konsole based terminal
2022-03-02 19:39:54 +00:00
PartialVolume
175b246291 Fixes a 100% CPU usage on Konsole based terminal
when Konsole terminal exited while nwipe is sitting at the
drive selection screen.

To avoid 100% CPU usage, check for a runaway condition caused by the
function "keystroke = getch() that immediately returns an error
condition. We check for an error condition because getch() returns a
ERR value when the timeout value "timeout( 250 );" expires as well as
when a real error occurs. We can't differentiate from normal operation
and a failure of the getch function to block for the specified period
of timeout. So here we check the while loop hasn't exceeded the number
of expected iterations per second ie. a timeout(250) block value of
250ms means we should not see any more than (1000/250) = 4 iterations.
We double this to 8 to allow a little tolerance. Why is this necessary?
It's been found that in KDE konsole and other terminals based on the QT
terminal engine exiting the terminal without first existing nwipe
results in nwipe remaining running but detached from any interface
which causes getch to fail and its associated timeout. So the CPU or
CPU core rises to 100%. Here we detect that failure and exit nwipe
gracefully with the appropriate error. This does not affect use of
tmux for attaching or detaching from a running nwipe session when
sitting at the selection screen. All other terminals correctly
terminate nwipe when the terminal itself is exited.
2022-03-02 19:34:05 +00:00
PartialVolume
58576f8191 Merge pull request #407 from PartialVolume/Fix_temperature_update_in_drive_selection_window
Fix temperature update in drive selection window
2022-02-25 22:47:06 +00:00
PartialVolume
1384d8a6d7 Fix temperature update in drive selection window
This fixes a problem where the drive temperature is not updated
automatically in the drive selection window only. The temperature
is however updated every correctly every 60 seconds during a wipe in
the wipe status window.

This bug would probably never be noticed by most people as usually the
drive temperature changes slowly and only rises once a wipe has started.

The only time I imagine it would have been noticed would have been if
the drive temperature was already high and you were trying to reduce the
temperature by cooling before starting a wipe.

This has now been corrected so that the temperature in the drive
selection window is updated every 60 seconds.
2022-02-25 22:40:07 +00:00
PartialVolume
7f16dd3f74 Merge pull request #406 from PartialVolume/fix_spurious_message_on_abort_before_wipe_starts_control_c
Fix spurious message on abort before wipe.
2022-02-25 15:47:18 +00:00
PartialVolume
14f70661d8 Fix spurious message on abort before wipe.
This patch fixes a minor display issue that occurs when
a user aborts a wipe before a wipe has started. It only occurs
if the user had selected one or more drives for wipe and then
aborted before starting the wipe. The spurious message only
occurs in a virtual terminal, i.e. /dev/tty1, /dev/tty2, /dev/console
It does not occur in terminal applications such as konsole, xterm,
terminator etc.

The spurious message that appears in the main window, states that
"/dev/sdxyz 100% complete" along with garbage values in the statistics
window. The message appears for a fraction of a second before being
replaced with the textual log information that correctly states that
the user aborted and no wipe was started.

Basically the gui status information update function tries to update
the data when the wipe hasn't even started. The fix is to only update
the statistics information only if a wipe has started by checking the
'global_wipe_status' value which indicates whether any wipe started. '1'
indicates that a wipe has started, else '0' if no wipe has started.
2022-02-25 15:38:42 +00:00
PartialVolume
dcd1d100ca Merge pull request #404 from PartialVolume/master
Bump minor version to 0.32.023
2022-01-13 20:31:11 +00:00
PartialVolume
334bcadae1 Bump minor version 2022-01-13 20:20:58 +00:00
PartialVolume
dff450c49d Merge pull request #403 from martijnvanbrummelen/revert-402-revert-401-update_isaac64_command_line_options_help_and_man_page
Revert "Revert "Isaac64, update options, help and man page""
2022-01-13 20:05:43 +00:00
PartialVolume
40569ce1c0 Revert "Revert "Isaac64, update options, help and man page"" 2022-01-13 20:03:47 +00:00
PartialVolume
34fca0747a Merge pull request #402 from martijnvanbrummelen/revert-401-update_isaac64_command_line_options_help_and_man_page
Revert "Isaac64, update options, help and man page" Checks failed.
2022-01-13 19:32:36 +00:00
PartialVolume
110f62de00 Revert "Isaac64, update options, help and man page" 2022-01-13 19:30:10 +00:00
PartialVolume
1705b31ae8 Merge pull request #401 from PartialVolume/update_isaac64_command_line_options_help_and_man_page
Isaac64, update options, help and man page
2022-01-13 19:27:52 +00:00
PartialVolume
1e43f17650 Isaac64, update options, help and man page 2022-01-13 19:25:43 +00:00
PartialVolume
8313506ec5 Merge pull request #400 from PartialVolume/Fix_summary_table_on_specific_failure
Fix obscure incorrect summary table status
2022-01-12 21:14:22 +00:00
PartialVolume
978c4e9c8b Fix obscure incorrect summary table status
If the drive becomes non responsive during the wipe, the MB/s will
slowly drop towards 0MB/s and will display a FAILURE -1 error. The logs
will display errors and nwipe's return status will be non zero, however
the summary table may display erased rather than FAILURE, this is because
the wipe thread exited prematurely without setting the pass error.

This fixes the error by checking the context's result status, i.e non zero
on failure and if pass equals zero it makes pass equal to one. This is
then picked up by the summary table log code which then marks the status
correctly as FAILURE in the summary table.
2022-01-12 21:03:58 +00:00
PartialVolume
5ca7458b8c Bump version to 0.32.021 2022-01-09 15:18:32 +00:00
PartialVolume
0bc79f9feb Merge pull request #399 from chkboom/gutmann
Random passes in the Gutmann method should not be rearranged.
2022-01-09 15:16:05 +00:00
AK-47
0b959b62da Random passes in the Gutmann method should not be rearranged.
https://www.cs.auckland.ac.nz/~pgut001/pubs/secure_del.html
"... random passes before and after the erase process, and by performing the deterministic passes in random order ..."
"The deterministic patterns between the random writes are permuted before the write is performed, ..."
2022-01-08 12:50:18 +11:00
PartialVolume
5e9ff6dfa5 Bumped version and year. 2022-01-06 23:37:02 +00:00
PartialVolume
d964c9245d Merge pull request #398 from chkboom/isaac64
Added ISAAC-64 PRNG for 64-bit systems.
2022-01-06 23:32:56 +00:00
AK-47
aa2c7727c4 Removed asserts and make "remain" const.
Attempt to fix formatting.
2022-01-07 00:28:39 +11:00
AK-47
3094fc2fa7 Leave the blanking setting alone when changing the verification setting. 2022-01-06 21:42:01 +11:00
AK-47
85fbba947a Select ISAAC-64 by default on a >=64-bit CPU.
Otherwise choose ISAAC instead of Mersenne Twister.
2022-01-06 20:57:18 +11:00
AK-47
6dff23d6b2 Significantly improved ISAAC and ISAAC-64 performance.
Each ISAAC call generates a block of integers, but only the first integer was used before the PRNG was called again.
This resulted in most of the random numbers being wasted and more calls to the PRNG than was necessary.
Also fixed some segmentation faults in ISAAC-64 code.
2022-01-06 13:55:00 +11:00
AK-47
76ca47f2cb Added ISAAC-64 PRNG for 64-bit systems.
Use RANDIZL=8 as recommended by ISAAC author.
Fixed possible buffer overflow in nwipe_isaac_read().
Slight performance improvement.
2022-01-06 01:36:12 +11:00
PartialVolume
fe9666bd41 Merge pull request #395 from Firminator/patch-2
Update README.md
2021-12-13 09:12:04 +00:00
Firminator
a19e07bd1b Update README.md
* remove redundant paragraphs and information especially regarding ShredOS
* move certain paragraphs around to streamline the readme and for better readability
* update links
* some minor changes
2021-12-13 00:33:30 -05:00
PartialVolume
c4430f149c Merge pull request #394 from PartialVolume/Mitigate_against_smartctls_inconsistent_use_of_case_in_labelling
Fix missing serial number on SAS drive. Fixes #384
2021-12-12 20:28:08 +00:00
PartialVolume
a83a27f8e5 Fix missing serial number on SAS drive
This was caused by inconsistent labeling of the
serial number by smartctl. In a majority of cases
smartctl would output serial number data using
the label "Serial Number:" however on a SAS
drive we found that smartctl output the label
as "Serial number:" i.e. differs with a lower
case 'n'. Unfortunately we were doing a case
sensitive search for "Serial Number" so the result
being the serial number was not found.

This patch converts both strings in the search
to lower case before searching.

In addition a new field was added to the
anonymize list, "logical unit id:" so when the
-q option is used "serial number", "lu wwn device id:"
and "logical unit id:" are all now anonymized in the
smartctl debug data.
2021-12-12 20:22:35 +00:00
PartialVolume
254a0efd2c Merge pull request #393 from PartialVolume/Improve_GUI_thread_cancellation_eror_handling
Improve GUI thread cancellation messaging
2021-12-08 23:47:38 +00:00
PartialVolume
323fc38631 Improve GUI thread cancellation messaging
If pthread_join failed, nwipe would report an error
but would also report that the thread had been
cancelled. This has been corrected so that only
the error message is displayed in a fault condition.
2021-12-08 23:43:01 +00:00
PartialVolume
7f547e7ccb Merge pull request #392 from PartialVolume/Improve_thread_cancellation_error_reporting
Improve thread cancellation error reporting
2021-12-07 23:17:25 +00:00
PartialVolume
c433326c9f Improve thread cancellation error reporting
Check for specific errors.
Add retry loop with timeout for pthread_join.
2021-12-07 23:10:20 +00:00
PartialVolume
4351b3db5d Merge pull request #391 from PartialVolume/Fix_use_of_modprobe_on_Debian_11_part2
Would help if I explicitly stated the paths ;-)
2021-12-02 22:51:48 +00:00
PartialVolume
5eb43855c7 Would help if I explicitly stated the paths :'-) 2021-12-02 22:47:48 +00:00
PartialVolume
86174b227d Merge pull request #390 from PartialVolume/Fix_use_of_modprobe_on_Debian_11
Check multiple paths for modprobe
Fixes #389
2021-12-02 22:34:09 +00:00
PartialVolume
acba2c8065 Check multiple paths for modprobe
Particularly relevant to Debian which when logged in as root
doesn't put /sbin in the $PATH environment setting.

This might have caused temperatures to not be available on Debian
systems, but not necessarily on distros based on Debian like
Ubuntu which would have worked ok.
2021-12-02 22:30:39 +00:00
PartialVolume
0d3e1af83d Merge pull request #388 from PartialVolume/Fix_second_occurence_of_incorrect_specifier
Fix 2nd occurrence of incorrect format specifier.
2021-12-01 19:45:20 +00:00
PartialVolume
981f666150 Fix 2nd occurrence of incorrect format specifier.
Causing incorrect sect/block/device size to be
printed in nwipe_log but only for 32 bit builds.
2021-12-01 19:42:28 +00:00
PartialVolume
4f531e65db Merge pull request #387 from PartialVolume/Fix_nwipe_log_format_specifier_incorrect
Fix nwipe log format specifier incorrect
2021-12-01 19:33:16 +00:00
PartialVolume
181ef543de nwipe_log format specifier doesn't match variable.
The format specifier didn't match the size of the variable that holds
c2[i]->device_sector_size which is an int. This didn't appear to cause
a problem with reporting in a 64 bit build. It does cause a problem in
a 32 bit build displaying a very large & incorrect number for sector,
block and device sizes.

This doesn't cause any issues with the overall function, simply
incorrect sector, block and device sizes in 32 bit builds as displayed
in the nwipe log.

I also changed the signed long long for c2[i]->device _size to a
unsigned long long as there is little point in a negative device size.
2021-12-01 19:20:34 +00:00
PartialVolume
aab863ea7d Update ShredOS link 2021-12-01 05:50:34 +00:00
PartialVolume
ef06fed886 Merge pull request #383 from Firminator/patch-1
Update options.c with additional infor for -q
2021-11-18 15:34:05 +00:00
Firminator
6396825eb6 Update options.c
* added additional info for -q, i.e. what data is being removed from GUI and logs
* removed superfluous new line break
2021-11-18 10:11:03 -05:00
PartialVolume
b35b14ba42 Merge pull request #382 from PartialVolume/Remove_trailing_character
Remove ')' character in nwipe_log message
2021-11-18 12:07:29 +00:00
PartialVolume
2b63fb74cb Remove ')' character in nwipe_log message 2021-11-18 12:02:35 +00:00
PartialVolume
fd11b9df35 Merge pull request #381 from PartialVolume/Update_hwmon_search_directories
Update temperature for some nvme devices
2021-11-18 11:29:27 +00:00
PartialVolume
0677cebe5b Update temperature
Add /sys/class/hwmon/hwmonX/device/ to the list
of directories to search for a given device.

Some nvme devices/controllers put the device name
in /sys/class/hwmon/hwmonX/device/ rather than
/sys/class/hwmon/hwmonX/device/nvme/nvme0/

Update debug messaging.
2021-11-18 11:25:44 +00:00
PartialVolume
6b930863a6 Update comment 2021-11-17 20:32:15 +00:00
PartialVolume
e07ae7e0ef Merge pull request #380 from PartialVolume/Update_NVME_temperature_code
Update nvme temperatures.
2021-11-17 19:30:39 +00:00
PartialVolume
1744d89692 Update nvme temperatures.
For sdX devices we look in
/sys/class/hwmon/hwmonX/block for the device
name.

However, for nvme we access the device name
by looking in ..
/sys/class/hwmon/hwmonX/device/nvme/nvme0

nvme0n1

Multiple nvme drives/controllers will need
to be tested.
2021-11-17 19:27:27 +00:00
PartialVolume
8b36b3d204 Merge pull request #379 from PartialVolume/Add_anonymized_label_to_banner
Make it clear we are in anonymized mode
2021-11-17 16:26:06 +00:00
PartialVolume
c0466c4850 Make it clear we are in anonymized mode
When selecting -q or --quiet as an nwipe
option, append " (ANONYMIZED)" to the nwipe
banner.
2021-11-17 16:14:28 +00:00
PartialVolume
bb7199adf6 Bump version to v0.32.010 2021-11-17 15:39:54 +00:00
PartialVolume
e2cd608741 Merge pull request #378 from PartialVolume/Add_VRFY_instead_of_WIPE_when_verify_ones_or_zeros_only_is_selected
Distinguish between a wipe & verify
2021-11-17 15:38:16 +00:00
PartialVolume
a4d2418597 Distinguish between a wipe & verify
In the drive selection window when you
select a drive, the drive is identified
as selected for wiping with the [wipe]
label, however if you then select a
verify only method such as 'verify with
ones' or 'verify with zeros' it still
says [wipe] which is technically a
contradiction.

This patch changes the [wipe] to a
[vrfy] when a verify only method is
selected. If a method is selected
that writes data to the disc then the
label is displayed as [wipe].
2021-11-17 15:27:45 +00:00
PartialVolume
40ae117db4 Merge pull request #377 from PartialVolume/add_temperature_support_to_nvme_drives
Add temperature support to NVME drives, patch #1 ready for checking @Firminator . Thanks
2021-11-17 14:44:53 +00:00
PartialVolume
4ef3dbc5dd Add temperature support to NVME drives
Patch #1 (first check)
2021-11-17 14:37:16 +00:00
PartialVolume
93fe596c04 Merge pull request #375 from PartialVolume/Dont_calculate_ETA_when_throughput_is_zero
Fixes ETA under fault condition
2021-11-17 11:53:38 +00:00
PartialVolume
dd44cc8176 Fixes ETA under fault condition
If a faulty drive fails mid wipe and it's
throughput drops until eventually reaching
zero. The ETA calculation grows to an enormously
high value.

This patch prevents the ETA being calculated if
the throughput for a given drive drops below
100,000 bytes per second. In this way we can still
see that something is wrong because the ETA is much
higher than normal but prevents the sort of calculation
that looks like this ! 90867213:29:12 i.e ..
90,867,213 hours, 29 minutes and 12 seconds, or put
another way, 3,786,133 days or 10,372 years.
2021-11-17 11:50:22 +00:00
PartialVolume
c6fda62558 Merge pull request #374 from PartialVolume/Make_verify_error_message_more_succinct_to_reduce_line_wrap_on_many_verification_errors
Make verify & pass error succinct
2021-11-17 10:45:10 +00:00
PartialVolume
87f63e1388 Make verify & pass error succinct
When many verification or pass errors are detected
the status line can wrap on a 80 column display.

This patch makes the error message more succinct
which will free up about 10 characters & prevents
the line wrapping.
2021-11-17 10:40:36 +00:00
PartialVolume
bfe5939e33 Merge pull request #373 from PartialVolume/Fix_intermittent_FAILED_message_instead_of_UABORTED_on_control-C
Fix summary table - Control-C
2021-11-17 10:03:45 +00:00
PartialVolume
fb6b47d12a Fix summary table - Control-C
If you used control-c during a wipe,
the summary table would report FAILED
rather than UABORTED, even though no
errors had occured and no errors were
reported in the error summary table.

The correct message on control-c abort
should be UABORTED if no errors on that
drive had so far been detected or FAILED
if errors had been detected.

nwipe reported correctly when letting
the wipe continue to it's natural completion.

This patch fixes that issue.
2021-11-17 09:59:20 +00:00
PartialVolume
5d0d0ecb8a Merge pull request #371 from PartialVolume/Add_LU_WWN_ID_to_the_list_of_items_that_can_be_anonymized
Anonymize 'LU WWN ID' when -q specified.
2021-11-16 17:54:11 +00:00
PartialVolume
5cb27e60ce Anonymize 'LU WWN ID' when -q specified.
Add 'LU WWN ID' to the list of data returned
by smartctl that should be anonymized when
-q or --quiet is specified.
2021-11-16 17:48:50 +00:00
PartialVolume
f3f5ab1cac Bump version 2021-11-15 22:00:57 +00:00
PartialVolume
357031ce54 Merge pull request #367 from PartialVolume/Anonymize_SMBIOS-DMI_data_in_log_when_q_option_used
Anonymize SMBIOS/DMI data if -q --quiet specified
2021-11-15 21:57:41 +00:00
PartialVolume
190dae3dec Anonymize SMBIOS/DMI data if -q --quiet specified 2021-11-15 21:46:20 +00:00
PartialVolume
b9cb2369d1 Merge pull request #366 from PartialVolume/Add_anonymize_serial_numbers_option
Add -q --quiet option - anonymize serial numbers
2021-11-15 18:41:03 +00:00
PartialVolume
e982ca5fee Add -q --quiet option - anonymize serial numbers
Anonymize the serial numbers in the gui, the
log and the summary table.

If a serial number was obtained from the device,
it is replaced with "XXXXXXXXXXXXXXX".

If the serial number could not be obtained from the
device, it's replaced with "???????????????".
2021-11-15 18:19:47 +00:00
PartialVolume
a074be7f87 Merge pull request #365 from PartialVolume/Remove_dev_prefix_for_long_device_names_for_gui
Remove /dev/ from gui for long filenames
2021-11-15 10:07:47 +00:00
PartialVolume
0960fd1259 Remove /dev/ from gui for long filenames
This fixes column alignment issues in the gui
with nvme drives i.e. nvme0n1 etc. If the drive
name including path exceeds 8 characters the
/dev/ is removed and prefixed with spaces to
a total max length of 8 characters.
2021-11-15 09:57:46 +00:00
PartialVolume
4aee9a2d28 Merge pull request #364 from PartialVolume/move_temperature
Moved the temperature readout
2021-11-13 22:06:41 +00:00
PartialVolume
8650b4838a Moved the temperature readout
In both selection and wipe status windows I
moved the temperature readout to the right
of the disk size column.

Also in the wipe status window, by moving to
the right of the disk size column the
temperature is no longer on the same line as
the disk pass progress. This reduces the line
length as I found that in tests if you had
many verification errors the temperature
being on the end of the line would disappear
of the right of the screen.
2021-11-13 21:55:48 +00:00
PartialVolume
07eac4d861 Merge pull request #363 from Firminator/patch-1
Update README.md
2021-11-13 17:07:10 +00:00
Firminator
20ea1bf251 Update README.md
rewording.
2021-11-13 11:25:08 -05:00
Firminator
673310ce6d Update README.md
added netboot.xyz
2021-11-13 11:21:08 -05:00
PartialVolume
a0e63c659b Merge pull request #361 from PartialVolume/temperature_on_select_screen
Added temperature to drive selection window
2021-11-12 23:39:55 +00:00
PartialVolume
90ed59fe06 Added temperature to drive selection window
Also removed 1. 2. etc from drive selection
to reduce the line length. Also removed the
space between > and [, ie "> [wipe]" becomes
">[wipe]" These changes remove 3 characters
and help to reduce the affect of the additional
temperature field [30C] which add 5 characters.
Therefore the line length overall, increased by
5-3 = 2 characters.

This helps to reduce line wrapping on 80
character terminals, when the drive model length
exceeds 24 characters.
2021-11-12 23:23:57 +00:00
PartialVolume
c38c9577bb Bump version 2021-11-10 23:32:38 +00:00
PartialVolume
584f70e3b0 Merge pull request #360 from PartialVolume/Add_drive_temperature
Add drive temperature monitoring
2021-11-10 23:28:04 +00:00
PartialVolume
588784a06b More additions to temperature feature
1. Changed a few nwipe log messages to improve
readability.

2. Added code so that the temperature changes from
- white text = (Temperature within spec)
- red text = max continuous temp reached
- red flashing text = critical upper temperature reached
- black text = minimum continuous temperature reached
- black flashing text = critical lower temperature reached.
2021-11-10 23:16:17 +00:00
PartialVolume
796d5e2294 More changes related to temperature feature
1. Changed gui format specifier to match signed
integer that we changed to in the previous commit.

2. Changed the format specifier in verbose nwipe logging of
the temperatures and moved the nwipe log message that prints
the hwmonX path to the log in order to remove
unnecessary printing to the log.
2021-11-10 19:09:12 +00:00
PartialVolume
e7237a7a75 Changes related to temperature feature
1. Changed u64 to int to support negative
temperature values, i.e. temp1_lcrit may
be as low as -40C

2. In gui surround temperature reading with
square brackets instead of round brackets to
be consistent with the rest of the drive status line
2021-11-10 18:40:42 +00:00
PartialVolume
1d5f2a7899 Stage 2 temperature monitor feature.
Stage 2 modifies the GUI to trigger a temperature
update every 60 seconds. Changes were made to the
drive progress line to include [ 30C ]. The drive
context structure had another variable added that
records the time of the temperature update.

Note. When the temperature data cannot be retrieved
from the hwmon (drivetemp) module the GUI displays
[ --C ]. USB devices, even those adapters that support
ATA pass through, don't seem to work with hwmon (drivetemp),
at least the adapters I have don't work with drivetemp
to monitor temperature.
2021-11-10 12:27:20 +00:00
PartialVolume
397f6fceb3 Stage 1 temperature monitor feature.
Stage 1 adds the additional variables to the drive
context and creates the temperature initialisation
function, which associates a hwmonX directory with
a block device. Also wrote the context update function,
that reads hwmon for each drive context and writes the
temperatures back to the context.

Stage 2 commit to follow which will make changes within
the GUI to call the update function every 60 seconds
and display the temperature information.
2021-11-10 01:27:52 +00:00
PartialVolume
74fa192efa Change message for unknown serial no.
Changed message from (No ATA pass-thru) to (S/N: unknown)
2021-11-07 00:10:38 +00:00
PartialVolume
aa196b9602 Merge pull request #356 from Firminator/patch-2
Update device.c
2021-11-07 00:05:19 +00:00
PartialVolume
4d59c31b8f Bump version to 0.32.002 2021-11-06 00:44:12 +00:00
PartialVolume
056b4745ba Merge pull request #358 from PartialVolume/add_SATA_to_smartctl
Check smartctl for unresolved bus types SATA
2021-11-05 23:47:53 +00:00
PartialVolume
366249b76a Check smartctl for unresolved bus types SATA
For some controllers/drivers the readlink method of
obtaining the bus type for GUI display does not work.

If we haven't already resolved the bus type, we then
also check smartctl for the transport protocol
for SATA.
2021-11-05 23:43:43 +00:00
Firminator
02c1fa4780 Update device.c
correct a few typos not found by codespell
2021-11-04 23:35:00 -04:00
PartialVolume
39de02db8c Merge pull request #353 from DimitriPapadopoulos/codespell_rc
Add a .codespellrc file to run codespell
2021-11-02 19:12:50 +00:00
PartialVolume
e4b033e566 Merge pull request #354 from DimitriPapadopoulos/typo
Typo not found by codespell
2021-11-02 11:28:54 +00:00
Dimitri Papadopoulos
4903f246c0 Typo not found by codespell
The it's → its typo is not detected bsy codespell. Both are valid.
A higher level analysis would be required to detect that kind of typo.
2021-11-02 12:20:59 +01:00
Dimitri Papadopoulos
009ccf294b Add a .codespellrc file to run codespell 2021-11-02 12:10:22 +01:00
PartialVolume
17609ecdcd Merge pull request #352 from DimitriPapadopoulos/spaces
Remove trailing spaces or empty lines
2021-11-02 09:34:37 +00:00
PartialVolume
9f58de6006 Merge pull request #351 from DimitriPapadopoulos/codespell
Typos found by codespell
2021-11-02 09:30:23 +00:00
Dimitri Papadopoulos
c545aa8447 Remove trailing spaces or empty lines 2021-11-02 08:21:34 +01:00
Dimitri Papadopoulos
b2c22d58cb Typos found by codespell 2021-11-02 08:13:48 +01:00
PartialVolume
2459b0a397 Merge pull request #350 from PartialVolume/Add_SAS_to_bus_type_for_GUI
Add SAS to GUI.
2021-11-01 23:02:34 +00:00
PartialVolume
3c4e51a1ff Add SAS to GUI.
For some controllers/drivers the readlink method of
obtaining the bus type for GUI display does not work.

If we haven't already resolved the bus type, we then
also check smartctl for the transport protocol
for SAS.
2021-11-01 22:54:55 +00:00
PartialVolume
0ee4099c64 Merge pull request #348 from PartialVolume/Fix_spaces_overwriting_first_two_chars_of_DOD
Fix slight screen corruption on 80 column display
2021-10-31 21:49:19 +00:00
PartialVolume
089c188b06 Fix slight screen corruption on 80 column display
When highlighting the verify ones option the first two
digits of DoD 5220 .20-M disappear. This patch fixes that
issue.
2021-10-31 21:30:20 +00:00
PartialVolume
154490e56f Merge pull request #347 from PartialVolume/update_ready_for_0.32_release
Update files for 0.32 release
2021-10-28 23:40:29 +01:00
PartialVolume
753e758b0a Update files for 0.32 release
Confirmed the following release files were/are updated.
configure.ac
CHANGELOG.md
nwipe.1
version.c
2021-10-28 23:34:46 +01:00
PartialVolume
7d58587eb0 Merge pull request #346 from PartialVolume/update_readme_with_new_ones_wipe_and_verification
Update README.md with new wipe methods
2021-10-28 22:18:14 +01:00
PartialVolume
996c6cbf02 Update README.md with new wipe methods
Updated with Ones wipe & Ones verification.
2021-10-28 22:16:37 +01:00
PartialVolume
7eba0aeb1b Merge pull request #345 from PartialVolume/add_verify_ones
Add ones (0xFF) verification method.
2021-10-28 21:55:50 +01:00
PartialVolume
a379329fca Add ones (0xFF) verification method. 2021-10-28 21:50:19 +01:00
PartialVolume
9196e7748b Merge pull request #344 from PartialVolume/update_help_and_man_pages_for_zeros_ones
Update help, man and options for the ones method
2021-10-28 10:46:56 +01:00
PartialVolume
f7730b9fea Update ones method, help, man and options 2021-10-28 10:44:09 +01:00
PartialVolume
bcb34f7a83 Merge pull request #343 from PartialVolume/Adjust_info_for_max_80_columns
Adjust method info for 80+ column display
2021-10-28 00:40:27 +01:00
PartialVolume
a8dbbd46ec Adjust method info for 80+ column display 2021-10-28 00:36:53 +01:00
PartialVolume
7a3f2f573f Merge pull request #342 from PartialVolume/add_wipe_with_ones_method
Add ones 0xFF method.
2021-10-27 23:42:15 +01:00
PartialVolume
8336653926 Add ones 0xFF method. 2021-10-27 23:40:30 +01:00
PartialVolume
e629d9b2d1 Merge pull request #341 from PartialVolume/Remove_syslinux.cfg_lines
Remove the old syslinux configuration hints.

Help on nwipe options is available from the command
line nwipe --help or man help.
2021-10-27 22:30:58 +01:00
PartialVolume
70c5383d97 Remove the old syslinux configuration hints.
Help on nwipe options is available from the command
line nwipe --help or man help.
2021-10-27 22:22:15 +01:00
PartialVolume
708c4e02c8 Merge pull request #340 from PartialVolume/Move_method_info
Move the method description
2021-10-27 21:12:16 +01:00
PartialVolume
8fcb314ed4 Move the method description
Move the method description to the right hand side
of the list of methods. This allows us to extend the
list of methods so that the info doesn't fall of the
terminal on a 80x24 system that is using the frame
buffer such as shredos.

Also updated the information, making it more
description in terms of describing the passes used
for each method.
2021-10-27 21:07:32 +01:00
PartialVolume
6497b43518 Merge pull request #339 from PartialVolume/add_fdata_sync_errors_to_summary_table
Add fdatasync errors to error summary table
2021-10-27 10:17:15 +01:00
PartialVolume
e6e6ed1e30 Add fdatasync errors to error summary table 2021-10-27 09:55:33 +01:00
PartialVolume
c821f3176b Merge pull request #337 from PartialVolume/change_color_theme
Toggle between dark/blank/default screens
2021-10-26 02:09:18 +01:00
PartialVolume
9db8ad854e Toggle between dark/blank/default screens
Using the 'b' key you can now toggle between
dark/blank/default screens during a wipe.

Added the dark option to prevent TFT/LCD image
persistence.

See:
https://en.wikipedia.org/wiki/Image_persistence
2021-10-26 02:03:58 +01:00
PartialVolume
6ce785c2f2 Update and rename ci_ubuntu_16.04.yml to ci_ubuntu_18.04.yml 2021-10-26 01:46:59 +01:00
PartialVolume
cb08dda2de Update README.md with distro info 2021-06-15 23:57:34 +01:00
PartialVolume
2fb882084d Update README.md 2021-06-15 13:36:47 +01:00
PartialVolume
64caac4b16 Update README.md 2021-06-15 13:30:15 +01:00
PartialVolume
47e523cf34 Update nwipe.1 with correct default sync rate 2021-06-08 23:25:17 +01:00
PartialVolume
cf3ae6a0f6 Merge pull request #328 from PartialVolume/update_to_0.31
Update to 0.31
2021-06-05 20:23:12 +01:00
PartialVolume
a88eeb9383 Update to 0.31 2021-06-05 19:40:00 +01:00
PartialVolume
a84894f317 Update CHANGELOG.md with version 0.31 changes
Update CHANGELOG.md with version 0.31 changes
2021-06-05 00:17:41 +01:00
PartialVolume
5c3eed8813 Merge pull request #326 from PartialVolume/Enable_verification_on_zero_pass_without_additional_blanking_pass
Allow Last Pass Verify to work without requiring final blanking (zero) pass.
2021-06-04 10:36:35 +01:00
PartialVolume
4b1c7007ff Various fixes to methods
1. Allows zero fill to be verified when blanking off.
Prior to this if you wanted to verify a zero pass,
blanking had to be on. This meant a zero pass, then a
blanking pass then a verify, effectively two zero passes
and a verify. This is now fixed so you can now do a zero
pass with verification without a blanking pass. This knocks
a third off the wipe time of a zero fill with verification.

This also means all other methods can have either all their
passes or just the last pass verified without blanking being
enabled.

2. OPS2 method requires the last pass to be random, the GUI
now disables the use of the blanking option for this message
and displays a warning message that a final blanking pass is
not allowed for OPS2. It never did a final blanking pass
anyway, even if it was selected, but this makes it clearer in
the GUI.

3. The caculate_round_size() function was improved by reducing
some duplicated code and bring the full calculation into this function.

4. On completion of each pass or verification the total number of
bytes written or read for each pass or verification is logged.
2021-06-04 10:20:23 +01:00
PartialVolume
970d74f0d5 Bump minor version number from 009 to 010 2021-06-01 02:36:51 +01:00
PartialVolume
c815235f7b Merge pull request #325 from PartialVolume/Add_count_of_fatal_non-fatal_and_verification_errors_to_summary_table
Add pass and verification summary table to log
2021-06-01 02:30:50 +01:00
PartialVolume
dcfa13a8db Add pass and verification summary table to log 2021-06-01 02:21:00 +01:00
PartialVolume
a1560de8b5 Merge pull request #324 from PartialVolume/Fixes_verify_status_message_not_shown_on_blanking_pass
Fix blanking pass verification status message
2021-05-31 23:44:41 +01:00
PartialVolume
18386f225e Fix blanking pass verification status message
Although the blanking pass verification is
completed correctly the GUI status message
did not show the status as 'Verifying', the
status message continued to say blanking.

This patch fixes the GUI message so if
verification and blanking pass are enabled,
then when blanking is complete and verification
starts the drive status message changes from
'blanking' to 'Verifying'.
2021-05-31 23:41:19 +01:00
PartialVolume
1f3b36f141 Merge pull request #323 from PartialVolume/Fix_mersenne_prng_always_being_used_even_when_user_selected_isaac
Fix the prng GUI selection
2021-05-30 23:09:01 +01:00
PartialVolume
962e1053dd Fix the prng GUI selection
This patch fixes the issue where irrespective
of whether the user selects mersenne or isaac
in the GUI, mersenne is always used without the
user being aware mersenne was being used instead
of isaac.
2021-05-30 23:05:47 +01:00
PartialVolume
93ea5f85d0 Merge pull request #322 from PartialVolume/populate_the_empty_isaac_read_function_with_some_actual_code
Fix non functional isaac prng
2021-05-30 22:34:36 +01:00
PartialVolume
76a7be696c Fix non functional isaac prng
Since at least 2013 (the initial nwipe commit),
isaac has never functioned. When the issac prng
was selected in the GUI, nwipe used the mersenne
twister prng instead. Not that you would ever
have known, as there were no log entries saying which
prng was being actively used.

However, I don't believe this was just an nwipe
issue, looking at the code for DBAN's dwipe the
same function nwipe_isaac_read( NWIPE_PRNG_READ_SIGNATURE )
exists as it does in nwipe. In both cases the function
has no code that actually does anything.

This patch populates this function and brings isaac
back to life !

This bug was also responsible for verification errors
when the option prng=isaac was used on the command
line. Worse still, if you used prng=isaac on the
command line then wiped using method=prng, no verification
and no blanking you would expect to see random data. You
don't, instead you would see either all zeros or mainly
zeros because the uninitialised buffer that should have
contained random data instead contained initialised text
data such as partial log entries. This patch and previously
submitted patches fix all these problems related to the
isaac implementation.

A separate commit will fix the GUI prng selection which
was leading everybody to believe isaac was being used
when in fact it was mersenne all along.
2021-05-30 22:30:31 +01:00
PartialVolume
630d107558 Merge pull request #321 from PartialVolume/check_prng_is_generating_data
Check that the prng produces output.
2021-05-29 21:31:47 +01:00
PartialVolume
5adc34b9e3 Check that the prng produces output.
Additional log messages are produced and a failed prng
causes a wipe failure. The buffer that outputs prng data
to the disk is now initialised with zeros (calloc rather than malloc)
to avoid uninitialised memory leakage to the disk in the event of some
unforeseen bug. This initialised buffer is also required for the check
process.

Why do this check? At a future date more prng methods may be added. This
is a very basic check that they produce some output although the output
is not verified in terms of it's randomness. This check was also
implemented to show an existing bug in the Isaac implementation in nwipe.

See the example log below that shows a failed prng. This would be caused
by a bug in the prng implementation. See the last few messages after
pass 3/3 starts. 3/3 in DoD short is the prng pass.

[2021/05/29 20:30:27]  notice: Invoking method 'DoD Short' on /dev/loop29
[2021/05/29 20:30:27]  notice: Starting round 1 of 1 on /dev/loop29
[2021/05/29 20:30:27]  notice: Starting pass 1/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:39]  notice: 1073741824 bytes written to /dev/loop29
[2021/05/29 20:30:39]  notice: Finished pass 1/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:39]  notice: Starting pass 2/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:58]  notice: 1073741824 bytes written to /dev/loop29
[2021/05/29 20:30:58]  notice: Finished pass 2/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:58]  notice: Starting pass 3/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:58]  notice: Initialising Isaac prng
[2021/05/29 20:30:58]   fatal: ERROR, prng wrote nothing to the buffer
[2021/05/29 20:30:58]  notice: 0 bytes written to /dev/loop29
[2021/05/29 20:31:03]   error: Nwipe exited with fatal errors on device = /dev/loop29

********************************************************************************
! Device | Status | Thru-put | HH:MM:SS | Model/Serial Number
--------------------------------------------------------------------------------
! loop29 |-FAILED-|  69 MB/s | 00:00:31 | Loopback device/
--------------------------------------------------------------------------------
[2021/05/29 20:31:03] Total Throughput  69 MB/s, DoD Short, 1R+NB+NV
********************************************************************************

A message is also shown for a successful prng output. i.e "prng is active"
See example below.

[2021/05/29 20:04:30]  notice: Invoking method 'DoD Short' on /dev/loop29
[2021/05/29 20:04:30]  notice: Starting round 1 of 1 on /dev/loop29
[2021/05/29 20:04:30]  notice: Starting pass 1/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:44]  notice: 1073741824 bytes written to /dev/loop29
[2021/05/29 20:04:44]  notice: Finished pass 1/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:44]  notice: Starting pass 2/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:59]  notice: 1073741824 bytes written to /dev/loop29
[2021/05/29 20:04:59]  notice: Finished pass 2/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:59]  notice: Starting pass 3/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:59]  notice: Initialising Mersenne Twister prng
[2021/05/29 20:04:59]  notice: prng stream is active
[2021/05/29 20:05:25]  notice: 1073741824 bytes written to /dev/loop29
2021-05-29 21:23:38 +01:00
PartialVolume
5bc61f2bdd Merge pull request #320 from PartialVolume/Log_intialisation_of_prng_method
Logs the specific prng that is initialised.
2021-05-28 19:54:49 +01:00
PartialVolume
b55b020a83 Log the initialisation of the prng type
Logs the specific prng that is initialised.
2021-05-28 19:45:19 +01:00
PartialVolume
b34c99b81b Bump banner & version minor version 2021-05-27 14:23:34 +01:00
PartialVolume
63d20dc4be Merge pull request #319 from PartialVolume/Add_details_of_wipe_to_log
log the nwipe options that the wipe/s is going to use.
2021-05-27 14:16:14 +01:00
PartialVolume
2111206fa3 Add nwipe options that have been selected.
The log now contains wipe configuration detail
such as method, prng, blanking, sync, rounds etc.
2021-05-27 14:06:57 +01:00
PartialVolume
5263a23cd6 Merge pull request #317 from PartialVolume/Fix_contradictory_log_messaging
Fixes contradictory log messages.
2021-05-27 08:18:29 +01:00
PartialVolume
a6b60bfd15 Fixes contradictory log messages.
1. The log reported verification errors while also
showing an entry in the log that said "[SUCCESS] Blanked /dev/...".
The blanked device message now shows [FAILURE] /dev/... may not be blanked"
if any verification errors are detected for a specific drive.

2. If a verification error occurred, the error would be correctly
shown in the GUI and in the logs but the summary table drive status
would show 'ERASED' not 'FAILED'. Now corrected so that the tables
drive status field shows 'FAILED' if any verification error is detected.
Prior to this it was marking the status as 'FAILED' only if the O.S
detected write errors. In practise most drive errors are detected
by the write I/O process on syncing but this will now detect errors not
recognised by the O.S. and found by the verification process. Despite
this the textual log and GUI correcty reported verification errors.

3. The final log message "Nwipe exited successfully" was checking for
fatal errors but ignoring non fatal errors despite being reported in
the log.

The final message now reads
either "Nwipe Exited Succesfully" if no fatal and non fatal errors were
detected. Alternatively it displays ...
"Nwipe exited with errors, check the log & summary table for individual drive status."
if any fatal OR non fatal errors are detected.
2021-05-27 08:07:20 +01:00
PartialVolume
d8d627dce3 Merge pull request #315 from PartialVolume/Fix_shutdown
Fix shutdown on buildroot based distros such as shredos 2020, while maintaining compatibility with Ubuntu/Debian etc.
2021-04-19 15:34:21 +01:00
PartialVolume
95d0b3f382 Fix shutdown on buildroot based distros
The shutdown command that nwipe currently uses is
"shutdown -P +1 "Broadcast shutdown message".
While the above command works works fine on Ubuntu 18.04 LTS it
does not work on the version of shutdown used in buildroot, failing
with the error:
"shutdown -H and -P flags can only be used along with -h flag"

Luckily there is a shutdown command with options that work correctly
on both buildroot (ShredOS) and Ubuntu 18.04 LTS, this is
shutdown -Ph +1 "Broadcast shutdown message". i.e. the option -h has been added.
2021-04-19 15:22:43 +01:00
PartialVolume
055d2e8b0c Bump minor revision 2021-03-17 21:28:29 +00:00
PartialVolume
9f0674b3b9 Merge pull request #314 from andrewvaughanj/code_formatting
Run 'make format'
2021-03-17 21:27:03 +00:00
PartialVolume
5f332a407d Merge pull request #313 from andrewvaughanj/fix_global_wipe_status
Correcting multiple definition of 'global_wipe_status'
2021-03-17 21:26:28 +00:00
Andrew V. Jones
543a880064 Run 'make format'
Signed-off-by: Andrew V. Jones <andrewvaughanj@gmail.com>
2021-03-17 17:41:32 +00:00
Andrew V. Jones
62c604bc0e Correcting multiple definition of 'global_wipe_status'
Signed-off-by: Andrew V. Jones <andrewvaughanj@gmail.com>
2021-03-17 16:07:37 +00:00
PartialVolume
2bc62a7217 Update README.md with link to gparted live 2021-02-17 21:16:55 +00:00
PartialVolume
7f5bc5aa34 Merge pull request #301 from ndowens/master
bits/sigthread.h is a glibc only and is not needed
2021-02-05 17:07:29 +00:00
PartialVolume
7fa5c98023 Merge pull request #312 from PartialVolume/fix_footer_corruption_on_resize_and_method_rounds_blanking_selection
Fixes footer bar corruption to the right of the message
2021-02-04 21:51:26 +00:00
PartialVolume
4e159a902c Merge branch 'master' into fix_footer_corruption_on_resize_and_method_rounds_blanking_selection 2021-02-04 21:50:06 +00:00
PartialVolume
3090b0682f Fixes footer bar corruption to the right of the message
This bug only occurs when you resize the terminal while
on the drive selection screen, then switch to method, rounds
or blanking. To the right of the message the text background
is now blue and not white and random box characters appear.

To me it seems to be a bug not in nwipe but in curses, however
placing double quotes around the message fixes the problem. I
also found that the contents of the message appeared to trigger
the problem, possibly the '=' symbol, however the fact that
the main selection text does not require the quotes is most odd.
Still, this simple fix seems to get rid of the problem.
2021-02-04 21:40:26 +00:00
PartialVolume
d2dff52407 Merge pull request #310 from Firminator/patch-1
Update gui.c - Add CTRL+A
2021-02-01 11:43:46 +00:00
PartialVolume
58a5184c88 Removed CTRL+A=SelectALL from help as it makes the help text greater than 80 characters required for system working with frame buffer displays using 80x25. I have a plan to make the help line responsive or multipage to overcome this limitation so more commands can be added. Secondly, one line needed to be formatted to pass CI format check. 2021-02-01 11:40:52 +00:00
PartialVolume
6dcaaa6920 Update README.md with make format
If submitting pull requests, you must `make format` prior to commiting code and submitting a pull request otherwise you pull request will fail the CI that checks formatting.
2021-01-31 00:17:35 +00:00
PartialVolume
8e9e2ae90f Update README.md with make format
If submitting pull requests, you must `make format` prior to commiting code and submitting a pull request otherwise you pull request will fail the CI that checks formatting.
2021-01-31 00:15:58 +00:00
PartialVolume
02e356e0ec Merge pull request #311 from PartialVolume/fix_uaborted_message_in_summary_table
Fixes to summary table & fix final status message Fixes #308
2021-01-30 19:17:15 +00:00
PartialVolume
12063ad954 Fixes to summary table & fix final status message
1. Prior to this fix, if a user aborted a multi drive using control-C,
and if some of the drives had completed their wipe either
successfully or with a I/O failures, the summary log would say
UABORTED for all drives. UABORTED is acceptable status for drives that
hadn't completed their wipe but for drives that had completed the wipe,
the summary table should have gave either a ERASED or FAILED status
message. This fix corrects the summary status when using control-c to
abort a multi drive wipe where some drives have completed and some have
not.

2. If I wipe was selected but not started and then the user used
control-C to abort nwipe, the summary table would possibly
intermittently be displayed showing the last drive wiped. The correct
behaviour is that no summary table is displayed if the wipe hasn't been
started yet. This fix corrects the behaviour of the summary table when
control-c is used and a drive has been selected for wiping but not
started, in this scenario the summary table is NOT displayed.

3. When nwipe exits it always prints the message "nwipe successfully
exited". To make this single line message more informative it now
reports a different message depending upon the wipe status.

These four messages are:

"Nwipe was aborted by the user. Check the summary table for the drive
status" -  When the user aborts during a wipe.

"Nwipe was aborted by the user prior to the wipe starting."

"Nwipe exited with fatal errors, check the summary table for individual
drive status." - When one or more drives failed.

"Nwipe successfully completed. See summary table for details." - When
selected drives were all erased without error.
2021-01-30 19:08:05 +00:00
Firminator
66d239c980 Update gui.c - Add CTRL+A
... and reduce confusion about lowercase and uppercase option. All options are now defaulting to show as lowercase in the GUI except Start which can only be invoked with SHIFT S to prevent accidental start of wipe. Unless someone enjoys pressing additionally SHIFT for B and R and V and all the other options I'd propose it might be time to remove unneeded code for this :)
2021-01-30 13:37:48 -05:00
PartialVolume
462777d92b Merge pull request #309 from Firminator/patch-1
Corrected --nousb
2021-01-30 09:14:50 +00:00
Firminator
69c9d7d6c5 Corrected --nousb
emphasized that no[gui,blank,wait,signals,usb] will ignore things
2021-01-29 21:13:37 -05:00
PartialVolume
fffee8bb34 Update README.md
Updated link to buildnwipe script
2021-01-08 23:35:07 +00:00
PartialVolume
b8a536a02f Merge pull request #303 from NoNameForMee/master
Correct one external link in README.md
2021-01-08 23:13:33 +00:00
NoNameForMee
0c542660ff Correct one external link in README.md
To official website of SystemRescue (also known as SystemRescueCd).
2021-01-08 20:35:45 +01:00
PartialVolume
412917ab17 Update README.md
Add link to repology with reference to nwipe. Information on which version of Nwipe is in which distro version.
2021-01-07 21:01:14 +00:00
Nathan Owens
f5501ccc45 bits/sigthread.h is a glibc only and is not needed 2020-12-21 12:23:53 -06:00
PartialVolume
d819330583 bump minor banner revision 2020-12-19 18:32:39 +00:00
PartialVolume
2061346ace Merge pull request #300 from andreasheil/update-man-and-help
Update man and help
2020-12-19 18:30:51 +00:00
Andreas Heil
69fed30dde fix typo and reformat 2020-12-18 10:14:06 +01:00
Andreas Heil
7cc1a68a89 updated manpage 2020-12-18 10:13:35 +01:00
PartialVolume
ab6c4c0014 Update version.c for 0.30 release 2020-12-09 17:28:14 +00:00
PartialVolume
22f596c228 Update nwipe.1 for 0.30 release 2020-12-09 17:27:03 +00:00
PartialVolume
be0de995f8 Update configure.ac for 0.30 release 2020-12-09 17:10:43 +00:00
PartialVolume
24a3eb5734 Update CHANGELOG.md for 0.30 release 2020-12-09 17:07:48 +00:00
PartialVolume
5f14819e65 Update CHANGELOG.md
Added nwipe version & OS info to log [#297](https://github.com/martijnvanbrummelen/nwipe/pull/297)
2020-12-05 01:00:48 +00:00
PartialVolume
e06db0702b Bump minor version from .010 to .011 2020-12-05 00:56:12 +00:00
PartialVolume
1e02b754ff Merge pull request #297 from PartialVolume/add_nwipe_version_and_OS_info_to_log
This commit adds nwipes banner version number and OS info derived from /proc/version to the nwipe log. This information may be useful when a user has an issue and submits a log file.
2020-12-05 00:43:17 +00:00
PartialVolume
4a1690be59 Added /proc/version info to log 2020-12-05 00:32:46 +00:00
PartialVolume
b826ce9fc5 Bump minor version number to .010 i.e 0.29.010 2020-12-03 22:08:40 +00:00
PartialVolume
9ebed56d43 Update CHANGELOG.md
Added ..
[DONE] Right Justify log labels to maintain column alignment [#280](https://github.com/martijnvanbrummelen/nwipe/issues/280)
2020-12-03 22:07:03 +00:00
PartialVolume
c03ec324ba Merge pull request #296 from PartialVolume/Right_justify_log_message_labels
Right justify log labels.
2020-12-03 21:59:52 +00:00
PartialVolume
fb27ab8d55 Right justify log labels.
Right justify log labels in order to maintain column alignment
2020-12-03 21:56:23 +00:00
PartialVolume
c7d486f776 Merge pull request #295 from PartialVolume/master
Use past tense of fix, i.e. Fixed.
2020-12-02 14:52:10 +00:00
PartialVolume
69b125ba4d Use past tense of fix, i.e. Fixed. 2020-12-02 14:48:13 +00:00
PartialVolume
3e15e6ef3c Update CHANGELOG.md with changes since 0.28 2020-12-02 14:30:45 +00:00
PartialVolume
2e7de74202 Bumped proposed Rev to 0.30 CHANGELOG.md
Skip 0.29 due to minor revs being used i.e 0.29.009 etc. When 0.30 is released, changes to the minor number in the master rev will be 0.30.001 etc
2020-12-02 14:16:01 +00:00
PartialVolume
21b5190fc4 Merge pull request #294 from PartialVolume/fix_musl_libc_compatibility
Fixes musl libc compatibility on NixOS issue #275
2020-12-02 13:07:58 +00:00
PartialVolume
d61b9005c3 Fixes musl libc compatibility on NixOS issue #275 2020-12-02 13:03:18 +00:00
PartialVolume
13ecd9d268 Bump minor rev to .009 2020-12-02 11:08:32 +00:00
PartialVolume
e24d7992ef Merge pull request #293 from PartialVolume/Add_sudo_message
Add sudo/su help message
2020-12-02 11:05:39 +00:00
PartialVolume
948813a692 Add sudo/su help message 2020-12-02 10:55:08 +00:00
PartialVolume
4abff9e287 Replace init.sh with autogen.sh 2020-12-01 21:56:15 +00:00
PartialVolume
2102301382 Merge pull request #279 from louib/ci_formatting
Moving formatting to a new GH action.
2020-12-01 21:33:11 +00:00
PartialVolume
9b2f71d4e7 Merge pull request #284 from louib/rename_init_script
Rename init.sh -> autogen.sh
2020-12-01 21:15:56 +00:00
PartialVolume
c54a1296aa bump minor version on banner 2020-12-01 21:02:57 +00:00
PartialVolume
e543f54029 Merge pull request #292 from PartialVolume/Changes_to_the_sync_section_in_help
Added some additional info to sync help
2020-12-01 20:57:01 +00:00
PartialVolume
d4261b8e37 Added some additional info to sync help 2020-12-01 20:48:32 +00:00
PartialVolume
a7982c8579 Merge pull request #285 from andreasheil/master
Fix --sync option
2020-12-01 19:13:09 +00:00
Andreas Heil
9f6e2de116 Added constant for DEFAULT_SYNC_RATE 2020-11-23 12:11:08 +01:00
PartialVolume
337223a126 Merge pull request #288 from PartialVolume/Fix_footer_message_during_wipe
Fix incorrect footer message during wipe
2020-10-03 22:42:52 +01:00
PartialVolume
496e51d84e Fix incorrect footer message during wipe 2020-10-03 22:34:31 +01:00
Andreas Heil
ca6b829687 Fix display_help() to reflect new default for --sync option. 2020-08-23 13:52:15 +02:00
Andreas Heil
2f1e87f09b Fix --sync option not allowing 0 as legal input. 2020-08-23 13:50:30 +02:00
louib
eb1297913a Rename init.sh -> autogen.sh 2020-07-13 19:10:12 -04:00
louib
7c10bc85a3 Remove apt-cache search from formatting job. 2020-07-12 13:11:32 -04:00
louib
d830db3c1c Bumping to clang-format-7 2020-07-12 13:11:32 -04:00
louib
4075b4b50e missing deps. 2020-07-12 13:11:32 -04:00
louib
69d6d9708c Moving formatting to a new GH action. 2020-07-12 13:11:32 -04:00
PartialVolume
cbe1d83801 Update README.md
With link to ShredOS 2020
2020-07-12 02:08:51 +01:00
PartialVolume
0df4678fbc Update README.md - fix broken link 2020-05-29 12:06:25 +01:00
PartialVolume
18e542bad7 Update README.md 2020-04-26 18:50:25 +01:00
PartialVolume
24d294cf6f Merge pull request #273 from PartialVolume/Update_example_gif
Update the example gif
2020-04-26 17:42:20 +00:00
PartialVolume
08c2b54a3f Update the example gif
Update the example gif and add some explanatory text
to README.md
2020-04-26 18:35:54 +01:00
PartialVolume
8d8e2e3191 Merge pull request #272 from PartialVolume/Fix_nwipes_behaviour_if_S_key_repeats
Fix nwipes behaviour with repeated S key
2020-04-24 22:11:02 +00:00
PartialVolume
86f01f0b36 Fix nwipes behaviour with repeated S key
Prior to this patch if S key held down keyboard would
be unresponsive for x seconds.
Where x = number of S keystrokes x 3.

Now keys are delayed for no longer than 3 seconds
while warning message is displayed, long enough for
the user to read the warning message.
2020-04-24 23:03:59 +01:00
PartialVolume
0e92a9ddee Merge pull request #271 from PartialVolume/Fix_memory_leak
Fix memory leak
2020-04-23 21:53:59 +00:00
PartialVolume
33690b9e37 Fix memory leak
Detected by cppcheck
2020-04-23 22:47:50 +01:00
PartialVolume
b29ca4c29e Update README.md 2020-04-20 21:46:25 +01:00
PartialVolume
cf3c6f148b Update README.md no downloads data in api 2020-04-19 23:40:46 +01:00
PartialVolume
65d6ab45b6 Update README.md install of download badges 2020-04-19 23:33:30 +01:00
PartialVolume
d76868617a Update CHANGELOG.md 2020-04-17 23:45:47 +01:00
PartialVolume
bd59f5ac98 Merge pull request #270 from PartialVolume/Fix_fatal_errors_reported_on_ctrl_C
Fix_error_reporting_on_ctrl_C before wipe starts
2020-04-17 23:35:45 +01:00
PartialVolume
af30da3cc2 Fix_error_reporting_on_ctrl_C before wipe starts
If you do a ctrl c to exit nwipe before you have
even started a wipe, it will be reported in the logs
that there are fatal or non fatal errors. This is
incorrect as no wipe has even been started.

This error is only relevant to when using ctrl c
before a wipe has started and not after a wipe has
started.

Basically the variables that hold the errors are
in an indeterminate state before wiping begins and
in the case of a user abort we mistakenly checked
those values and reported. They should only be used
after a thread has completed or failed when their
values are then valid.

Now if you exit nwipe before any wiping started
there are no fatal/non fatal errors reported.
2020-04-17 23:31:00 +01:00
PartialVolume
4cc8a34bbc Merge pull request #267 from PartialVolume/Add_ctrl_a_toggle_for_drive_selection
Add ctrl a to select/deselect wipe for ALL drives.
2020-04-17 15:17:02 +01:00
PartialVolume
b3def7c336 Add ctrl a to select/deselect wipe, all drives.
To select or deselect all drives for wiping you can
now type ctrl a.

Useful for users that are wiping many drives
simultaneously.
2020-04-17 15:13:07 +01:00
PartialVolume
dc012e46b2 Update README.md 2020-04-17 07:07:49 +01:00
PartialVolume
88e2adf6a2 Merge pull request #265 from PartialVolume/No_drives_selected_warning
Warn user if no drives are selected, when attempting to start a wipe
2020-04-16 20:13:08 +01:00
PartialVolume
ddb0ca8c35 Warn user about no drives selected
If a user attempts to start a wipe but hasn't yet
selected any drives for wiping, a warning message
will now appear for a few seconds suggesting
they select a drive.

Prior to this patch, if you tried to start a wipe
without selecting a drive, nwipe would immediately
display a message saying the wipe was complete
and press enter to exit. You had no choice but to
exit and restart nwipe.
2020-04-16 20:06:33 +01:00
PartialVolume
b185818732 Update README.md 2020-04-16 14:19:07 +01:00
PartialVolume
1335455d7e Update README.md 2020-04-16 13:14:01 +01:00
PartialVolume
cf75391b93 Update README.md
Make it clear right at the start of the readme, that the latest version of nwipe is available as a bootable USB flash image
2020-04-16 13:12:16 +01:00
PartialVolume
082a4e53d6 Merge pull request #263 from PartialVolume/Warn_user_if_the_press_lower_case_s
Warn user if they press 's' instead of 'S'
2020-04-15 22:26:32 +01:00
PartialVolume
a4d5164602 Warn user if they press 's' instead of 'S'
I have come across a new user that couldn't start a wipe, until it was
pointed out that to start a wipe you needed to type shift S. While this
is often true, shift S doesn't start a wipe if you have caps lock on. To
be precise you need to type a capital S. Confusing to a new user because
if they have been told to type shift S but their caps lock is on, then
nothing happens. Also how would you know you are supposed to type a
capital S when the key info puts all keys in caps.

The fix for this is to trap the lower case s and then print a message on
the status line that says "Use capital S to start a wipe". This message
could remain on the status line for 3 seconds then revert back to the
standard key info.

The use of capital S is to try to reduce the likelihood of an accidental
wipe you didn't mean to start, however, I've always thought that maybe
we should have a 'are you sure ?' after the user types 'S' .
A non issue once you're familiar with nwipe but probably irritating to
a new user.
2020-04-15 22:01:56 +01:00
PartialVolume
7d93a44f18 Update README.md with revised shredos info 2020-04-14 13:06:18 +01:00
PartialVolume
52df4390f7 Merge pull request #259 from PartialVolume/Fix_minor_error_in_disc_block_size_pertains_to_log_display_only
Fix minor error in reporting block size in log
2020-04-08 22:28:34 +01:00
PartialVolume
92a6a76c51 Fix minor error in reporting block size in log
Fix a minor error in the reporting of the
discs total number of blocks. This only
affects reporting to the log file and
does not affect the programs operation.
2020-04-08 22:24:09 +01:00
PartialVolume
68ef665b2d Merge pull request #258 from PartialVolume/Remove_unnecssary_ATA_that_prefixes_some_model_numbers
Remove redundant ATA prefix from the model number.
2020-04-08 17:10:07 +01:00
PartialVolume
fcd35ea910 Remove redundant ATA prefix from the model number.
We already determine the bus type,
ATA, USB, NVME, VIRT (loop) etc
and display the bus type on the GUI.
libparted prefixes the model number
with ATA which we don't need, especially
as we try to keep the drive display length
to a maximum of 80 characters.
2020-04-08 17:05:06 +01:00
PartialVolume
5aded13bf7 Merge pull request #257 from PartialVolume/Summary_table_FAILED_should_take_precedence_over_UABORTED
Fix summary table message precedence
2020-04-08 11:14:56 +01:00
PartialVolume
5cd00da2a6 Fix summary table message precedence
Previously if a drive failed during
a multiple drive wipe and the user
decided to abort nwipe to say remove
the drive and start over, the user would
use CONTROl-C to abort. This would be
reflected in the summary table as ALL drives
having been aborted including the drive that
failed. It makes more sense for a failed drive
to be marked as failed in the summary table
even though the user aborted the wipe.

This patch fixes that, so that if a drive failed
it reflects that drives status in the summary
even if the user aborts the wipe.
2020-04-08 10:59:09 +01:00
PartialVolume
3ee514c395 Merge pull request #255 from martijnvanbrummelen/Update-README.md-with-latest-ShredOS-details
Update README.md with latest ShredOS details
2020-04-05 18:58:08 +01:00
PartialVolume
fe93c77e22 Update README.md with latest ShredOS details
Recompiled ShredOS with support for Smartmontools, C++ V7.x support. Nwipe in this version of ShredOS, now supports the display of serial numbers for USB bridges that have chipsets that support ATA pass through functionality.
2020-04-05 18:49:35 +01:00
PartialVolume
d3ac79bb0e Update README.md update img link 2020-04-02 23:15:50 +01:00
PartialVolume
2322c690a4 Merge pull request #252 from martijnvanbrummelen/PartialVolume-patch-1
Update README.md Add link to nwipe bootable master
2020-04-02 18:51:49 +01:00
PartialVolume
243d8a5e81 Update README.md Add link to nwipe bootable master 2020-04-02 18:48:17 +01:00
PartialVolume
4596c5f06d Merge pull request #251 from martijnvanbrummelen/PartialVolume-patch-1
Update README.md ShredOS download with nwipe master
2020-04-02 18:39:54 +01:00
PartialVolume
e91721d06b Update README.md ShredOS download with nwipe master
Build of ShredOS and download link with the latest nwipe master.
2020-04-02 18:14:31 +01:00
PartialVolume
2a6d6e10df Update CHANGELOG.md spelling mistake 2020-04-02 04:43:38 +01:00
PartialVolume
73b6b2ef6d Merge pull request #249 from PartialVolume/Fix_--nousb_missing_a_USB_drive
Fix --nousb missing a drive
2020-04-01 21:35:15 +01:00
PartialVolume
0488138c43 Fix --nousb missing a drive
If a USB device generated a particular error
code from smartmontools, the --nousb option
incorrectly did not exclude it from the
enumerated drives.

This has now been corrected.
2020-04-01 21:29:08 +01:00
PartialVolume
57eeab2292 Update CHANGELOG.md Fixed obscure segfault 2020-04-01 20:22:07 +01:00
PartialVolume
c3756e0f53 Merge pull request #248 from PartialVolume/Fix_segfault_when_scrolling_drive_selection_window
Fix obscure segfault when resizing terminal
2020-04-01 20:00:26 +01:00
PartialVolume
d140feb94b Fix obscure segfault when resizing terminal
This was a very obscure segmentation fault I
stumbled across while testing the drive
selection window. I confirmed it exists
in all versions at least going back prior
to 0.24 and maybe a lot earlier.

It was a very tricky bug to track down as you
had to do some very specific things to cause it to
occur. Probably most people would not have seen
it, however for those that did, this was what you
needed to do to trigger it.

1. First you had to be wiping more than one drive.

2. Then you needed to scroll down to the bottom
drive in the list.

3. You then needed to minimise the vertical height
of the terminal so you could no longer see the
selected drive.

4. Then you needed to expand the vertical height
of the terminal. This last step would trigger a
segmentation fault and crash nwipe.

So, the theory. nwipe uses four variables to
allow you to scroll through multiple displayed
drives. These four variables are:

count = the number of enumerated drives.

slots = the number of available horizontal lines
        to display the drives. The number of slots
        varies depending upon vertical resizing
        of the terminal. So slots is calculated
        in real time.

focus = which drive the GUI '>' pointer is pointing to.

offset = A value between 0 and slots that describes
         what drives are displayed in the available
         slots.

offset is then used along with i in a for loop to index
the drive contexts. This is where the segfault
occurred.

The calculation failed to take correct account of a varying
number of slots so in the condition described above the
offset would create an index that was out of bounds.

So first I fixed the miss calculation and second I placed
an if statement that acts as a bounds checker so if
ever this code is changed by someone in the future and
they break the calculation the bounds checker 'if' statement
will log the details of the error and prevent a segfault which
is far easier to debug.
2020-04-01 19:50:04 +01:00
PartialVolume
62beaca8ac Merge pull request #247 from PartialVolume/Add_NVME_to_bus_types_and_make_bus_types_4_digits
Add NVME & VIRT to device types.
2020-03-31 15:20:06 +01:00
PartialVolume
497fcb73b5 Add NVME & VIRT to device types.
Added NVME and VIRT to device type table.

VIRT are virtual devices such as loop devices
created with losetup.

NVME for solid state storage devices.

Due to the longer device names used for NVME, I will
need to do some work on the device name in the selection
window so column alignment is maintained.
2020-03-31 15:14:41 +01:00
PartialVolume
00085b403e Merge pull request #246 from PartialVolume/Add_Green_Red_color_to_SUCCESS_FAILURE_messages
Visually enhance failure messages
2020-03-30 22:19:41 +01:00
PartialVolume
fea6facadc Visually enhance failure messages
When a drive fails display the failure message
with red text on a white background.

This makes it more visually obvious a drive
failure has occurred.
2020-03-30 22:02:54 +01:00
PartialVolume
186bd9e03b Update CHANGELOG.md 2020-03-30 20:42:47 +01:00
PartialVolume
f5db72a983 Merge pull request #244 from PartialVolume/Use_nomenclature_function
Use nwipe's nomenclature function
2020-03-30 16:20:13 +01:00
PartialVolume
030338f1bd Use nwipe's nomenclature function
Benefits include:

1. Standard fixed width output for disk
throughput, combined throughput and disk
capacity. Allows for better column alignment
when wiping multiple drives.

2. Removal of about 40 lines of duplicated code.
2020-03-30 16:01:16 +01:00
PartialVolume
eee523d3d1 Merge pull request #243 from PartialVolume/Make_percentage_fixed_width
Make percentage width fixed.
2020-03-30 14:56:07 +01:00
PartialVolume
c3642e8904 Make percentage width fixed.
For drives that are wiping the percentage
completion is displayed. To retain column
alignment when wiping multiple drives, the
percentage values from 0.01% to 9.99% are
displayed with a leading space, i.e
[ 9.99%, then 10.00% to 99.99% is displayed
as, i.e [10.01%, etc..
2020-03-30 14:49:14 +01:00
PartialVolume
16a3b3c487 Merge pull request #242 from PartialVolume/Combine_writing_syncing_etc_fields_in_GUI
Combine [writing][blanking] fields
2020-03-30 14:26:21 +01:00
PartialVolume
fa9eb6892b Combine [writing][blanking] fields
When wiping a drive a status message is displayed
that show [writing] or [syncing] or [verifying] or
[blanking] etc. Previously there were two bracketed
fields, [syncing] occupied one field and all the others
occupied the other field.

To conserve screen space they all occupy the same
bracketed field.

The bracketed field is also now a fixed length of
9 characters padded with spaces as necessary to maintain
column alignment when wiping multiple drives simultaneously.
2020-03-30 14:22:19 +01:00
PartialVolume
3ed8dfd708 Merge pull request #241 from PartialVolume/Stop_throughput_calculation_once_wipe_has_finished
Fix individual drive throughput running after a wipe has finished
2020-03-30 09:21:31 +01:00
PartialVolume
cbe959455a Fix individual drive throughput running after
a wipe has finished.

This problem was not seen when wiping multiple drives
of the same size as they all ended at the same time.
Also not seen when wiping  a single drive, but if you
wiped multiple drives of different sizes where the
drive wipes ended at different times then you could
see the throughput being calculated as steadily dropping
for a drive that had completed it's wipe.

Also fixed overall throughput. When all wipes had completed
overall throughput showed the throughput of the last drive
that finished. It should show 0 B/s as all wiping had
ceased. In the log table you will see individual drive
throughput and overall throughput which is the sum of
all the drives throughputs.
2020-03-30 09:14:00 +01:00
PartialVolume
8e52c926ab Update README.md, readlink ( coreutils package ) 2020-03-28 22:10:05 +00:00
PartialVolume
22b08d43c8 Update CHANGELOG.md, fix hyperlinks 2020-03-27 21:51:46 +00:00
PartialVolume
98775a4837 Merge pull request #240 from PartialVolume/fix_readlink_missing_message
Fix incorrect readlink error message
2020-03-27 21:43:48 +00:00
PartialVolume
4fe7f4a697 Fix incorrect readlink error message 2020-03-27 21:40:56 +00:00
PartialVolume
ddfa194ed9 Merge pull request #239 from PartialVolume/add_no_usb_option
Add --nousb option.
2020-03-27 21:03:02 +00:00
PartialVolume
b9a9386d2f Add --nousb option.
If you use the option --nousb, all USB devices will be ignored.
They won't show up in the GUI and they won't be wiped if you use
the --nogui --autonuke command. They will even be ignored if you
specifically name them on the command line.
2020-03-27 20:57:33 +00:00
PartialVolume
8430befdc3 Update README.md 2020-03-27 00:19:16 +00:00
PartialVolume
dc692735ce Update README.md 2020-03-27 00:16:57 +00:00
PartialVolume
4e4c37dd4a Update CHANGELOG.md 2020-03-26 20:36:18 +00:00
PartialVolume
ac0fe876a1 Merge pull request #237 from PartialVolume/Correct_disk_capacity_nomenclature
Fix incorrect disk capacity nomenclature.
2020-03-26 20:09:51 +00:00
PartialVolume
e46e80277d Fix incorrect disk capacity nomenclature.
I've always wondered, when you first view
all the drives, why drives above 999GB appeared
in their GB nomenclature instead of TB. For
instance a 2TB drive would appear as 2000GB.
Unlike other places in nwipe that does a proper
job of describing capacity just this one location
in the program was wrong.

This information was obtained by a call to a function
in libparted. Maybe when libparted was written there
was no such thing as a TByte drive ?? Who knows, so
anyway it was far easier to use nwipes build in function
called 'determine_C_B_nomenclature()' This provides us
with the correct nomenclature that is a fixed number of
digits (three) and prefixed with spaces so the length
is always the same. In the GUI this gives a nice
list when viewing multiple drives that appears in neat
columns.
2020-03-26 19:41:07 +00:00
PartialVolume
ac9757dfe7 Merge pull request #236 from PartialVolume/Fix_search_for_dmidecode
Fix search method for dmidecode
2020-03-25 23:08:07 +00:00
PartialVolume
7af0dd57c7 Fix search method for dmidecode 2020-03-25 22:58:51 +00:00
PartialVolume
14d5178013 Merge pull request #235 from PartialVolume/smartctl_directory_search-2
Fix the way I look for smartctl & readlink
2020-03-25 22:31:25 +00:00
PartialVolume
2446db741f Fix the way I look for smartctl & readlink 2020-03-25 22:26:43 +00:00
PartialVolume
081051c25f Merge pull request #234 from PartialVolume/smartctl_directory_search-1
fix smartctl directory search
2020-03-25 18:27:22 +00:00
PartialVolume
055b90d4c7 fix smartctl directory search 2020-03-25 18:20:06 +00:00
PartialVolume
9789c4748f Merge pull request #233 from PartialVolume/Check_directories_for_smartmontools_and_readlink
Search extra directories for smartctl & readlink
2020-03-25 17:41:18 +00:00
PartialVolume
a2f70661b8 Search extra directories for smartctl & readlink
This is mainly required for Debian sid if using
su instead of su - to run nwipe.
2020-03-25 17:35:14 +00:00
PartialVolume
bb0019fe40 Merge pull request #232 from PartialVolume/tidy_smartctl_and_readlink_warning_messages
Tidy the smartctl & readlink warning messages
2020-03-25 15:07:41 +00:00
PartialVolume
186ec9172c Tidy the smartctl & readlink warning messages 2020-03-25 15:02:40 +00:00
PartialVolume
415f43c975 Update README.md 2020-03-25 10:11:00 +00:00
PartialVolume
5809d0febd Merge pull request #231 from PartialVolume/Fix_duplicated_serial_no
Fix duplicated serial number
2020-03-24 23:12:29 +00:00
PartialVolume
fdf3140249 Fix duplicated serial number
If any drive doesn't have a serial number it's
serial number field was populated with the previous
drives serial number.

This is fixed by this patch.
2020-03-24 23:07:39 +00:00
PartialVolume
2f7979476b Update README.md readlink smartmontools 2020-03-24 22:41:44 +00:00
PartialVolume
c53a93ec9c Update README.md 2020-03-24 22:39:56 +00:00
PartialVolume
6943e35a33 Merge pull request #230 from PartialVolume/Get_device_bus_type_and_serial_number
Add serial number support for USB devices
2020-03-24 21:07:27 +00:00
PartialVolume
541a002a99 Add serial number support for USB devices
Add serial number support for USB devices for USB
to IDE/SATA adapters. Note this will only work
with USB IDE/SATA adapters that support ATA pass
through. See #149 for further details of
supported devices.

This patch requires readlink and smartmontools (smartctl)
to be installed. If not installed the serial number for
supported USB hardware will be missing.

The device type, i.e USB or ATA is now shown on the selection
and wipe windows.
2020-03-24 21:01:05 +00:00
PartialVolume
c29185999e Update CHANGELOG.md - Fix system info - Debian Sid 2020-03-22 22:53:15 +00:00
PartialVolume
fc406d2346 Merge pull request #229 from PartialVolume/Check_for_dmidecode_in_sbin
Check for dmidecode in /sbin
2020-03-22 22:43:56 +00:00
PartialVolume
0c4493e11c Check for dmidecode in /sbin
In Debian Sid dmidecode is not found as /sbin is not
searched when nwipe only specifies 'dmidecode', so
if it fails then it will next try /sbin/dmidecode
which is where it's normally located if it's installed.

In ubuntu etc, the sudo environment is setup so /sbin
is automatically searched.
2020-03-22 22:34:50 +00:00
PartialVolume
acf296d25d Merge pull request #228 from PartialVolume/Fix_visual_syncing_annoyance
Make the [syncing] a bit easier on the eyes
2020-03-22 16:56:39 +00:00
PartialVolume
2738522bb8 Make the [syncing] a bit easier on the eyes
I don't know if it's just me, but I'm not keen on the
way the status line length changes every few seconds
depending on whether nwipe is syncing or not. So
while still retaining the syncing message I think
it looks better if when not syncing, [syncing] is
replaced with [-------]. This keeps the status line
length pretty much constant and I find it easier on
my eyes.
2020-03-22 16:33:41 +00:00
PartialVolume
34d86e9c19 Merge pull request #227 from PartialVolume/Fix_inaccurate_throughput_calculation
Fix throughput so it shows the average throughput
2020-03-22 10:41:39 +00:00
PartialVolume
8f10179120 Fix throughput so it shows the average throughput
Fix throughput so it shows the average throughput
calculated from the start of the wipe.

Because we currently use cached access to the disks
initially for a few seconds or minute the throughput looks high
as nwipes writes are cached in memory before being written to disc.

When we change to a non cached or nwipe buffered model the
throughput will reflect a throughput that is actual
disc throughput.

Using an averaged throughput means that when the wipe finishes it will show
a higher value than the previous calculation but this new calculation is the
actual averaged speed of the wipe and reflects a value that is closer to what
you would expect a given drive to exhibit.

For instance a 160GB WD1600AAJS using Dod-S, B+VL, using the old
calculation would finish with a throughput of 48MB/s, using the
new calculation it finishes with a throughput of 76MB/s. This was tested
over multiple wipes and multiple rounds and gave consistently similiar
results.

Throughput is not so accurate on small loop drives due to the fact the drive
is so small it fits within CPU memory so when reading back to verify your're
actually reading back from cache not the disk. Another reason I want to move
to non cached I/O and have nwipe manage buffering and size of block writes.
2020-03-22 10:37:03 +00:00
PartialVolume
2b225f5cb9 Merge pull request #225 from PartialVolume/Add_ETA_to_status_when_SIGUSR1_received
Add eta to status when sigusr1 received
2020-03-20 18:57:09 +00:00
PartialVolume
8d31f2cf4a Update CHANGELOG.md 2020-03-20 18:05:51 +00:00
PartialVolume
d59e0323de Add ETA to to status when nwipe is sent a SIGUSR1
If a sudo kill -s USR1 (Nwipe's PID) is issued
on the command line while nwipe is operating in
--nogui mode, ETA is now displayed along with
percentage completion, pass and round information.

Note! Because we rely upon cached I/O at the moment
the calculated ETA early in the wipe is very inaccurate
but becomes more accurate as CPU memory cache is filled.
2020-03-20 17:52:35 +00:00
PartialVolume
7ac7c80731 Update CHANGELOG.md - --nogui drive stats 2020-03-19 22:00:01 +00:00
PartialVolume
a1e6e3bd52 Merge pull request #224 from PartialVolume/fix_summary_duration_during_shutdown_in_middle_of_wipe
Fix incorrect summary duration during shutdown
2020-03-19 21:20:19 +00:00
PartialVolume
62a8e76205 Fix incorrect summary duration during shutdown
If the system is shutdown while nwipe is still
wiping, the duration calculation would be
incorrect. This patch fixes that problem, so for
instance if a UPS signals the system running nwipe to
shutdown, nwipe typically traps that signal and
exits in an orderly manner. The log summary
is generated showing the wipe was aborted and
the wipe duration shows a valid value i.e the
elapsed time since the start of the wipe.
2020-03-19 21:09:02 +00:00
PartialVolume
fbfcbf8d34 Merge pull request #223 from PartialVolume/create_nwipe_log_summary_table
Add a summary table to the log that shows each drives status
2020-03-18 23:57:01 +00:00
PartialVolume
6c99166b75 Add a summary table to the log that shows each drives status
Add a summary table to the log that shows each drives status
i.e. erased or failed, throughput, duration of wipe, model,
serial no etc. In particular it benefits those that wipe many
drives simultaneously in rack servers. At a glance any failed
drives can be seen without having to browse back through the
log. Especially useful in --nogui mode, but also useful in GUI
mode.
2020-03-18 23:42:44 +00:00
PartialVolume
a022fffacb Update README.md 2020-03-14 11:51:11 +00:00
PartialVolume
ec9a322683 Update README.md - changes to automation section 2020-03-14 09:00:29 +00:00
PartialVolume
e6dd32a74b Update README.md 2020-03-14 08:56:01 +00:00
PartialVolume
523351531c Update README.md 2020-03-14 08:54:04 +00:00
PartialVolume
1d83fd6f8f Merge pull request #221 from louib/version_badge
Adding version badge to README.
2020-03-14 07:04:22 +00:00
louib
74243d392d Adding version badge to README. 2020-03-13 21:35:04 -04:00
PartialVolume
06fe803eb1 Merge pull request #220 from PartialVolume/create_spinner
Add a spinner to the GUI for each drive
2020-03-13 23:49:55 +00:00
PartialVolume
298ee05b8c Merge branch 'master' into create_spinner 2020-03-13 23:48:56 +00:00
PartialVolume
4928eb094e Add a spinner to the GUI for each drive
Add a spinner to the GUI for each drive being wiped.
When nwipe is syncing the percentage completion pauses,
having a spinner gives a clear indication that the wipe
is still running. Each devices spinner disappears on completion
of a given devices wipe.
2020-03-13 23:43:32 +00:00
PartialVolume
9caceaa75d Update CHANGELOG.md 2020-03-13 18:06:20 +00:00
PartialVolume
75fce57ab4 Merge pull request #219 from PartialVolume/reduce_unneccesary_lines_in_log_while_retaining_info
Reduce unnecessary lines in log while retaining info
2020-03-13 17:51:32 +00:00
PartialVolume
e955725fc5 Style formatting 2020-03-13 17:48:20 +00:00
PartialVolume
1c1b25e1ae Keep nwipe_log notices succinct
1. Keep nwipe_log notices succinct and below 80 chars in length including
timestamp. This is especially relevant for 80x30 terminal use such
as ALT-F2 etc or Shredos without losing any information.

2. Add [SUCCESS] to blanked & verified messages to make them stand out for quicker checking.
2020-03-13 17:24:08 +00:00
PartialVolume
d4963092dd Update README.md 2020-03-13 08:42:39 +00:00
PartialVolume
1083207d49 Update README.md with automation script
This script will install all the necessary libraries and software to compiling nwipe, download the latest master version of nwipe and run it, all with a single command ./buildnwipe
2020-03-13 01:22:01 +00:00
PartialVolume
458a3d780f Update CHANGELOG.md, adding verbose option to 0.29
Add verbose option -v, --verbose
Only display thread cancellation info messages, excluding error
messages, only when verbose option is selected.

This helps to keep the log a bit cleaner especially when wiping many
drives simultaneously.
2020-03-12 13:03:09 +00:00
PartialVolume
08c9cbe9f1 Merge pull request #217 from PartialVolume/add_verbose_option
Add verbose option
2020-03-12 12:59:13 +00:00
PartialVolume
e9caad3bef Add verbose option
Add verbose option -v, --verbose
Only display thread cancellation info messages, excluding error
messages, only when verbose option is selected.

This helps to keep the log a bit cleaner especially when wiping many
drives simultaneously.
2020-03-12 12:55:10 +00:00
PartialVolume
50e7cfaa7b Merge pull request #216 from PartialVolume/master
Update CHANGELOG.md
2020-03-12 00:45:15 +00:00
PartialVolume
ea39f57afb Update CHANGELOG.md 2020-03-12 00:38:25 +00:00
PartialVolume
880823cc9b Merge pull request #215 from PartialVolume/add_auto_poweroff
Add auto poweroff, fix non working nowait option.
2020-03-12 00:05:20 +00:00
PartialVolume
7d3a3c5f1e format code style 2020-03-12 00:00:06 +00:00
PartialVolume
e33c1bb06d Add --autopoweroff option
Fix non working --nowait option.
Update version info to 0.29-release candidate
2020-03-11 23:44:11 +00:00
35 changed files with 4243 additions and 1100 deletions

View File

@@ -77,4 +77,3 @@ Standard: Cpp11
TabWidth: 4
UseTab: Never
...

2
.codespellrc Normal file
View File

@@ -0,0 +1,2 @@
[codespell]
skip = ./.git

View File

@@ -1,24 +1,21 @@
name: ci_ubuntu_16.04
name: ci_formatting
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-16.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: updating available system dependencies
run: sudo apt-get update
- name: installing system dependencies
run: sudo apt-get install -y build-essential pkg-config automake libncurses5-dev autotools-dev libparted-dev dmidecode clang-format-5.0
run: sudo apt-get install -y build-essential pkg-config automake libncurses5-dev autotools-dev libparted-dev dmidecode clang-format-7
- name: creating autoconf files
run: ./init.sh
run: ./autogen.sh
- name: configuring
run: ./configure CFLAGS='-O0 -g -Wall -Wextra'
- name: compiling
run: make
# Changing the path should no longer be necessary when clang-format6 is installed.
- name: verifying code style
run: export PATH=$PATH:/usr/lib/llvm-5.0/bin && make check-format
run: make check-format

21
.github/workflows/ci_ubuntu_18.04.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: ci_ubuntu_18.04
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- name: updating available system dependencies
run: sudo apt-get update
- name: installing system dependencies
run: sudo apt-get install -y build-essential pkg-config automake libncurses5-dev autotools-dev libparted-dev dmidecode
- name: creating autoconf files
run: ./autogen.sh
- name: configuring
run: ./configure CFLAGS='-O0 -g -Wall -Wextra'
- name: compiling
run: make

View File

@@ -12,13 +12,10 @@ jobs:
- name: updating available system dependencies
run: sudo apt-get update
- name: installing system dependencies
run: sudo apt-get install -y build-essential pkg-config automake libncurses5-dev autotools-dev libparted-dev dmidecode clang-format-5.0
run: sudo apt-get install -y build-essential pkg-config automake libncurses5-dev autotools-dev libparted-dev dmidecode
- name: creating autoconf files
run: ./init.sh
run: ./autogen.sh
- name: configuring
run: ./configure CFLAGS='-O0 -g -Wall -Wextra'
- name: compiling
run: make
# Changing the path should no longer be necessary when clang-format6 is installed.
- name: verifying code style
run: export PATH=$PATH:/usr/lib/llvm-5.0/bin && make check-format

View File

@@ -1,25 +1,112 @@
RELEASE NOTES
=============
v0.33
-----------------------
- Fixes a slight screen corruption on 80 column display. When highlighting the verify ones option the first two digits of DoD 5220.20-M disappear. This patch fixes that issue.@PartialVolume #348
- For some controllers/drivers the readlink method of obtaining the bus type for GUI display does not work. If we haven't already resolved the bus type, we then also check smartctl for the transport protocol for SAS. @PartialVolume #350
- Check smartctl for unresolved bus types SATA @PartialVolume #358
- Changed message from (No ATA pass-thru) to (S/N: unknown) as the reason the serial number is unknown is because there is no ATA pass through for the chipset being used by the USB to SATA adapter, basically we are making the message more meaningful for the end user rather than for the engineer/programmer that may understand the previous terminology used. @PartialVolume @Firminator #356
- Add drive temperature monitoring and display temperature in degrees Celsius in the GUI. Requires the kernel drivetemp module and makes use of the hwmon sub system in the kernel to extract drive temperatures. Nwipe will automatically load the drivetemp module if it's available. @PartialVolume #360 #361 #364
- Remove /dev/ from gui for long device names. This fixes column alignment issues in the gui with nvme drives i.e. nvme0n1 etc. If the drive name including path exceeds 8 characters the /dev/ is removed and prefixed with spaces to a total max length of 8 characters. @PartialVolume #365
- Add -q --quiet option - anonymize serial numbers and SMBIOS-DMI data. This anonymizes serial numbers and related identifiable information for drives and hardware but does not remove model information in both the GUI and the log displayed by stdout at the end of a wipe and also in the log file if enabled in options. This feature is useful for uploading logs when submitting bug reports. @PartialVolume #366 #367 #371 #379 #383
- Fixes a intermittent FAILED message that is displayed in the summary table when the message should have been UABORTED. The incorrect FAILED message only occurred when using control-C to abort a wipe. @PartialVolume #373
- When many verification or pass errors are detected the status line can wrap on a 80 column display. This patch makes the error message more succinct which will free up about 10 characters & prevents the line wrapping. @PartialVolume #374
- Fixes a problem that occurs with a unresponsive drive that causes the ETA to grow to an enormous value. We now do not calculate an individual drives ETA when the throughput of the drive is zero so avoiding the overall ETA being incorrect for drives that are working correctly when multiple drives are being simultaneously wiped. While a individual drives ETA is calculated it is not displayed but only used to determine the overall ETA when all drives have completed. @PartialVolume #375
- Add temperature monitoring and display with NVMe drives. @PartialVolume #377 #380 #381
- When one of the two verify only methods are selected change the drive selected text from WIPE to VRFY to indicate the drive is not being wiped, but is only being verified. @PartialVolume #378
- Fixes a incorrect sector, block and device sizes in 32 bit builds only as displayed in the nwipe log. This problem had no affect on the wipe as the issue was caused by a incorrect format specifier that affected the log text only. @PartialVolume #387 #388
- Fixes a issue where temperatures may not have been available on Debian systems due to the location of modprobe. Particularly relevant to Debian which when logged in as root doesn't put /sbin in the $PATH environment setting. This issue was not necessarily relevant for Linux distros based on Debian, for instance, Ubuntu where nwipe would have found the modprobe command. @PartialVolume #390 #391
- Improve wipe thread cancellation error checking. @PartialVolume #392
- Improve GUI thread messaging if a pthread_join fails. @PartialVolume #393
- Fixed a missing serial number on SAS drive.@PartialVolume #394
- Added ISAAC-64 for 64 bit systems. Thanks @chkboom #398 #401
- Fixes a problem with the Gutmann wipe where the random passes at the beginning and end were being re-arranged when only the inner passes should be rearranged. Thanks @chkboom #399
- Fixes a obscure incorrect summary table status, while the log text correctly reports the failure. If the drive becomes non responsive during the wipe, the MB/s throughput will slowly drop towards 0MB/s and will display a FAILURE -1 error. The logs will correctly display errors and nwipe's return status will be non zero, however the summary table may display erased rather than FAILURE, this is because
the wipe thread exited prematurely without setting the pass error. This fixes the error by checking the context's result status, i.e non zero on failure and if pass equals zero it makes pass equal to one. This is then picked up by the summary table log code which then marks the status
correctly as FAILURE in the summary table. @PartialVolume #400
- Fixes a spurious message on abort before wipe.This patch fixes a minor display issue that occurs when a user aborts a wipe before a wipe has started. It only occurs if the user had selected one or more drives for wipe and then aborted before starting the wipe. The spurious message only occurs in a virtual terminal, i.e. /dev/tty1, /dev/tty2, /dev/console It does not occur in terminal applications such as konsole, xterm, terminator etc. The spurious message that appears in the main window, states that "/dev/sdxyz 100% complete" along with garbage values in the statistics window. The message appears for a fraction of a second before being replaced with the textual log information that correctly states that the user aborted and no wipe was started. Basically the gui status information update function tries to update the data when the wipe hasn't even started. The fix is to only update the statistics information only if a wipe has started by checking the 'global_wipe_status' value which indicates whether any wipe started. '1' indicates that a wipe has started, else '0' if no wipe has started. @PartialVolume #406
- Fixes temperature update in drive selection window. This fixes a problem where the drive temperature is not updated
automatically in only the drive selection window. The temperature is however updated correctly every 60 seconds during a wipe in the wipe status window. This bug would probably never be noticed by most people as usually the drive temperature changes slowly and only rises once a wipe has started. The only time I imagine it would have been noticed would have been if the drive temperature was already high and you were trying to reduce the temperature by cooling before starting a wipe. This has now been corrected so that the temperature in the drive
selection window is updated every 60 seconds. @PartialVolume #407
- Fixes a zombie nwipe process running at 100% CPU on one core but only on a Konsole based terminal. This only occurred when the Konsole terminal is exited while nwipe is sitting at the drive selection screen but nwipe did not exit when the konsole terminal was closed. If nwipe is exited normally on completion of a wipe or aborted by using control C then this problem would not be seen. Also occurs during a wipe if the konsole terminal is closed without exiting nwipe first, again only on Konsole based terminals. @PartialVolume #408 #409
- Fixes a obscure segfault when --logfile option used with a non writable directory. @PartialVolume #410
v0.32
-----------------------
- Add ones (0xFF) wipe to the methods. Renamed Zero Fill to Fill with Zeros and the new ones wipe, is called Fill with Ones.
- Add ones verication to the methods. Renamed Verify Blank to Verify Zeros (0x00) and the new verification is called Verify Ones (0xFF).
- Move method information from below the list of methods to the right of the method list. This allows better use of the screen space by allowing more methods to be added to the list, especially relevant to nwipe running as a standalone application on small distros such as shredos 2020 in frame buffer mode.
- Removed the old DBAN syslinux.cfg configuration hints as not relevant to nwipe. See nwipe --help or man nwipe for command line options.
- Add fdatasync errors to the error summary table.
- During a wipe, you can now toggle between dark screen, blank screen and default blue screen by repeatedly pressing the b key. Dark screen, which is grey text on black background has been introduced to prevent TFT/LCD image persistence on monitors that are sensitive to that issue.
v0.31
-----------------------
- Blanking disabled in GUI for OPS2 (mandatory requirement of standard). [#326](https://github.com/martijnvanbrummelen/nwipe/pull/326)
- Total bytes written/read for ALL passes or verifications are now logged. [#326](https://github.com/martijnvanbrummelen/nwipe/pull/326)
- Final blanking being enabled is no longer required for verification passes. GUI Fix. [#326](https://github.com/martijnvanbrummelen/nwipe/pull/326)
- Add a summary table to the log that shows totals for pass & verification errors. [#325](https://github.com/martijnvanbrummelen/nwipe/pull/325)
- Fix the missing 'Verifying' message on final blanking. [#324](https://github.com/martijnvanbrummelen/nwipe/pull/324)
- Fix prng selection always using mersenne irrespective of whatever prng the user selected. [#323](https://github.com/martijnvanbrummelen/nwipe/pull/323)
- Fix a non functional Isaac prng. (May have never worked even in DBAN/dwipe 2.3.0). [#322](https://github.com/martijnvanbrummelen/nwipe/pull/322)
- Log whether the prng produces a stream, if not log failure message. [#321](https://github.com/martijnvanbrummelen/nwipe/pull/321)
- Log the specific prng that is initialised. [#320](https://github.com/martijnvanbrummelen/nwipe/pull/320)
- Log selection details to the log. [#319](https://github.com/martijnvanbrummelen/nwipe/pull/319)
- Improve log messaging. [#317](https://github.com/martijnvanbrummelen/nwipe/pull/317)
- Fix auto shutdown option for some distros. [#315](https://github.com/martijnvanbrummelen/nwipe/pull/315)
- Fix build for musl. [#301](https://github.com/martijnvanbrummelen/nwipe/pull/301)
- Fixes to summary table & fix final status message. [311](https://github.com/martijnvanbrummelen/nwipe/pull/311/commits/12063ad9549860cd625cb91d047bd304217a9ebf)
- Updates to --help options [#309](https://github.com/martijnvanbrummelen/nwipe/pull/309/commits/69c9d7d6c5a091c58b3e747078d0022ccdd95a99)
- Updates to manpage. [#300](https://github.com/martijnvanbrummelen/nwipe/commit/7cc1a68a89236c4b501dde9149be82c208defccd)
v0.30
-----------------------
- Add auto power off option on completion of wipe ( --autopoweroff ) (Thanks PartialVolume)
- Fixed --nowait option that wasn't working. (Thanks PartialVolume)
- Add verbose option. -v, --verbose.
- Add a spinner to the GUI for each drive being wiped. When nwipe is syncing the percentage completion pauses, having a spinner gives a clear indication that the wipe is still running. Each devices spinner disappears on completion of a given devices wipe. (Thanks PartialVolume)
- Make log messages, especially the ones with the tag 'notice' succinct and less than 80 characters including the timestamp. This is of more importance when nwipe is used on a 80x30 terminal (ALT-F2, Shredos etc) but generally makes the logs more readable. While doing this all information was still retained. (Thanks PartialVolume)
- Add a summary table to the log that shows each drives status, i.e. erased or failed, throughput, duration of wipe, model, serial no etc. In particular it benefits those that wipe many drives simultaneously in rack servers. At a glance any failed drives can be seen without having to browse back through the log. (Thanks PartialVolume)
- Add ETA to --nogui wipes status when SIGUSR1 (kill -s USR1 (nwipes PID) is issued on the command line.
- Fixed misleading throughput calculation. Throughput now shows average throughput calculated from start of wipe.
- Fixed system info not being displayed in Debian Sid. [#229](https://github.com/martijnvanbrummelen/nwipe/issues/229) (Thanks PartialVolume)
- Add serial number display for USB to IDE/SATA adapters. This only works if the USB to IDE/SATA adapter supports ATA pass through. See [#149](https://github.com/martijnvanbrummelen/nwipe/issues/149) for further details (Thanks PartialVolume)
- Fixed disk capacity nomenclature, width and padding on drive selection screen. See [#237](https://github.com/martijnvanbrummelen/nwipe/issues/237) (Thanks PartialVolume)
- Add bus type, ATA or USB, amongst others to drive selection and wipe windows. (Thanks PartialVolume)
- Add --nousb option. If you use the option --nousb, all USB devices will be ignored. They won't show up in the GUI and they won't be wiped if you use the --nogui --autonuke command. They will even be ignored if you specifically name them on the command line.
- Miscellaneous GUI fixes, throughput display format, percentage display format to improve column alignment when wiping multiple discs. (Thanks PartialVolume)
- Improve visibility of failure messages with red text on white background. (Thanks PartialVolume)
- Add NVME and VIRT (loop etc) devices to device type table for display in GUI and logs. NVME devices now show up as NVME devices rather than UNK (Thanks PartialVolume)
- Fixed very obscure segmentation fault going back to at least 0.24 in drive selection window when resizing terminal vertical axis while drive focus symbol '>' is pointing to the last drive of a multi drive selection window. See [#248](https://github.com/martijnvanbrummelen/nwipe/pull/248) for further details (Thanks PartialVolume)
- Warn the user if they are incorrectly typing a lower case s to start a wipe, when they should be typing a capital S [#262](https://github.com/martijnvanbrummelen/nwipe/issues/262) (Thanks PartialVolume)
- Warn the user if they are typing capital S in order to start a wipe but haven't yet selected any drives for wiping [#261](https://github.com/martijnvanbrummelen/nwipe/issues/261) (Thanks PartialVolume)
- Add ctrl A that toggles drive selection, all drives selected for wipe or all drives deselected. [#266](https://github.com/martijnvanbrummelen/nwipe/issues/266)
- Fixed compilation issue with NixOS with broken musl libc error due to missing header [#275](https://github.com/martijnvanbrummelen/nwipe/issues/275)
- Fixed status bar message showing incorrect information [#287](https://github.com/martijnvanbrummelen/nwipe/issues/287)
- Right Justify log labels to maintain column alignment [#280](https://github.com/martijnvanbrummelen/nwipe/issues/280)
- Added nwipe version & OS info to log [#297](https://github.com/martijnvanbrummelen/nwipe/pull/297)
v0.28
-----------------------
- Fix premature exit when terminal resized on completion of wipes (Thanks PartialVolume)
- Fix GUI when terminal is resized, currently not handled correctly causing missing or incorrectly sized ncurses windows/panels (Thanks PartialVolume)
- Fix GUI screen flicker under various situations. [#200](https://github.com/martijnvanbrummelen/nwipe/pull/200) Fixes [#115](https://github.com/martijnvanbrummelen/nwipe/issues/115) (Thanks PartialVolume)
- Fix responsivness of screen during wipe when resized. Info is updated every 10th/sec. Key presses are more responsive. (Thanks PartialVolume)
- Fix compiler warning regarding buffer overflow. Fixes [#202](https://github.com/martijnvanbrummelen/nwipe/issues/202) (Thanks PartialVolume)
- Fix Man page (Thanks martijnvanbrummelen)
- Fix individual device throughput. On completion of a wipe instead of the throughput calculation stopping for a completed wipe, it would continue to calculate resulting in a particular drives throughtput slowly dropping until eventually it reached zero. The overall throughput was not affected. (Thanks PartialVolume)
- Fixed premature exit when terminal resized on completion of wipes (Thanks PartialVolume)
- Fixed GUI when terminal is resized, currently not handled correctly causing missing or incorrectly sized ncurses windows/panels (Thanks PartialVolume)
- Fixed GUI screen flicker under various situations. [#200](https://github.com/martijnvanbrummelen/nwipe/pull/200) Fixes [#115](https://github.com/martijnvanbrummelen/nwipe/issues/115) (Thanks PartialVolume)
- Fixed responsivness of screen during wipe when resized. Info is updated every 10th/sec. Key presses are more responsive. (Thanks PartialVolume)
- Fixed compiler warning regarding buffer overflow. Fixes [#202](https://github.com/martijnvanbrummelen/nwipe/issues/202) (Thanks PartialVolume)
- Fixed Man page (Thanks martijnvanbrummelen)
- Fixed individual device throughput. On completion of a wipe instead of the throughput calculation stopping for a completed wipe, it would continue to calculate resulting in a particular drives throughtput slowly dropping until eventually it reached zero. The overall throughput was not affected. (Thanks PartialVolume)
v0.27
-----------------------
- Add `verify` method to verify a disk is zero filled [#128](https://github.com/martijnvanbrummelen/nwipe/pull/128) (Thanks Legogizmo)
- Add new HMG IS5 enhanced wipe method [#168](https://github.com/martijnvanbrummelen/nwipe/pull/168) (Thanks infrastation)
- Fix percentage progress and show on completion of wipe (Thanks PartialVolume)
- Fixed percentage progress and show on completion of wipe (Thanks PartialVolume)
- Implement clang-format support (Thanks louib)
- Implement more frequent disk sync support (Thanks Legogizmo)
- Format command line help to 80 character line length [#114](https://github.com/martijnvanbrummelen/nwipe/pull/114) (Thanks PartialVolume)
- Fix nwipe message log and missing messages that was causing segfaults under certain conditions (Thanks PartialVolume)
- Fixed nwipe message log and missing messages that was causing segfaults under certain conditions (Thanks PartialVolume)
- Add the Github build CI service and update Readme with build status labels (Thanks louib)
- Miscellaneous smaller fixes
@@ -32,12 +119,12 @@ v0.26
v0.25
-----
- Correct J=Up K=Down in footer (Thanks PartialVolume)
- Fix segfault initialize `nwipe_gui_thread` (Thanks PartialVolume)
- Fix memory leaks (Thanks PartialVolume)
- Fixed segfault initialize `nwipe_gui_thread` (Thanks PartialVolume)
- Fixed memory leaks (Thanks PartialVolume)
- Check right pointer (Thanks PartialVolume)
- Fix casting problem (Thanks PartialVolume)
- Fix serial number
- Fixes uninitialized variable warning (Thanks PartialVolume)
- Fixed casting problem (Thanks PartialVolume)
- Fixed serial number
- Fixed uninitialized variable warning (Thanks PartialVolume)
v0.24
-----
@@ -56,15 +143,15 @@ v0.22
v0.21
-----
- Fix ETA not updating properly and bad total throughput display. (Thanks Niels Bassler).
- Fixed ETA not updating properly and bad total throughput display. (Thanks Niels Bassler).
v0.20
-----
- Fix build when panel header is not in `/usr/include` (Thanks Vincent Untz).
- Fixed build when panel header is not in `/usr/include` (Thanks Vincent Untz).
v0.19
-----
- Fix building on Fedora(Unknown `off64_t`) bug #19.
- Fixed building on Fedora(Unknown `off64_t`) bug #19.
- Use PRNG instead of zero's bug #7. (Thanks xambroz).
v0.18
@@ -81,11 +168,11 @@ v0.17
- Remove control reaches end of non-void function" warnings (Thanks Vincent Untz).
- Remove unused variables (Thanks Vincent Untz).
- Change start key to 'S' instead of F10 (closes debian bug #755474).
- Fix problem with unusable device (Closes debian bug #755473).
- Fixed problem with unusable device (Closes debian bug #755473).
v0.16
-----
- Fix problems building with clang compiler (Thanks Martijn van Brummelen)
- Fixed problems building with clang compiler (Thanks Martijn van Brummelen)
v0.15
-----

121
README.md
View File

@@ -1,44 +1,55 @@
# nwipe
![GitHub CI badge](https://github.com/martijnvanbrummelen/nwipe/workflows/ci_ubuntu_latest/badge.svg)
![GitHub CI badge](https://github.com/martijnvanbrummelen/nwipe/workflows/ci_ubuntu_16.04/badge.svg)
[![GitHub release](https://img.shields.io/github/release/martijnvanbrummelen/nwipe)](https://github.com/martijnvanbrummelen/nwipe/releases/)
nwipe is a program that will securely erase disks. It can operate as both a command line
tool without a GUI or with an ncurses GUI as shown in the example below. It can wipe multiple
disks simultaneously.
nwipe is a fork of the dwipe command originally used by Darik's Boot and Nuke (DBAN). nwipe was created out of a need to run the DBAN dwipe command outside of DBAN, in order to allow its use with any host distribution, thus giving better hardware support.
nwipe is a program that will securely erase the entire contents of disks. It can wipe a single drive or multiple disks simultaneously. It can operate as both a command line tool without a GUI or with a ncurses GUI as shown in the example below:
![Example wipe](/images/example_wipe.gif)
<i>GIF showing six drives being simultaneously erased. It skips to the completion of all six wipes and shows five drives that were successfully erased and one drive that failed due to an I/O error. The drive that failed would then normally be physically destroyed. The five drives that were successfully wiped with zero errors or failures can then be redeployed.</i>
The user can select from a variety of recognised secure erase methods which include:
* Zero Fill - Fills the device with zeros, one round only.
* Fill With Zeros - Fills the device with zeros (0x00), one round only.
* Fill With Ones - Fills the device with ones (0xFF), one round only.
* RCMP TSSIT OPS-II - Royal Candian Mounted Police Technical Security Standard, OPS-II
* DoD Short - The American Department of Defense 5220.22-M short 3 pass wipe (passes 1, 2 & 7).
* DoD 5220.22M - The American Department of Defense 5220.22-M full 7 pass wipe.
* Gutmann Wipe - Peter Gutmann's method (Secure Deletion of Data from Magnetic and Solid-State Memory).
* PRNG Stream - Fills the device with a stream from the PRNG.
* Verify only - This method only reads the device and checks that it is all zero.
* Verify Zeros - This method only reads the device and checks that it is filled with zeros (0x00).
* Verify Ones - This method only reads the device and checks that it is filled with ones (0xFF).
* HMG IS5 enhanced - Secure Sanitisation of Protectively Marked Information or Sensitive Information
It also includes the following pseudo random number generators:
nwipe also includes the following pseudo random number generators:
* Mersenne Twister
* ISAAC
It is a fork of the dwipe command used by
Darik's Boot and Nuke (dban). nwipe is included with [partedmagic](https://partedmagic.com) and
[ShredOS](https://github.com/nadenislamarre/shredos) if you want a quick and easy bootable CD or USB version.
These can be used to overwrite a drive with a stream of randomly generated characters.
Nwipe was created out of a need to run the DBAN dwipe command outside
of DBAN, in order to allow its use with any host distribution, thus
giving better hardware support.
nwipe can be found in many [Linux distro repositories](#which-linux-distro-uses-the-latest-nwipe).
![Example wipe](/images/example_wipe.gif)
nwipe is also included in [ShredOS](https://github.com/PartialVolume/shredos.x86_64) which was developed in particular to showcase nwipe as a fast-to-boot standalone method similar to DBAN. ShredOS always contains the latest nwipe version.
## Compiling & Installing
For a development setup, see the [Hacking section](#hacking) below. For a bootable version of the very latest nwipe master that you can write to an USB flash drive or CD/DVD, see the [Quick and easy bootable version of nwipe master section](#quick--easy-usb-bootable-version-of-nwipe-master-for-x86_64-systems) below.
`nwipe` requires the following libraries to be installed:
* ncurses
* pthreads
* parted
and optionally, but recommended, the following programs:
* dmidecode
* readlink
* smartmontools
### Debian & Ubuntu prerequisites
If you are compiling `nwipe` from source, the following libraries will need to be installed first:
@@ -51,7 +62,9 @@ sudo apt install \
libncurses5-dev \
autotools-dev \
libparted-dev \
dmidecode
dmidecode \
coreutils \
smartmontools
```
### Fedora prerequisites
@@ -64,21 +77,33 @@ dnf groupinstall "C Development Tools and Libraries"
yum install ncurses-devel
yum install parted-devel
yum install dmidecode
yum install coreutils
yum install smartmontools
```
Note. dmidecode is optional, it provides SMBIOS/DMI host data to stdout or the log file.
Note. The following programs are optionally installed although recommended. 1. dmidecode 2. readlink 3. smartmontools.
#### dmidecode
dmidecode provides SMBIOS/DMI host data to stdout or the log file. If you don't install it you won't see the SMBIOS/DMI host data at the beginning of nwipes log.
#### coreutils (provides readlink)
readlink determines the bus type, i.e. ATA, USB etc. Without it the --nousb option won't work and bus type information will be missing from nwipes selection and wipe windows. The coreutils package is often automatically installed as default in most if not all distros.
#### smartmontools
smartmontools obtains serial number information for supported USB to IDE/SATA adapters. Without it, drives plugged into USB ports will not show serial number information.
If you want a quick and easy way to keep your copy of nwipe running the latest master release of nwipe see the [automating the download and compilation](#automating-the-download-and-compilation-process-for-debian-based-distros) section.
### Compilation
For a development setup, see [the hacking section below](#Hacking).
First create all the autoconf files:
```
./init.sh
./autogen.sh
```
Then compile & install using the following standard commands:
```
./configure
make format (only required if submitting pull requests)
make
make install
```
@@ -100,14 +125,12 @@ This can be done using the following compile commands:
```
./configure --prefix=/usr CFLAGS='-O0 -g -Wall -Wextra'
make format (necessary if submitting pull requests)
make
make install
```
The `-O0 -g` flags disable optimisations. This is required if you're debugging with
`gdb` in an IDE such as Kdevelop. With these optimisations enabled you won't be
able to see the values of many variables in nwipe, not to mention the IDE won't step
through the code properly.
The `-O0 -g` flags disable optimisations. This is required if you're debugging with `gdb` in an IDE such as Kdevelop. With these optimisations enabled you won't be able to see the values of many variables in nwipe, not to mention the IDE won't step through the code properly.
The `-Wall` and `-Wextra` flags enable all compiler warnings. Please submit code with zero warnings.
@@ -117,13 +140,61 @@ make format
```
You will need `clang-format` installed to use the `format` command.
Once done with your coding then the released/patch/fixed code can be compiled,
with all the normal optimisations, using:
Once done with your coding then the released/patch/fixed code can be compiled, with all the normal optimisations, using:
```
./configure --prefix=/usr && make && make install
```
## Automating the download and compilation process for Debian based distros.
Here's a script that will do just that! It will create a directory in your home folder called 'nwipe_master'. It installs all the libraries required to compile the software (build-essential) and all the libraries that nwipe requires (libparted etc). It downloads the latest master copy of nwipe from github. It then compiles the software and then runs the latest nwipe. It doesn't write over the version of nwipe that's installed in the repository (If you had nwipe already installed). To run the latest master version of nwipe manually you would run it like this `sudo ~/nwipe_master/nwipe/src/nwipe`
You can run the script multiple times; the first time it's run it will install all the libraries; subsequent times it will just say the libraries are up to date. As it always downloads a fresh copy of the nwipe master from Github, you can always stay up to date. Just run it to get the latest version of nwipe. It only takes 11 seconds to compile on my i7.
If you already have nwipe installed from the repository, you need to take care which version you are running. If you typed `nwipe` from any directory it will always run the original repository copy of nwipe. To run the latest nwipe you have to explicitly tell it where the new copy is, e.g in the directory `~/nwipe_master/nwipe/src`. That's why you would run it by typing `sudo ~/nwipe_master/nwipe/src/nwipe` alternatively you could cd to the directory and run it like this:
```
cd ~/nwipe_master/nwipe/src
./nwipe
```
Note the ./, that means only look in the current directory for nwipe. if you forgot to type ./ the computer would run the older repository version of nwipe.
Once you have copied the script below into a file called buildnwipe, you need to give the file execute permissions `chmod +x buildnwipe` before you can run it. [Download script](
https://drive.google.com/file/d/1BsQDlMqtEycAgfk9FpG1sxv3jFz5dzNO/view?usp=sharing)
```
#!/bin/bash
cd "$HOME"
nwipe_directory="nwipe_master"
mkdir $nwipe_directory
cd $nwipe_directory
sudo apt install build-essential pkg-config automake libncurses5-dev autotools-dev libparted-dev dmidecode readlink smartmontools git
rm -rf nwipe
git clone https://github.com/martijnvanbrummelen/nwipe.git
cd "nwipe"
./autogen.sh
./configure
make
cd "src"
sudo ./nwipe
```
## Quick & Easy, USB bootable version of nwipe master for x86_64 systems.
If you want to just try out a bootable version of nwipe you can download [ShredOS](https://github.com/PartialVolume/shredos.x86_64). The ShredOS image is around 60MB and can be written to an USB flash drive in seconds, allowing you to boot straight into the latest version of nwipe. ShredOS is available for x86_64 (64-bit) and i686 (32-bit) CPU architectures and will boot both legacy BIOS and UEFI devices. It comes as .IMG (bootable USB flash drive image) or .ISO (for CD-R/DVD-R). Instructions and download can be found [here](https://github.com/PartialVolume/shredos.x86_64#obtaining-and-writing-shredos-to-a-usb-flash-drive-the-easy-way-).
## Which Linux distro uses the latest nwipe?
See [Repology](https://repology.org/project/nwipe/versions)
And in addition checkout the following distros that all include nwipe:
- [ShredOS](https://github.com/PartialVolume/shredos.x86_64) Always has the latest nwipe release.
- [netboot.xyz](https://github.com/netbootxyz/netboot.xyz) Can network-boot ShredOS.
- [partedmagic](https://partedmagic.com)
- [SystemRescueCD](https://www.system-rescue.org)
- [gparted live](https://sourceforge.net/projects/gparted/files/gparted-live-testing/1.2.0-2/)
Know of other distros that include nwipe? Then please let us know or issue a PR on this README.md. Thanks.
## Bugs
Bugs can be reported on GitHub:

View File

View File

@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.64])
AC_INIT([nwipe], [0.28], [git@brumit.nl])
AC_INIT([nwipe], [0.33], [git@brumit.nl])
AM_INIT_AUTOMAKE(foreign subdir-objects)
AC_OUTPUT(Makefile src/Makefile man/Makefile)
AC_CONFIG_SRCDIR([src/nwipe.c])

Binary file not shown.

Before

Width:  |  Height:  |  Size: 945 KiB

After

Width:  |  Height:  |  Size: 6.1 MiB

View File

@@ -1,4 +1,4 @@
.TH NWIPE "1" "March 2020" "nwipe version 0.28" "User Commands"
.TH NWIPE "1" "March 2022" "nwipe version 0.33" "User Commands"
.SH NAME
nwipe \- securely erase disks
.SH SYNOPSIS
@@ -34,8 +34,22 @@ If no devices have been specified on the command line, starts wiping all
devices immediately. If devices have been specified, starts wiping only
those specified devices immediately.
.TP
\fB\-\-sync\fR
Open devices in sync mode
\fB\-\-autopoweroff\fR
Power off system on completion of wipe delayed for for one minute. During
this one minute delay you can abort the shutdown by typing sudo shutdown -c
.TP
\fB\-\-sync\fR=\fINUM\fR
Will perform a syn after NUM writes (default: 100000)
.IP
0 \- fdatasync after the disk is completely written
fdatasync errors not detected until completion.
0 is not recommended as disk errors may cause nwipe
to appear to hang
.IP
1 \- fdatasync after every write
Warning: Lower values will reduce wipe speeds.
.IP
1000 \- fdatasync after 1000 writes
.TP
\fB\-\-noblank\fR
Do not perform the final blanking pass after the wipe (default is to blank,
@@ -47,11 +61,18 @@ Do not wait for a key before exiting (default is to wait).
\fB\-\-nosignals\fR
Do not allow signals to interrupt a wipe (default is to allow).
.TP
\fB\-\-nousb\fR
Do not show or wipe any USB devices, whether in GUI, --nogui or autonuke
mode. (default is to allow USB devices to be shown and wiped).
.TP
\fB\-\-nogui\fR
Do not show the GUI interface. Can only be used with the autonuke option.
Nowait option is automatically invoked with the nogui option.
SIGUSR1 can be used to retrieve the current wiping statistics.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
Log more messages, useful for debugging.
.TP
\fB\-\-verify\fR=\fITYPE\fR
Whether to perform verification of erasure (default: last)
.IP
@@ -77,9 +98,13 @@ ops2 \- RCMP TSSIT OPS\-II
.IP
random / prng / stream \- PRNG Stream
.IP
zero / quick \- Overwrite with zeros
zero / quick \- Overwrite with zeros 0x00
.IP
verify \- Verifies disk is zero filled
one \- Overwrite with ones 0xFF
.IP
verify_zero \- Verifies disk is zero filled
.IP
verify_one \- Verifies disk is 0xFF filled
.IP
is5enh \- HMG IS5 enhanced
.TP
@@ -87,7 +112,12 @@ is5enh \- HMG IS5 enhanced
Filename to log to. Default is STDOUT
.TP
\fB\-p\fR, \fB\-\-prng\fR=\fIMETHOD\fR
PRNG option (mersenne|twister|isaac)
PRNG option (mersenne|twister|isaac|isaac64)
.TP
\fB\-q\fR, \fB\-\-quiet\fR
Anonymize serial numbers, Gui & logs display:
XXXXXXXX = S/N obtained & anonymized.
???????? = S/N not available.
.TP
\fB\-r\fR, \fB\-\-rounds\fR=\fINUM\fR
Number of times to wipe the device using the selected method (default: 1)
@@ -107,4 +137,3 @@ Nwipe is developed by Martijn van Brummelen <github@brumit.nl>
.BR dd (1),
.BR dcfldd (1),
.BR dc3dd (1)

View File

@@ -6,6 +6,5 @@ AM_LDFLAGS =
# this lists the binaries to produce, the (non-PHONY, binary) targets in
# the previous manual Makefile
bin_PROGRAMS = nwipe
nwipe_SOURCES = context.h isaac_rand/isaac_rand.c logging.h options.h prng.h nwipe.c gui.c isaac_rand/isaac_rand.h method.h pass.c device.c gui.h isaac_rand/isaac_standard.h mt19937ar-cok/mt19937ar-cok.c nwipe.h mt19937ar-cok/mt19937ar-cok.h pass.h device.h logging.c method.c options.c prng.c version.c version.h
nwipe_CFLAGS = $(PARTED_CFLAGS)
nwipe_SOURCES = context.h logging.h options.h prng.h version.h temperature.h nwipe.c gui.c method.h pass.c device.c gui.h isaac_rand/isaac_standard.h isaac_rand/isaac_rand.h isaac_rand/isaac_rand.c isaac_rand/isaac64.h isaac_rand/isaac64.c mt19937ar-cok/mt19937ar-cok.c nwipe.h mt19937ar-cok/mt19937ar-cok.h pass.h device.h logging.c method.c options.c prng.c version.c temperature.c
nwipe_LDADD = $(PARTED_LIBS)

View File

@@ -30,8 +30,12 @@ typedef enum nwipe_device_t_ {
NWIPE_DEVICE_IDE,
NWIPE_DEVICE_SCSI,
NWIPE_DEVICE_COMPAQ, // Unimplemented.
NWIPE_DEVICE_USB, // Unimplemented.
NWIPE_DEVICE_IEEE1394 // Unimplemented.
NWIPE_DEVICE_USB,
NWIPE_DEVICE_IEEE1394, // Unimplemented.
NWIPE_DEVICE_ATA,
NWIPE_DEVICE_NVME,
NWIPE_DEVICE_VIRT,
NWIPE_DEVICE_SAS
} nwipe_device_t;
typedef enum nwipe_pass_t_ {
@@ -66,6 +70,10 @@ typedef struct nwipe_speedring_t_
} nwipe_speedring_t;
#define NWIPE_DEVICE_LABEL_LENGTH 200
#define NWIPE_DEVICE_SIZE_TXT_LENGTH 7
// Arbitary length, so far most paths don't exceed about 25 characters
#define MAX_HWMON_PATH_LENGTH 100
typedef struct nwipe_context_t_
{
@@ -83,12 +91,16 @@ typedef struct nwipe_context_t_
int device_minor; // The minor device number.
int device_part; // The device partition or slice number.
char* device_name; // The device file name.
long long device_size; // The device size in bytes.
char device_name_without_path[100];
char gui_device_name[100];
unsigned long long device_size; // The device size in bytes.
char* device_size_text; // The device size in a more (human)readable format.
char device_size_txt[NWIPE_DEVICE_SIZE_TXT_LENGTH]; // The device size in a more (human)readable format.
char* device_model; // The model of the device.
char device_label[NWIPE_DEVICE_LABEL_LENGTH]; // The label (name, model, size and serial) of the device.
struct stat device_stat; // The device file state from fstat().
nwipe_device_t device_type; // Indicates an IDE, SCSI, or Compaq SMART device.
nwipe_device_t device_type; // Indicates an IDE, SCSI, or Compaq SMART device in enumerated form (int)
char device_type_str[14]; // Indicates an IDE, SCSI, USB etc as per nwipe_device_t but in ascii
char device_serial_no[21]; // Serial number(processed, 20 characters plus null termination) of the device.
int device_target; // The device target.
@@ -117,7 +129,28 @@ typedef struct nwipe_context_t_
pthread_t thread; // The ID of the thread.
u64 throughput; // Average throughput in bytes per second.
u64 verify_errors; // The number of verification errors across all passes.
char temp1_path[MAX_HWMON_PATH_LENGTH]; // path to temperature variables /sys/class/hwmon/hwmonX/ etc.
int temp1_crit; // Critical high drive temperature, 1000000=unitialised, millidegree celsius.
int temp1_highest; // Historical highest temperature reached, 1000000=unitialised, millidegree celsius.
int temp1_input; // drive temperature, -1=unitialised. 1000000=unitialised, millidegree celsius.
int temp1_lcrit; // Critical low drive temperature, 1000000=unitialised, millidegree celsius.
int temp1_lowest; // Historically lowest temperature, 1000000=unitialised, millidegree celsius.
int temp1_max; // Maximum allowed temperature, 1000000=unitialised, millidegree celsius.
int temp1_min; // Miniumum allowed temperature, 1000000=unitialised, millidegree celsius.
int temp1_monitored_wipe_max;
int temp1_monitored_wipe_min;
int temp1_monitored_wipe_avg;
int temp1_flash_rate; // number relates to one tenth of a second, so 2 means a flash on and off = 0.4s
int temp1_flash_rate_counter; // used by the gui for timing the flash rate
int temp1_flash_rate_status; // 0=blank 1=visible
time_t temp1_time; // The time when temperature was last checked, seconds since epoch
int wipe_status; // Wipe finished = 0, wipe in progress = 1, wipe yet to start = -1.
int spinner_idx; // Index into the spinner character array
char spinner_character[1]; // The current spinner character
double duration; // Duration of the wipe in seconds
time_t start_time; // Start time of wipe
time_t end_time; // End time of wipe
u64 fsyncdata_errors; // The number of fsyncdata errors across all passes.
/*
* Identity contains the raw serial number of the drive
* (where applicable), however, for use within nwipe use the

View File

@@ -20,10 +20,16 @@
*
*/
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
#include <stdio.h>
#include <stdint.h>
#include "nwipe.h"
#include "context.h"
#include "device.h"
#include "method.h"
#include "options.h"
#include "logging.h"
@@ -41,6 +47,8 @@
int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount );
char* trim( char* str );
extern int terminate_signal;
int nwipe_device_scan( nwipe_context_t*** c )
{
/**
@@ -61,6 +69,13 @@ int nwipe_device_scan( nwipe_context_t*** c )
{
if( check_device( c, dev, dcount ) )
dcount++;
/* Don't bother scanning drives if the terminate signal is active ! as in the case of
* the readlink program missing which is required if the --nousb option has been specified */
if( terminate_signal == 1 )
{
break;
}
}
/* Return the number of devices that were found. */
@@ -98,6 +113,13 @@ int nwipe_device_get( nwipe_context_t*** c, char** devnamelist, int ndevnames )
if( check_device( c, dev, dcount ) )
dcount++;
/* Don't bother scanning drives if the terminate signal is active ! as in the case of
* the readlink program missing which is required if the --nousb option has been specified */
if( terminate_signal == 1 )
{
break;
}
}
/* Return the number of devices that were found. */
@@ -111,6 +133,11 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount )
nwipe_context_t* next_device;
int fd;
int idx;
int r;
char tmp_serial[21];
nwipe_device_t bus;
bus = 0;
/* Check whether this drive is on the excluded drive list ? */
idx = 0;
@@ -123,6 +150,36 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount )
}
}
/* Check whether the user has specified using the --nousb option
* that all USB devices should not be displayed or wiped whether
* in GUI, --nogui or --autonuke modes */
if( nwipe_options.nousb )
{
/* retrieve bus and drive serial number, HOWEVER we are only interested in the bus at this time */
r = nwipe_get_device_bus_type_and_serialno( dev->path, &bus, tmp_serial );
/* See nwipe_get_device_bus_type_and_serialno() function for meaning of these codes */
if( r == 0 || ( r >= 3 && r <= 6 ) )
{
if( bus == NWIPE_DEVICE_USB )
{
nwipe_log( NWIPE_LOG_NOTICE, "Device %s ignored as per command line option --nousb", dev->path );
return 0;
}
}
else
{
if( r == 2 )
{
nwipe_log(
NWIPE_LOG_NOTICE, "--nousb requires the 'readlink' program, please install readlink", dev->path );
terminate_signal = 1;
return 0;
}
}
}
/* Try opening the device to see if it's valid. Close on completion. */
if( !ped_device_open( dev ) )
{
@@ -149,12 +206,35 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount )
/* Get device information */
next_device->device_model = dev->model;
remove_ATA_prefix( next_device->device_model );
/* full device name, i.e. /dev/sda */
next_device->device_name = dev->path;
/* remove /dev/ from device, right justify and prefix name so string length is eight characters */
nwipe_strip_path( next_device->device_name_without_path, next_device->device_name );
/* To maintain column alignment in the gui we have to remove /dev/ from device names that
* exceed eight characters including the /dev/ path.
*/
if( strlen( next_device->device_name ) > MAX_LENGTH_OF_DEVICE_STRING )
{
strcpy( next_device->gui_device_name, next_device->device_name_without_path );
}
else
{
strcpy( next_device->gui_device_name, next_device->device_name );
}
next_device->device_size = dev->length * dev->sector_size;
next_device->device_size_text = ped_unit_format_byte( dev, dev->length * dev->sector_size );
Determine_C_B_nomenclature( next_device->device_size, next_device->device_size_txt, NWIPE_DEVICE_SIZE_TXT_LENGTH );
next_device->device_size_text = next_device->device_size_txt;
next_device->result = -2;
/* Attempt to get serial number of device. */
/* Attempt to get serial number of device.
*/
next_device->device_serial_no[0] = 0; /* initialise the serial number */
if( ( fd = open( next_device->device_name = dev->path, O_RDONLY ) ) == ERR )
{
nwipe_log( NWIPE_LOG_WARNING, "Unable to open device %s to obtain serial number", next_device->device_name );
@@ -175,15 +255,87 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount )
// Terminate the string.
next_device->device_serial_no[20] = 0;
// Remove leading/trailing whitespace from serial number and left justify.
trim( (char*) next_device->device_serial_no );
/* if we couldn't obtain serial number by using the above method .. try this */
r = nwipe_get_device_bus_type_and_serialno( next_device->device_name, &next_device->device_type, tmp_serial );
/* If serial number & bus retrieved (0) OR unsupported USB bus identified (5) */
if( r == 0 || r == 5 )
{
/* If the serial number hasn't already been populated */
if( next_device->device_serial_no[0] == 0 )
{
strcpy( next_device->device_serial_no, tmp_serial );
}
}
/* Does the user want to anonymize serial numbers ? */
if( nwipe_options.quiet )
{
if( next_device->device_serial_no[0] == 0 )
{
strcpy( next_device->device_serial_no, "???????????????" );
}
else
{
strcpy( next_device->device_serial_no, "XXXXXXXXXXXXXXX" );
}
}
/* All device strings should be 4 characters, prefix with space if under 4 characters */
switch( next_device->device_type )
{
case NWIPE_DEVICE_UNKNOWN:
strcpy( next_device->device_type_str, " UNK" );
break;
case NWIPE_DEVICE_IDE:
strcpy( next_device->device_type_str, " IDE" );
break;
case NWIPE_DEVICE_SCSI:
strcpy( next_device->device_type_str, " SCSI" );
break;
case NWIPE_DEVICE_COMPAQ:
strcpy( next_device->device_type_str, " CPQ" );
break;
case NWIPE_DEVICE_USB:
strcpy( next_device->device_type_str, " USB" );
break;
case NWIPE_DEVICE_IEEE1394:
strcpy( next_device->device_type_str, "1394" );
break;
case NWIPE_DEVICE_ATA:
strcpy( next_device->device_type_str, " ATA" );
break;
case NWIPE_DEVICE_NVME:
strcpy( next_device->device_type_str, "NVME" );
break;
case NWIPE_DEVICE_VIRT:
strcpy( next_device->device_type_str, "VIRT" );
break;
case NWIPE_DEVICE_SAS:
strcpy( next_device->device_type_str, " SAS" );
break;
}
if( strlen( (const char*) next_device->device_serial_no ) )
{
snprintf( next_device->device_label,
NWIPE_DEVICE_LABEL_LENGTH,
"%s (%s) - %s S/N:%s",
"%s %s [%s] %s/%s",
next_device->device_name,
next_device->device_type_str,
next_device->device_size_text,
next_device->device_model,
next_device->device_serial_no );
@@ -192,16 +344,18 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount )
{
snprintf( next_device->device_label,
NWIPE_DEVICE_LABEL_LENGTH,
"%s (%s) - %s",
"%s %s [%s] %s",
next_device->device_name,
next_device->device_type_str,
next_device->device_size_text,
next_device->device_model );
}
nwipe_log( NWIPE_LOG_INFO,
"Found drive model=\"%s\", device path=\"%s\", size=\"%s\", serial number=\"%s\"",
next_device->device_model,
nwipe_log( NWIPE_LOG_NOTICE,
"Found %s, %s, %s, %s, S/N=%s",
next_device->device_name,
next_device->device_type_str,
next_device->device_model,
next_device->device_size_text,
next_device->device_serial_no );
@@ -209,7 +363,7 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount )
return 1;
}
/* Remove leading/training whitespace from a string and left justify result */
/* Remove leading/trailing whitespace from a string and left justify result */
char* trim( char* str )
{
size_t len = 0;
@@ -261,3 +415,415 @@ char* trim( char* str )
}
return str;
}
int nwipe_get_device_bus_type_and_serialno( char* device, nwipe_device_t* bus, char* serialnumber )
{
/* The caller provides a string that contains the device, i.e. /dev/sdc, also a pointer
* to a integer (bus type) and thirdly a 21 byte
* character string which this function populates with the serial number (20 characters + null terminator).
*
* The function populates the bus integer and serial number strings for the given device.
* Results for bus would typically be ATA or USB see nwipe_device_t in context.h
*
* Return Values:
* 0 = Success
* 1 = popen failed to create stream for readlink
* 2 = readlink exit code not 0, see nwipe logs
* 3 = popen failed to create stream for smartctl
* 4 = smartctl command not found, install smartmontools
* 5 = smartctl detected unsupported USB to IDE/SATA adapter
* 6 = All other errors !
*
*/
FILE* fp;
int r; // A result buffer.
int idx_src;
int idx_dest;
int device_len;
int set_return_value;
int exit_status;
int idx;
int idx2;
char readlink_command[] = "readlink /sys/block/%s";
char readlink_command2[] = "/usr/bin/readlink /sys/block/%s";
char readlink_command3[] = "/sbin/readlink /sys/block/%s";
char smartctl_command[] = "smartctl -i %s";
char smartctl_command2[] = "/sbin/smartctl -i %s";
char smartctl_command3[] = "/usr/bin/smartctl -i %s";
char device_shortform[50];
char result[512];
char final_cmd_readlink[sizeof( readlink_command ) + sizeof( device_shortform )];
char final_cmd_smartctl[sizeof( smartctl_command ) + 256];
char* pResult;
char smartctl_labels_to_anonymize[][18] = {
"serial number:", "lu wwn device id:", "logical unit id:", "" /* Don't remove this empty string !, important */
};
/* Initialise return value */
set_return_value = 0;
*bus = 0;
/* Scan device name and if device is for instance /dev/sdx then convert to sdx
* If already sdx then just copy. */
idx_dest = 0;
device_shortform[idx_dest] = 0;
device_len = strlen( device );
idx_src = device_len;
while( idx_src >= 0 )
{
if( device[idx_src] == '/' || idx_src == 0 )
{
idx_src++;
/* Now scan forwards copying the short form device i.e sdc */
while( idx_src < device_len )
{
device_shortform[idx_dest++] = device[idx_src++];
}
break;
}
else
{
idx_src--;
}
}
device_shortform[idx_dest] = 0;
final_cmd_readlink[0] = 0;
/* Determine whether we can access readlink, required if the PATH environment is not setup ! (Debian sid 'su' as
* opposed to 'su -' */
if( system( "which readlink > /dev/null 2>&1" ) )
{
if( system( "which /sbin/readlink > /dev/null 2>&1" ) )
{
if( system( "which /usr/bin/readlink > /dev/null 2>&1" ) )
{
nwipe_log( NWIPE_LOG_WARNING, "Command not found. Install readlink !" );
set_return_value = 2;
/* Return immediately if --nousb specified. Readlink is a requirement for this option. */
if( nwipe_options.nousb )
{
return set_return_value;
}
}
else
{
sprintf( final_cmd_readlink, readlink_command3, device_shortform );
}
}
else
{
sprintf( final_cmd_readlink, readlink_command2, device_shortform );
}
}
else
{
sprintf( final_cmd_readlink, readlink_command, device_shortform );
}
if( final_cmd_readlink[0] != 0 )
{
fp = popen( final_cmd_readlink, "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_WARNING,
"nwipe_get_device_bus_type_and_serialno: Failed to create stream to %s",
readlink_command );
set_return_value = 1;
}
if( fp != NULL )
{
/* Read the output a line at a time - output it. */
if( fgets( result, sizeof( result ) - 1, fp ) != NULL )
{
if( nwipe_options.verbose )
{
strip_CR_LF( result );
nwipe_log( NWIPE_LOG_DEBUG, "Readlink: %s", result );
}
/* Scan the readlink results for bus types, i.e. USB or ATA
* Example: readlink
* /sys/block/sdd../devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host6/target6:0:0/6:0:0:0/block/sdd
*/
if( strstr( result, "/usb" ) != 0 )
{
*bus = NWIPE_DEVICE_USB;
}
else
{
if( strstr( result, "/ata" ) != 0 )
{
*bus = NWIPE_DEVICE_ATA;
}
else
{
if( strstr( result, "/nvme/" ) != 0 )
{
*bus = NWIPE_DEVICE_NVME;
}
else
{
if( strstr( result, "/virtual/" ) != 0 )
{
*bus = NWIPE_DEVICE_VIRT;
}
}
}
}
}
/* close */
r = pclose( fp );
if( r > 0 )
{
exit_status = WEXITSTATUS( r );
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_WARNING,
"nwipe_get_device_bus_type_and_serialno(): readlink failed, \"%s\" exit status = %u",
final_cmd_readlink,
exit_status );
}
if( exit_status == 127 )
{
nwipe_log( NWIPE_LOG_WARNING, "Command not found. Install Readlink recommended !" );
set_return_value = 2;
if( nwipe_options.nousb )
{
return set_return_value;
}
}
}
}
}
/*
* Retrieve smartmontools drive information if USB bridge supports it, so we can retrieve the serial number of the
* drive that's on the other side of the USB bridge.. */
final_cmd_smartctl[0] = 0;
/* Determine whether we can access smartctl, required if the PATH environment is not setup ! (Debian sid 'su' as
* opposed to 'su -' */
if( system( "which smartctl > /dev/null 2>&1" ) )
{
if( system( "which /sbin/smartctl > /dev/null 2>&1" ) )
{
if( system( "which /usr/bin/smartctl > /dev/null 2>&1" ) )
{
nwipe_log( NWIPE_LOG_WARNING, "Command not found. Install smartmontools !" );
}
else
{
sprintf( final_cmd_smartctl, smartctl_command3, device );
}
}
else
{
sprintf( final_cmd_smartctl, smartctl_command2, device );
}
}
else
{
sprintf( final_cmd_smartctl, smartctl_command, device );
}
if( final_cmd_smartctl[0] != 0 )
{
fp = popen( final_cmd_smartctl, "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_WARNING,
"nwipe_get_device_bus_type_and_serialno(): Failed to create stream to %s",
smartctl_command );
set_return_value = 3;
}
else
{
/* Read the output a line at a time - output it. */
while( fgets( result, sizeof( result ) - 1, fp ) != NULL )
{
/* Convert the label, i.e everything before the ':' to lower case, it's required to
* convert to lower case as smartctl seems to use inconsistent case when labeling
* for serial number, i.e mostly it produces labels "Serial Number:" but occasionaly
* it produces a label "Serial number:" */
idx = 0;
while( result[idx] != 0 && result[idx] != ':' )
{
/* If upper case alpha character, change to lower case */
if( result[idx] >= 'A' && result[idx] <= 'Z' )
{
result[idx] += 32;
}
idx++;
}
if( nwipe_options.verbose && result[0] != 0x0A )
{
strip_CR_LF( result );
/* Remove serial number if -q option specified */
if( nwipe_options.quiet )
{
/* initialise index into string array */
idx2 = 0;
while( smartctl_labels_to_anonymize[idx2][0] != 0 )
{
if( ( pResult = strstr( result, &smartctl_labels_to_anonymize[idx2][0] ) ) != 0 )
{
/* set index to character after end of label string */
idx = strlen( &smartctl_labels_to_anonymize[idx2][0] );
/* Ignore spaces, overwrite other characters */
while( *( pResult + idx ) != 0x0A && *( pResult + idx ) != 0x0D
&& *( pResult + idx ) != 0 && idx <= sizeof( result ) - 1 )
{
if( *( pResult + idx ) == ' ' )
{
idx++;
continue;
}
else
{
/* ignore if the serial number has been written over with '?' */
if( *( pResult + idx ) != '?' )
{
*( pResult + idx ) = 'X';
}
idx++;
}
}
}
idx2++;
}
}
nwipe_log( NWIPE_LOG_DEBUG, "smartctl: %s", result );
}
if( strstr( result, "serial number:" ) != 0 )
{
/* strip any leading or trailing spaces and left justify, +15 is the length of "Serial Number:" */
trim( &result[15] );
strncpy( serialnumber, &result[15], 20 );
}
if( *bus == 0 )
{
if( strstr( result, "transport protocol:" ) != 0 )
{
/* strip any leading or trailing spaces and left justify, +4 is the length of "bus type:" */
trim( &result[19] );
if( strncmp( &result[19], "sas", 3 ) == 0 )
{
*bus = NWIPE_DEVICE_SAS;
}
}
if( strstr( result, "sata version is:" ) != 0 )
{
/* strip any leading or trailing spaces and left justify, +4 is the length of "bus type:" */
trim( &result[16] );
if( strncmp( &result[16], "sata", 4 ) == 0 )
{
*bus = NWIPE_DEVICE_ATA;
}
}
}
}
/* close */
r = pclose( fp );
if( r > 0 )
{
exit_status = WEXITSTATUS( r );
if( nwipe_options.verbose && exit_status != 1 )
{
nwipe_log( NWIPE_LOG_WARNING,
"nwipe_get_device_bus_type_and_serialno(): smartctl failed, \"%s\" exit status = %u",
final_cmd_smartctl,
exit_status );
}
set_return_value = 6;
if( exit_status == 127 )
{
nwipe_log( NWIPE_LOG_WARNING, "Command not found. Install Smartctl recommended !" );
set_return_value = 4;
}
if( exit_status == 1 )
{
nwipe_log( NWIPE_LOG_WARNING, "%s USB bridge, no pass-through support", device );
if( *bus == NWIPE_DEVICE_USB )
{
strcpy( serialnumber, "(S/N: unknown)" );
set_return_value = 5;
}
}
}
}
}
return set_return_value;
}
void strip_CR_LF( char* str )
{
/* In the specified string, replace any CR or LF with a space */
int idx = 0;
int len = strlen( str );
while( idx < len )
{
if( str[idx] == 0x0A || str[idx] == 0x0D )
{
str[idx] = ' ';
}
idx++;
}
}
void remove_ATA_prefix( char* str )
{
/* Remove "ATA" prefix if present in the model no. string, left justifing string */
int idx_pre = 4;
int idx_post = 0;
if( !strncmp( str, "ATA ", 4 ) )
{
while( str[idx_pre] != 0 )
{
str[idx_post++] = str[idx_pre++];
}
str[idx_post] = 0;
}
}

View File

@@ -23,8 +23,15 @@
#ifndef DEVICE_H_
#define DEVICE_H_
#define MAX_LENGTH_OF_DEVICE_STRING 8
void nwipe_device_identify( nwipe_context_t* c ); // Get hardware information about the device.
int nwipe_device_scan( nwipe_context_t*** c ); // Find devices that we can wipe.
int nwipe_device_get( nwipe_context_t*** c, char** devnamelist, int ndevnames ); // Get info about devices to wipe.
int nwipe_get_device_bus_type_and_serialno( char*, nwipe_device_t*, char* );
void strip_CR_LF( char* );
void determine_disk_capacity_nomenclature( u64, char* );
void remove_ATA_prefix( char* );
char* trim( char* );
#endif /* DEVICE_H_ */

1423
src/gui.c

File diff suppressed because it is too large Load Diff

View File

@@ -31,6 +31,7 @@ void nwipe_gui_create_footer_window( const char* ); // Create the footer window
void nwipe_gui_create_options_window( void ); // Create the options window
void nwipe_gui_create_stats_window( void ); // Create the stats window
void nwipe_gui_create_all_windows_on_terminal_resize(
int force_creation,
const char* footer_text ); // If terminal is resized recreate all windows
void nwipe_gui_select( int count, nwipe_context_t** c ); // Select devices to wipe.
void* nwipe_gui_status( void* ptr ); // Update operation progress.
@@ -40,8 +41,22 @@ void nwipe_gui_prng( void ); // Change the prng option.
void nwipe_gui_rounds( void ); // Change the rounds option.
void nwipe_gui_verify( void ); // Change the verify option.
void nwipe_gui_noblank( void ); // Change the noblank option.
int spinner( nwipe_context_t** ptr, int ); // Return the next spinner character
void temp1_flash( nwipe_context_t* ); // toggles term1_flash_status, which flashes the temperature
void wprintw_temperature( nwipe_context_t* );
int compute_stats( void* ptr );
void nwipe_update_speedring( nwipe_speedring_t* speedring, u64 speedring_done, time_t speedring_now );
#define NOMENCLATURE_RESULT_STR_SIZE 8
/* Note Do not change unless you understand how this value affects keyboard response and screen refresh when
* the drive selection screen is displayed. (prior to wipe starting). */
#define GETCH_BLOCK_MS 250 /* millisecond block time for getch() */
/* Note The value of 1 (100ms) is the ideal speed for screen refresh during a wipe, a value of 2 is noticably slower,
* don't change unless you understand how this value affects keyboard responsiveness and speed of screen stats/spinner
* updating */
#define GETCH_GUI_STATS_UPDATE_MS 1 /* 1 * 100 = 1/10/sec = millisecond block time for gui stats screen updates */
#endif /* GUI_H_ */

119
src/isaac_rand/isaac64.c Normal file
View File

@@ -0,0 +1,119 @@
/*
------------------------------------------------------------------------------
isaac64.c: My random number generator for 64-bit machines.
By Bob Jenkins, 1996. Public Domain.
------------------------------------------------------------------------------
*/
#ifndef STANDARD
#include "isaac_standard.h"
#endif
#ifndef ISAAC64
#include "isaac64.h"
#endif
#define ind(mm,x) (*(ub8 *)((ub1 *)(mm) + ((x) & ((RANDSIZ-1)<<3))))
#define rngstep(mix,a,b,mm,m,m2,r,x) \
{ \
x = *m; \
a = (mix) + *(m2++); \
*(m++) = y = ind(mm,x) + a + b; \
*(r++) = b = ind(mm,y>>RANDSIZL) + x; \
}
void isaac64(rand64ctx *ctx)
{
register ub8 a,b,x,y,*m,*mm,*m2,*r,*mend;
mm=ctx->mm; r=ctx->randrsl;
a = ctx->aa; b = ctx->bb + (++ctx->cc);
for (m = mm, mend = m2 = m+(RANDSIZ/2); m<mend; )
{
rngstep(~(a^(a<<21)), a, b, mm, m, m2, r, x);
rngstep( a^(a>>5) , a, b, mm, m, m2, r, x);
rngstep( a^(a<<12) , a, b, mm, m, m2, r, x);
rngstep( a^(a>>33) , a, b, mm, m, m2, r, x);
}
for (m2 = mm; m2<mend; )
{
rngstep(~(a^(a<<21)), a, b, mm, m, m2, r, x);
rngstep( a^(a>>5) , a, b, mm, m, m2, r, x);
rngstep( a^(a<<12) , a, b, mm, m, m2, r, x);
rngstep( a^(a>>33) , a, b, mm, m, m2, r, x);
}
ctx->bb = b; ctx->aa = a;
}
#define mix(a,b,c,d,e,f,g,h) \
{ \
a-=e; f^=h>>9; h+=a; \
b-=f; g^=a<<9; a+=b; \
c-=g; h^=b>>23; b+=c; \
d-=h; a^=c<<15; c+=d; \
e-=a; b^=d>>14; d+=e; \
f-=b; c^=e<<20; e+=f; \
g-=c; d^=f>>17; f+=g; \
h-=d; e^=g<<14; g+=h; \
}
void rand64init(rand64ctx *ctx, word flag)
{
word i;
ub8 a,b,c,d,e,f,g,h;
ub8 *mm, *randrsl;
ctx->aa = ctx->bb = ctx->cc = (ub8)0;
mm=ctx->mm;
randrsl=ctx->randrsl;
a=b=c=d=e=f=g=h=0x9e3779b97f4a7c13LL; /* the golden ratio */
for (i=0; i<4; ++i) /* scramble it */
{
mix(a,b,c,d,e,f,g,h);
}
for (i=0; i<RANDSIZ; i+=8) /* fill in mm[] with messy stuff */
{
if (flag) /* use all the information in the seed */
{
a+=randrsl[i ]; b+=randrsl[i+1]; c+=randrsl[i+2]; d+=randrsl[i+3];
e+=randrsl[i+4]; f+=randrsl[i+5]; g+=randrsl[i+6]; h+=randrsl[i+7];
}
mix(a,b,c,d,e,f,g,h);
mm[i ]=a; mm[i+1]=b; mm[i+2]=c; mm[i+3]=d;
mm[i+4]=e; mm[i+5]=f; mm[i+6]=g; mm[i+7]=h;
}
if (flag)
{ /* do a second pass to make all of the seed affect all of mm */
for (i=0; i<RANDSIZ; i+=8)
{
a+=mm[i ]; b+=mm[i+1]; c+=mm[i+2]; d+=mm[i+3];
e+=mm[i+4]; f+=mm[i+5]; g+=mm[i+6]; h+=mm[i+7];
mix(a,b,c,d,e,f,g,h);
mm[i ]=a; mm[i+1]=b; mm[i+2]=c; mm[i+3]=d;
mm[i+4]=e; mm[i+5]=f; mm[i+6]=g; mm[i+7]=h;
}
}
isaac64(ctx); /* fill in the first set of results */
ctx->randcnt=RANDSIZ; /* prepare to use the first set of results */
}
#ifdef NEVER
int main()
{
ub8 i,j;
rand64ctx ctx;
ctx.aa=ctx.bb=ctx.cc=(ub8)0;
for (i=0; i<RANDSIZ; ++i) ctx.mm[i]=(ub8)0;
rand64init(&ctx, TRUE);
for (i=0; i<2; ++i)
{
isaac64(&ctx);
for (j=0; j<RANDSIZ; ++j)
{
printf("%.8lx%.8lx",(ub4)(ctx.randrsl[j]>>32),(ub4)ctx.randrsl[j]);
if ((j&3)==3) printf("\n");
}
}
}
#endif

41
src/isaac_rand/isaac64.h Normal file
View File

@@ -0,0 +1,41 @@
/*
------------------------------------------------------------------------------
isaac64.h: definitions for a random number generator
Bob Jenkins, 1996, Public Domain
------------------------------------------------------------------------------
*/
#ifndef ISAAC64
#define ISAAC64
#include "isaac_standard.h"
struct rand64ctx
{
ub8 randrsl[RANDSIZ], randcnt;
ub8 mm[RANDSIZ];
ub8 aa, bb, cc;
};
typedef struct rand64ctx rand64ctx;
/*
------------------------------------------------------------------------------
If (flag==TRUE), then use the contents of randrsl[0..255] as the seed.
------------------------------------------------------------------------------
*/
void rand64init(rand64ctx *r, word flag);
void isaac64(rand64ctx *ctx);
/*
------------------------------------------------------------------------------
Call rand64() to retrieve a single 64-bit random value
------------------------------------------------------------------------------
*/
#define isaac64_rand() \
(!(r)->randcnt-- ? \
(isaac64(r), (r)->randcnt=RANDSIZ-1, (r)->randrsl[(r)->>randcnt]) : \
(r)->randrsl[(r)->randcnt])
#endif /* ISAAC64 */

View File

@@ -10,14 +10,10 @@ MODIFIED:
010626: note this is public domain
------------------------------------------------------------------------------
*/
#ifndef STANDARD
#include "isaac_standard.h"
#endif
#ifndef RAND
#define RAND
#define RANDSIZL (8) /* I recommend 8 for crypto, 4 for simulations */
#define RANDSIZ (1<<RANDSIZL)
#include "isaac_standard.h"
/* context of random number generator */
struct randctx

View File

@@ -54,4 +54,7 @@ typedef int word; /* fastest type available */
#define FALSE 0
#define SUCCESS 0 /* 1 on VAX */
#define RANDSIZL (8) /* I recommend 8 for crypto, 4 for simulations */
#define RANDSIZ (1<<RANDSIZL)
#endif /* STANDARD */

View File

@@ -28,6 +28,7 @@
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "stdarg.h"
#include "nwipe.h"
#include "context.h"
@@ -50,6 +51,9 @@ void nwipe_log( nwipe_log_t level, const char* format, ... )
*
*/
extern int terminate_signal;
extern int user_abort;
char** result;
char* malloc_result;
char message_buffer[MAX_LOG_LINE_CHARS * sizeof( char )];
@@ -77,16 +81,22 @@ void nwipe_log( nwipe_log_t level, const char* format, ... )
/* Position of writing to current log string */
int line_current_pos = 0;
/* initialise characters written */
chars_written = 0;
/* Print the date. The rc script uses the same format. */
chars_written = snprintf( message_buffer,
MAX_LOG_LINE_CHARS,
"[%i/%02i/%02i %02i:%02i:%02i] nwipe: ",
1900 + p->tm_year,
1 + p->tm_mon,
p->tm_mday,
p->tm_hour,
p->tm_min,
p->tm_sec );
if( level != NWIPE_LOG_NOTIMESTAMP )
{
chars_written = snprintf( message_buffer,
MAX_LOG_LINE_CHARS,
"[%i/%02i/%02i %02i:%02i:%02i] ",
1900 + p->tm_year,
1 + p->tm_mon,
p->tm_mday,
p->tm_hour,
p->tm_min,
p->tm_sec );
}
/*
* Has the end of the buffer been reached ?, snprintf returns the number of characters that would have been
@@ -127,22 +137,28 @@ void nwipe_log( nwipe_log_t level, const char* format, ... )
{
case NWIPE_LOG_NONE:
case NWIPE_LOG_NOTIMESTAMP:
/* Do nothing. */
break;
/* NOTE! The debug labels, i.e. debug, info, notice etc should be left padded with spaces, in order
* to maintain column alignment. Pad a label to achieve the length of whatever the longest label happens
* to be. Important to know if you are thinking of adding another label.
*/
case NWIPE_LOG_DEBUG:
chars_written =
snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, "debug: " );
snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, " debug: " );
break;
case NWIPE_LOG_INFO:
chars_written =
snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, "info: " );
snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, " info: " );
break;
case NWIPE_LOG_NOTICE:
chars_written =
snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, "notice: " );
snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, " notice: " );
break;
case NWIPE_LOG_WARNING:
@@ -152,18 +168,18 @@ void nwipe_log( nwipe_log_t level, const char* format, ... )
case NWIPE_LOG_ERROR:
chars_written =
snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, "error: " );
snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, " error: " );
break;
case NWIPE_LOG_FATAL:
chars_written =
snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, "fatal: " );
snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, " fatal: " );
break;
case NWIPE_LOG_SANITY:
/* TODO: Request that the user report the log. */
chars_written =
snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, "sanity: " );
snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, " sanity: " );
break;
default:
@@ -313,57 +329,64 @@ void nwipe_log( nwipe_log_t level, const char* format, ... )
/* Open the log file for appending. */
fp = fopen( nwipe_options.logfile, "a" );
if( fp == NULL )
if( fp != NULL )
{
fprintf( stderr, "nwipe_log: Unable to open '%s' for logging.\n", nwipe_options.logfile );
/* Get the file descriptor of the log file. */
fd = fileno( fp );
/* Block and lock. */
r = flock( fd, LOCK_EX );
if( r != 0 )
{
perror( "nwipe_log: flock:" );
fprintf( stderr, "nwipe_log: Unable to lock '%s' for logging.\n", nwipe_options.logfile );
r = pthread_mutex_unlock( &mutex1 );
if( r != 0 )
{
fprintf( stderr, "nwipe_log: pthread_mutex_unlock failed. Code %i \n", r );
/* Unlock the file. */
r = flock( fd, LOCK_UN );
fclose( fp );
return;
}
}
fprintf( fp, "%s\n", log_lines[log_current_element] );
/* Unlock the file. */
r = flock( fd, LOCK_UN );
if( r != 0 )
{
perror( "nwipe_log: flock:" );
fprintf( stderr, "Error: Unable to unlock '%s' after logging.\n", nwipe_options.logfile );
}
/* Close the stream. */
r = fclose( fp );
if( r != 0 )
{
perror( "nwipe_log: fclose:" );
fprintf( stderr, "Error: Unable to close '%s' after logging.\n", nwipe_options.logfile );
}
}
else
{
/* Tell user we can't create/open the log and terminate nwipe */
fprintf(
stderr, "\nERROR:Unable to create/open '%s' for logging, permissions?\n\n", nwipe_options.logfile );
r = pthread_mutex_unlock( &mutex1 );
if( r != 0 )
{
fprintf( stderr, "nwipe_log: pthread_mutex_unlock failed. Code %i \n", r );
return;
}
}
/* Get the file descriptor of the log file. */
fd = fileno( fp );
/* Block and lock. */
r = flock( fd, LOCK_EX );
if( r != 0 )
{
perror( "nwipe_log: flock:" );
fprintf( stderr, "nwipe_log: Unable to lock '%s' for logging.\n", nwipe_options.logfile );
r = pthread_mutex_unlock( &mutex1 );
if( r != 0 )
{
fprintf( stderr, "nwipe_log: pthread_mutex_unlock failed. Code %i \n", r );
/* Unlock the file. */
r = flock( fd, LOCK_UN );
fclose( fp );
return;
}
}
fprintf( fp, "%s\n", log_lines[log_current_element] );
/* Unlock the file. */
r = flock( fd, LOCK_UN );
if( r != 0 )
{
perror( "nwipe_log: flock:" );
fprintf( stderr, "Error: Unable to unlock '%s' after logging.\n", nwipe_options.logfile );
}
/* Close the stream. */
r = fclose( fp );
if( r != 0 )
{
perror( "nwipe_log: fclose:" );
fprintf( stderr, "Error: Unable to close '%s' after logging.\n", nwipe_options.logfile );
user_abort = 1;
terminate_signal = 1;
return;
}
}
@@ -391,6 +414,88 @@ void nwipe_perror( int nwipe_errno, const char* f, const char* s )
} /* nwipe_perror */
void nwipe_log_OSinfo()
{
/* Read /proc/version, format and write to the log */
FILE* fp = NULL;
char OS_info_temp[MAX_SIZE_OS_STRING + 1];
char OS_info[MAX_SIZE_OS_STRING + 1];
int idx;
int idx2;
int idx3;
int idx4;
/* initialise OS_info & OS_info_temp strings */
idx = 0;
while( idx < MAX_SIZE_OS_STRING + 1 )
{
OS_info_temp[idx] = 0;
OS_info[idx] = 0;
idx++;
}
/* Open a pipe to /proc/version for reading */
fp = popen( "cat /proc/version", "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_WARNING, "Unable to create a pipe to /proc/version" );
return;
}
/* Read the OS info */
if( fgets( OS_info_temp, MAX_SIZE_OS_STRING, fp ) == NULL )
{
nwipe_log( NWIPE_LOG_WARNING, "fget failed to read /proc/version" );
fclose( fp );
return;
}
/* Format the string for the log, place on multiple lines as necessary,
* column aligned, left offset with n (OS_info_Line_offset) spaces */
idx = 0;
idx2 = 0;
idx3 = OS_info_Line_Length;
while( OS_info_temp[idx] != 0 )
{
while( idx2 < idx3 && idx2 < MAX_SIZE_OS_STRING )
{
/* remove newlines from the source */
if( OS_info_temp[idx] == 0x0a )
{
idx++;
}
/* copy the character */
OS_info[idx2++] = OS_info_temp[idx++];
}
if( OS_info_temp[idx] != 0 )
{
OS_info[idx2++] = 0x0a;
idx4 = 0;
/* left indent with spaces */
while( idx4 < OS_info_Line_offset && idx2 < MAX_SIZE_OS_STRING )
{
OS_info[idx2++] = ' ';
idx4++;
}
/* calculate idx3 ready for next line */
idx3 += OS_info_Line_offset + OS_info_Line_Length;
}
else
{
continue;
}
}
nwipe_log( NWIPE_LOG_INFO, "%s", OS_info );
fclose( fp );
return;
}
int nwipe_log_sysinfo()
{
FILE* fp;
@@ -403,71 +508,500 @@ int nwipe_log_sysinfo()
* be logged, making sure the last entry in the array is a NULL string. To remove
* an entry simply comment out the keyword with //
*/
char dmidecode_keywords[][24] = {
"bios-version",
"bios-release-date",
"system-manufacturer",
"system-product-name",
"system-version",
"system-serial-number",
"system-uuid",
"baseboard-manufacturer",
"baseboard-product-name",
"baseboard-version",
"baseboard-serial-number",
"baseboard-asset-tag",
"chassis-manufacturer",
"chassis-type",
"chassis-version",
"chassis-serial-number",
"chassis-asset-tag",
"processor-family",
"processor-manufacturer",
"processor-version",
"processor-frequency",
"" // terminates the keyword array. DO NOT REMOVE
/* The 0/1 after the keyword determines whether the data for this
* keyword is displayed when -q (anonymize) has been specified
* by the user. An quick reminder about multi dimensional arrays, the first
* []=the keyword (0-21) including the empty string. The second [] is the
* 1 or 0 value (0 or 1). The third [] is the index value into either string.
*/
char dmidecode_keywords[][2][24] = {
{ "bios-version", "1" },
{ "bios-release-date", "1" },
{ "system-manufacturer", "1" },
{ "system-product-name", "1" },
{ "system-version", "1" },
{ "system-serial-number", "0" },
{ "system-uuid", "0" },
{ "baseboard-manufacturer", "1" },
{ "baseboard-product-name", "1" },
{ "baseboard-version", "1" },
{ "baseboard-serial-number", "0" },
{ "baseboard-asset-tag", "0" },
{ "chassis-manufacturer", "1" },
{ "chassis-type", "1" },
{ "chassis-version", "1" },
{ "chassis-serial-number", "0" },
{ "chassis-asset-tag", "0" },
{ "processor-family", "1" },
{ "processor-manufacturer", "1" },
{ "processor-version", "1" },
{ "processor-frequency", "1" },
{ "", "" } // terminates the keyword array. DO NOT REMOVE
};
char dmidecode_command[] = "dmidecode -s %s";
char dmidecode_command2[] = "/sbin/dmidecode -s %s";
char dmidecode_command3[] = "/usr/bin/dmidecode -s %s";
char* p_dmidecode_command;
char cmd[sizeof( dmidecode_keywords ) + sizeof( dmidecode_command )];
char cmd[sizeof( dmidecode_keywords ) + sizeof( dmidecode_command2 )];
unsigned int keywords_idx;
keywords_idx = 0;
/* Run the dmidecode command to retrieve each dmidecode keyword, one at a time */
while( dmidecode_keywords[keywords_idx][0] != 0 )
p_dmidecode_command = 0;
if( system( "which dmidecode > /dev/null 2>&1" ) )
{
sprintf( cmd, dmidecode_command, &dmidecode_keywords[keywords_idx][0] );
fp = popen( cmd, "r" );
if( fp == NULL )
if( system( "which /sbin/dmidecode > /dev/null 2>&1" ) )
{
nwipe_log( NWIPE_LOG_INFO, "nwipe_log_sysinfo: Failed to create stream to %s", cmd );
return 1;
}
/* Read the output a line at a time - output it. */
while( fgets( path, sizeof( path ) - 1, fp ) != NULL )
{
/* Remove any trailing return from the string, as nwipe_log automatically adds a return */
len = strlen( path );
if( path[len - 1] == '\n' )
if( system( "which /usr/bin/dmidecode > /dev/null 2>&1" ) )
{
path[len - 1] = 0;
nwipe_log( NWIPE_LOG_WARNING, "Command not found. Install dmidecode !" );
}
else
{
p_dmidecode_command = &dmidecode_command3[0];
}
nwipe_log( NWIPE_LOG_INFO, "%s = %s", &dmidecode_keywords[keywords_idx][0], path );
}
/* close */
r = pclose( fp );
if( r > 0 )
else
{
nwipe_log( NWIPE_LOG_INFO,
"nwipe_log_sysinfo(): dmidecode failed, \"%s\" exit status = %u",
cmd,
WEXITSTATUS( r ) );
return 1;
p_dmidecode_command = &dmidecode_command2[0];
}
}
else
{
p_dmidecode_command = &dmidecode_command[0];
}
if( p_dmidecode_command != 0 )
{
/* Run the dmidecode command to retrieve each dmidecode keyword, one at a time */
while( dmidecode_keywords[keywords_idx][0][0] != 0 )
{
sprintf( cmd, p_dmidecode_command, &dmidecode_keywords[keywords_idx][0][0] );
fp = popen( cmd, "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_WARNING, "nwipe_log_sysinfo: Failed to create stream to %s", cmd );
return 1;
}
/* Read the output a line at a time - output it. */
while( fgets( path, sizeof( path ) - 1, fp ) != NULL )
{
/* Remove any trailing return from the string, as nwipe_log automatically adds a return */
len = strlen( path );
if( path[len - 1] == '\n' )
{
path[len - 1] = 0;
}
if( nwipe_options.quiet )
{
if( *( &dmidecode_keywords[keywords_idx][1][0] ) == '0' )
{
nwipe_log(
NWIPE_LOG_NOTICE, "%s = %s", &dmidecode_keywords[keywords_idx][0][0], "XXXXXXXXXXXXXXX" );
}
else
{
nwipe_log( NWIPE_LOG_NOTICE, "%s = %s", &dmidecode_keywords[keywords_idx][0][0], path );
}
}
else
{
nwipe_log( NWIPE_LOG_NOTICE, "%s = %s", &dmidecode_keywords[keywords_idx][0][0], path );
}
}
/* close */
r = pclose( fp );
if( r > 0 )
{
nwipe_log( NWIPE_LOG_WARNING,
"nwipe_log_sysinfo(): dmidecode failed, \"%s\" exit status = %u",
cmd,
WEXITSTATUS( r ) );
return 1;
}
keywords_idx++;
}
keywords_idx++;
}
return 0;
}
void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected )
{
/* Prints two summary tables, the first is the device pass and verification summary
* and the second is the main summary table detaining the drives, status, throughput,
* model and serial number */
int i;
int idx_src;
int idx_dest;
char device[18];
char status[9];
char throughput[13];
char total_throughput_string[13];
char summary_top_border[256];
char summary_top_column_titles[256];
char blank[3];
char verify[3];
// char duration[5];
char duration[314];
char model[18];
char serial_no[20];
char exclamation_flag[2];
int hours;
int minutes;
int seconds;
u64 total_duration_seconds;
u64 total_throughput;
nwipe_context_t** c;
c = ptr;
exclamation_flag[0] = 0;
device[0] = 0;
status[0] = 0;
throughput[0] = 0;
summary_top_border[0] = 0;
summary_top_column_titles[0] = 0;
blank[0] = 0;
verify[0] = 0;
duration[0] = 0;
model[0] = 0;
serial_no[0] = 0;
hours = 0;
minutes = 0;
seconds = 0;
/* A time buffer. */
time_t t;
/* A pointer to the system time struct. */
struct tm* p;
/* Nothing to do, user never started a wipe so no summary table required. */
if( global_wipe_status == 0 )
{
return;
}
/* Print the pass and verifications table */
/* IMPORTANT: Keep maximum columns (line length) to 80 characters for use with 80x30 terminals, Shredos, ALT-F2 etc
* --------------------------------01234567890123456789012345678901234567890123456789012345678901234567890123456789-*/
nwipe_log( NWIPE_LOG_NOTIMESTAMP, "" );
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
"******************************** Error Summary *********************************" );
nwipe_log( NWIPE_LOG_NOTIMESTAMP, "! Device | Pass Errors | Verifications Errors | Fdatasync I\\O Errors" );
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
"--------------------------------------------------------------------------------" );
for( i = 0; i < nwipe_selected; i++ )
{
if( c[i]->pass_errors != 0 || c[i]->verify_errors != 0 || c[i]->fsyncdata_errors != 0 )
{
strncpy( exclamation_flag, "!", 1 );
exclamation_flag[1] = 0;
}
else
{
strncpy( exclamation_flag, " ", 1 );
exclamation_flag[1] = 0;
}
/* Device name, strip any prefixed /dev/.. leaving up to 6 right justified
* characters eg " sda", prefixed with space to 6 characters, note that
* we are processing the strings right to left */
idx_dest = 6;
device[idx_dest--] = 0;
idx_src = strlen( c[i]->device_name );
idx_src--;
nwipe_strip_path( device, c[i]->device_name );
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
"%s %s | %10llu | %10llu | %10llu",
exclamation_flag,
device,
c[i]->pass_errors,
c[i]->verify_errors,
c[i]->fsyncdata_errors );
}
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
"********************************************************************************" );
/* Print the main summary table */
/* initialise */
total_throughput = 0;
/* Get the current time. */
t = time( NULL );
p = localtime( &t );
/* IMPORTANT: Keep maximum columns (line length) to 80 characters for use with 80x30 terminals, Shredos, ALT-F2 etc
* --------------------------------01234567890123456789012345678901234567890123456789012345678901234567890123456789-*/
nwipe_log( NWIPE_LOG_NOTIMESTAMP, "" );
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
"********************************* Drive Status *********************************" );
nwipe_log( NWIPE_LOG_NOTIMESTAMP, "! Device | Status | Thru-put | HH:MM:SS | Model/Serial Number" );
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
"--------------------------------------------------------------------------------" );
/* Example layout:
* "! sdb |--FAIL--| 120MB/s | 01:22:01 | WD6788.8488YNHj/ZX677888388-N "
* ); " sdc | Erased | 120MB/s | 01:25:04 | WD6784.8488JKGG/ZX677888388-N " ); " sdv | Erased |
* 120MB/s | 01:19:07 | WD6788.848HHDDR/ZX677888388-N " ); End of Example layout */
for( i = 0; i < nwipe_selected; i++ )
{
/* Device name, strip any prefixed /dev/.. leaving up to 8 right justified
* characters eg " sda", prefixed with space to 8 characters, note that
* we are processing the strings right to left */
nwipe_strip_path( device, c[i]->device_name );
extern int user_abort;
/* Any errors ? if so set the exclamation_flag and fail message,
* All status messages should be eight characters EXACTLY !
*/
if( c[i]->pass_errors != 0 || c[i]->verify_errors != 0 || c[i]->fsyncdata_errors != 0 )
{
strncpy( exclamation_flag, "!", 1 );
exclamation_flag[1] = 0;
strncpy( status, "-FAILED-", 8 );
status[8] = 0;
}
else
{
if( c[i]->wipe_status == 0 )
{
strncpy( exclamation_flag, " ", 1 );
exclamation_flag[1] = 0;
strncpy( status, " Erased ", 8 );
status[8] = 0;
}
else
{
if( user_abort == 1 )
{
strncpy( exclamation_flag, "!", 1 );
exclamation_flag[1] = 0;
strncpy( status, "UABORTED", 8 );
status[8] = 0;
}
else
{
/* If this ever happens, there is a bug ! */
strncpy( exclamation_flag, " ", 1 );
exclamation_flag[1] = 0;
strncpy( status, "INSANITY", 8 );
status[8] = 0;
}
}
}
/* Determine the size of throughput so that the correct nomenclature can be used */
Determine_C_B_nomenclature( c[i]->throughput, throughput, 13 );
/* Add this devices throughput to the total throughput */
total_throughput += c[i]->throughput;
/* Retrieve the duration of the wipe in seconds and convert to hours and minutes and seconds */
if( c[i]->start_time != 0 && c[i]->end_time != 0 )
{
/* For a summary when the wipe has finished */
c[i]->duration = difftime( c[i]->end_time, c[i]->start_time );
}
else
{
if( c[i]->start_time != 0 && c[i]->end_time == 0 )
{
/* For a summary in the event of a system shutdown */
c[i]->duration = difftime( t, c[i]->start_time );
}
}
total_duration_seconds = (u64) c[i]->duration;
/* Convert binary seconds into three binary variables, hours, minutes and seconds */
convert_seconds_to_hours_minutes_seconds( total_duration_seconds, &hours, &minutes, &seconds );
/* Device Model */
strncpy( model, c[i]->device_model, 17 );
model[17] = 0;
/* Serial No. */
strncpy( serial_no, c[i]->device_serial_no, 20 );
model[17] = 0;
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
"%s %s |%s| %s/s | %02i:%02i:%02i | %s/%s",
exclamation_flag,
device,
status,
throughput,
hours,
minutes,
seconds,
model,
serial_no );
}
/* Determine the size of throughput so that the correct nomenclature can be used */
Determine_C_B_nomenclature( total_throughput, total_throughput_string, 13 );
/* Blank abbreviations used in summary table B=blank, NB=no blank */
if( nwipe_options.noblank )
{
strcpy( blank, "NB" );
}
else
{
strcpy( blank, "B" );
}
/* Verify abbreviations used in summary table */
switch( nwipe_options.verify )
{
case NWIPE_VERIFY_NONE:
strcpy( verify, "NV" );
break;
case NWIPE_VERIFY_LAST:
strcpy( verify, "VL" );
break;
case NWIPE_VERIFY_ALL:
strcpy( verify, "VA" );
break;
}
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
"--------------------------------------------------------------------------------" );
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
"[%i/%02i/%02i %02i:%02i:%02i] Total Throughput %s/s, %s, %iR+%s+%s",
1900 + p->tm_year,
1 + p->tm_mon,
p->tm_mday,
p->tm_hour,
p->tm_min,
p->tm_sec,
total_throughput_string,
nwipe_method_label( nwipe_options.method ),
nwipe_options.rounds,
blank,
verify );
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
"********************************************************************************" );
nwipe_log( NWIPE_LOG_NOTIMESTAMP, "" );
}
void Determine_C_B_nomenclature( u64 speed, char* result, int result_array_size )
{
/* C_B ? Determine Capacity or Bandwidth nomenclature
*
* A pointer to a result character string with a minimum of 13 characters in length
* should be provided.
*
* Outputs a string of the form xxxTB/s, xxxGB/s, xxxMB/s, xxxKB/s B/s depending on the value of 'speed'
*/
/* Initialise the output array */
int idx = 0;
while( idx < result_array_size )
{
result[idx++] = 0;
}
/* Determine the size of throughput so that the correct nomenclature can be used */
if( speed >= INT64_C( 1000000000000 ) )
{
snprintf( result, result_array_size, "%3llu TB", speed / INT64_C( 1000000000000 ) );
}
else if( speed >= INT64_C( 1000000000 ) )
{
snprintf( result, result_array_size, "%3llu GB", speed / INT64_C( 1000000000 ) );
}
else if( speed >= INT64_C( 1000000 ) )
{
snprintf( result, result_array_size, "%3llu MB", speed / INT64_C( 1000000 ) );
}
else if( speed >= INT64_C( 1000 ) )
{
snprintf( result, result_array_size, "%3llu KB", speed / INT64_C( 1000 ) );
}
else
{
snprintf( result, result_array_size, "%3llu B", speed / INT64_C( 1 ) );
}
}
void convert_seconds_to_hours_minutes_seconds( u64 total_seconds, int* hours, int* minutes, int* seconds )
{
/* Convert binary seconds into binary hours, minutes and seconds */
if( total_seconds % 60 )
{
*minutes = total_seconds / 60;
*seconds = total_seconds - ( *minutes * 60 );
}
else
{
*minutes = total_seconds / 60;
*seconds = 0;
}
if( *minutes > 59 )
{
*hours = *minutes / 60;
if( *minutes % 60 )
{
*minutes = *minutes - ( *hours * 60 );
}
else
{
*minutes = 0;
}
}
}
int nwipe_strip_path( char* output, char* input )
{
/* Take the input string, say "/dev/sda" and remove the "/dev/", prefix the result
* with 'length' spaces. So if length=8 and input=/dev/sda, output will
* be " sda", a string 8 characters long right justified with spaces.
*/
int idx_dest;
int idx_src;
idx_dest = 8;
// idx_dest = length;
output[idx_dest--] = 0;
idx_src = strlen( input );
idx_src--;
while( idx_dest >= 0 )
{
/* if the device name contains a / start prefixing spaces */
if( input[idx_src] == '/' )
{
output[idx_dest--] = ' ';
continue;
}
if( idx_src >= 0 )
{
output[idx_dest--] = input[idx_src--];
}
}
}

View File

@@ -24,6 +24,10 @@
/* Maximum size of a log message */
#define MAX_LOG_LINE_CHARS 512
#define MAX_SIZE_OS_STRING 512 /* Maximum size of acceptable OS string */
#define OS_info_Line_offset 31 /* OS_info line offset in log */
#define OS_info_Line_Length 48 /* OS_info line length */
typedef enum nwipe_log_t_ {
NWIPE_LOG_NONE = 0,
NWIPE_LOG_DEBUG, // TODO: Very verbose logging.
@@ -32,11 +36,17 @@ typedef enum nwipe_log_t_ {
NWIPE_LOG_WARNING, // Things that the user should know about.
NWIPE_LOG_ERROR, // Non-fatal errors that result in failure.
NWIPE_LOG_FATAL, // Errors that cause the program to exit.
NWIPE_LOG_SANITY // Programming errors.
NWIPE_LOG_SANITY, // Programming errors.
NWIPE_LOG_NOTIMESTAMP // logs the message without the timestamp
} nwipe_log_t;
void nwipe_log( nwipe_log_t level, const char* format, ... );
void nwipe_perror( int nwipe_errno, const char* f, const char* s );
void nwipe_log_OSinfo();
int nwipe_log_sysinfo();
void nwipe_log_summary( nwipe_context_t**, int ); // This produces the wipe status table on exit
void Determine_C_B_nomenclature( u64, char*, int );
void convert_seconds_to_hours_minutes_seconds( u64, int*, int*, int* );
int nwipe_strip_path( char*, char* );
#endif /* LOGGING_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -51,7 +51,9 @@ void* nwipe_ops2( void* ptr );
void* nwipe_is5enh( void* ptr );
void* nwipe_random( void* ptr );
void* nwipe_zero( void* ptr );
void* nwipe_verify( void* ptr );
void* nwipe_one( void* ptr );
void* nwipe_verify_zero( void* ptr );
void* nwipe_verify_one( void* ptr );
void calculate_round_size( nwipe_context_t* );

View File

@@ -19,6 +19,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
@@ -27,8 +31,7 @@
#include <time.h>
#include <signal.h>
#include <pthread.h>
#include <bits/pthreadtypes.h>
#include <bits/sigthread.h>
#include <sys/types.h>
#include "nwipe.h"
#include "context.h"
@@ -38,6 +41,7 @@
#include "device.h"
#include "logging.h"
#include "gui.h"
#include "temperature.h"
#include <sys/ioctl.h> /* FIXME: Twice Included */
#include <sys/shm.h>
@@ -45,8 +49,11 @@
#include <parted/parted.h>
#include <parted/debug.h>
#include "version.h"
int terminate_signal;
int user_abort;
int global_wipe_status;
int main( int argc, char** argv )
{
@@ -54,9 +61,17 @@ int main( int argc, char** argv )
int nwipe_enumerated; // The number of contexts that have been enumerated.
int nwipe_error = 0; // An error counter.
int nwipe_selected = 0; // The number of contexts that have been selected.
int any_threads_still_running; // used in wipe thread cancellation wait loop
int thread_timeout_counter; // timeout thread cancellation after THREAD_CANCELLATION_TIMEOUT seconds
pthread_t nwipe_gui_thread = 0; // The thread ID of the GUI thread.
pthread_t nwipe_sigint_thread; // The thread ID of the sigint handler.
char modprobe_command[] = "modprobe %s";
char modprobe_command2[] = "/sbin/modprobe %s";
char modprobe_command3[] = "/usr/sbin/modprobe %s";
char module_shortform[50];
char final_cmd_modprobe[sizeof( modprobe_command ) + sizeof( module_shortform )];
/* The entropy source file handle. */
int nwipe_entropy;
@@ -67,12 +82,28 @@ int main( int argc, char** argv )
/* The generic result buffer. */
int r;
/* Log nwipes version */
nwipe_log( NWIPE_LOG_INFO, "%s", banner );
/* Log OS info */
nwipe_log_OSinfo();
/* Initialise the termintaion signal, 1=terminate nwipe */
terminate_signal = 0;
/* Initialise the user abort signal, 1=User aborted with CNTRL-C,SIGTERM, SIGQUIT, SIGINT etc.. */
user_abort = 0;
/* nwipes return status value, set prior to exit at the end of nwipe, as no other exit points allowed */
int return_status = 0;
/* Initialise, flag indicating whether a wipe has actually started or not 0=no, 1=yes */
global_wipe_status = 0;
/* Initialise flags that indicate whether a fatal or non fatal error occurred on ANY drive */
int fatal_errors_flag = 0;
int non_fatal_errors_flag = 0;
/* Two arrays are used, containing pointers to the the typedef for each disk */
/* The first array (c1) points to all devices, the second points to only */
/* the disks selected for wiping. */
@@ -81,16 +112,26 @@ int main( int argc, char** argv )
/* Initialised and populated in device scan. */
nwipe_context_t** c1 = 0;
int wipe_threads_started = 0;
/* Parse command line options. */
nwipe_optind = nwipe_options_parse( argc, argv );
if( nwipe_optind == argc )
{
/* File names were not given by the user. Scan for devices. */
nwipe_enumerated = nwipe_device_scan( &c1 );
if( terminate_signal == 1 )
{
cleanup();
exit( 1 );
}
if( nwipe_enumerated == 0 )
{
nwipe_log( NWIPE_LOG_INFO, "Storage devices not found." );
nwipe_log( NWIPE_LOG_INFO,
"Storage devices not found. Nwipe should be run as root or sudo/su, i.e sudo nwipe etc" );
cleanup();
return -1;
}
@@ -108,12 +149,18 @@ int main( int argc, char** argv )
if( nwipe_enumerated == 0 )
{
nwipe_log( NWIPE_LOG_ERROR, "Devices not found. Check you're not excluding drives unnecessarily." );
printf( "No drives found" );
printf( "No drives found\n" );
cleanup();
exit( 1 );
}
}
if( terminate_signal == 1 )
{
cleanup();
exit( 1 );
}
/* Log the System information */
nwipe_log_sysinfo();
@@ -129,6 +176,7 @@ int main( int argc, char** argv )
nwipe_perror( errno, __FUNCTION__, "open" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to open entropy source %s.", NWIPE_KNOB_ENTROPY );
cleanup();
free( c2 );
return errno;
}
@@ -170,6 +218,53 @@ int main( int argc, char** argv )
pthread_create( &nwipe_sigint_thread, &pthread_attr, signal_hand, &nwipe_thread_data_ptr );
}
/* Makesure the drivetemp module is loaded, else drives hwmon entries won't appear in /sys/class/hwmon */
final_cmd_modprobe[0] = 0;
/* The kernel module we are going to load */
strcpy( module_shortform, "drivetemp" );
/* Determine whether we can access modprobe, required if the PATH environment is not setup ! (Debian sid 'su' as
* opposed to 'su -' */
if( system( "which modprobe > /dev/null 2>&1" ) )
{
if( system( "which /sbin/modprobe > /dev/null 2>&1" ) )
{
if( system( "which /usr/sbin/modprobe > /dev/null 2>&1" ) )
{
nwipe_log( NWIPE_LOG_WARNING, "modprobe command not found. Install kmod package (modprobe)) !" );
nwipe_log( NWIPE_LOG_WARNING, "Most temperature monitoring may be unavailable as module drivetemp" );
nwipe_log( NWIPE_LOG_WARNING, "could not be loaded. drivetemp is not available on kernels < v5.5" );
}
else
{
sprintf( final_cmd_modprobe, modprobe_command3, module_shortform );
}
}
else
{
sprintf( final_cmd_modprobe, modprobe_command2, module_shortform );
}
}
else
{
sprintf( final_cmd_modprobe, modprobe_command, module_shortform );
}
/* load the drivetemp module */
if( system( final_cmd_modprobe ) != 0 )
{
nwipe_log( NWIPE_LOG_WARNING, "hwmon: Unable to load module drivetemp, temperatures may be unavilable." );
nwipe_log( NWIPE_LOG_WARNING, "hwmon: It's possible the drivetemp software isn't modular but built-in" );
nwipe_log( NWIPE_LOG_WARNING, "hwmon: to the kernel, as is the case with ShredOS.x86_64 in which case" );
nwipe_log( NWIPE_LOG_WARNING, "hwmon: the temperatures will actually be available despite this issue." );
}
else
{
nwipe_log( NWIPE_LOG_NOTICE, "hwmon: Module drivetemp loaded, drive temperatures available" );
}
/* A context struct for each device has already been created. */
/* Now set specific nwipe options */
for( i = 0; i < nwipe_enumerated; i++ )
@@ -192,17 +287,20 @@ int main( int argc, char** argv )
c1[i]->select = NWIPE_SELECT_FALSE;
}
/* Set the PRNG implementation. */
c1[i]->prng = nwipe_options.prng;
c1[i]->prng_seed.length = 0;
c1[i]->prng_seed.s = 0;
c1[i]->prng_state = 0;
/* Initialise temperature variables for device */
nwipe_init_temperature( c1[i] );
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_NOTICE, "hwmon: Device %s hwmon path = %s", c1[i]->device_name, c1[i]->temp1_path );
}
nwipe_update_temperature( c1[i] );
}
/* Check for initialization errors. */
if( nwipe_error )
{
nwipe_log( NWIPE_LOG_ERROR, "Initialization eror %i\n", nwipe_error );
nwipe_log( NWIPE_LOG_ERROR, "Initialization error %i\n", nwipe_error );
cleanup();
return -1;
}
@@ -232,13 +330,22 @@ int main( int argc, char** argv )
}
}
/* Count the number of selected contexts. */
for( i = 0; i < nwipe_enumerated; i++ )
{
/* Set the PRNG implementation, which must always come after the function nwipe_gui_select ! */
c1[i]->prng = nwipe_options.prng;
c1[i]->prng_seed.length = 0;
c1[i]->prng_seed.s = 0;
c1[i]->prng_state = 0;
/* Count the number of selected contexts. */
if( c1[i]->select == NWIPE_SELECT_TRUE )
{
nwipe_selected += 1;
}
/* Initialise the wipe result value */
c1[i]->result = 0;
}
/* Pass the number selected to the struct for other threads */
@@ -255,150 +362,172 @@ int main( int argc, char** argv )
}
/* TODO: free c1 and c2 memory. */
for( i = 0; i < nwipe_selected; i++ )
if( user_abort == 0 )
{
/* A result buffer for the BLKGETSIZE64 ioctl. */
u64 size64;
/* Log the wipe options that have been selected immediately prior to the start of the wipe */
nwipe_options_log();
/* Initialise the wipe_status flag, -1 = wipe not yet started */
c2[i]->wipe_status = -1;
/* The wipe has been initiated */
global_wipe_status = 1;
/* Open the file for reads and writes. */
c2[i]->device_fd = open( c2[i]->device_name, O_RDWR );
/* Check the open() result. */
if( c2[i]->device_fd < 0 )
for( i = 0; i < nwipe_selected; i++ )
{
nwipe_perror( errno, __FUNCTION__, "open" );
nwipe_log( NWIPE_LOG_WARNING, "Unable to open device '%s'.", c2[i]->device_name );
c2[i]->select = NWIPE_SELECT_DISABLED;
continue;
}
/* A result buffer for the BLKGETSIZE64 ioctl. */
u64 size64;
/* Stat the file. */
if( fstat( c2[i]->device_fd, &c2[i]->device_stat ) != 0 )
{
nwipe_perror( errno, __FUNCTION__, "fstat" );
nwipe_log( NWIPE_LOG_ERROR, "Unable to stat file '%s'.", c2[i]->device_name );
nwipe_error++;
continue;
}
/* Initialise the spinner character index */
c2[i]->spinner_idx = 0;
/* Check that the file is a block device. */
if( !S_ISBLK( c2[i]->device_stat.st_mode ) )
{
nwipe_log( NWIPE_LOG_ERROR, "'%s' is not a block device.", c2[i]->device_name );
nwipe_error++;
continue;
}
/* Initialise the start and end time of the wipe */
c2[i]->start_time = 0;
c2[i]->end_time = 0;
/* TODO: Lock the file for exclusive access. */
/*
if( flock( c2[i]->device_fd, LOCK_EX | LOCK_NB ) != 0 )
{
nwipe_perror( errno, __FUNCTION__, "flock" );
nwipe_log( NWIPE_LOG_ERROR, "Unable to lock the '%s' file.", c2[i]->device_name );
/* Initialise the wipe_status flag, -1 = wipe not yet started */
c2[i]->wipe_status = -1;
/* Open the file for reads and writes. */
c2[i]->device_fd = open( c2[i]->device_name, O_RDWR );
/* Check the open() result. */
if( c2[i]->device_fd < 0 )
{
nwipe_perror( errno, __FUNCTION__, "open" );
nwipe_log( NWIPE_LOG_WARNING, "Unable to open device '%s'.", c2[i]->device_name );
c2[i]->select = NWIPE_SELECT_DISABLED;
continue;
}
/* Stat the file. */
if( fstat( c2[i]->device_fd, &c2[i]->device_stat ) != 0 )
{
nwipe_perror( errno, __FUNCTION__, "fstat" );
nwipe_log( NWIPE_LOG_ERROR, "Unable to stat file '%s'.", c2[i]->device_name );
nwipe_error++;
continue;
}
*/
}
/* Print serial number of device if it exists. */
if( strlen( (const char*) c2[i]->device_serial_no ) )
{
nwipe_log( NWIPE_LOG_INFO, "Device %s has serial number %s", c2[i]->device_name, c2[i]->device_serial_no );
}
/* Do sector size and block size checking. */
if( ioctl( c2[i]->device_fd, BLKSSZGET, &c2[i]->device_sector_size ) == 0 )
{
nwipe_log(
NWIPE_LOG_INFO, "Device '%s' has sector size %i.", c2[i]->device_name, c2[i]->device_sector_size );
if( ioctl( c2[i]->device_fd, BLKBSZGET, &c2[i]->device_block_size ) == 0 )
/* Check that the file is a block device. */
if( !S_ISBLK( c2[i]->device_stat.st_mode ) )
{
nwipe_log(
NWIPE_LOG_INFO, "Device '%s' has block size %i.", c2[i]->device_name, c2[i]->device_block_size );
nwipe_log( NWIPE_LOG_ERROR, "'%s' is not a block device.", c2[i]->device_name );
nwipe_error++;
continue;
}
/* TODO: Lock the file for exclusive access. */
/*
if( flock( c2[i]->device_fd, LOCK_EX | LOCK_NB ) != 0 )
{
nwipe_perror( errno, __FUNCTION__, "flock" );
nwipe_log( NWIPE_LOG_ERROR, "Unable to lock the '%s' file.", c2[i]->device_name );
nwipe_error++;
continue;
}
*/
/* Print serial number of device if it exists. */
if( strlen( (const char*) c2[i]->device_serial_no ) )
{
nwipe_log( NWIPE_LOG_NOTICE, "%s has serial number %s", c2[i]->device_name, c2[i]->device_serial_no );
}
/* Do sector size and block size checking. */
if( ioctl( c2[i]->device_fd, BLKSSZGET, &c2[i]->device_sector_size ) == 0 )
{
if( ioctl( c2[i]->device_fd, BLKBSZGET, &c2[i]->device_block_size ) != 0 )
{
nwipe_log( NWIPE_LOG_WARNING, "Device '%s' failed BLKBSZGET ioctl.", c2[i]->device_name );
c2[i]->device_block_size = 0;
}
}
else
{
nwipe_log( NWIPE_LOG_WARNING, "Device '%s' failed BLKBSZGET ioctl.", c2[i]->device_name );
nwipe_log( NWIPE_LOG_WARNING, "Device '%s' failed BLKSSZGET ioctl.", c2[i]->device_name );
c2[i]->device_sector_size = 0;
c2[i]->device_block_size = 0;
}
}
else
{
nwipe_log( NWIPE_LOG_WARNING, "Device '%s' failed BLKSSZGET ioctl.", c2[i]->device_name );
c2[i]->device_sector_size = 0;
c2[i]->device_block_size = 0;
}
/* The st_size field is zero for block devices. */
/* ioctl( c2[i]->device_fd, BLKGETSIZE64, &c2[i]->device_size ); */
/* The st_size field is zero for block devices. */
/* ioctl( c2[i]->device_fd, BLKGETSIZE64, &c2[i]->device_size ); */
/* Seek to the end of the device to determine its size. */
c2[i]->device_size = lseek( c2[i]->device_fd, 0, SEEK_END );
/* Seek to the end of the device to determine its size. */
c2[i]->device_size = lseek( c2[i]->device_fd, 0, SEEK_END );
/* Also ask the driver for the device size. */
/* if( ioctl( c2[i]->device_fd, BLKGETSIZE64, &size64 ) ) */
if( ioctl( c2[i]->device_fd, _IOR( 0x12, 114, size_t ), &size64 ) )
{
/* The ioctl failed. */
fprintf( stderr, "Error: BLKGETSIZE64 failed on '%s'.\n", c2[i]->device_name );
nwipe_log( NWIPE_LOG_ERROR, "BLKGETSIZE64 failed on '%s'.\n", c2[i]->device_name );
nwipe_error++;
}
c2[i]->device_size = size64;
/* Check whether the two size values agree. */
if( c2[i]->device_size != size64 )
{
/* This could be caused by the linux last-odd-block problem. */
fprintf( stderr, "Error: Last-odd-block detected on '%s'.\n", c2[i]->device_name );
nwipe_log( NWIPE_LOG_ERROR, "Last-odd-block detected on '%s'.", c2[i]->device_name );
nwipe_error++;
}
if( c2[i]->device_size == (long long) -1 )
{
/* We cannot determine the size of this device. */
nwipe_perror( errno, __FUNCTION__, "lseek" );
nwipe_log( NWIPE_LOG_ERROR, "Unable to determine the size of '%s'.", c2[i]->device_name );
nwipe_error++;
}
else
{
/* Reset the file pointer. */
r = lseek( c2[i]->device_fd, 0, SEEK_SET );
if( r == (off64_t) -1 )
/* Also ask the driver for the device size. */
/* if( ioctl( c2[i]->device_fd, BLKGETSIZE64, &size64 ) ) */
if( ioctl( c2[i]->device_fd, _IOR( 0x12, 114, size_t ), &size64 ) )
{
nwipe_perror( errno, __FUNCTION__, "lseek" );
nwipe_log( NWIPE_LOG_ERROR, "Unable to reset the '%s' file offset.", c2[i]->device_name );
/* The ioctl failed. */
fprintf( stderr, "Error: BLKGETSIZE64 failed on '%s'.\n", c2[i]->device_name );
nwipe_log( NWIPE_LOG_ERROR, "BLKGETSIZE64 failed on '%s'.\n", c2[i]->device_name );
nwipe_error++;
}
}
c2[i]->device_size = size64;
if( c2[i]->device_size == 0 )
{
nwipe_log( NWIPE_LOG_ERROR, "Device '%s' is size %llu.", c2[i]->device_name, c2[i]->device_size );
nwipe_error++;
continue;
}
else
{
nwipe_log( NWIPE_LOG_INFO, "Device '%s' is size %llu.", c2[i]->device_name, c2[i]->device_size );
}
/* Check whether the two size values agree. */
if( c2[i]->device_size != size64 )
{
/* This could be caused by the linux last-odd-block problem. */
fprintf( stderr, "Error: Last-odd-block detected on '%s'.\n", c2[i]->device_name );
nwipe_log( NWIPE_LOG_ERROR, "Last-odd-block detected on '%s'.", c2[i]->device_name );
nwipe_error++;
}
/* Fork a child process. */
errno = pthread_create( &c2[i]->thread, NULL, nwipe_options.method, (void*) c2[i] );
if( errno )
{
nwipe_perror( errno, __FUNCTION__, "pthread_create" );
if( !nwipe_options.nogui )
nwipe_gui_free();
return errno;
if( c2[i]->device_size == (long long) -1 )
{
/* We cannot determine the size of this device. */
nwipe_perror( errno, __FUNCTION__, "lseek" );
nwipe_log( NWIPE_LOG_ERROR, "Unable to determine the size of '%s'.", c2[i]->device_name );
nwipe_error++;
}
else
{
/* Reset the file pointer. */
r = lseek( c2[i]->device_fd, 0, SEEK_SET );
if( r == (off64_t) -1 )
{
nwipe_perror( errno, __FUNCTION__, "lseek" );
nwipe_log( NWIPE_LOG_ERROR, "Unable to reset the '%s' file offset.", c2[i]->device_name );
nwipe_error++;
}
}
if( c2[i]->device_size == 0 )
{
nwipe_log( NWIPE_LOG_ERROR,
"%s, sect/blk/dev %i/%i/%llu",
c2[i]->device_name,
c2[i]->device_sector_size,
c2[i]->device_block_size,
c2[i]->device_size );
nwipe_error++;
continue;
}
else
{
nwipe_log( NWIPE_LOG_NOTICE,
"%s, sect/blk/dev %i/%i/%llu",
c2[i]->device_name,
c2[i]->device_sector_size,
c2[i]->device_block_size,
c2[i]->device_size );
}
/* Fork a child process. */
errno = pthread_create( &c2[i]->thread, NULL, nwipe_options.method, (void*) c2[i] );
if( errno )
{
nwipe_perror( errno, __FUNCTION__, "pthread_create" );
if( !nwipe_options.nogui )
nwipe_gui_free();
return errno;
}
else
{
wipe_threads_started = 1;
}
}
}
@@ -419,6 +548,10 @@ int main( int argc, char** argv )
}
/* Wait for all the wiping threads to finish, but don't wait if we receive the terminate signal */
/* set getch delay to 2/10th second. */
halfdelay( 10 );
i = 0;
while( i < nwipe_selected && terminate_signal == 0 )
{
@@ -436,33 +569,34 @@ int main( int argc, char** argv )
i++;
continue;
}
sleep( 2 ); /* DO NOT REMOVE ! Stops the routine hogging CPU cycles */
sleep( 1 ); /* DO NOT REMOVE ! Stops the routine hogging CPU cycles */
}
if( terminate_signal == 1 )
if( terminate_signal != 1 )
{
nwipe_log( NWIPE_LOG_INFO, "Program interrupted" );
}
else
{
if( !nwipe_options.nowait )
if( !nwipe_options.nowait && !nwipe_options.autopoweroff )
{
do
{
sleep( 1 );
} while( terminate_signal != 1 );
}
}
nwipe_log( NWIPE_LOG_INFO, "Exit in progress" );
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_INFO, "Exit in progress" );
}
/* Send a REQUEST for the wipe threads to be cancelled */
for( i = 0; i < nwipe_selected; i++ )
{
if( c2[i]->thread )
{
nwipe_log( NWIPE_LOG_INFO, "Requesting wipe thread cancellation for %s", c2[i]->device_name );
nwipe_log( NWIPE_LOG_INFO, "Please wait.." );
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_INFO, "Requesting wipe thread cancellation for %s", c2[i]->device_name );
}
pthread_cancel( c2[i]->thread );
}
}
@@ -470,7 +604,10 @@ int main( int argc, char** argv )
/* Kill the GUI thread */
if( nwipe_gui_thread )
{
nwipe_log( NWIPE_LOG_INFO, "Cancelling the GUI thread." );
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_INFO, "Cancelling the GUI thread." );
}
/* We don't want to use pthread_cancel as our GUI thread is aware of the control-c
* signal and will exit itself we just join the GUI thread and wait for confirmation
@@ -480,7 +617,13 @@ int main( int argc, char** argv )
{
nwipe_log( NWIPE_LOG_WARNING, "main()>pthread_join():Error when waiting for GUI thread to cancel." );
}
nwipe_log( NWIPE_LOG_INFO, "GUI compute_stats thread has been cancelled" );
else
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_INFO, "GUI compute_stats thread has been cancelled" );
}
}
}
/* Release the gui. */
@@ -490,51 +633,169 @@ int main( int argc, char** argv )
}
/* Now join the wipe threads and wait until they have terminated */
for( i = 0; i < nwipe_selected; i++ )
any_threads_still_running = 1;
thread_timeout_counter = THREAD_CANCELLATION_TIMEOUT;
while( any_threads_still_running )
{
if( c2[i]->thread )
/* quit waiting if we've tried 'thread_timeout_counter' times */
if( thread_timeout_counter == 0 )
{
/* Joins the thread and waits for completion before continuing */
r = pthread_join( c2[i]->thread, NULL );
if( r != 0 )
break;
}
any_threads_still_running = 0;
for( i = 0; i < nwipe_selected; i++ )
{
if( c2[i]->thread )
{
nwipe_log( NWIPE_LOG_WARNING, "main()>pthread_join():Error when waiting for wipe thread to cancel." );
printf( "\nWaiting for wipe thread to cancel for %s\n", c2[i]->device_name );
/* Joins the thread and waits for completion before continuing */
r = pthread_join( c2[i]->thread, NULL );
if( r != 0 )
{
nwipe_log( NWIPE_LOG_ERROR,
"Error joining the wipe thread when waiting for thread to cancel.",
c2[i]->device_name );
if( r == EDEADLK )
{
nwipe_log( NWIPE_LOG_ERROR,
"Error joining the wipe thread: EDEADLK: Deadlock detected.",
c2[i]->device_name );
}
else
{
if( r == EINVAL )
{
nwipe_log( NWIPE_LOG_ERROR,
"Error joining the wipe thread: %s EINVAL: thread is not joinable.",
c2[i]->device_name );
}
else
{
if( r == ESRCH )
{
nwipe_log( NWIPE_LOG_ERROR,
"Error joining the wipe thread: %s ESRCH: no matching thread found",
c2[i]->device_name );
}
}
}
any_threads_still_running = 1;
}
else
{
c2[i]->thread = 0; /* Zero the thread so we know it's been cancelled */
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_INFO, "Wipe thread for device %s has terminated", c2[i]->device_name );
}
/* Close the device file descriptor. */
close( c2[i]->device_fd );
}
}
c2[i]->thread = 0; /* Zero the thread so we know it's been cancelled */
nwipe_log( NWIPE_LOG_INFO, "Wipe thread for device %s has been cancelled", c2[i]->device_name );
/* Close the device file descriptor. */
close( c2[i]->device_fd );
}
thread_timeout_counter--;
sleep( 1 );
}
for( i = 0; i < nwipe_selected; i++ )
if( nwipe_options.verbose )
{
/* Check for non-fatal errors. */
if( c2[i]->result > 0 )
for( i = 0; i < nwipe_selected; i++ )
{
nwipe_log( NWIPE_LOG_FATAL, "Nwipe exited with non fatal errors on device = %s\n", c2[i]->device_name );
return_status = 1;
nwipe_log( NWIPE_LOG_DEBUG,
"Status: %s, result=%d, pass_errors=%llu, verify_errors=%llu, fsync_errors=%llu",
c2[i]->device_name,
c2[i]->result,
c2[i]->pass_errors,
c2[i]->verify_errors,
c2[i]->fsyncdata_errors );
}
}
for( i = 0; i < nwipe_selected; i++ )
/* if no wipe threads started then zero each selected drive result flag,
* as we don't need to report fatal/non fatal errors if no wipes were ever started ! */
if( wipe_threads_started == 0 )
{
/* Check for fatal errors. */
if( c2[i]->result < 0 )
for( i = 0; i < nwipe_selected; i++ )
{
nwipe_log( NWIPE_LOG_ERROR, "Nwipe exited with fatal errors on device = %s\n", c2[i]->device_name );
return_status = -1;
c2[i]->result = 0;
}
}
else
{
for( i = 0; i < nwipe_selected; i++ )
{
/* Check for errors. */
if( c2[i]->result != 0 || c2[i]->pass_errors != 0 || c2[i]->verify_errors != 0
|| c2[i]->fsyncdata_errors != 0 )
{
/* If the run_method ever returns anything other than zero then makesure there is at least one pass
* error This is so that the log summary tables correctly show a failure when one occurs as it only
* shows pass, verification and fdatasync errors. */
if( c2[i]->result != 0 )
{
if( c2[i]->pass_errors == 0 )
{
c2[i]->pass_errors = 1;
}
}
nwipe_log( NWIPE_LOG_FATAL,
"Nwipe exited with errors on device = %s, see log for specific error\n",
c2[i]->device_name );
nwipe_log( NWIPE_LOG_DEBUG,
"Status: %s, result=%d, pass_errors=%llu, verify_errors=%llu, fsync_errors=%llu",
c2[i]->device_name,
c2[i]->result,
c2[i]->pass_errors,
c2[i]->verify_errors,
c2[i]->fsyncdata_errors );
non_fatal_errors_flag = 1;
return_status = 1;
}
}
}
if( return_status == 0 )
/* Generate and send the drive status summary to the log */
nwipe_log_summary( c2, nwipe_selected );
/* Print a one line status message for the user */
if( return_status == 0 || return_status == 1 )
{
nwipe_log( NWIPE_LOG_INFO, "Nwipe successfully exited." );
if( user_abort == 1 )
{
if( global_wipe_status == 1 )
{
nwipe_log( NWIPE_LOG_INFO,
"Nwipe was aborted by the user. Check the summary table for the drive status." );
}
else
{
nwipe_log( NWIPE_LOG_INFO, "Nwipe was aborted by the user prior to the wipe starting." );
}
}
else
{
if( fatal_errors_flag == 1 || non_fatal_errors_flag == 1 )
{
nwipe_log( NWIPE_LOG_INFO,
"Nwipe exited with errors, check the log & summary table for individual drive status." );
}
else
{
nwipe_log( NWIPE_LOG_INFO, "Nwipe successfully completed. See summary table for details." );
}
}
}
cleanup();
check_for_autopoweroff();
/* Exit. */
return return_status;
}
@@ -542,6 +803,13 @@ int main( int argc, char** argv )
void* signal_hand( void* ptr )
{
int sig;
int hours;
int minutes;
int seconds;
hours = 0;
minutes = 0;
seconds = 0;
// Define signals that this handler should react to
sigset_t sigset;
@@ -553,6 +821,7 @@ void* signal_hand( void* ptr )
sigaddset( &sigset, SIGUSR1 );
int i;
char eta[9];
/* Set up the structs we will use for the data required. */
nwipe_thread_data_ptr_t* nwipe_thread_data_ptr;
@@ -574,7 +843,6 @@ void* signal_hand( void* ptr )
// Log current status. All values are automatically updated by the GUI
case SIGUSR1:
{
compute_stats( ptr );
for( i = 0; i < nwipe_misc_thread_data->nwipe_selected; i++ )
@@ -608,14 +876,20 @@ void* signal_hand( void* ptr )
{
status = "[syncing]";
}
convert_seconds_to_hours_minutes_seconds( c[i]->eta, &hours, &minutes, &seconds );
nwipe_log( NWIPE_LOG_INFO,
"%s: %05.2f%%, round %i of %i, pass %i of %i %s",
"%s: %05.2f%%, round %i of %i, pass %i of %i, eta %02i:%02i:%02i, %s",
c[i]->device_name,
c[i]->round_percent,
c[i]->round_working,
c[i]->round_count,
c[i]->pass_working,
c[i]->pass_count,
hours,
minutes,
seconds,
status );
}
else
@@ -638,21 +912,21 @@ void* signal_hand( void* ptr )
}
break;
}
case SIGHUP:
case SIGINT:
case SIGQUIT:
case SIGTERM:
{
/* Set termination flag for main() which will do housekeeping prior to exit */
terminate_signal = 1;
/* Set the user abort flag */
user_abort = 1;
/* Return control to the main thread, returning the signal received */
return ( (void*) 0 );
break;
}
}
}
@@ -688,3 +962,21 @@ int cleanup()
return 0;
}
void check_for_autopoweroff( void )
{
char cmd[] = "shutdown -Ph +1 \"System going down in one minute\"";
FILE* fp;
int r; // A result buffer.
/* User request auto power down ? */
if( nwipe_options.autopoweroff == 1 )
{
fp = popen( cmd, "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_INFO, "Failed to autopoweroff to %s", cmd );
return;
}
r = pclose( fp );
}
}

View File

@@ -25,6 +25,8 @@
/* Function prototypes */
int cleanup();
void check_for_autopoweroff( void );
void* signal_hand( void* );
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
@@ -66,17 +68,13 @@ int cleanup();
#include <time.h>
#include <unistd.h>
#include "config.h"
/*#include "config.h"*/
/* System errors. */
extern int errno;
/* Global array to hold log values to print when logging to STDOUT */
/* char **log_lines;
int log_current_element = 0;
int log_elements_allocated = 0;
int log_elements_displayed = 0;
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; */
/* 0=wipe not yet started, 1=wipe has been started by the user */
extern int global_wipe_status;
/* Ncurses headers. */
#ifdef NCURSES_IN_SUBDIR
@@ -108,9 +106,9 @@ typedef unsigned char u8;
#define BLKBSZSET _IOW( 0x12, 113, size_t )
#define BLKGETSIZE64 _IOR( 0x12, 114, sizeof( u64 ) )
#define THREAD_CANCELLATION_TIMEOUT 10
/* This is required for ioctl FDFLUSH. */
#include <linux/fd.h>
void* signal_hand( void* );
#endif /* NWIPE_H_ */

View File

@@ -40,6 +40,7 @@ int nwipe_options_parse( int argc, char** argv )
extern nwipe_prng_t nwipe_twister;
extern nwipe_prng_t nwipe_isaac;
extern nwipe_prng_t nwipe_isaac64;
/* The getopt() result holder. */
int nwipe_opt;
@@ -53,65 +54,81 @@ int nwipe_options_parse( int argc, char** argv )
int i;
/* The list of acceptable short options. */
char nwipe_options_short[] = "Vhl:m:p:r:e:";
char nwipe_options_short[] = "Vvhl:m:p:qr:e:";
/* The list of acceptable long options. */
static struct option nwipe_options_long[] = {
/* Set when the user wants to wipe without a confirmation prompt. */
{"autonuke", no_argument, 0, 0},
{ "autonuke", no_argument, 0, 0 },
/* Set when the user wants to have the system powerdown on completion of wipe. */
{ "autopoweroff", no_argument, 0, 0 },
/* A GNU standard option. Corresponds to the 'h' short option. */
{"help", no_argument, 0, 'h'},
{ "help", no_argument, 0, 'h' },
/* The wipe method. Corresponds to the 'm' short option. */
{"method", required_argument, 0, 'm'},
{ "method", required_argument, 0, 'm' },
/* Log file. Corresponds to the 'l' short option. */
{"logfile", required_argument, 0, 'l'},
{ "logfile", required_argument, 0, 'l' },
/* Exclude devices, comma separated list */
{"exclude", required_argument, 0, 'e'},
{ "exclude", required_argument, 0, 'e' },
/* The Pseudo Random Number Generator. */
{"prng", required_argument, 0, 'p'},
{ "prng", required_argument, 0, 'p' },
/* The number of times to run the method. */
{"rounds", required_argument, 0, 'r'},
{ "rounds", required_argument, 0, 'r' },
/* Whether to blank the disk after wiping. */
{"noblank", no_argument, 0, 0},
{ "noblank", no_argument, 0, 0 },
/* Whether to ignore all USB devices. */
{ "nousb", no_argument, 0, 0 },
/* Whether to exit after wiping or wait for a keypress. */
{"nowait", no_argument, 0, 0},
{ "nowait", no_argument, 0, 0 },
/* Whether to allow signals to interrupt a wipe. */
{"nosignals", no_argument, 0, 0},
{ "nosignals", no_argument, 0, 0 },
/* Whether to exit after wiping or wait for a keypress. */
{"nogui", no_argument, 0, 0},
/* Whether to display the gui. */
{ "nogui", no_argument, 0, 0 },
/* A flag to indicate whether the devices whould be opened in sync mode. */
{"sync", required_argument, 0, 0},
/* Whether to anonymize the serial numbers. */
{ "quiet", no_argument, 0, 'q' },
/* A flag to indicate whether the devices would be opened in sync mode. */
{ "sync", required_argument, 0, 0 },
/* Verify that wipe patterns are being written to the device. */
{"verify", required_argument, 0, 0},
{ "verify", required_argument, 0, 0 },
/* Display program version. */
{"version", no_argument, 0, 'V'},
{ "verbose", no_argument, 0, 'v' },
/* Display program version. */
{ "version", no_argument, 0, 'V' },
/* Requisite padding for getopt(). */
{0, 0, 0, 0}};
{ 0, 0, 0, 0 } };
/* Set default options. */
nwipe_options.autonuke = 0;
nwipe_options.autopoweroff = 0;
nwipe_options.method = &nwipe_dodshort;
nwipe_options.prng = &nwipe_twister;
nwipe_options.prng = ( sizeof( unsigned long int ) >= 8 ) ? &nwipe_isaac64 : &nwipe_isaac;
nwipe_options.rounds = 1;
nwipe_options.noblank = 0;
nwipe_options.nousb = 0;
nwipe_options.nowait = 0;
nwipe_options.nosignals = 0;
nwipe_options.nogui = 0;
nwipe_options.sync = 100000;
nwipe_options.quiet = 0;
nwipe_options.sync = DEFAULT_SYNC_RATE;
nwipe_options.verbose = 0;
nwipe_options.verify = NWIPE_VERIFY_LAST;
memset( nwipe_options.logfile, '\0', sizeof( nwipe_options.logfile ) );
@@ -143,12 +160,24 @@ int nwipe_options_parse( int argc, char** argv )
break;
}
if( strcmp( nwipe_options_long[i].name, "autopoweroff" ) == 0 )
{
nwipe_options.autopoweroff = 1;
break;
}
if( strcmp( nwipe_options_long[i].name, "noblank" ) == 0 )
{
nwipe_options.noblank = 1;
break;
}
if( strcmp( nwipe_options_long[i].name, "nousb" ) == 0 )
{
nwipe_options.nousb = 1;
break;
}
if( strcmp( nwipe_options_long[i].name, "nowait" ) == 0 )
{
nwipe_options.nowait = 1;
@@ -168,11 +197,17 @@ int nwipe_options_parse( int argc, char** argv )
break;
}
if( strcmp( nwipe_options_long[i].name, "verbose" ) == 0 )
{
nwipe_options.verbose = 1;
break;
}
if( strcmp( nwipe_options_long[i].name, "sync" ) == 0 )
{
if( sscanf( optarg, " %i", &nwipe_options.sync ) != 1 || nwipe_options.sync < 1 )
if( sscanf( optarg, " %i", &nwipe_options.sync ) != 1 || nwipe_options.sync < 0 )
{
fprintf( stderr, "Error: The sync argument must be a positive integer.\n" );
fprintf( stderr, "Error: The sync argument must be a positive integer or zero.\n" );
exit( EINVAL );
}
break;
@@ -246,9 +281,21 @@ int nwipe_options_parse( int argc, char** argv )
break;
}
if( strcmp( optarg, "verify" ) == 0 )
if( strcmp( optarg, "one" ) == 0 )
{
nwipe_options.method = &nwipe_verify;
nwipe_options.method = &nwipe_one;
break;
}
if( strcmp( optarg, "verify_zero" ) == 0 )
{
nwipe_options.method = &nwipe_verify_zero;
break;
}
if( strcmp( optarg, "verify_one" ) == 0 )
{
nwipe_options.method = &nwipe_verify_one;
break;
}
@@ -329,10 +376,21 @@ int nwipe_options_parse( int argc, char** argv )
break;
}
if( strcmp( optarg, "isaac64" ) == 0 )
{
nwipe_options.prng = &nwipe_isaac64;
break;
}
/* Else we do not know this PRNG. */
fprintf( stderr, "Error: Unknown prng '%s'.\n", optarg );
exit( EINVAL );
case 'q': /* Anonymize serial numbers */
nwipe_options.quiet = 1;
break;
case 'r': /* Rounds option. */
if( sscanf( optarg, " %i", &nwipe_options.rounds ) != 1 || nwipe_options.rounds < 1 )
@@ -343,6 +401,11 @@ int nwipe_options_parse( int argc, char** argv )
break;
case 'v': /* verbose */
nwipe_options.verbose = 1;
break;
case 'V': /* Version option. */
printf( "%s version %s\n", program_name, version_string );
@@ -364,6 +427,10 @@ int nwipe_options_parse( int argc, char** argv )
void nwipe_options_log( void )
{
extern nwipe_prng_t nwipe_twister;
extern nwipe_prng_t nwipe_isaac;
extern nwipe_prng_t nwipe_isaac64;
/**
* Prints a manifest of options to the log.
*/
@@ -379,6 +446,15 @@ void nwipe_options_log( void )
nwipe_log( NWIPE_LOG_NOTICE, " autonuke = %i (off)", nwipe_options.autonuke );
}
if( nwipe_options.autopoweroff )
{
nwipe_log( NWIPE_LOG_NOTICE, " autopoweroff = %i (on)", nwipe_options.autopoweroff );
}
else
{
nwipe_log( NWIPE_LOG_NOTICE, " autopoweroff = %i (off)", nwipe_options.autopoweroff );
}
if( nwipe_options.noblank )
{
nwipe_log( NWIPE_LOG_NOTICE, " do not perform a final blank pass" );
@@ -400,7 +476,32 @@ void nwipe_options_log( void )
}
nwipe_log( NWIPE_LOG_NOTICE, " banner = %s", banner );
if( nwipe_options.prng == &nwipe_twister )
{
nwipe_log( NWIPE_LOG_NOTICE, " prng = Mersenne Twister" );
}
else
{
if( nwipe_options.prng == &nwipe_isaac )
{
nwipe_log( NWIPE_LOG_NOTICE, " prng = Isaac" );
}
else
{
if( nwipe_options.prng == &nwipe_isaac64 )
{
nwipe_log( NWIPE_LOG_NOTICE, " prng = Isaac64" );
}
else
{
nwipe_log( NWIPE_LOG_NOTICE, " prng = Undefined" );
}
}
}
nwipe_log( NWIPE_LOG_NOTICE, " method = %s", nwipe_method_label( nwipe_options.method ) );
nwipe_log( NWIPE_LOG_NOTICE, " quiet = %i", nwipe_options.quiet );
nwipe_log( NWIPE_LOG_NOTICE, " rounds = %i", nwipe_options.rounds );
nwipe_log( NWIPE_LOG_NOTICE, " sync = %i", nwipe_options.sync );
@@ -435,15 +536,23 @@ void display_help()
/* Limit line length to a maximum of 80 characters so it looks good in 80x25 terminals i.e shredos */
/* ___12345678901234567890123456789012345678901234567890123456789012345678901234567890< Do not exceed */
puts( " -V, --version Prints the version number\n" );
puts( " -v, --verbose Prints more messages to the log\n" );
puts( " -h, --help Prints this help\n" );
puts( " --autonuke If no devices have been specified on the command line," );
puts( " starts wiping all devices immediately. If devices have" );
puts( " been specified, starts wiping only those specified" );
puts( " devices immediately.\n" );
puts( " --sync=NUM Will perform a sync after NUM writes (default: 0)" );
puts( " 0 - fdatasync after the disk is completely written" );
puts( " 1 - fdatasync after every write" );
puts( " 1000000 - fdatasync after 1000000 writes ect." );
puts( " --autopoweroff Power off system on completion of wipe delayed for" );
puts( " for one minute. During this one minute delay you can" );
puts( " abort the shutdown by typing sudo shutdown -c\n" );
printf( " --sync=NUM Will perform a sync after NUM writes (default: %d)\n", DEFAULT_SYNC_RATE );
puts( " 0 - fdatasync after the disk is completely written" );
puts( " fdatasync errors not detected until completion." );
puts( " 0 is not recommended as disk errors may cause" );
puts( " nwipe to appear to hang" );
puts( " 1 - fdatasync after every write" );
puts( " Warning: Lower values will reduce wipe speeds." );
puts( " 1000 - fdatasync after 1000 writes etc.\n" );
puts( " --verify=TYPE Whether to perform verification of erasure" );
puts( " (default: last)" );
puts( " off - Do not verify" );
@@ -457,20 +566,27 @@ void display_help()
puts( " ops2 - RCMP TSSIT OPS-II" );
puts( " random / prng / stream - PRNG Stream" );
puts( " zero / quick - Overwrite with zeros" );
puts( " verify - Verifies disk is zero filled\n" );
puts( " one - Overwrite with ones (0xFF)" );
puts( " verify_zero - Verifies disk is zero filled" );
puts( " verify_one - Verifies disk is 0xFF filled\n" );
puts( " -l, --logfile=FILE Filename to log to. Default is STDOUT\n" );
puts( " -p, --prng=METHOD PRNG option (mersenne|twister|isaac)\n" );
puts( " -p, --prng=METHOD PRNG option (mersenne|twister|isaac|isaac64)\n" );
puts( " -q, --quiet Anonymize logs and the GUI by removing unique data, i.e." );
puts( " serial numbers, LU WWN Device ID, and SMBIOS/DMI data" );
puts( " XXXXXX = S/N exists, ????? = S/N not obtainable\n" );
puts( " -r, --rounds=NUM Number of times to wipe the device using the selected" );
puts( " method (default: 1)\n" );
puts( " --noblank Do not blank disk after wipe" );
puts( " --noblank Do NOT blank disk after wipe" );
puts( " (default is to complete a final blank pass)\n" );
puts( " --nowait Do not wait for a key before exiting" );
puts( " --nowait Do NOT wait for a key before exiting" );
puts( " (default is to wait)\n" );
puts( " --nosignals Do not allow signals to interrupt a wipe" );
puts( " --nosignals Do NOT allow signals to interrupt a wipe" );
puts( " (default is to allow)\n" );
puts( " --nogui Do not show the GUI interface. Automatically invokes" );
puts( " --nogui Do NOT show the GUI interface. Automatically invokes" );
puts( " the nowait option. Must be used with the --autonuke" );
puts( " option. Send SIGUSR1 to log current stats\n" );
puts( " --nousb Do NOT show or wipe any USB devices whether in GUI" );
puts( " mode, --nogui or --autonuke modes.\n" );
puts( " -e, --exclude=DEVICES Up to ten comma separated devices to be excluded" );
puts( " --exclude=/dev/sdc" );
puts( " --exclude=/dev/sdc,/dev/sdd" );

View File

@@ -37,6 +37,7 @@
#define NWIPE_KNOB_STAT "/proc/stat"
#define MAX_NUMBER_EXCLUDED_DRIVES 10
#define MAX_DRIVE_PATH_LENGTH 200 // e.g. /dev/sda is only 8 characters long, so 200 should be plenty.
#define DEFAULT_SYNC_RATE 100000
/* Function prototypes for loading options from the environment and command line. */
int nwipe_options_parse( int argc, char** argv );
@@ -48,7 +49,9 @@ void display_help();
typedef struct
{
int autonuke; // Do not prompt the user for confirmation when set.
int autopoweroff; // Power off on completion of wipe
int noblank; // Do not perform a final blanking pass.
int nousb; // Do not show or wipe any USB devices.
int nowait; // Do not wait for a final key before exiting.
int nosignals; // Do not allow signals to interrupt a wipe.
int nogui; // Do not show the GUI.
@@ -57,8 +60,10 @@ typedef struct
char logfile[FILENAME_MAX]; // The filename to log the output to.
char exclude[MAX_NUMBER_EXCLUDED_DRIVES][MAX_DRIVE_PATH_LENGTH]; // Drives excluded from the search.
nwipe_prng_t* prng; // The pseudo random number generator implementation.
int quiet; // Anonymize serial numbers
int rounds; // The number of times that the wipe method should be called.
int sync; // A flag to indicate whether and how often writes should be sync'd.
int verbose; // Make log more verbose
nwipe_verify_t verify; // A flag to indicate whether writes should be verified.
} nwipe_options_t;

View File

@@ -130,6 +130,7 @@ int nwipe_random_verify( nwipe_context_t* c )
/* FIXME: Is there a better way to handle this? */
nwipe_perror( errno, __FUNCTION__, "fdatasync" );
nwipe_log( NWIPE_LOG_WARNING, "Buffer flush failure on '%s'.", c->device_name );
c->fsyncdata_errors++;
}
/* Reseed the PRNG. */
@@ -248,6 +249,9 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
/* Counter to track when to do a fdatasync. */
int i = 0;
/* general index counter */
int idx;
if( c->prng_seed.s == NULL )
{
nwipe_log( NWIPE_LOG_SANITY, "__FUNCTION__: Null seed pointer." );
@@ -260,8 +264,9 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
return -1;
}
/* Create the output buffer. */
b = malloc( c->device_stat.st_blksize );
/* Create the initialised output buffer. Initialised because we don't want memory leaks
* to disk in the event of some future undetected bug in a prng or its implementation. */
b = calloc( c->device_stat.st_blksize, sizeof( char ) );
/* Check the memory allocation. */
if( !b )
@@ -317,6 +322,26 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
/* Fill the output buffer with the random pattern. */
c->prng->read( &c->prng_state, b, blocksize );
/* For the first block only, check the prng actually wrote something to the buffer */
if( z == c->device_size )
{
idx = c->device_stat.st_blksize;
while( idx > 0 )
{
if( b[idx] != 0 )
{
nwipe_log( NWIPE_LOG_NOTICE, "prng stream is active" );
break;
}
idx--;
}
if( idx == 0 )
{
nwipe_log( NWIPE_LOG_FATAL, "ERROR, prng wrote nothing to the buffer" );
return -1;
}
}
/* Write the next block out to the device. */
r = write( c->device_fd, b, blocksize );
@@ -382,6 +407,7 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
nwipe_perror( errno, __FUNCTION__, "fdatasync" );
nwipe_log( NWIPE_LOG_WARNING, "Buffer flush failure on '%s'.", c->device_name );
nwipe_log( NWIPE_LOG_WARNING, "Wrote %llu bytes on '%s'.", c->pass_done, c->device_name );
c->fsyncdata_errors++;
free( b );
return -1;
}
@@ -411,6 +437,7 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
/* FIXME: Is there a better way to handle this? */
nwipe_perror( errno, __FUNCTION__, "fdatasync" );
nwipe_log( NWIPE_LOG_WARNING, "Buffer flush failure on '%s'.", c->device_name );
c->fsyncdata_errors++;
}
/* We're done. */
@@ -505,6 +532,7 @@ int nwipe_static_verify( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
/* FIXME: Is there a better way to handle this? */
nwipe_perror( errno, __FUNCTION__, "fdatasync" );
nwipe_log( NWIPE_LOG_WARNING, "Buffer flush failure on '%s'.", c->device_name );
c->fsyncdata_errors++;
}
/* Reset the file pointer. */
@@ -799,6 +827,7 @@ int nwipe_static_pass( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
nwipe_perror( errno, __FUNCTION__, "fdatasync" );
nwipe_log( NWIPE_LOG_WARNING, "Buffer flush failure on '%s'.", c->device_name );
nwipe_log( NWIPE_LOG_WARNING, "Wrote %llu bytes on '%s'.", c->pass_done, c->device_name );
c->fsyncdata_errors++;
free( b );
return -1;
}
@@ -825,6 +854,7 @@ int nwipe_static_pass( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
/* FIXME: Is there a better way to handle this? */
nwipe_perror( errno, __FUNCTION__, "fdatasync" );
nwipe_log( NWIPE_LOG_WARNING, "Buffer flush failure on '%s'.", c->device_name );
c->fsyncdata_errors++;
}
/* Release the output buffer. */

View File

@@ -9,7 +9,7 @@
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
@@ -19,39 +19,60 @@
#include "nwipe.h"
#include "prng.h"
#include "context.h"
#include "logging.h"
#include "mt19937ar-cok/mt19937ar-cok.h"
#include "isaac_rand/isaac_rand.h"
#include "isaac_rand/isaac64.h"
nwipe_prng_t nwipe_twister = {"Mersenne Twister (mt19937ar-cok)", nwipe_twister_init, nwipe_twister_read};
nwipe_prng_t nwipe_twister = { "Mersenne Twister (mt19937ar-cok)", nwipe_twister_init, nwipe_twister_read };
nwipe_prng_t nwipe_isaac = {"ISAAC (rand.c 20010626)", nwipe_isaac_init, nwipe_isaac_read};
nwipe_prng_t nwipe_isaac = { "ISAAC (rand.c 20010626)", nwipe_isaac_init, nwipe_isaac_read };
nwipe_prng_t nwipe_isaac64 = { "ISAAC-64 (isaac64.c)", nwipe_isaac64_init, nwipe_isaac64_read };
int nwipe_u32tobuffer( u8* buffer, u32 rand, int len )
/* Print given number of bytes from unsigned integer number to a byte stream buffer starting with low-endian. */
static inline void u32_to_buffer( u8* restrict buffer, u32 val, const int len )
{
/*
* Print given number of bytes from unsigned integer number to a byte stream buffer starting with low-endian.
*/
int i;
u8 c; // single char
if( len > sizeof( u32 ) )
for( int i = 0; i < len; ++i )
{
nwipe_log( NWIPE_LOG_FATAL, "Tried to print longer number than the value passed." );
len = sizeof( u32 );
buffer[i] = ( u8 )( val & 0xFFUL );
val >>= 8;
}
for( i = 0; i < len; i++ )
}
static inline void u64_to_buffer( u8* restrict buffer, u64 val, const int len )
{
for( int i = 0; i < len; ++i )
{
c = rand & 0xFFUL;
rand = rand >> 8;
buffer[i] = c;
buffer[i] = ( u8 )( val & 0xFFULL );
val >>= 8;
}
return 0;
}
static inline u32 isaac_nextval( randctx* restrict ctx )
{
if( ctx->randcnt == 0 )
{
isaac( ctx );
ctx->randcnt = RANDSIZ;
}
ctx->randcnt--;
return ctx->randrsl[ctx->randcnt];
}
static inline u64 isaac64_nextval( rand64ctx* restrict ctx )
{
if( ctx->randcnt == 0 )
{
isaac64( ctx );
ctx->randcnt = RANDSIZ;
}
ctx->randcnt--;
return ctx->randrsl[ctx->randcnt];
}
int nwipe_twister_init( NWIPE_PRNG_INIT_SIGNATURE )
{
nwipe_log( NWIPE_LOG_NOTICE, "Initialising Mersenne Twister prng" );
if( *state == NULL )
{
/* This is the first time that we have been called. */
@@ -63,23 +84,22 @@ int nwipe_twister_init( NWIPE_PRNG_INIT_SIGNATURE )
int nwipe_twister_read( NWIPE_PRNG_READ_SIGNATURE )
{
u32 i = 0;
u32 ii;
u32 words = count / SIZE_OF_TWISTER; // the values of twister_genrand_int32 is strictly 4 bytes
u32 remain = count % SIZE_OF_TWISTER; // the values of twister_genrand_int32 is strictly 4 bytes
u8* restrict bufpos = buffer;
size_t words = count / SIZE_OF_TWISTER; // the values of twister_genrand_int32 is strictly 4 bytes
/* Twister returns 4-bytes per call, so progress by 4 bytes. */
for( ii = 0; ii < words; ++ii )
for( size_t ii = 0; ii < words; ++ii )
{
nwipe_u32tobuffer( (u8*) ( buffer + i ), twister_genrand_int32( (twister_state_t*) *state ), SIZE_OF_TWISTER );
i = i + SIZE_OF_TWISTER;
u32_to_buffer( bufpos, twister_genrand_int32( (twister_state_t*) *state ), SIZE_OF_TWISTER );
bufpos += SIZE_OF_TWISTER;
}
/* If there is some remainder copy only relevant number of bytes to not
* overflow the buffer. */
const size_t remain = count % SIZE_OF_TWISTER; // SIZE_OF_TWISTER is strictly 4 bytes
if( remain > 0 )
{
nwipe_u32tobuffer( (u8*) ( buffer + i ), twister_genrand_int32( (twister_state_t*) *state ), remain );
u32_to_buffer( bufpos, twister_genrand_int32( (twister_state_t*) *state ), remain );
}
return 0;
@@ -90,6 +110,8 @@ int nwipe_isaac_init( NWIPE_PRNG_INIT_SIGNATURE )
int count;
randctx* isaac_state = *state;
nwipe_log( NWIPE_LOG_NOTICE, "Initialising Isaac prng" );
if( *state == NULL )
{
/* This is the first time that we have been called. */
@@ -135,18 +157,96 @@ int nwipe_isaac_init( NWIPE_PRNG_INIT_SIGNATURE )
int nwipe_isaac_read( NWIPE_PRNG_READ_SIGNATURE )
{
/* The purpose of this function is unclear, as it does not do anything except immediately return !
* Because the variables in the macro NWIPE_PRNG_READ_SIGNATURE were then unused this throws
* up a handful of compiler warnings, related to variables being unused. To stop the compiler warnings
* I've simply put in a (void) var so that compiler sees the variable are supposed to be unused.
*
* As this code works, I thought it best not to remove this function, just in case it serves
* some purpose or is there for future use.
*/
randctx* isaac_state = *state;
u8* restrict bufpos = buffer;
size_t words = count / SIZE_OF_ISAAC; // the values of isaac is strictly 4 bytes
(void) state;
(void) buffer;
(void) count;
/* Isaac returns 4-bytes per call, so progress by 4 bytes. */
for( size_t ii = 0; ii < words; ++ii )
{
/* get the next 32bit random number */
u32_to_buffer( bufpos, isaac_nextval( isaac_state ), SIZE_OF_ISAAC );
bufpos += SIZE_OF_ISAAC;
}
/* If there is some remainder copy only relevant number of bytes to not overflow the buffer. */
const size_t remain = count % SIZE_OF_ISAAC; // SIZE_OF_ISAAC is strictly 4 bytes
if( remain > 0 )
{
u32_to_buffer( bufpos, isaac_nextval( isaac_state ), remain );
}
return 0;
}
int nwipe_isaac64_init( NWIPE_PRNG_INIT_SIGNATURE )
{
int count;
rand64ctx* isaac_state = *state;
nwipe_log( NWIPE_LOG_NOTICE, "Initialising ISAAC-64 prng" );
if( *state == NULL )
{
/* This is the first time that we have been called. */
*state = malloc( sizeof( rand64ctx ) );
isaac_state = *state;
/* Check the memory allocation. */
if( isaac_state == 0 )
{
nwipe_perror( errno, __FUNCTION__, "malloc" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to allocate memory for the isaac state." );
return -1;
}
}
/* Take the minimum of the isaac seed size and available entropy. */
if( sizeof( isaac_state->randrsl ) < seed->length )
{
count = sizeof( isaac_state->randrsl );
}
else
{
memset( isaac_state->randrsl, 0, sizeof( isaac_state->randrsl ) );
count = seed->length;
}
if( count == 0 )
{
/* Start ISACC without a seed. */
rand64init( isaac_state, 0 );
}
else
{
/* Seed the ISAAC state with entropy. */
memcpy( isaac_state->randrsl, seed->s, count );
/* The second parameter indicates that randrsl is non-empty. */
rand64init( isaac_state, 1 );
}
return 0;
}
int nwipe_isaac64_read( NWIPE_PRNG_READ_SIGNATURE )
{
rand64ctx* isaac_state = *state;
u8* restrict bufpos = buffer;
size_t words = count / SIZE_OF_ISAAC64; // the values of ISAAC-64 is strictly 8 bytes
for( size_t ii = 0; ii < words; ++ii )
{
u64_to_buffer( bufpos, isaac64_nextval( isaac_state ), SIZE_OF_ISAAC64 );
bufpos += SIZE_OF_ISAAC64;
}
/* If there is some remainder copy only relevant number of bytes to not overflow the buffer. */
const size_t remain = count % SIZE_OF_ISAAC64; // SIZE_OF_ISAAC64 is strictly 8 bytes
if( remain > 0 )
{
u64_to_buffer( bufpos, isaac64_nextval( isaac_state ), remain );
}
return 0;
}

View File

@@ -21,6 +21,8 @@
#ifndef PRNG_H_
#define PRNG_H_
#include <sys/types.h>
/* A chunk of random data. */
typedef struct
{
@@ -50,8 +52,14 @@ int nwipe_twister_read( NWIPE_PRNG_READ_SIGNATURE );
/* ISAAC prototypes. */
int nwipe_isaac_init( NWIPE_PRNG_INIT_SIGNATURE );
int nwipe_isaac_read( NWIPE_PRNG_READ_SIGNATURE );
int nwipe_isaac64_init( NWIPE_PRNG_INIT_SIGNATURE );
int nwipe_isaac64_read( NWIPE_PRNG_READ_SIGNATURE );
/* Size of the twister is not derived from the architecture, but it is strictly 4 bytes */
#define SIZE_OF_TWISTER 4
/* Size of the isaac/isaac64 is not derived from the architecture, but it is strictly 4 or 8 bytes */
#define SIZE_OF_ISAAC 4
#define SIZE_OF_ISAAC64 8
#endif /* PRNG_H_ */

270
src/temperature.c Normal file
View File

@@ -0,0 +1,270 @@
/*
* temperature.c: functions that populate the drive temperature variables
* in each drives context structure.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
//#define _LARGEFILE64_SOURCE
//#define _FILE_OFFSET_BITS 64
#define _BSD_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include <dirent.h>
#include "nwipe.h"
#include "context.h"
#include "method.h"
#include "device.h"
#include "prng.h"
#include "options.h"
#include "device.h"
#include "logging.h"
#include "temperature.h"
int nwipe_init_temperature( nwipe_context_t* c )
{
/* This function is called after each nwipe_context_t has been created.
* It initialises the temperature variables in each context and then
* constructs a path that is placed in the context that points to the
* appropriate /sys/class/hwmon/hwmonX directory that corresponds with
* the particular drive represented in the context structure.
*/
DIR* dir;
DIR* dir2;
const char dirpath[] = "/sys/class/hwmon";
char dirpath_tmp[256];
char dirpath_tmp2[256];
char dirpath_hwmonX[256];
char device[256];
char device_context_name[256];
// const char dirpath[] = "/home/nick/mouse/hwmon1";
struct dirent* dp;
struct dirent* dp2;
/* Why Initialise with 1000000? Because the GUI needs to know whether data
* has been obtained so it can display appropriate information when a
* device is unable to provide temperature data */
c->temp1_crit = 1000000;
c->temp1_highest = 1000000;
c->temp1_input = 1000000;
c->temp1_lcrit = 1000000;
c->temp1_lowest = 1000000;
c->temp1_max = 1000000;
c->temp1_min = 1000000;
c->temp1_monitored_wipe_max = 1000000;
c->temp1_monitored_wipe_min = 1000000;
c->temp1_monitored_wipe_avg = 1000000;
c->temp1_flash_rate = 2;
c->temp1_flash_rate_counter = 0;
c->temp1_path[0] = 0;
c->temp1_time = 0;
/* Each hwmonX directory is processed in turn and once a hwmonX directory has been
* found that is a block device and the block device name matches the drive
* name in the current context then the path to ../hwmonX is constructed and written
* to the drive context structure '* c'. This path is used in the nwipe_update_temperature
* function to retrieve temperature data and store it in the device context
*/
if( ( dir = opendir( dirpath ) ) != NULL )
{
/* Process each hwmonX sub directory in turn */
while( ( dp = readdir( dir ) ) != NULL )
{
/* Does the directory start with 'hwmon' */
if( strstr( dp->d_name, "hwmon" ) != NULL )
{
if( nwipe_options.verbose )
{
/* print a empty line to separate the different hwmon sensors */
nwipe_log( NWIPE_LOG_DEBUG, "hwmon:" );
}
strcpy( dirpath_tmp, dirpath );
strcat( dirpath_tmp, "/" );
strcat( dirpath_tmp, dp->d_name );
strcpy( dirpath_hwmonX, dirpath_tmp );
strcat( dirpath_tmp, "/device/block" );
/* Depending on the class of block device, the device name may
* appear in different sub-directories. So we try to open each
* directory that are known to contain block devices. These are
* /sys/class/hwmon/hwmonX/device/block
* /sys/class/hwmon/hwmonX/device/nvme/nvme0
* /sys/class/hwmon/hwmonX/device/
*/
if( ( dir2 = opendir( dirpath_tmp ) ) == NULL )
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_DEBUG, "hwmon: %s doesn't exist, trying next path", dirpath_tmp );
}
strcpy( dirpath_tmp2, dirpath_hwmonX );
strcat( dirpath_tmp2, "/device/nvme/nvme0" );
strcpy( dirpath_tmp, dirpath_tmp2 );
if( ( dir2 = opendir( dirpath_tmp ) ) == NULL )
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_DEBUG, "hwmon: %s doesn't exist, trying next path", dirpath_tmp );
}
strcpy( dirpath_tmp2, dirpath_hwmonX );
strcat( dirpath_tmp2, "/device" );
strcpy( dirpath_tmp, dirpath_tmp2 );
if( ( dir2 = opendir( dirpath_tmp ) ) == NULL )
{
if( nwipe_options.verbose )
{
nwipe_log(
NWIPE_LOG_DEBUG, "hwmon: %s doesn't exist, no more paths to try", dirpath_tmp );
}
continue;
}
}
}
if( dir2 != NULL )
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_DEBUG, "hwmon: Found %s", dirpath_tmp );
}
/* Read the device name */
while( ( dp2 = readdir( dir2 ) ) != NULL )
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_DEBUG, "hwmon: dirpath_tmp=%s/%s", dirpath_tmp, &dp2->d_name[0] );
}
/* Skip the '.' and '..' directories */
if( dp2->d_name[0] == '.' )
{
continue;
}
strcpy( device, dp2->d_name );
/* Create a copy of the device name from the context but strip the path from it, right justify
* device name, prefix with spaces so length is 8. */
nwipe_strip_path( device_context_name, c->device_name );
/* Remove leading/training whitespace from a string and left justify result */
trim( device_context_name );
/* Does the hwmon device match the device for this drive context */
if( strcmp( device, device_context_name ) != 0 )
{
/* No, so try next hwmon device */
continue;
}
else
{
/* Match ! This hwmon device matches this context, so write the hwmonX path to the context
*/
nwipe_log( NWIPE_LOG_NOTICE, "hwmon: %s has temperature monitoring", device, dirpath_tmp );
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_DEBUG, "hwmon: %s found in %s", device, dirpath_tmp );
}
/* Copy the hwmon path to the drive context structure */
strcpy( c->temp1_path, dirpath_hwmonX );
}
}
closedir( dir2 );
}
}
}
closedir( dir );
}
return 0;
}
void nwipe_update_temperature( nwipe_context_t* c )
{
/* For the given drive context obtain the path to it's hwmon temperature settings
* and read then write the temperature values back to the context. A numeric ascii to integer conversion is
* performed. The temperaures should be updated no more frequently than every 60 seconds
*/
char temperature_label[NUMBER_OF_FILES][20] = {
"temp1_crit", "temp1_highest", "temp1_input", "temp1_lcrit", "temp1_lowest", "temp1_max", "temp1_min" };
int* temperature_pcontext[NUMBER_OF_FILES] = {
&( c->temp1_crit ),
&( c->temp1_highest ),
&( c->temp1_input ),
&( c->temp1_lcrit ),
&( c->temp1_lowest ),
&( c->temp1_max ),
&( c->temp1_min ) };
char path[256];
char temperature[256];
FILE* fptr;
int idx;
int result;
for( idx = 0; idx < NUMBER_OF_FILES; idx++ )
{
/* Construct the full path including filename */
strcpy( path, c->temp1_path );
strcat( path, "/" );
strcat( path, &( temperature_label[idx][0] ) );
/* Open the file */
if( ( fptr = fopen( path, "r" ) ) != NULL )
{
/* Acquire data until we reach a newline */
result = fscanf( fptr, "%[^\n]", temperature );
/* Convert numeric ascii to binary integer */
*( temperature_pcontext[idx] ) = atoi( temperature );
/* Divide by 1000 to get degrees celcius */
*( temperature_pcontext[idx] ) = *( temperature_pcontext[idx] ) / 1000;
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_NOTICE, "hwmon: %s %dC", path, *( temperature_pcontext[idx] ) );
}
fclose( fptr );
}
else
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_NOTICE, "hwmon: Unable to open %s", path );
}
}
}
/* Update the time stamp that records when we checked the temperature,
* this is used by the GUI to check temperatures periodically, typically
* every 60 seconds */
c->temp1_time = time( NULL );
return;
}

30
src/temperature.h Normal file
View File

@@ -0,0 +1,30 @@
/*.
* temperature.h: The header file for disk drive temperature sensing
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef TEMPERATURE_H_
#define TEMPERATURE_H_
#include <sys/types.h>
#include "context.h"
int nwipe_init_temperature( nwipe_context_t* );
void nwipe_update_temperature( nwipe_context_t* );
#define NUMBER_OF_FILES 7
#endif /* TEMPERATURE_H_ */

View File

@@ -4,14 +4,14 @@
* used by configure to dynamically assign those values
* to documentation files.
*/
const char* version_string = "0.28";
const char* version_string = "0.33";
const char* program_name = "nwipe";
const char* author_name = "Martijn van Brummelen";
const char* email_address = "git@brumit.nl";
const char* years = "2020";
const char* years = "2022";
const char* copyright = "Copyright Darik Horn <dajhorn-dban@vanadac.com>\n\
Modifications to original dwipe Copyright Andy Beverley <andy@andybev.com>\n\
This is free software; see the source for copying conditions.\n\
There is NO warranty; not even for MERCHANTABILITY or FITNESS\n\
FOR A PARTICULAR PURPOSE.\n";
const char* banner = "nwipe 0.28";
const char* banner = "nwipe 0.33";