From b8a76890cbd33f201fa49ac2547dfead8d5d3e86 Mon Sep 17 00:00:00 2001
From: arvoreen <arvoreen@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Mon, 13 Oct 2003 14:31:34 +0000
Subject: [PATCH] Add notes to MAN pages indicating that 3ware controllers are
 NOT currently supported under FreeBSD.

Clean up warning message output as per Bruce's request


git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@1113 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 sm5/CHANGELOG        |  5 +++-
 sm5/NEWS             | 11 +++++---
 sm5/os_freebsd.c     | 60 +++++++++++++++++++++++++++++++++-----------
 sm5/os_freebsd.cpp   | 60 +++++++++++++++++++++++++++++++++-----------
 sm5/smartctl.8.in    | 10 +++++---
 sm5/smartd.8.in      | 10 +++++---
 sm5/smartd.conf.5.in | 10 +++++---
 7 files changed, 122 insertions(+), 44 deletions(-)

diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG
index c5de22263..6a1a3ff2e 100644
--- a/sm5/CHANGELOG
+++ b/sm5/CHANGELOG
@@ -1,6 +1,6 @@
 CHANGELOG for smartmontools
 
-$Id: CHANGELOG,v 1.209 2003/10/13 04:58:01 ballen4705 Exp $
+$Id: CHANGELOG,v 1.210 2003/10/13 14:31:34 arvoreen Exp $
 
 Maintainers / Developers Key:
 [BA] Bruce Allen
@@ -21,6 +21,9 @@ CURRENT DEVELOPMENT VERSION (see VERSION file in this directory):
 
   <ADDITIONS TO THE CHANGE LOG SHOULD BE ADDED HERE, PLEASE>
 
+  [EM] Update MAN pages with notes that 3ware drives are NOT supported
+	under FreeBSD. Cleanup FreeBSD warning message handling.
+
   [EM] FreeBSD only: Fix first user found bug....I guess I was making
        the wrong assumption on how to convert ATA devnames to
        channel/unit numbers.
diff --git a/sm5/NEWS b/sm5/NEWS
index 6c317eaef..1006b3adf 100644
--- a/sm5/NEWS
+++ b/sm5/NEWS
@@ -1,13 +1,18 @@
 smartmontools NEWS
 ------------------
-CVS ID: $Id: NEWS,v 1.6 2003/10/13 05:24:29 ballen4705 Exp $
+CVS ID: $Id: NEWS,v 1.7 2003/10/13 14:31:34 arvoreen Exp $
 
 Refer to the CHANGELOG file for a complete change log.
 
 See http://sourceforge.net/news/?group_id=64297 for the most recent news.
 
-Eduard, in preparation for the upcoming release, please add a
-preliminary entry here (a few lines) describing the FreeBSD support.
+Date: ????
+Summary: smartmontools release 5.21
+-----------------------------------
+
+Preliminary support for FreeBSD.  ATA support requires a 5.1-CURRENT kernel
+while SCSI support should work across multiple versions (any that support CAM)
+
 
 Date: 2003-10-04
 Summary: smartmontools release 5.20
diff --git a/sm5/os_freebsd.c b/sm5/os_freebsd.c
index 3d156837e..6722772fc 100644
--- a/sm5/os_freebsd.c
+++ b/sm5/os_freebsd.c
@@ -36,7 +36,7 @@
 #include "utility.h"
 #include "os_freebsd.h"
 
-const char *os_XXXX_c_cvsid="$Id: os_freebsd.c,v 1.16 2003/10/13 02:28:15 arvoreen Exp $" \
+const char *os_XXXX_c_cvsid="$Id: os_freebsd.c,v 1.17 2003/10/13 14:31:34 arvoreen Exp $" \
 ATACMDS_H_CVSID CONFIG_H_CVSID OS_XXXX_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
 
 // to hold onto exit code for atexit routine
@@ -144,6 +144,37 @@ int deviceclose (int fd) {
   return failed;
 }
 
