some code cleaning, time debugging added

This commit is contained in:
Gerold Gruber
2023-10-11 00:05:57 +02:00
parent 97efd12b93
commit 47112c4de2
4 changed files with 21 additions and 60 deletions

View File

@@ -823,9 +823,21 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
wprintw( main_window, "[%s] ", c[i + offset]->device_size_text );
// NOTE temporary timing code
clock_t t;
t = clock();
/* Read the drive temperature values */
nwipe_update_temperature( c[i + offset] );
// NOTE temporary timing code
t = clock() - t;
double time_taken = ( (double) t ) / CLOCKS_PER_SEC; // in seconds
nwipe_log( NWIPE_LOG_INFO,
"nwipe_update_temperature() took %f seconds for %s",
time_taken,
c[i + offset]->device_name );
/* print the temperature */
wprintw_temperature( c[i + offset] );

View File

@@ -3,6 +3,8 @@
* in SCSI/SAS drives context structure.
* Routines from hddtemp are used here.
*
* Author: Gerold Gruber <Gerold.Gruber@edv2g.de>
*
* 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.
@@ -42,6 +44,8 @@
#include "hddtemp.h"
#include "scsi.h"
int scsi_get_temperature( struct disk * );
int nwipe_init_scsi_temperature( nwipe_context_t* c )
{

View File

@@ -35,17 +35,6 @@ typedef __u16 u16;
#define C_to_F(val) (int)(((double)(val)*(double)1.8) + (double)32.0)
enum e_bustype { ERROR = 0, BUS_UNKNOWN, BUS_SATA, BUS_ATA, BUS_SCSI, BUS_TYPE_MAX };
// enum e_gettemp {
// GETTEMP_ERROR, /* Error */
// GETTEMP_NOT_APPLICABLE, /* */
// GETTEMP_UNKNOWN, /* Drive is not in database */
// GETTEMP_GUESS, /* Not in database, but something was guessed, user must
// check that the temperature returned is correct */
// GETTEMP_KNOWN, /* Drive appear in database */
// GETTEMP_NOSENSOR, /* Drive appear in database but is known to have no sensor */
// GETTEMP_DRIVE_SLEEP, /* Drive is sleeping */
// GETTEMP_SUCCESS /* read temperature successfully */
// };
#define GETTEMP_SUCCESS 0
#define GETTEMP_ERROR 1

View File

@@ -18,6 +18,9 @@
/*
* Adapted from a patch sended by : Frederic LOCHON <lochon@roulaise.net>
*/
/*
* Adapted for use with nwipe by : Gerold Gruber <Gerold.Gruber@edv2g.de>
*/
// Include file generated by ./configure
#ifdef HAVE_CONFIG_H
@@ -47,26 +50,6 @@
#include "scsicmds.h"
#include "hddtemp.h"
/*
static int scsi_probe(int device) {
int bus_num;
if(ioctl(device, SCSI_IOCTL_GET_BUS_NUMBER, &bus_num))
return 0;
else
return 1;
}
static const char *scsi_model (int device) {
unsigned char buf[36];
if (scsi_inquiry(device, buf) != 0)
return strdup(_("unknown"));
else {
return strdup(buf + 8);
}
}
*/
int scsi_get_temperature(struct disk *dsk) {
int i;
int tempPage = 0;
@@ -75,26 +58,9 @@ int scsi_get_temperature(struct disk *dsk) {
/*
on triche un peu
we cheat a little and do not really read form drivedb as SCSI disks are not included there
original code omitted as there is no need for it in the context of nwipe
*/
// dsk->db_entry = (struct harddrive_entry*) malloc(sizeof(struct harddrive_entry));
// if(dsk->db_entry == NULL) {
// perror("malloc");
// exit(-1);
// }
//
// dsk->db_entry->regexp = "";
// dsk->db_entry->description = "";
// dsk->db_entry->attribute_id = 0;
// dsk->db_entry->unit = 'C';
// dsk->db_entry->next = NULL;
//
// if (scsi_smartsupport(dsk->fd) == 0) {
// snprintf(dsk->errormsg, MAX_ERRORMSG_SIZE, _("S.M.A.R.T. not available"));
// close(dsk->fd);
// dsk->fd = -1;
// return GETTEMP_NOT_APPLICABLE;
// }
//
/*
Enable SMART
*/
@@ -141,13 +107,3 @@ int scsi_get_temperature(struct disk *dsk) {
}
}
/*******************************
*******************************/
/*
struct bustype scsi_bus = {
"SCSI",
scsi_probe,
scsi_model,
scsi_get_temperature
};
*/