Files
nwipe/src/logging.h
PartialVolume e6a9944a7a HPA_DCO_006 - Add HPA/DCO capability
1. If nwipe enumerates a USB bridge that does not support
ATA pass through or you are wiping a USB memory stick,
nwipe will show a message in the GUI that says
"HPA/DCO hidden area indeterminate". If you get this message
you know to either get yourself a better quality USB to SATA
adapter or in the case of a USB memory stick, i've never
come across one that supports HPA/DCO so either don't worry
about it and wipe it as normal or physically destroy it.

2.We now check for a nonsense "real max sectors" as produced
by the bug in hdparm. We use our own low level function to
issue a DCO identify command and retrieve the correct value.

3. Changed the dmidecode info at the start of the log from
a 'notice' classification to 'info'.

4. Made changes to the nwipe_log function so that any messages
logged that are classified as 'debug' will not be logged unless
the --verbose flag has been set on the command line options. I
send the hex data structures and hex sense data to the logs as debug
information and as they can take up a lot of space and make the
log look untidy they will only appear in --verbose mode.

5. I also extended the nwipe's log message length from 512 to 1024
as some of the sense data was being truncated in the log.
2023-03-10 00:28:31 +00:00

66 lines
2.6 KiB
C

/*
* logging.c: Logging facilities for nwipe.
*
* Copyright Darik Horn <dajhorn-dban@vanadac.com>.
*
* 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 LOGGING_H_
#define LOGGING_H_
/* Maximum size of a log message */
#define MAX_LOG_LINE_CHARS 1024
#define MAX_SIZE_OS_STRING 1024 /* 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, // Output only when --verbose option used on cmd line.
NWIPE_LOG_INFO, // General Info not specifically relevant to the wipe.
NWIPE_LOG_NOTICE, // Most logging happens at this level related to wiping.
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_NOTIMESTAMP // logs the message without the timestamp
} nwipe_log_t;
/**
* Writes a string to the log. nwipe_log timestamps the string
* @param level the tag to display:
* NWIPE_LOG_NONE Don't display a tag
* NWIPE_LOG_DEBUG, Very verbose logging.
* NWIPE_LOG_INFO, Verbose logging.
* NWIPE_LOG_NOTICE, Most logging happens at this level.
* 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_NOTIMESTAMP logs the message without the timestamp
* @param format the string to be logged
*/
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
#endif /* LOGGING_H_ */