+#define NO_RETURN 0
+#define BAD_SMART 1
+#define NO_3WARE 2
+#define BAD_KERNEL 3
+#define MAX_MSG 3
+
+// Utility function for printing warnings
+void printwarning(int msgNo, const char* extra) {
+  static int printed[] = {0,0,0,0};
+  static const char* message[]={
+    "The SMART RETURN STATUS return value (smartmontools -H option/Directive)\n can not be retrieved with this version of ATAng, please do not rely on this value\n",
+    
+    "Error SMART Status command failed\nPlease get assistance from \n" PROJECTHOME "\nRegister values returned from SMART Status command are:\n",
+    
+    PACKAGE_STRING " does not currentlly support TWE devices (3ware Escalade)\n",
+    
+    "ATA support is not provided for this kernel version. Please ugrade to a recent 5-CURRENT kernel (post 09/01/2003 or so)\n"
+  };
+
+  if (msgNo >= 0 && msgNo <= MAX_MSG) {
+    if (!printed[msgNo]) {
+      printed[msgNo] = 1;
+      pout("%s", message[msgNo]);
+      if (extra)
+	pout("%s",extra);
+    }
+  }
+  return;
+}
+
+
 // Interface to ATA devices.  See os_linux.c
 int ata_command_interface(int fd, smart_command_set command, int select, char *data) {
   struct freebsd_dev_channel* con;
@@ -157,6 +188,7 @@ int ata_command_interface(int fd, smart_command_set command, int select, char *d
 
 #ifndef ATAREQUEST
   // sorry, but without ATAng, we can't do anything here
+  printwarning(OLD_KERNEL,NULL);
   errno = ENOSYS;
   return -;
 #else
@@ -252,7 +284,7 @@ int ata_command_interface(int fd, smart_command_set command, int select, char *d
 #endif
     break;
   default:
-    pout("Unrecognized command %d in linux_ata_command_interface()\n", command);
+    pout("Unrecognized command %d in ata_command_interface()\n", command);
     EXIT(1);
     break;
   }
@@ -266,7 +298,7 @@ int ata_command_interface(int fd, smart_command_set command, int select, char *d
       return -1;
 
 #ifndef ATA_CMD_READ_REG
-    pout("The SMART RETURN STATUS return value (smartmontools -H option/Directive)\n can not be retrieved with this version of ATAng, please do not rely on this value\n");
+    printwarning(NO_RETURN,NULL);
 #endif
 
     high = (iocmd.u.request.u.ata.lba >> 16) & 0xff;
@@ -281,16 +313,16 @@ int ata_command_interface(int fd, smart_command_set command, int select, char *d
       return 1;
     
     // We haven't gotten output that makes sense; print out some debugging info
-    syserror("Error SMART Status command failed");
-    pout("Please get assistance from %s\n",PROJECTHOME);
-    pout("Register values returned from SMART Status command are:\n");
-    pout("CMD=0x%02x\n",(int)iocmd.u.request.u.ata.command);
-    pout("FR =0x%02x\n",(int)iocmd.u.request.u.ata.feature);
-    pout("NS =0x%02x\n",(int)iocmd.u.request.u.ata.count);
-    pout("SC =0x%02x\n",(int)((iocmd.u.request.u.ata.lba) & 0xff));
-    pout("CL =0x%02x\n",(int)((iocmd.u.request.u.ata.lba>>8) & 0xff));
-    pout("CH =0x%02x\n",(int)((iocmd.u.request.u.ata.lba>>16) & 0xff));
-    pout("RETURN =0x%04x\n",(int)iocmd.u.request.error);
+    char buf[512];
+    sprintf(buf,"CMD=0x%02x\nFR =0x%02x\nNS =0x%02x\nSC =0x%02x\nCL =0x%02x\nCH =0x%02x\nRETURN =0x%04x\n",
+	    (int)iocmd.u.request.u.ata.command,
+	    (int)iocmd.u.request.u.ata.feature,
+	    (int)iocmd.u.request.u.ata.count,
+	    (int)((iocmd.u.request.u.ata.lba) & 0xff),
+	    (int)((iocmd.u.request.u.ata.lba>>8) & 0xff),
+	    (int)((iocmd.u.request.u.ata.lba>>16) & 0xff),
+	    (int)iocmd.u.request.error);
+    printwarning(BAD_SMART,buf);
     return 0;   
   }
 
@@ -405,7 +437,7 @@ int do_scsi_cmnd_io(int fd, struct scsi_cmnd_io * iop, int report)
 
 // Interface to ATA devices behind 3ware escalade RAID controller cards.  See os_linux.c
 int escalade_command_interface(int fd, int disknum, smart_command_set command, int select, char *data) {
-  // not currently supported
+  printwarning(NO_3WARE,NULL);
   return -1;
 }
 
diff --git a/sm5/os_freebsd.cpp b/sm5/os_freebsd.cpp
index ba2d43591..ad8078fe8 100644
--- a/sm5/os_freebsd.cpp
+++ b/sm5/os_freebsd.cpp
@@ -36,7 +36,7 @@
 #include "utility.h"
 #include "os_freebsd.h"
 
-const char *os_XXXX_c_cvsid="$Id: os_freebsd.cpp,v 1.16 2003/10/13 02:28:15 arvoreen Exp $" \
+const char *os_XXXX_c_cvsid="$Id: os_freebsd.cpp,v 1.17 2003/10/13 14:31:34 arvoreen Exp $" \
 ATACMDS_H_CVSID CONFIG_H_CVSID OS_XXXX_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
 
 // to hold onto exit code for atexit routine
@@ -144,6 +144,37 @@ int deviceclose (int fd) {
   return failed;
 }
 
+#define NO_RETURN 0
+#define BAD_SMART 1
+#define NO_3WARE 2
+#define BAD_KERNEL 3
+#define MAX_MSG 3
+
+// Utility function for printing warnings
+void printwarning(int msgNo, const char* extra) {
+  static int printed[] = {0,0,0,0};
+  static const char* message[]={
+    "The SMART RETURN STATUS return value (smartmontools -H option/Directive)\n can not be retrieved with this version of ATAng, please do not rely on this value\n",
+    
+    "Error SMART Status command failed\nPlease get assistance from \n" PROJECTHOME "\nRegister values returned from SMART Status command are:\n",
+    
+    PACKAGE_STRING " does not currentlly support TWE devices (3ware Escalade)\n",
+    
+    "ATA support is not provided for this kernel version. Please ugrade to a recent 5-CURRENT kernel (post 09/01/2003 or so)\n"
+  };
+
+  if (msgNo >= 0 && msgNo <= MAX_MSG) {
+    if (!printed[msgNo]) {
+      printed[msgNo] = 1;
+      pout("%s", message[msgNo]);
+      if (extra)
+	pout("%s",extra);
+    }
+  }
+  return;
+}
+
+
 // Interface to ATA devices.  See os_linux.c
 int ata_command_interface(int fd, smart_command_set command, int select, char *data) {
   struct freebsd_dev_channel* con;
@@ -157,6 +188,7 @@ int ata_command_interface(int fd, smart_command_set command, int select, char *d
 
 #ifndef ATAREQUEST
   // sorry, but without ATAng, we can't do anything here
+  printwarning(OLD_KERNEL,NULL);
   errno = ENOSYS;
   return -;
 #else
@@ -252,7 +284,7 @@ int ata_command_interface(int fd, smart_command_set command, int select, char *d
 #endif
     break;
   default:
-    pout("Unrecognized command %d in linux_ata_command_interface()\n", command);
+    pout("Unrecognized command %d in ata_command_interface()\n", command);
     EXIT(1);
     break;
   }
@@ -266,7 +298,7 @@ int ata_command_interface(int fd, smart_command_set command, int select, char *d
       return -1;
 
 #ifndef ATA_CMD_READ_REG
-    pout("The SMART RETURN STATUS return value (smartmontools -H option/Directive)\n can not be retrieved with this version of ATAng, please do not rely on this value\n");
+    printwarning(NO_RETURN,NULL);
 #endif
 
     high = (iocmd.u.request.u.ata.lba >> 16) & 0xff;
@@ -281,16 +313,16 @@ int ata_command_interface(int fd, smart_command_set command, int select, char *d
       return 1;
     
     // We haven't gotten output that makes sense; print out some debugging info
-    syserror("Error SMART Status command failed");
-    pout("Please get assistance from %s\n",PROJECTHOME);
-    pout("Register values returned from SMART Status command are:\n");
-    pout("CMD=0x%02x\n",(int)iocmd.u.request.u.ata.command);
-    pout("FR =0x%02x\n",(int)iocmd.u.request.u.ata.feature);
-    pout("NS =0x%02x\n",(int)iocmd.u.request.u.ata.count);
-    pout("SC =0x%02x\n",(int)((iocmd.u.request.u.ata.lba) & 0xff));
-    pout("CL =0x%02x\n",(int)((iocmd.u.request.u.ata.lba>>8) & 0xff));
-    pout("CH =0x%02x\n",(int)((iocmd.u.request.u.ata.lba>>16) & 0xff));
-    pout("RETURN =0x%04x\n",(int)iocmd.u.request.error);
+    char buf[512];
+    sprintf(buf,"CMD=0x%02x\nFR =0x%02x\nNS =0x%02x\nSC =0x%02x\nCL =0x%02x\nCH =0x%02x\nRETURN =0x%04x\n",
+	    (int)iocmd.u.request.u.ata.command,
+	    (int)iocmd.u.request.u.ata.feature,
+	    (int)iocmd.u.request.u.ata.count,
+	    (int)((iocmd.u.request.u.ata.lba) & 0xff),
+	    (int)((iocmd.u.request.u.ata.lba>>8) & 0xff),
+	    (int)((iocmd.u.request.u.ata.lba>>16) & 0xff),
+	    (int)iocmd.u.request.error);
+    printwarning(BAD_SMART,buf);
     return 0;   
   }
 
@@ -405,7 +437,7 @@ int do_scsi_cmnd_io(int fd, struct scsi_cmnd_io * iop, int report)
 
 // Interface to ATA devices behind 3ware escalade RAID controller cards.  See os_linux.c
 int escalade_command_interface(int fd, int disknum, smart_command_set command, int select, char *data) {
-  // not currently supported
+  printwarning(NO_3WARE,NULL);
   return -1;
 }
 
diff --git a/sm5/smartctl.8.in b/sm5/smartctl.8.in
index 02e2a6d2b..e0bbcbcd0 100644
--- a/sm5/smartctl.8.in
+++ b/sm5/smartctl.8.in
@@ -1,6 +1,6 @@
 \# Copyright (C) 2002-3 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 \#
-\# $Id: smartctl.8.in,v 1.7 2003/10/06 08:15:04 ballen4705 Exp $
+\# $Id: smartctl.8.in,v 1.8 2003/10/13 14:31:34 arvoreen 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
@@ -16,7 +16,7 @@
 \# Research Center), Jack Baskin School of Engineering, University of
 \# California, Santa Cruz. http://ssrc.soe.ucsc.edu/
 \#
-.TH SMARTCTL 8  "$Date: 2003/10/06 08:15:04 $" RELEASE
+.TH SMARTCTL 8  "$Date: 2003/10/13 14:31:34 $" RELEASE
 .SH NAME
 \fBsmartctl\fP \- Control and Monitor Utility for SMART Disks
 
@@ -27,7 +27,7 @@
 .B /usr/sbin/smartctl
 
 .SH PACKAGE VERSION
-\fBRELEASE\fP "$Date: 2003/10/06 08:15:04 $"
+\fBRELEASE\fP "$Date: 2003/10/13 14:31:34 $"
 
 .SH DESCRIPTION
 \fBsmartctl\fP controls the Self-Monitoring, Analysis and Reporting
@@ -154,6 +154,8 @@ can be fixed by upgrading to version 1.02.00.037 or later of the
 3w-xxxx driver, or by applying a patch to older versions. See
 \fBhttp://smartmontools.sourceforge.net/\fP for instructions.
 
+.B 3ware controllers are NOT supported under FreeBSD yet.
+
 .TP
 .B \-T TYPE, \-\-tolerance=TYPE
 Specifies how tolerant \fBsmartctl\fP should be of ATA and SMART command
@@ -967,4 +969,4 @@ these documents may be found in the References section of the
 
 .SH
 CVS ID OF THIS PAGE:
-$Id: smartctl.8.in,v 1.7 2003/10/06 08:15:04 ballen4705 Exp $
+$Id: smartctl.8.in,v 1.8 2003/10/13 14:31:34 arvoreen Exp $
diff --git a/sm5/smartd.8.in b/sm5/smartd.8.in
index e0941d9fc..953470732 100644
--- a/sm5/smartd.8.in
+++ b/sm5/smartd.8.in
@@ -1,6 +1,6 @@
 \# Copyright (C) 2002-3 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 \# 
-\# $Id: smartd.8.in,v 1.5 2003/10/06 00:37:04 ballen4705 Exp $
+\# $Id: smartd.8.in,v 1.6 2003/10/13 14:31:34 arvoreen 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
@@ -16,7 +16,7 @@
 \# Research Center), Jack Baskin School of Engineering, University of
 \# California, Santa Cruz. http://ssrc.soe.ucsc.edu/
 \#
-.TH SMARTD 8  "$Date: 2003/10/06 00:37:04 $" RELEASE
+.TH SMARTD 8  "$Date: 2003/10/13 14:31:34 $" RELEASE
 .SH NAME
 \fBsmartd\fP \- SMART Disk Monitoring Daemon
 
@@ -27,7 +27,7 @@
 .B /usr/sbin/smartd
 
 .SH PACKAGE VERSION
-\fBRELEASE\fP "$Date: 2003/10/06 00:37:04 $"
+\fBRELEASE\fP "$Date: 2003/10/13 14:31:34 $"
 
 .SH DESCRIPTION
 .B smartd
@@ -490,6 +490,8 @@ can be fixed by upgrading to version 1.02.00.037 or later of the
 3w-xxxx driver, or by applying a patch to older versions. See
 \fBhttp://smartmontools.sourceforge.net/\fP for instructions.
 
+.B 3ware controllers are NOT supported under FreeBSD yet.
+
 .I removable
 \- the device or its media is removable.  This indicates to
 .B smartd
@@ -1336,4 +1338,4 @@ smartmontools home page at \fBhttp://smartmontools.sourceforge.net/\fP .
 
 .SH
 CVS ID OF THIS PAGE:
-$Id: smartd.8.in,v 1.5 2003/10/06 00:37:04 ballen4705 Exp $
+$Id: smartd.8.in,v 1.6 2003/10/13 14:31:34 arvoreen Exp $
diff --git a/sm5/smartd.conf.5.in b/sm5/smartd.conf.5.in
index 672db6f05..73ace305e 100644
--- a/sm5/smartd.conf.5.in
+++ b/sm5/smartd.conf.5.in
@@ -1,6 +1,6 @@
 \# Copyright (C) 2002-3 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 \# 
-\# $Id: smartd.conf.5.in,v 1.4 2003/10/06 00:37:04 ballen4705 Exp $
+\# $Id: smartd.conf.5.in,v 1.5 2003/10/13 14:31:34 arvoreen 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
@@ -16,11 +16,11 @@
 \# Research Center), Jack Baskin School of Engineering, University of
 \# California, Santa Cruz. http://ssrc.soe.ucsc.edu/
 \#
-.TH SMARTD.CONF 5  "$Date: 2003/10/06 00:37:04 $" RELEASE
+.TH SMARTD.CONF 5  "$Date: 2003/10/13 14:31:34 $" RELEASE
 .SH NAME
 \fBsmartd.conf\fP \- SMART Disk Monitoring Daemon Configuration File \- \fBRELEASE\fP
 .SH PACKAGE VERSION
-RELEASE "$Date: 2003/10/06 00:37:04 $"
+RELEASE "$Date: 2003/10/13 14:31:34 $"
 
 .SH DESCRIPTION
 \fB/etc/smartd.conf\fP is the configuration file for the \fBsmartd\fP
@@ -230,6 +230,8 @@ can be fixed by upgrading to version 1.02.00.037 or later of the
 3w-xxxx driver, or by applying a patch to older versions. See
 \fBhttp://smartmontools.sourceforge.net/\fP for instructions.
 
+.B 3ware controllers are NOT supported under FreeBSD yet.
+
 .I removable
 \- the device or its media is removable.  This indicates to
 .B smartd
@@ -945,4 +947,4 @@ SEE ALSO:
 
 .SH
 CVS ID OF THIS PAGE:
-$Id: smartd.conf.5.in,v 1.4 2003/10/06 00:37:04 ballen4705 Exp $
+$Id: smartd.conf.5.in,v 1.5 2003/10/13 14:31:34 arvoreen Exp $
-- 
GitLab