diff --git a/sm5/atacmds.c b/sm5/atacmds.c index f4dbd8e4194b604cb0e77b55ba9d573fa9a1d5d4..cb93596fad77f97c2e955fd8a681907089b38391 100644 --- a/sm5/atacmds.c +++ b/sm5/atacmds.c @@ -23,14 +23,13 @@ * */ - #include <stdio.h> #include <string.h> #include <syslog.h> #include <errno.h> #include "atacmds.h" -const char *CVSid1="$Id: atacmds.c,v 1.20 2002/10/23 13:43:42 ballen4705 Exp $\n" "\t" CVSID1 ; +const char *CVSid1="$Id: atacmds.c,v 1.21 2002/10/23 20:36:59 ballen4705 Exp $" CVSID1; // These Drive Identity tables are taken from hdparm 5.2, and are also // given in the ATA/ATAPI specs for the IDENTIFY DEVICE command. Note @@ -49,9 +48,9 @@ const char *minor_str[] = { /* word 81 value: */ "ATA-1 X3T9.2 781D revision 4", /* 0x0003 */ "ATA-2 published, ANSI X3.279-1996", /* 0x0004 */ "ATA-2 X3T10 948D prior to revision 2k", /* 0x0005 */ - "ATA-3 X3T10 2008D revision 1", /* 0x0006 */ + "ATA-3 X3T10 2008D revision 1", /* 0x0006 */ /* SMART NOT INCLUDED */ "ATA-2 X3T10 948D revision 2k", /* 0x0007 */ - "ATA-3 X3T10 2008D revision 0", /* 0x0008 */ /* SMART NOT INCLUDED */ + "ATA-3 X3T10 2008D revision 0", /* 0x0008 */ "ATA-2 X3T10 948D revision 3", /* 0x0009 */ "ATA-3 published, ANSI X3.298-199x", /* 0x000a */ "ATA-3 X3T10 2008D revision 6", /* 0x000b */ /* 1st VERSION WITH SMART */ @@ -82,7 +81,7 @@ const char *minor_str[] = { /* word 81 value: */ // disk that is ATA/ATAPI-4 or above can not be trusted to show the // vendor values in sensible format. - +// Negative values below are because it doesn't support SMART const int actual_ver[] = { /* word 81 value: */ 0, /* 0x0000 WARNING: */ @@ -91,7 +90,7 @@ const int actual_ver[] = { 1, /* 0x0003 WARNING: */ 2, /* 0x0004 WARNING: This array */ 2, /* 0x0005 WARNING: corresponds */ - 3, /* 0x0006 WARNING: *exactly* */ + -3, /* 0x0006 WARNING: *exactly* */ 2, /* 0x0007 WARNING: to the ATA/ */ -3, /*<== */ /* 0x0008 WARNING: ATAPI version */ 2, /* 0x0009 WARNING: listed in */ @@ -117,13 +116,12 @@ const int actual_ver[] = { 0 /* 0x001d-0xfffe */ }; - // Used to warn users about invalid checksums. However we will not // abort on invalid checksums. void checksumwarning(const char *string){ - pout("Warning! %s error: invalid checksum.\n",string); - fprintf(stderr,"Warning! %s error: invalid checksum.\n",string); - syslog(LOG_INFO,"Warning! %s error: invalid checksum.\n",string); + pout("Warning! %s error: invalid SMART checksum.\n",string); + fprintf(stderr,"Warning! %s error: invalid SMART checksum.\n",string); + syslog(LOG_INFO,"Warning! %s error: invalid SMART checksum.\n",string); return; } @@ -142,7 +140,6 @@ int ataReadHDIdentity ( int device, struct hd_driveid *buf){ } #endif - // Reads current Device Identity info (512 bytes) into buf int ataReadHDIdentity (int device, struct hd_driveid *buf){ unsigned short driveidchecksum; @@ -349,12 +346,7 @@ int ataReadErrorLog (int device, struct ata_smart_errorlog *data){ } -// This routine is marked as "Obsolete" in the ATA-5 spec, but it's -// very important for us. Together with the SMART READ DATA command -// above, it's the only way for us to find out if the SMART status is -// good or not. Hopefully this will get fixed -- I will find a way to -// get SMART Status directly. -int ataReadSmartThresholds ( int device, struct ata_smart_thresholds *data){ +int ataReadSmartThresholds (int device, struct ata_smart_thresholds *data){ int i; unsigned char chksum=0; unsigned char buf[HDIO_DRIVE_CMD_HDR_SIZE+ATA_SMART_SEC_SIZE] = @@ -380,7 +372,8 @@ int ataReadSmartThresholds ( int device, struct ata_smart_thresholds *data){ // This routine is not currently in use, and it's been marked as // "Obsolete" in the ANSI ATA-5 spec. So it should probably be left -// alone and unused. +// alone and unused. If you do modify the thresholds, be sure to set +// the checksum correctly before putting the structure back! int ataSetSmartThresholds ( int device, struct ata_smart_thresholds *data){ unsigned char buf[HDIO_DRIVE_CMD_HDR_SIZE+ATA_SMART_SEC_SIZE] = {WIN_SMART, 1, 0xD7, 1,}; @@ -391,7 +384,6 @@ int ataSetSmartThresholds ( int device, struct ata_smart_thresholds *data){ perror ("SMART Thresholds Read failed"); return -1; } - return 0; } @@ -460,13 +452,14 @@ int ataDisableAutoOffline (int device ){ } -// Not being used correctly. Must examine the CL and CH registers to -// see what the smart status was. Look at ataSmartStatus2() +// This function does NOTHING except tell us if SMART is working & +// enabled on the device. See ataSmartStatus2() for one that actually +// returns SMART status. int ataSmartStatus (int device ){ unsigned char parms[4] = {WIN_SMART, 0, SMART_STATUS, 0}; if (ioctl(device, HDIO_DRIVE_CMD, parms)){ - perror("Return SMART Status failed"); + perror("Return SMART Status via HDIO_DRIVE_CMD failed"); return -1; } return 0; @@ -481,37 +474,28 @@ int ataDoesSmartWork(int device){ } -// This function needs to be properly tested and debugged. I am not -// yet sure if this is right; have asked Andre for help. May need to -// use IDE_DRIVE_TASK. Does CONFIG_IDE_TASKFILE_IO need to be -// configured into the kernel? +// This function uses a different interface (DRIVE_TASK) than the +// other commands in this file. int ataSmartStatus2(int device){ unsigned char normal_cyl_lo=0x4f, normal_cyl_hi=0xc2; unsigned char failed_cyl_lo=0xf4, failed_cyl_hi=0x2c; - + unsigned char parms[HDIO_DRIVE_TASK_HDR_SIZE]= - {WIN_SMART, // CMD - SMART_STATUS, // FR - 0, // NS - 0, // SC - 0, // CL - 0, // CH - 0 // SEL -- Andre, is this right?? Or should it be 1? - }; - + {WIN_SMART, SMART_STATUS, 0, 0, 0, 0, 0}; + // load CL and CH values parms[4]=normal_cyl_lo; parms[5]=normal_cyl_hi; if (ioctl(device,HDIO_DRIVE_TASK,parms)){ - perror("SMART Status command failed"); + perror("SMART Status command via HDIO_DRIVE_TASK failed"); return -1; } // Cyl low and Cyl high unchanged means "Good SMART status" if (parms[4]==normal_cyl_lo && parms[5]==normal_cyl_hi) return 0; - + // These values mean "Bad SMART status" if (parms[4]==failed_cyl_lo && parms[5]==failed_cyl_hi) return 1; @@ -577,7 +561,6 @@ int ataSmartTest(int device, int testtype){ return 0; } - /* Test Time Functions */ int TestTime(struct ata_smart_values data,int testtype){ switch (testtype){ diff --git a/sm5/atacmds.cpp b/sm5/atacmds.cpp index faee25e67f7c125f000c23c7a67928a214f70340..880509c6c3785d2d1dc68e8c235ef54464bc0ce9 100644 --- a/sm5/atacmds.cpp +++ b/sm5/atacmds.cpp @@ -23,14 +23,13 @@ * */ - #include <stdio.h> #include <string.h> #include <syslog.h> #include <errno.h> #include "atacmds.h" -const char *CVSid1="$Id: atacmds.cpp,v 1.20 2002/10/23 13:43:42 ballen4705 Exp $\n" "\t" CVSID1 ; +const char *CVSid1="$Id: atacmds.cpp,v 1.21 2002/10/23 20:36:59 ballen4705 Exp $" CVSID1; // These Drive Identity tables are taken from hdparm 5.2, and are also // given in the ATA/ATAPI specs for the IDENTIFY DEVICE command. Note @@ -49,9 +48,9 @@ const char *minor_str[] = { /* word 81 value: */ "ATA-1 X3T9.2 781D revision 4", /* 0x0003 */ "ATA-2 published, ANSI X3.279-1996", /* 0x0004 */ "ATA-2 X3T10 948D prior to revision 2k", /* 0x0005 */ - "ATA-3 X3T10 2008D revision 1", /* 0x0006 */ + "ATA-3 X3T10 2008D revision 1", /* 0x0006 */ /* SMART NOT INCLUDED */ "ATA-2 X3T10 948D revision 2k", /* 0x0007 */ - "ATA-3 X3T10 2008D revision 0", /* 0x0008 */ /* SMART NOT INCLUDED */ + "ATA-3 X3T10 2008D revision 0", /* 0x0008 */ "ATA-2 X3T10 948D revision 3", /* 0x0009 */ "ATA-3 published, ANSI X3.298-199x", /* 0x000a */ "ATA-3 X3T10 2008D revision 6", /* 0x000b */ /* 1st VERSION WITH SMART */ @@ -82,7 +81,7 @@ const char *minor_str[] = { /* word 81 value: */ // disk that is ATA/ATAPI-4 or above can not be trusted to show the // vendor values in sensible format. - +// Negative values below are because it doesn't support SMART const int actual_ver[] = { /* word 81 value: */ 0, /* 0x0000 WARNING: */ @@ -91,7 +90,7 @@ const int actual_ver[] = { 1, /* 0x0003 WARNING: */ 2, /* 0x0004 WARNING: This array */ 2, /* 0x0005 WARNING: corresponds */ - 3, /* 0x0006 WARNING: *exactly* */ + -3, /* 0x0006 WARNING: *exactly* */ 2, /* 0x0007 WARNING: to the ATA/ */ -3, /*<== */ /* 0x0008 WARNING: ATAPI version */ 2, /* 0x0009 WARNING: listed in */ @@ -117,13 +116,12 @@ const int actual_ver[] = { 0 /* 0x001d-0xfffe */ }; - // Used to warn users about invalid checksums. However we will not // abort on invalid checksums. void checksumwarning(const char *string){ - pout("Warning! %s error: invalid checksum.\n",string); - fprintf(stderr,"Warning! %s error: invalid checksum.\n",string); - syslog(LOG_INFO,"Warning! %s error: invalid checksum.\n",string); + pout("Warning! %s error: invalid SMART checksum.\n",string); + fprintf(stderr,"Warning! %s error: invalid SMART checksum.\n",string); + syslog(LOG_INFO,"Warning! %s error: invalid SMART checksum.\n",string); return; } @@ -142,7 +140,6 @@ int ataReadHDIdentity ( int device, struct hd_driveid *buf){ } #endif - // Reads current Device Identity info (512 bytes) into buf int ataReadHDIdentity (int device, struct hd_driveid *buf){ unsigned short driveidchecksum; @@ -349,12 +346,7 @@ int ataReadErrorLog (int device, struct ata_smart_errorlog *data){ } -// This routine is marked as "Obsolete" in the ATA-5 spec, but it's -// very important for us. Together with the SMART READ DATA command -// above, it's the only way for us to find out if the SMART status is -// good or not. Hopefully this will get fixed -- I will find a way to -// get SMART Status directly. -int ataReadSmartThresholds ( int device, struct ata_smart_thresholds *data){ +int ataReadSmartThresholds (int device, struct ata_smart_thresholds *data){ int i; unsigned char chksum=0; unsigned char buf[HDIO_DRIVE_CMD_HDR_SIZE+ATA_SMART_SEC_SIZE] = @@ -380,7 +372,8 @@ int ataReadSmartThresholds ( int device, struct ata_smart_thresholds *data){ // This routine is not currently in use, and it's been marked as // "Obsolete" in the ANSI ATA-5 spec. So it should probably be left -// alone and unused. +// alone and unused. If you do modify the thresholds, be sure to set +// the checksum correctly before putting the structure back! int ataSetSmartThresholds ( int device, struct ata_smart_thresholds *data){ unsigned char buf[HDIO_DRIVE_CMD_HDR_SIZE+ATA_SMART_SEC_SIZE] = {WIN_SMART, 1, 0xD7, 1,}; @@ -391,7 +384,6 @@ int ataSetSmartThresholds ( int device, struct ata_smart_thresholds *data){ perror ("SMART Thresholds Read failed"); return -1; } - return 0; } @@ -460,13 +452,14 @@ int ataDisableAutoOffline (int device ){ } -// Not being used correctly. Must examine the CL and CH registers to -// see what the smart status was. Look at ataSmartStatus2() +// This function does NOTHING except tell us if SMART is working & +// enabled on the device. See ataSmartStatus2() for one that actually +// returns SMART status. int ataSmartStatus (int device ){ unsigned char parms[4] = {WIN_SMART, 0, SMART_STATUS, 0}; if (ioctl(device, HDIO_DRIVE_CMD, parms)){ - perror("Return SMART Status failed"); + perror("Return SMART Status via HDIO_DRIVE_CMD failed"); return -1; } return 0; @@ -481,37 +474,28 @@ int ataDoesSmartWork(int device){ } -// This function needs to be properly tested and debugged. I am not -// yet sure if this is right; have asked Andre for help. May need to -// use IDE_DRIVE_TASK. Does CONFIG_IDE_TASKFILE_IO need to be -// configured into the kernel? +// This function uses a different interface (DRIVE_TASK) than the +// other commands in this file. int ataSmartStatus2(int device){ unsigned char normal_cyl_lo=0x4f, normal_cyl_hi=0xc2; unsigned char failed_cyl_lo=0xf4, failed_cyl_hi=0x2c; - + unsigned char parms[HDIO_DRIVE_TASK_HDR_SIZE]= - {WIN_SMART, // CMD - SMART_STATUS, // FR - 0, // NS - 0, // SC - 0, // CL - 0, // CH - 0 // SEL -- Andre, is this right?? Or should it be 1? - }; - + {WIN_SMART, SMART_STATUS, 0, 0, 0, 0, 0}; + // load CL and CH values parms[4]=normal_cyl_lo; parms[5]=normal_cyl_hi; if (ioctl(device,HDIO_DRIVE_TASK,parms)){ - perror("SMART Status command failed"); + perror("SMART Status command via HDIO_DRIVE_TASK failed"); return -1; } // Cyl low and Cyl high unchanged means "Good SMART status" if (parms[4]==normal_cyl_lo && parms[5]==normal_cyl_hi) return 0; - + // These values mean "Bad SMART status" if (parms[4]==failed_cyl_lo && parms[5]==failed_cyl_hi) return 1; @@ -577,7 +561,6 @@ int ataSmartTest(int device, int testtype){ return 0; } - /* Test Time Functions */ int TestTime(struct ata_smart_values data,int testtype){ switch (testtype){ diff --git a/sm5/ataprint.c b/sm5/ataprint.c index 9d34d7d08fd1965c58a0fccc665270f7266deafb..3555732f2416e94edf2a32d61f96f46647474e46 100644 --- a/sm5/ataprint.c +++ b/sm5/ataprint.c @@ -28,8 +28,8 @@ #include "smartctl.h" #include "extern.h" -const char *CVSid4="$Id: ataprint.c,v 1.29 2002/10/23 15:15:43 ballen4705 Exp $\n" - "\t" CVSID2 "\t" CVSID3 "\t" CVSID6 ; +const char *CVSid4="$Id: ataprint.c,v 1.30 2002/10/23 20:36:59 ballen4705 Exp $" +CVSID2 CVSID3 CVSID6; // Function for printing ASCII byte-swapped strings, skipping white // space. This is needed on little-endian architectures, eg Intel, diff --git a/sm5/ataprint.cpp b/sm5/ataprint.cpp index 9b625bed743d30e0881e5cf5e5d2f27894de9769..acf26c5bbc43b5e9e9843e5257d1b16fa7955f24 100644 --- a/sm5/ataprint.cpp +++ b/sm5/ataprint.cpp @@ -28,8 +28,8 @@ #include "smartctl.h" #include "extern.h" -const char *CVSid4="$Id: ataprint.cpp,v 1.29 2002/10/23 15:15:43 ballen4705 Exp $\n" - "\t" CVSID2 "\t" CVSID3 "\t" CVSID6 ; +const char *CVSid4="$Id: ataprint.cpp,v 1.30 2002/10/23 20:36:59 ballen4705 Exp $" +CVSID2 CVSID3 CVSID6; // Function for printing ASCII byte-swapped strings, skipping white // space. This is needed on little-endian architectures, eg Intel, diff --git a/sm5/scsicmds.c b/sm5/scsicmds.c index 362f19436199b3515397a528a009d6517ab14f45..cad4705a2c01a2e5f94d1d3146a026965d51bfdb 100644 --- a/sm5/scsicmds.c +++ b/sm5/scsicmds.c @@ -33,7 +33,7 @@ #include <scsi/scsi.h> #include "scsicmds.h" -const char *CVSid2="$Id: scsicmds.c,v 1.10 2002/10/22 09:50:54 ballen4705 Exp $\n" "\t" CVSID4 ; +const char *CVSid2="$Id: scsicmds.c,v 1.11 2002/10/23 20:36:59 ballen4705 Exp $" CVSID4; UINT8 logsense (int device, UINT8 pagenum, UINT8 *pBuf) diff --git a/sm5/scsicmds.cpp b/sm5/scsicmds.cpp index 0cf0ec0cb056759ed99de1a4134c8851e7676d6b..9ef4b0f19302f6ace51dadb6f964a158f1bb8271 100644 --- a/sm5/scsicmds.cpp +++ b/sm5/scsicmds.cpp @@ -33,7 +33,7 @@ #include <scsi/scsi.h> #include "scsicmds.h" -const char *CVSid2="$Id: scsicmds.cpp,v 1.10 2002/10/22 09:50:54 ballen4705 Exp $\n" "\t" CVSID4 ; +const char *CVSid2="$Id: scsicmds.cpp,v 1.11 2002/10/23 20:36:59 ballen4705 Exp $" CVSID4; UINT8 logsense (int device, UINT8 pagenum, UINT8 *pBuf) diff --git a/sm5/scsiprint.c b/sm5/scsiprint.c index 16e90156aa0da9030fd16c8a27726f084b0f1337..d459b84dbcaa167a3c68182749484da799e41bd6 100644 --- a/sm5/scsiprint.c +++ b/sm5/scsiprint.c @@ -36,7 +36,8 @@ #define GBUF_SIZE 65535 -const char* CVSid5="$Id: scsiprint.c,v 1.8 2002/10/22 09:50:54 ballen4705 Exp $\n" "\t" CVSID3 "\t" CVSID4 "\t" CVSID5 "\t" CVSID6 ; +const char* CVSid5="$Id: scsiprint.c,v 1.9 2002/10/23 20:36:59 ballen4705 Exp $" +CVSID3 CVSID4 CVSID5 CVSID6; UINT8 gBuf[GBUF_SIZE]; diff --git a/sm5/scsiprint.cpp b/sm5/scsiprint.cpp index bb6116c3885657628a32de819ea046510649c3fb..288d67f996f9a6861fab6b58be6d1418d7531d6a 100644 --- a/sm5/scsiprint.cpp +++ b/sm5/scsiprint.cpp @@ -36,7 +36,8 @@ #define GBUF_SIZE 65535 -const char* CVSid5="$Id: scsiprint.cpp,v 1.8 2002/10/22 09:50:54 ballen4705 Exp $\n" "\t" CVSID3 "\t" CVSID4 "\t" CVSID5 "\t" CVSID6 ; +const char* CVSid5="$Id: scsiprint.cpp,v 1.9 2002/10/23 20:36:59 ballen4705 Exp $" +CVSID3 CVSID4 CVSID5 CVSID6; UINT8 gBuf[GBUF_SIZE]; diff --git a/sm5/smartctl.c b/sm5/smartctl.c index 85aece2e0f606c8ae3cf94ff88a1e47256327403..fab7c17a1a43e72868828d1ff1511df90b07d290 100644 --- a/sm5/smartctl.c +++ b/sm5/smartctl.c @@ -38,8 +38,8 @@ #include "scsiprint.h" extern const char *CVSid1, *CVSid2, *CVSid4, *CVSid5; -const char* CVSid6="$Id: smartctl.c,v 1.16 2002/10/23 14:29:49 ballen4705 Exp $\n" -"\t" CVSID1 "\t" CVSID2 "\t" CVSID4 "\t" CVSID5 "\t" CVSID6 ; +const char* CVSid6="$Id: smartctl.c,v 1.17 2002/10/23 20:36:59 ballen4705 Exp $" +CVSID1 CVSID2 CVSID4 CVSID5 CVSID6; unsigned char driveinfo = FALSE; unsigned char checksmart = FALSE; diff --git a/sm5/smartctl.cpp b/sm5/smartctl.cpp index 28b6302e7dbda45e94473a90167801bcb8719c23..9ed11df949dee8fc9f1ad49910a0cb0c68da7093 100644 --- a/sm5/smartctl.cpp +++ b/sm5/smartctl.cpp @@ -38,8 +38,8 @@ #include "scsiprint.h" extern const char *CVSid1, *CVSid2, *CVSid4, *CVSid5; -const char* CVSid6="$Id: smartctl.cpp,v 1.16 2002/10/23 14:29:49 ballen4705 Exp $\n" -"\t" CVSID1 "\t" CVSID2 "\t" CVSID4 "\t" CVSID5 "\t" CVSID6 ; +const char* CVSid6="$Id: smartctl.cpp,v 1.17 2002/10/23 20:36:59 ballen4705 Exp $" +CVSID1 CVSID2 CVSID4 CVSID5 CVSID6; unsigned char driveinfo = FALSE; unsigned char checksmart = FALSE; diff --git a/sm5/smartd.c b/sm5/smartd.c index e64a57685fadac2c8083aba214ac61adf840ed81..b0498622b1acfb5561b0a0c004d990ebd706772c 100644 --- a/sm5/smartd.c +++ b/sm5/smartd.c @@ -36,8 +36,8 @@ #include "smartd.h" extern const char *CVSid1, *CVSid2; -const char *CVSid3="$Id: smartd.c,v 1.14 2002/10/23 12:24:24 ballen4705 Exp $\n" -"\t" CVSID1 "\t" CVSID4 "\t" CVSID7 ; +const char *CVSid3="$Id: smartd.c,v 1.15 2002/10/23 20:36:59 ballen4705 Exp $" +CVSID1 CVSID4 CVSID7; int daemon_init(void){ pid_t pid; @@ -288,6 +288,73 @@ void CheckDevices ( atadevices_t *atadevices, scsidevices_t *scsidevices) } } + +int massagecvs(char *out,const char *in){ + char filename[128], version[128], date[128]; + int i=0; + const char *savein=in; + + // skip to I of $Id: + while (*in !='\0' && *in!='I') + in++; + + // skip to start of filename + if (!*in) + return 0; + in+=4; + + // copy filename + i=0; + while (i<100 && *in!=',' && *in) + filename[i++]=*in++; + filename[i]='\0'; + if (!*in) + return 0; + + // skip ,v and space + in+=3; + + i=0; + // copy version number + while (i<100 && *in!=' ' && *in) + version[i++]=*in++; + version[i]='\0'; + if (!*in) + return 0; + + // skip space + in++; + // copy date + i=0; + while (i<100 && *in!=' ' && *in) + date[i++]=*in++; + date[i]='\0'; + + sprintf(out,"%-13s revision: %-6s date: %-15s", filename, version, date); + return in-savein; +} + +// prints a single set of CVS ids +void printone(const char *cvsid){ + char strings[512]; + const char *here; + int len,line=1; + here=cvsid; + while ((len=massagecvs(strings,here))){ + switch (line++){ + case 1: + printout(LOG_INFO,"Module:"); + break; + default: + printout(LOG_INFO," uses:"); + } + printout(LOG_INFO," %s\n",strings); + here+=len; + } + return; +} + + char copyleftstring[]= "Home page of smartd is " PROJECTHOME "\n\n" "smartd comes with ABSOLUTELY NO WARRANTY. This\n" @@ -336,7 +403,10 @@ int main (int argc, char **argv){ printout(LOG_INFO,"smartd version %d.%d-%d Copyright (C) Bruce Allen 2002\n", RELEASE_MAJOR,RELEASE_MINOR,SMARTMONTOOLS_VERSION); printout(LOG_INFO,copyleftstring); - printout(LOG_INFO,"CVS version IDs of files used to build this code are:\n%s%s%s",CVSid1,CVSid2,CVSid3); + printout(LOG_INFO,"CVS version IDs of files used to build this code are:\n"); + printone(CVSid3); + printone(CVSid1); + printone(CVSid2); exit(0); } diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp index c400f374bfca679edde04d054c121621c1fad5f9..a4080846a8982c767df8fb66672d6b04d119db05 100644 --- a/sm5/smartd.cpp +++ b/sm5/smartd.cpp @@ -36,8 +36,8 @@ #include "smartd.h" extern const char *CVSid1, *CVSid2; -const char *CVSid3="$Id: smartd.cpp,v 1.14 2002/10/23 12:24:24 ballen4705 Exp $\n" -"\t" CVSID1 "\t" CVSID4 "\t" CVSID7 ; +const char *CVSid3="$Id: smartd.cpp,v 1.15 2002/10/23 20:36:59 ballen4705 Exp $" +CVSID1 CVSID4 CVSID7; int daemon_init(void){ pid_t pid; @@ -288,6 +288,73 @@ void CheckDevices ( atadevices_t *atadevices, scsidevices_t *scsidevices) } } + +int massagecvs(char *out,const char *in){ + char filename[128], version[128], date[128]; + int i=0; + const char *savein=in; + + // skip to I of $Id: + while (*in !='\0' && *in!='I') + in++; + + // skip to start of filename + if (!*in) + return 0; + in+=4; + + // copy filename + i=0; + while (i<100 && *in!=',' && *in) + filename[i++]=*in++; + filename[i]='\0'; + if (!*in) + return 0; + + // skip ,v and space + in+=3; + + i=0; + // copy version number + while (i<100 && *in!=' ' && *in) + version[i++]=*in++; + version[i]='\0'; + if (!*in) + return 0; + + // skip space + in++; + // copy date + i=0; + while (i<100 && *in!=' ' && *in) + date[i++]=*in++; + date[i]='\0'; + + sprintf(out,"%-13s revision: %-6s date: %-15s", filename, version, date); + return in-savein; +} + +// prints a single set of CVS ids +void printone(const char *cvsid){ + char strings[512]; + const char *here; + int len,line=1; + here=cvsid; + while ((len=massagecvs(strings,here))){ + switch (line++){ + case 1: + printout(LOG_INFO,"Module:"); + break; + default: + printout(LOG_INFO," uses:"); + } + printout(LOG_INFO," %s\n",strings); + here+=len; + } + return; +} + + char copyleftstring[]= "Home page of smartd is " PROJECTHOME "\n\n" "smartd comes with ABSOLUTELY NO WARRANTY. This\n" @@ -336,7 +403,10 @@ int main (int argc, char **argv){ printout(LOG_INFO,"smartd version %d.%d-%d Copyright (C) Bruce Allen 2002\n", RELEASE_MAJOR,RELEASE_MINOR,SMARTMONTOOLS_VERSION); printout(LOG_INFO,copyleftstring); - printout(LOG_INFO,"CVS version IDs of files used to build this code are:\n%s%s%s",CVSid1,CVSid2,CVSid3); + printout(LOG_INFO,"CVS version IDs of files used to build this code are:\n"); + printone(CVSid3); + printone(CVSid1); + printone(CVSid2); exit(0); }