diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG
index 80b93c6f96b8b306f8440150306c72629e82b504..d8085b55d626f22bf3a65a2a1aeb0dfd1055557b 100644
--- a/sm5/CHANGELOG
+++ b/sm5/CHANGELOG
@@ -1,6 +1,6 @@
 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>
 
@@ -26,6 +26,11 @@ NOTES FOR NEXT RELEASE:
     Next release: handle extended error and self-test logs gracefully.
     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
 
diff --git a/sm5/TODO b/sm5/TODO
index ee634a18a24372c9678aad28cd0ebd77ba5c6d39..38ec8654734770412bace619fbed8d1c77095eed 100644
--- a/sm5/TODO
+++ b/sm5/TODO
@@ -4,7 +4,7 @@ Home page of code is: http://smartmontools.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
 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 --
 
 Fixes
 -----
-SCSI code in smartd leaves file descriptors open if SMART not supported..
 
 Fix lots of syntax like if (a != 0)
 
diff --git a/sm5/smartd.c b/sm5/smartd.c
index 72772f34c1875075175f4a5f9bb610cc7adc1ef9..36262fa64414d57599079a013fa77858e34308ba 100644
--- a/sm5/smartd.c
+++ b/sm5/smartd.c
@@ -37,7 +37,7 @@
 #include "ataprint.h"
 
 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;
 
 int daemon_init(void){
@@ -113,8 +113,8 @@ void atadevicescan ( atadevices_t *devices){
     
     printout(LOG_INFO,"Reading Device %s\n", device);
     
-    fd = open ( device , O_RDWR );
-    if ( fd < 0)
+    fd = open(device, O_RDONLY);
+    if (fd < 0)
       // no such device
       continue;
     
@@ -162,38 +162,42 @@ void scsidevicescan ( scsidevices_t *devices){
     
     printout(LOG_INFO,"Reading Device %s\n", device);
     
-    fd = open ( device , O_RDWR );
+    fd=open (device, O_RDWR);
     
-    if ( fd >= 0 && !testunitready (fd)) {
-      if (modesense ( fd, 0x1c, (UINT8 *) &tBuf) != 0){
+    if (fd<0)
+      continue;
+
+    if (!testunitready (fd)) {
+      if (modesense(fd, 0x1c, (UINT8 *) &tBuf)){
 	printout(LOG_INFO,"Device: %s, Failed read of ModePage 1C \n", device);
 	close(fd);
       }
       else
-	if ( scsiSmartSupport( fd, (UINT8 *) &smartsupport) == 0){			
-	  if (!(smartsupport & DEXCPT_ENABLE)){
-	    devices[numscsidevices].fd = fd;
-	    strcpy(devices[numscsidevices].devicename,device);
-	    
-	    printout(LOG_INFO, "Device: %s, Found and is SMART capable\n",device);
-	    
-	    if (logsense ( fd , SUPPORT_LOG_PAGES, (UINT8 *) &tBuf) == 0){
-	      for ( i = 4; i < tBuf[3] + LOGPAGEHDRSIZE ; i++){
-		switch ( tBuf[i]){ 
-		case TEMPERATURE_PAGE:
-		  devices[numscsidevices].TempPageSupported = 1;
-		  break;
-		case SMART_PAGE:
-		  devices[numscsidevices].SmartPageSupported = 1;
-		  break;
-		default:
-		  break;
-		}
-	      }	
-	    }
-	    numscsidevices++;
+	if (!scsiSmartSupport( fd, (UINT8 *) &smartsupport) &&
+	    !(smartsupport & DEXCPT_ENABLE)){
+	  devices[numscsidevices].fd = fd;
+	  strcpy(devices[numscsidevices].devicename,device);
+	  
+	  printout(LOG_INFO, "Device: %s, Found and is SMART capable\n",device);
+	  
+	  if (logsense ( fd , SUPPORT_LOG_PAGES, (UINT8 *) &tBuf) == 0){
+	    for ( i = 4; i < tBuf[3] + LOGPAGEHDRSIZE ; i++){
+	      switch ( tBuf[i]){ 
+	      case TEMPERATURE_PAGE:
+		devices[numscsidevices].TempPageSupported = 1;
+		break;
+	      case SMART_PAGE:
+		devices[numscsidevices].SmartPageSupported = 1;
+		break;
+	      default:
+		break;
+	      }
+	    }	
 	  }
+	  numscsidevices++;
 	}
+	else
+	  close(fd);
     }
   }
 }
diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp
index 5c45d75519bb39cf9dfe858bcf099f5bce611ade..f7ac3107f919306f8833b46dcd6e4d2678d7e5ad 100644
--- a/sm5/smartd.cpp
+++ b/sm5/smartd.cpp
@@ -37,7 +37,7 @@
 #include "ataprint.h"
 
 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;
 
 int daemon_init(void){
@@ -113,8 +113,8 @@ void atadevicescan ( atadevices_t *devices){
     
     printout(LOG_INFO,"Reading Device %s\n", device);
     
-    fd = open ( device , O_RDWR );
-    if ( fd < 0)
+    fd = open(device, O_RDONLY);
+    if (fd < 0)
       // no such device
       continue;
     
@@ -162,38 +162,42 @@ void scsidevicescan ( scsidevices_t *devices){
     
     printout(LOG_INFO,"Reading Device %s\n", device);
     
-    fd = open ( device , O_RDWR );
+    fd=open (device, O_RDWR);
     
-    if ( fd >= 0 && !testunitready (fd)) {
-      if (modesense ( fd, 0x1c, (UINT8 *) &tBuf) != 0){
+    if (fd<0)
+      continue;
+
+    if (!testunitready (fd)) {
+      if (modesense(fd, 0x1c, (UINT8 *) &tBuf)){
 	printout(LOG_INFO,"Device: %s, Failed read of ModePage 1C \n", device);
 	close(fd);
       }
       else
-	if ( scsiSmartSupport( fd, (UINT8 *) &smartsupport) == 0){			
-	  if (!(smartsupport & DEXCPT_ENABLE)){
-	    devices[numscsidevices].fd = fd;
-	    strcpy(devices[numscsidevices].devicename,device);
-	    
-	    printout(LOG_INFO, "Device: %s, Found and is SMART capable\n",device);
-	    
-	    if (logsense ( fd , SUPPORT_LOG_PAGES, (UINT8 *) &tBuf) == 0){
-	      for ( i = 4; i < tBuf[3] + LOGPAGEHDRSIZE ; i++){
-		switch ( tBuf[i]){ 
-		case TEMPERATURE_PAGE:
-		  devices[numscsidevices].TempPageSupported = 1;
-		  break;
-		case SMART_PAGE:
-		  devices[numscsidevices].SmartPageSupported = 1;
-		  break;
-		default:
-		  break;
-		}
-	      }	
-	    }
-	    numscsidevices++;
+	if (!scsiSmartSupport( fd, (UINT8 *) &smartsupport) &&
+	    !(smartsupport & DEXCPT_ENABLE)){
+	  devices[numscsidevices].fd = fd;
+	  strcpy(devices[numscsidevices].devicename,device);
+	  
+	  printout(LOG_INFO, "Device: %s, Found and is SMART capable\n",device);
+	  
+	  if (logsense ( fd , SUPPORT_LOG_PAGES, (UINT8 *) &tBuf) == 0){
+	    for ( i = 4; i < tBuf[3] + LOGPAGEHDRSIZE ; i++){
+	      switch ( tBuf[i]){ 
+	      case TEMPERATURE_PAGE:
+		devices[numscsidevices].TempPageSupported = 1;
+		break;
+	      case SMART_PAGE:
+		devices[numscsidevices].SmartPageSupported = 1;
+		break;
+	      default:
+		break;
+	      }
+	    }	
 	  }
+	  numscsidevices++;
 	}
+	else
+	  close(fd);
     }
   }
 }