Skip to content
Snippets Groups Projects
Commit 540530d0 authored by ballen4705's avatar ballen4705
Browse files

smartd: close file descriptors of SCSI device if not SMART capable

added new temperature attribute (231, temperature)
smartd: now open ATA disks using O_RDONLY
 ----------------------------------------------------------------------


git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@111 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent 33f02c29
Branches
No related tags found
No related merge requests found
CHANGELOG for smartmontools CHANGELOG for smartmontools
$Id: CHANGELOG,v 1.18 2002/10/24 10:53:50 ballen4705 Exp $ $Id: CHANGELOG,v 1.19 2002/10/24 11:38:11 ballen4705 Exp $
Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
...@@ -26,6 +26,11 @@ NOTES FOR NEXT RELEASE: ...@@ -26,6 +26,11 @@ NOTES FOR NEXT RELEASE:
Next release: handle extended error and self-test logs gracefully. Next release: handle extended error and self-test logs gracefully.
Parse and print attribute flag meanings Parse and print attribute flag meanings
smartmontools-5.0-12
smartd: close file descriptors of SCSI device if not SMART capable
added new temperature attribute (231, temperature)
smartd: now open ATA disks using O_RDONLY
smartmontools-5.0-11 smartmontools-5.0-11
......
...@@ -4,7 +4,7 @@ Home page of code is: http://smartmontools.sourceforge.net ...@@ -4,7 +4,7 @@ Home page of code is: http://smartmontools.sourceforge.net
Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
$Id: TODO,v 1.12 2002/10/24 10:31:02 ballen4705 Exp $ $Id: TODO,v 1.13 2002/10/24 11:38:11 ballen4705 Exp $
This program is free software; you can redistribute it and/or modify it 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 under the terms of the GNU General Public License as published by the Free
...@@ -50,7 +50,6 @@ Print flags meanings in Vendor Attribute list -- not hex value -- ...@@ -50,7 +50,6 @@ Print flags meanings in Vendor Attribute list -- not hex value --
Fixes Fixes
----- -----
SCSI code in smartd leaves file descriptors open if SMART not supported..
Fix lots of syntax like if (a != 0) Fix lots of syntax like if (a != 0)
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include "ataprint.h" #include "ataprint.h"
extern const char *CVSid1, *CVSid2; extern const char *CVSid1, *CVSid2;
const char *CVSid3="$Id: smartd.c,v 1.24 2002/10/24 10:56:10 ballen4705 Exp $" const char *CVSid3="$Id: smartd.c,v 1.25 2002/10/24 11:38:11 ballen4705 Exp $"
CVSID1 CVSID4 CVSID7; CVSID1 CVSID4 CVSID7;
int daemon_init(void){ int daemon_init(void){
...@@ -113,7 +113,7 @@ void atadevicescan ( atadevices_t *devices){ ...@@ -113,7 +113,7 @@ void atadevicescan ( atadevices_t *devices){
printout(LOG_INFO,"Reading Device %s\n", device); printout(LOG_INFO,"Reading Device %s\n", device);
fd = open ( device , O_RDWR ); fd = open(device, O_RDONLY);
if (fd < 0) if (fd < 0)
// no such device // no such device
continue; continue;
...@@ -164,14 +164,17 @@ void scsidevicescan ( scsidevices_t *devices){ ...@@ -164,14 +164,17 @@ void scsidevicescan ( scsidevices_t *devices){
fd=open (device, O_RDWR); fd=open (device, O_RDWR);
if ( fd >= 0 && !testunitready (fd)) { if (fd<0)
if (modesense ( fd, 0x1c, (UINT8 *) &tBuf) != 0){ continue;
if (!testunitready (fd)) {
if (modesense(fd, 0x1c, (UINT8 *) &tBuf)){
printout(LOG_INFO,"Device: %s, Failed read of ModePage 1C \n", device); printout(LOG_INFO,"Device: %s, Failed read of ModePage 1C \n", device);
close(fd); close(fd);
} }
else else
if ( scsiSmartSupport( fd, (UINT8 *) &smartsupport) == 0){ if (!scsiSmartSupport( fd, (UINT8 *) &smartsupport) &&
if (!(smartsupport & DEXCPT_ENABLE)){ !(smartsupport & DEXCPT_ENABLE)){
devices[numscsidevices].fd = fd; devices[numscsidevices].fd = fd;
strcpy(devices[numscsidevices].devicename,device); strcpy(devices[numscsidevices].devicename,device);
...@@ -193,7 +196,8 @@ void scsidevicescan ( scsidevices_t *devices){ ...@@ -193,7 +196,8 @@ void scsidevicescan ( scsidevices_t *devices){
} }
numscsidevices++; numscsidevices++;
} }
} else
close(fd);
} }
} }
} }
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include "ataprint.h" #include "ataprint.h"
extern const char *CVSid1, *CVSid2; extern const char *CVSid1, *CVSid2;
const char *CVSid3="$Id: smartd.cpp,v 1.24 2002/10/24 10:56:10 ballen4705 Exp $" const char *CVSid3="$Id: smartd.cpp,v 1.25 2002/10/24 11:38:11 ballen4705 Exp $"
CVSID1 CVSID4 CVSID7; CVSID1 CVSID4 CVSID7;
int daemon_init(void){ int daemon_init(void){
...@@ -113,7 +113,7 @@ void atadevicescan ( atadevices_t *devices){ ...@@ -113,7 +113,7 @@ void atadevicescan ( atadevices_t *devices){
printout(LOG_INFO,"Reading Device %s\n", device); printout(LOG_INFO,"Reading Device %s\n", device);
fd = open ( device , O_RDWR ); fd = open(device, O_RDONLY);
if (fd < 0) if (fd < 0)
// no such device // no such device
continue; continue;
...@@ -164,14 +164,17 @@ void scsidevicescan ( scsidevices_t *devices){ ...@@ -164,14 +164,17 @@ void scsidevicescan ( scsidevices_t *devices){
fd=open (device, O_RDWR); fd=open (device, O_RDWR);
if ( fd >= 0 && !testunitready (fd)) { if (fd<0)
if (modesense ( fd, 0x1c, (UINT8 *) &tBuf) != 0){ continue;
if (!testunitready (fd)) {
if (modesense(fd, 0x1c, (UINT8 *) &tBuf)){
printout(LOG_INFO,"Device: %s, Failed read of ModePage 1C \n", device); printout(LOG_INFO,"Device: %s, Failed read of ModePage 1C \n", device);
close(fd); close(fd);
} }
else else
if ( scsiSmartSupport( fd, (UINT8 *) &smartsupport) == 0){ if (!scsiSmartSupport( fd, (UINT8 *) &smartsupport) &&
if (!(smartsupport & DEXCPT_ENABLE)){ !(smartsupport & DEXCPT_ENABLE)){
devices[numscsidevices].fd = fd; devices[numscsidevices].fd = fd;
strcpy(devices[numscsidevices].devicename,device); strcpy(devices[numscsidevices].devicename,device);
...@@ -193,7 +196,8 @@ void scsidevicescan ( scsidevices_t *devices){ ...@@ -193,7 +196,8 @@ void scsidevicescan ( scsidevices_t *devices){
} }
numscsidevices++; numscsidevices++;
} }
} else
close(fd);
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment