Compare commits

...

11 Commits

Author SHA1 Message Date
openeuler-ci-bot
2c07640b67
!4 update to 0.3-0.52
From: @zhang__3125 
Reviewed-by: @dwl301 
Signed-off-by: @dwl301
2023-01-09 03:56:54 +00:00
zhang__3125
10872a7154 update to 0.3-0.52 2023-01-09 11:48:49 +08:00
openeuler-ci-bot
52ac71e922 !3 20201201 add yaml file
From: @zhang__3125
Reviewed-by: @dwl301
Signed-off-by: @dwl301
2020-12-02 20:04:15 +08:00
张琳
26468c5839 update hddtemp.spec. 2020-12-02 19:56:56 +08:00
张琳
0ea8a1d7c9 update hddtemp.spec. 2020-12-02 19:50:30 +08:00
zhang__3125
f9276c1df3 20201201 add yaml file 2020-12-02 19:39:10 +08:00
张琳
a492ffb0f4 update hddtemp.spec. 2020-12-02 19:27:28 +08:00
张琳
82f1e229a8 update hddtemp.spec. 2020-12-02 19:26:54 +08:00
zhang__3125
5dd668e1c0 20201201 add yaml file 2020-12-02 19:18:28 +08:00
openeuler-ci-bot
d8d0a5b8e8 !1 Init hddtemp package
Merge pull request !1 from 陈棋德/master
2020-07-13 16:29:30 +08:00
dillon chen
92423cf5e8 Init hddtemp package 2020-07-07 20:01:05 +08:00
16 changed files with 831 additions and 0 deletions

View File

@ -0,0 +1,26 @@
From e677018004a41a1895a44fca88a6ff2323093064 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
Date: Fri, 10 Jan 2014 00:21:07 +0200
Subject: [PATCH] Allow binding to a listen address that doesn't exist yet
---
src/daemon.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/daemon.c b/src/daemon.c
index 3e211f2..ee836e5 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -98,6 +98,9 @@ void daemon_open_sockets(void)
/* Allow local port reuse in TIME_WAIT */
setsockopt(sks_serv[sks_serv_num], SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
+ /* Allow binding to a listen address that doesn't exist yet */
+ setsockopt(sks_serv[sks_serv_num], SOL_IP, IP_FREEBIND, &on, sizeof(on));
+
/* Now we've got a socket - we need to bind it. */
if (bind(sks_serv[sks_serv_num], resp->ai_addr, resp->ai_addrlen) < 0) {
/* Nope, try another */
--
1.8.3.1

View File

@ -0,0 +1,104 @@
From d3c162af0ca0110ce715c1e364194475f2eee3ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
Date: Sat, 18 Jan 2014 13:59:27 +0200
Subject: [PATCH] Try attribute 190 if 194 doesn't exist
---
src/ata.c | 2 ++
src/db.c | 1 +
src/db.h | 1 +
src/hddtemp.c | 1 +
src/hddtemp.h | 1 +
src/sata.c | 2 ++
src/scsi.c | 1 +
7 files changed, 9 insertions(+)
diff --git a/src/ata.c b/src/ata.c
index 1d908ac..742129a 100644
--- a/src/ata.c
+++ b/src/ata.c
@@ -141,6 +141,8 @@ static enum e_gettemp ata_get_temperature(struct disk *dsk) {
/* temperature */
field = ata_search_temperature(values, dsk->db_entry->attribute_id);
+ if(!field && dsk->db_entry->attribute_id2 != 0)
+ field = ata_search_temperature(values, dsk->db_entry->attribute_id2);
if(field)
dsk->value = *(field+3);
diff --git a/src/db.c b/src/db.c
index 5aed8e8..f8a1822 100644
--- a/src/db.c
+++ b/src/db.c
@@ -196,6 +196,7 @@ static int parse_db_line(char *line) {
new_entry->regexp = strdup(regexp);
new_entry->description = strdup(description);
new_entry->attribute_id = value;
+ new_entry->attribute_id2 = 0;
new_entry->unit = unit;
new_entry->next = NULL;
*last_entry = new_entry;
diff --git a/src/db.h b/src/db.h
index 6c08e87..dccb21c 100644
--- a/src/db.h
+++ b/src/db.h
@@ -26,6 +26,7 @@
struct harddrive_entry {
char *regexp;
short int attribute_id;
+ short int attribute_id2;
char *description;
unsigned char unit;
struct harddrive_entry *next;
diff --git a/src/hddtemp.c b/src/hddtemp.c
index 300cb0e..bce5e91 100644
--- a/src/hddtemp.c
+++ b/src/hddtemp.c
@@ -528,6 +528,7 @@ int main(int argc, char* argv[]) {
dsk->db_entry->regexp = "";
dsk->db_entry->description = "";
dsk->db_entry->attribute_id = DEFAULT_ATTRIBUTE_ID;
+ dsk->db_entry->attribute_id2 = DEFAULT_ATTRIBUTE_ID2;
dsk->db_entry->unit = 'C';
dsk->db_entry->next = NULL;
}
diff --git a/src/hddtemp.h b/src/hddtemp.h
index ed4ed5d..2460639 100644
--- a/src/hddtemp.h
+++ b/src/hddtemp.h
@@ -30,6 +30,7 @@ typedef __u16 u16;
#define MAX_ERRORMSG_SIZE 128
#define DEFAULT_ATTRIBUTE_ID 194
+#define DEFAULT_ATTRIBUTE_ID2 190
#define F_to_C(val) (int)(((double)(val)-32.0)/1.8)
#define C_to_F(val) (int)(((double)(val)*(double)1.8) + (double)32.0)
diff --git a/src/sata.c b/src/sata.c
index d67621f..0afe13c 100644
--- a/src/sata.c
+++ b/src/sata.c
@@ -166,6 +166,8 @@ static enum e_gettemp sata_get_temperature(struct disk *dsk) {
/* temperature */
field = sata_search_temperature(values, dsk->db_entry->attribute_id);
+ if(!field && dsk->db_entry->attribute_id2 != 0)
+ field = sata_search_temperature(values, dsk->db_entry->attribute_id2);
if(field)
dsk->value = *(field+3);
diff --git a/src/scsi.c b/src/scsi.c
index 71c9b82..b92b235 100644
--- a/src/scsi.c
+++ b/src/scsi.c
@@ -84,6 +84,7 @@ static enum e_gettemp scsi_get_temperature(struct disk *dsk) {
dsk->db_entry->regexp = "";
dsk->db_entry->description = "";
dsk->db_entry->attribute_id = 0;
+ dsk->db_entry->attribute_id2 = 0;
dsk->db_entry->unit = 'C';
dsk->db_entry->next = NULL;
--
1.8.3.1

12
fix-model-length.patch Normal file
View File

@ -0,0 +1,12 @@
diff -Naur hddtemp-0.3-beta15.orig/src/sata.c hddtemp-0.3-beta15/src/sata.c
--- hddtemp-0.3-beta15.orig/src/sata.c 2014-03-07 19:09:31.000000000 +0100
+++ hddtemp-0.3-beta15/src/sata.c 2014-03-07 19:29:07.738284373 +0100
@@ -88,7 +88,7 @@
return strdup(_("unknown"));
else
{
- sata_fixstring(identify + 54, 24);
+ sata_fixstring(identify + 54, 40);
return strdup(identify + 54);
}
}

View File

@ -0,0 +1,85 @@
diff -up hddtemp-0.3-beta15/doc/hddtemp.8~ hddtemp-0.3-beta15/doc/hddtemp.8
--- hddtemp-0.3-beta15/doc/hddtemp.8~ 2011-08-18 00:36:05.689001470 +0300
+++ hddtemp-0.3-beta15/doc/hddtemp.8 2011-08-18 00:44:46.753006253 +0300
@@ -19,7 +19,7 @@
hddtemp \- Utility to monitor hard drive temperature
.SH SYNOPSIS
.B hddtemp
-.RI [ options ] " [type:]disk" ...
+.RI [ options ] " [[type:]disk]" ...
.SH "DESCRIPTION"
.PP
.B hddtemp
@@ -35,7 +35,8 @@ You can specify one or more device drive
with a
.B type
like PATA, SATA or SCSI to force hddtemp too use one of these type
-(because detection can fail).
+(because detection can fail). If no paths are specified, autodetection of
+installed drives is attempted.
.SH "OPTIONS"
diff -up hddtemp-0.3-beta15/src/hddtemp.c~ hddtemp-0.3-beta15/src/hddtemp.c
--- hddtemp-0.3-beta15/src/hddtemp.c~ 2011-08-18 00:36:05.638996861 +0300
+++ hddtemp-0.3-beta15/src/hddtemp.c 2011-08-18 00:35:55.485060798 +0300
@@ -54,6 +54,7 @@
#include <linux/hdreg.h>
#include <ctype.h>
#include <assert.h>
+#include <glob.h>
// Application specific includes
#include "ata.h"
@@ -255,6 +256,7 @@ int main(int argc, char* argv[]) {
int ret = 0;
int show_db;
struct disk * ldisks;
+ glob_t diskglob;
backtrace_sigsegv();
backtrace_sigill();
@@ -419,11 +421,6 @@ int main(int argc, char* argv[]) {
exit(0);
}
- if(argc - optind <= 0) {
- fprintf(stderr, _("Too few arguments: you must specify one drive, at least.\n"));
- exit(1);
- }
-
if(debug) {
/* argc = optind + 1;*/
quiet = 1;
@@ -434,6 +431,23 @@ int main(int argc, char* argv[]) {
exit(1);
}
+ memset(&diskglob, 0, sizeof(glob_t));
+ if(argc - optind <= 0) {
+ if(glob("/dev/[hs]d[a-z]", 0, NULL, &diskglob) == 0) {
+ argc = diskglob.gl_pathc;
+ argv = diskglob.gl_pathv;
+ optind = 0;
+ } else {
+ argc = 0;
+ }
+ }
+
+ if(argc - optind <= 0) {
+ globfree(&diskglob);
+ fprintf(stderr, _("Too few arguments: you must specify one drive, at least.\n"));
+ exit(1);
+ }
+
init_bus_types();
/* collect disks informations */
@@ -527,6 +541,7 @@ int main(int argc, char* argv[]) {
else {
do_direct_mode(ldisks);
}
+ globfree(&diskglob);
return ret;
}

BIN
hddtemp-0.3-beta15.tar.bz2 Normal file

Binary file not shown.

View File

@ -0,0 +1,30 @@
Avoid calling exit without declaring it first. Future compilers will not
accept implicit function declarations.
This is in autoconf-generated code. Current autoconf does not produce
it anymore, so the issue will go away if upstream ever regenerates the
configure script.
diff -ur hddtemp-0.3-beta15.orig/configure hddtemp-0.3-beta15/configure
--- hddtemp-0.3-beta15.orig/configure 2005-10-17 21:19:28.000000000 +0200
+++ hddtemp-0.3-beta15/configure 2022-12-08 15:59:35.947637944 +0100
@@ -2588,7 +2588,7 @@
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
for ac_declaration in \
- '' \
+ '#include <stdlib.h>' \
'extern "C" void std::exit (int) throw (); using std::exit;' \
'extern "C" void std::exit (int); using std::exit;' \
'extern "C" void exit (int) throw ();' \
@@ -3332,8 +3332,8 @@
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
- exit(2);
- exit (0);
+ return 2;
+ return 0;
}
_ACEOF
rm -f conftest$ac_exeext

385
hddtemp-nvme.patch Normal file
View File

@ -0,0 +1,385 @@
diff -uNr hddtemp-0.3-beta15.old/src/hddtemp.c hddtemp-0.3-beta15/src/hddtemp.c
--- hddtemp-0.3-beta15.old/src/hddtemp.c 2020-02-03 14:23:19.781566750 +0200
+++ hddtemp-0.3-beta15/src/hddtemp.c 2020-02-03 14:31:03.526209746 +0200
@@ -61,6 +61,7 @@
#include "utf8.h"
#include "sata.h"
#include "scsi.h"
+#include "nvme.h"
#include "db.h"
#include "hddtemp.h"
#include "backtrace.h"
@@ -87,6 +88,7 @@
bus[BUS_SATA] = &sata_bus;
bus[BUS_ATA] = &ata_bus;
bus[BUS_SCSI] = &scsi_bus;
+ bus[BUS_NVME] = &nvme_bus;
}
/*******************************************************
@@ -130,6 +132,8 @@
return BUS_ATA;
else if(bus[BUS_SCSI]->probe(dsk->fd))
return BUS_SCSI;
+ else if (bus[BUS_NVME]->probe(dsk->fd))
+ return BUS_NVME;
else
return BUS_UNKNOWN;
}
diff -uNr hddtemp-0.3-beta15.old/src/hddtemp.h hddtemp-0.3-beta15/src/hddtemp.h
--- hddtemp-0.3-beta15.old/src/hddtemp.h 2020-02-03 14:23:19.781566750 +0200
+++ hddtemp-0.3-beta15/src/hddtemp.h 2020-02-03 08:50:34.755411875 +0200
@@ -35,7 +35,7 @@
#define F_to_C(val) (int)(((double)(val)-32.0)/1.8)
#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_bustype { ERROR = 0, BUS_UNKNOWN, BUS_SATA, BUS_ATA, BUS_SCSI, BUS_NVME, BUS_TYPE_MAX };
enum e_gettemp {
GETTEMP_ERROR, /* Error */
GETTEMP_NOT_APPLICABLE, /* */
diff -uNr hddtemp-0.3-beta15.old/src/Makefile.am hddtemp-0.3-beta15/src/Makefile.am
--- hddtemp-0.3-beta15.old/src/Makefile.am 2005-03-15 02:23:13.000000000 +0200
+++ hddtemp-0.3-beta15/src/Makefile.am 2020-02-03 08:50:34.737411657 +0200
@@ -13,7 +13,7 @@
scsi.c scsi.h \
scsicmds.c scsicmds.h \
backtrace.c backtrace.h \
- utf8.c utf8.h
+ utf8.c utf8.h nvme.o
hddtemp_CFLAGS = -Wall -W -rdynamic
#hddtemp_CFLAGS = -Wall -fomit-frame-pointer -rdynamic
diff -uNr hddtemp-0.3-beta15.old/src/Makefile.in hddtemp-0.3-beta15/src/Makefile.in
--- hddtemp-0.3-beta15.old/src/Makefile.in 2005-10-17 21:20:28.000000000 +0200
+++ hddtemp-0.3-beta15/src/Makefile.in 2020-02-03 08:50:34.790412300 +0200
@@ -157,7 +157,7 @@
scsi.c scsi.h \
scsicmds.c scsicmds.h \
backtrace.c backtrace.h \
- utf8.c utf8.h
+ utf8.c utf8.h nvme.c
hddtemp_CFLAGS = -Wall -W -rdynamic
@@ -180,7 +180,7 @@
hddtemp-hddtemp.$(OBJEXT) hddtemp-sata.$(OBJEXT) \
hddtemp-satacmds.$(OBJEXT) hddtemp-scsi.$(OBJEXT) \
hddtemp-scsicmds.$(OBJEXT) hddtemp-backtrace.$(OBJEXT) \
- hddtemp-utf8.$(OBJEXT)
+ hddtemp-utf8.$(OBJEXT) hddtemp-nvme.$(OBJEXT)
hddtemp_OBJECTS = $(am_hddtemp_OBJECTS)
hddtemp_DEPENDENCIES =
hddtemp_LDFLAGS =
@@ -195,6 +195,7 @@
@AMDEP_TRUE@ ./$(DEPDIR)/hddtemp-db.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/hddtemp-hddtemp.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/hddtemp-sata.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/hddtemp-nvme.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/hddtemp-satacmds.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/hddtemp-scsi.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/hddtemp-scsicmds.Po \
@@ -257,6 +258,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hddtemp-db.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hddtemp-hddtemp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hddtemp-sata.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hddtemp-nvme.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hddtemp-satacmds.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hddtemp-scsi.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hddtemp-scsicmds.Po@am__quote@
@@ -416,6 +418,28 @@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hddtemp_CFLAGS) $(CFLAGS) -c -o hddtemp-sata.obj `if test -f 'sata.c'; then $(CYGPATH_W) 'sata.c'; else $(CYGPATH_W) '$(srcdir)/sata.c'; fi`
+hddtemp-nvme.o: nvme.c
+@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hddtemp_CFLAGS) $(CFLAGS) -MT hddtemp-nvme.o -MD -MP -MF "$(DEPDIR)/hddtemp-nvme.Tpo" \
+@am__fastdepCC_TRUE@ -c -o hddtemp-nvme.o `test -f 'nvme.c' || echo '$(srcdir)/'`nvme.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/hddtemp-nvme.Tpo" "$(DEPDIR)/hddtemp-nvme.Po"; \
+@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/hddtemp-nvme.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@ fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nvme.c' object='hddtemp-nvme.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/hddtemp-nvme.Po' tmpdepfile='$(DEPDIR)/hddtemp-nvme.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hddtemp_CFLAGS) $(CFLAGS) -c -o hddtemp-nvme.o `test -f 'nvme.c' || echo '$(srcdir)/'`nvme.c
+
+hddtemp-nvme.obj: nvme.c
+@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hddtemp_CFLAGS) $(CFLAGS) -MT hddtemp-nvme.obj -MD -MP -MF "$(DEPDIR)/hddtemp-nvme.Tpo" \
+@am__fastdepCC_TRUE@ -c -o hddtemp-nvme.obj `if test -f 'nvme.c'; then $(CYGPATH_W) 'nvme.c'; else $(CYGPATH_W) '$(srcdir)/nvme.c'; fi`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/hddtemp-nvme.Tpo" "$(DEPDIR)/hddtemp-nvme.Po"; \
+@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/hddtemp-nvme.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@ fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nvme.c' object='hddtemp-nvme.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/hddtemp-nvme.Po' tmpdepfile='$(DEPDIR)/hddtemp-nvme.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hddtemp_CFLAGS) $(CFLAGS) -c -o hddtemp-nvme.obj `if test -f 'nvme.c'; then $(CYGPATH_W) 'nvme.c'; else $(CYGPATH_W) '$(srcdir)/nvme.c'; fi`
+
hddtemp-satacmds.o: satacmds.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hddtemp_CFLAGS) $(CFLAGS) -MT hddtemp-satacmds.o -MD -MP -MF "$(DEPDIR)/hddtemp-satacmds.Tpo" \
@am__fastdepCC_TRUE@ -c -o hddtemp-satacmds.o `test -f 'satacmds.c' || echo '$(srcdir)/'`satacmds.c; \
diff -uNr hddtemp-0.3-beta15.old/src/nvme.c hddtemp-0.3-beta15/src/nvme.c
--- hddtemp-0.3-beta15.old/src/nvme.c 1970-01-01 02:00:00.000000000 +0200
+++ hddtemp-0.3-beta15/src/nvme.c 2020-02-03 15:36:20.217181895 +0200
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) 2020 Constantine Gavrilov <constantine.gavrilov@gmail.com>
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "hddtemp.h"
+#include <sys/ioctl.h>
+#include <linux/nvme_ioctl.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <string.h>
+
+struct nvme_smart_log {
+ unsigned char critical_warning;
+ unsigned char temperature[2];
+ unsigned char avail_spare;
+ unsigned char spare_thresh;
+ unsigned char percent_used;
+ unsigned char rsvd6[26];
+ unsigned char data_units_read[16];
+ unsigned char data_units_written[16];
+ unsigned char host_reads[16];
+ unsigned char host_writes[16];
+ unsigned char ctrl_busy_time[16];
+ unsigned char power_cycles[16];
+ unsigned char power_on_hours[16];
+ unsigned char unsafe_shutdowns[16];
+ unsigned char media_errors[16];
+ unsigned char num_err_log_entries[16];
+ unsigned int warning_temp_time;
+ unsigned int critical_comp_time;
+ unsigned short temp_sensor[8];
+ unsigned int thm_temp1_trans_count;
+ unsigned int thm_temp2_trans_count;
+ unsigned int thm_temp1_total_time;
+ unsigned int thm_temp2_total_time;
+ unsigned char rsvd232[280];
+};
+
+struct nvme_id_power_state {
+ unsigned short max_power; // centiwatts
+ unsigned char rsvd2;
+ unsigned char flags;
+ unsigned int entry_lat; // microseconds
+ unsigned int exit_lat; // microseconds
+ unsigned char read_tput;
+ unsigned char read_lat;
+ unsigned char write_tput;
+ unsigned char write_lat;
+ unsigned short idle_power;
+ unsigned char idle_scale;
+ unsigned char rsvd19;
+ unsigned short active_power;
+ unsigned char active_work_scale;
+ unsigned char rsvd23[9];
+};
+
+struct nvme_id_ctrl {
+ unsigned short vid;
+ unsigned short ssvid;
+ char sn[20];
+ char mn[40];
+ char fr[8];
+ unsigned char rab;
+ unsigned char ieee[3];
+ unsigned char cmic;
+ unsigned char mdts;
+ unsigned short cntlid;
+ unsigned int ver;
+ unsigned int rtd3r;
+ unsigned int rtd3e;
+ unsigned int oaes;
+ unsigned int ctratt;
+ unsigned char rsvd100[156];
+ unsigned short oacs;
+ unsigned char acl;
+ unsigned char aerl;
+ unsigned char frmw;
+ unsigned char lpa;
+ unsigned char elpe;
+ unsigned char npss;
+ unsigned char avscc;
+ unsigned char apsta;
+ unsigned short wctemp;
+ unsigned short cctemp;
+ unsigned short mtfa;
+ unsigned int hmpre;
+ unsigned int hmmin;
+ unsigned char tnvmcap[16];
+ unsigned char unvmcap[16];
+ unsigned int rpmbs;
+ unsigned short edstt;
+ unsigned char dsto;
+ unsigned char fwug;
+ unsigned short kas;
+ unsigned short hctma;
+ unsigned short mntmt;
+ unsigned short mxtmt;
+ unsigned int sanicap;
+ unsigned char rsvd332[180];
+ unsigned char sqes;
+ unsigned char cqes;
+ unsigned short maxcmd;
+ unsigned int nn;
+ unsigned short oncs;
+ unsigned short fuses;
+ unsigned char fna;
+ unsigned char vwc;
+ unsigned short awun;
+ unsigned short awupf;
+ unsigned char nvscc;
+ unsigned char rsvd531;
+ unsigned short acwu;
+ unsigned char rsvd534[2];
+ unsigned int sgls;
+ unsigned char rsvd540[228];
+ char subnqn[256];
+ unsigned char rsvd1024[768];
+ unsigned int ioccsz;
+ unsigned int iorcsz;
+ unsigned short icdoff;
+ unsigned char ctrattr;
+ unsigned char msdbd;
+ unsigned char rsvd1804[244];
+ struct nvme_id_power_state psd[32];
+ unsigned char vs[1024];
+};
+
+#include <stdio.h>
+
+static int nvme_probe(int fd)
+{
+ return (ioctl(fd, NVME_IOCTL_ID, NULL) > 0);
+}
+
+static bool nvme_read_smart_log(int fd, struct nvme_smart_log *smart_log)
+{
+ unsigned int size = sizeof(*smart_log);
+ struct nvme_passthru_cmd pt = { 0 };
+
+ memset(smart_log, 0, size);
+ pt.opcode = 0x02;
+ pt.nsid = 0xffffffff;
+ pt.addr = (uint64_t)smart_log;
+ pt.data_len = size;
+ pt.cdw10 = 0x02 | (((size / 4) - 1) << 16);
+ if (ioctl(fd, NVME_IOCTL_ADMIN_CMD, &pt) < 0)
+ return false;
+ return true;
+}
+
+static bool nvme_read_id_ctrl(int fd, struct nvme_id_ctrl *id)
+{
+ memset(id, 0, sizeof(*id));
+ struct nvme_passthru_cmd pt = { 0 };
+ pt.opcode = 0x06;
+ pt.nsid = 0;
+ pt.addr = (uint64_t)id;
+ pt.data_len = sizeof(*id);
+ pt.cdw10 = 0x01;
+ if (ioctl(fd, NVME_IOCTL_ADMIN_CMD, &pt) < 0)
+ return false;
+ return true;
+}
+
+
+const char *nvme_model(int fd)
+{
+ struct nvme_id_ctrl id;
+ unsigned int i;
+ char *p;
+ const unsigned int name_len = sizeof(id.mn);
+
+ if (nvme_read_id_ctrl(fd, &id) == false)
+ return "NVME Disk";
+ id.mn[name_len-1] = '\0';
+ for (i = name_len - 2; i > 0; i--) {
+ if (id.mn[i] == ' ')
+ id.mn[i] = '\0';
+ else
+ break;
+ }
+ p = id.mn;
+ for (i = 0; i < name_len; i++) {
+ if (id.mn[i] == ' ')
+ id.mn[i] = '\0';
+ else
+ break;
+ }
+ p = strdup(p);
+ if (!p || strlen(p) == 0)
+ return "NVME Disk";
+ for (i = 0; p[i]; i++) {
+ if (p[i] < 0x20 || p[i] > 0x7e)
+ p[i] = '?';
+ }
+ return p;
+}
+
+enum e_gettemp nvme_get_temperature(struct disk *disk)
+{
+ struct nvme_smart_log smart_log;
+ if (nvme_read_smart_log(disk->fd, &smart_log) == false)
+ return GETTEMP_UNKNOWN;
+ disk->value = smart_log.temperature[0] + (smart_log.temperature[1] << 8) - 273;
+ return GETTEMP_KNOWN;
+}
+
+struct bustype nvme_bus = {
+ "NVME",
+ nvme_probe,
+ nvme_model,
+ nvme_get_temperature
+};
+
+
diff -uNr hddtemp-0.3-beta15.old/src/nvme.h hddtemp-0.3-beta15/src/nvme.h
--- hddtemp-0.3-beta15.old/src/nvme.h 1970-01-01 02:00:00.000000000 +0200
+++ hddtemp-0.3-beta15/src/nvme.h 2020-02-03 08:08:03.708300652 +0200
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2020 Constnatine Gavrilov <constantine.gavrilov@gmail.com>
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _HDDTEMP_NVME_H_
+#define _HDDTEMP_NVME_H_
+
+extern struct bustype nvme_bus;
+
+#endif
+

3
hddtemp.consoleapp Normal file
View File

@ -0,0 +1,3 @@
USER=root
PROGRAM=/usr/sbin/hddtemp
GUI=no

55
hddtemp.db Normal file
View File

@ -0,0 +1,55 @@
# Minimal database for drives not covered by defaults. hddtemp will first try
# S.M.A.R.T. attribute 194. If it does not exist, it will try attribute 190.
#
# The four columns are:
# 1) Regular expression matching the drive identification, which you see as
# the Model in the output of: hddtemp --debug /dev/drive
# 2) S.M.A.R.T. attribute number to get drive temperature. A value of zero
# means that we know that the drive doesn't have a temperature sensor.
# 3) Temperature units reported (C or F).
# 4) Human readable string representing the drive model.
"FUJITSU MHM2100AT" 0 C "Fujitsu MHM2100AT"
"HITACHI_DK228A-65" 0 C "Hitachi DK228A-65"
"IBM-DARA-212000" 0 C "IBM Travelstar 12GN"
"IBM-DHEA-(34330|36480)" 0 C "IBM Deskstar 5 serie"
"IBM-DHEA-(34331|36481|38451)" 0 C "IBM Deskstar 8 serie"
"IBM-DJNA-35.*" 231 C "IBM Deskstar 25 GP serie"
"IBM-DJNA-37.*" 231 C "IBM Deskstar 22 GXP serie"
"IBM-DPTA-35.*" 231 C "IBM Deskstar 37GP serie"
"IBM-DPTA-37.*" 231 C "IBM Deskstar 34GXP serie"
"IBM-DTTA-35*" 0 C "IBM Deskstar 16GP serie"
"MK4313MAT" 220 C "Toshiba MK4313MAT"
"Maxtor 5(1024|1369|2049|2732|3073|4098)U(2|3|4|6|8)" 0 C "Maxtor DiamondMax Plus 40"
"Maxtor 5T0[24]0H[24]" 0 C "Maxtor DiamondMax Plus 60"
"Maxtor 94098U8" 11 C "Maxtor DiamondMax 40 94098U8"
"QUANTUM FIREBALL CX10.2A" 0 C "Quantum Fireball CX10.2A"
"QUANTUM FIREBALLP AS40.0" 0 C "Quantum Fireball AS40"
"SAMSUNG SSD PM8[01]0" 0 C "Samsung SSD PM800/810"
"SAMSUNG SV0432A" 0 C "Samsung SV0432A"
"SAMSUNG SV3002H" 0 C "Samsung SpinPoint V30 serie"
"SAMSUNG SW0434A" 0 C "Samsung SW0434A"
"ST310210A" 0 C "Seagate ST310210A"
"ST310220A" 0 C "Seagate ST310220A"
"ST310240A" 0 C "Seagate Medalist 10240 Ultra ATA-3"
"ST313021A" 0 C "Seagate U8 ST313021A"
"ST320423A" 0 C "Seagate U10 20423, Ultra ATA/66"
"ST3412A" 0 C "Seagate ST3412A"
"ST38641A" 0 C "Seagate ST38641A"
"Seagate Technology 1275MB - ST31276A" 0 C "Seagate ST31276A"
"TOSHIBA MK1517GAP" 0 C "Toshiba MK1517GAP"
"TOSHIBA MK2018GAS" 226 F "Toshiba MK2018GAS"
"TOSHIBA MK3017GAP" 0 C "Toshiba MK3017GAP"
"WDC AC22000L" 0 C "Western Digital Caviar AC22000"
"WDC AC418000D" 231 C "Western Digital AC418000D"
"WDC AC420400D" 231 C "Western Digital Caviar AC420400D"
"WDC WD100EB-00BHF0" 0 C "Western Digital 100EB-00BHF0"
"WDC WD135BA" 231 C "Western Digital WD135BA"
"WDC WD200BB-00AUA1" 0 C "Western Digital Caviar WD200BB"
"WDC WD300BB-00CAA0" 0 C "Western Digital WD300BB"
"WDC WD400BB-(18CA|00DE)A0" 0 C "Western Digital Caviar WD400BB"
"WDC WD400BB-00CAA0" 0 C "Western Digital 400BB-00CAA0"
"WDC WD400EB-00CPF0" 0 C "Western Digital 400EB-00CPF0"
"WDC WD600BB-32BSA0" 0 C "Western Digital 600BB-32BSA0"
"WDC WD800BB-00CAA1" 0 C "Western Digital WD800BB-00CAA1"
"WDC WD800JB-00CRA1" 0 C "Western Digital Caviar WD800JB"

4
hddtemp.pam Normal file
View File

@ -0,0 +1,4 @@
#%PAM-1.0
auth sufficient pam_rootok.so
auth required pam_localuser.so
account required pam_permit.so

11
hddtemp.service Normal file
View File

@ -0,0 +1,11 @@
[Unit]
Description=Hard drive temperature monitor daemon
Documentation=man:hddtemp(8)
[Service]
Environment=HDDTEMP_OPTIONS=--listen=127.0.0.1
EnvironmentFile=-/etc/sysconfig/hddtemp
ExecStart=/usr/sbin/hddtemp -dF $HDDTEMP_OPTIONS
[Install]
WantedBy=multi-user.target

95
hddtemp.spec Normal file
View File

@ -0,0 +1,95 @@
Name: hddtemp
Version: 0.3
Release: 0.52.beta15
Summary: Hard disk temperature tool
License: GPLv2+
URL: http://savannah.nongnu.org/projects/hddtemp/
Source0: http://download.savannah.nongnu.org/releases/hddtemp/%{name}-%{version}-beta15.tar.bz2
Source1: %{name}.db
Source2: %{name}.service
Source3: %{name}.sysconfig
Source4: %{name}.pam
Source5: %{name}.consoleapp
Patch0: 0001-Try-attribute-190-if-194-doesn-t-exist.patch
Patch1: http://ftp.debian.org/debian/pool/main/h/hddtemp/hddtemp_0.3-beta15-53.diff.gz
Patch2: %{name}-0.3-beta15-autodetect-717479.patch
Patch3: 0001-Allow-binding-to-a-listen-address-that-doesn-t-exist.patch
Patch4: fix-model-length.patch
Patch5: ru.po.patch
Patch6: %{name}-nvme.patch
Patch7: hddtemp-configure-c99.patch
BuildRequires: make
BuildRequires: gcc
BuildRequires: gettext
# systemd >= 186 for scriptlet macros
BuildRequires: systemd >= 186
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
Requires: %{_bindir}/consolehelper
%description
hddtemp is a tool that gives you the temperature of your hard drive by
reading S.M.A.R.T. information.
%prep
%setup -q -n %{name}-%{version}-beta15
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch0 -p1
%patch4 -p1
%patch5 -p0
%patch6 -p1
%patch7 -p1
sed -i -e 's|/etc/hddtemp.db|/usr/share/misc/hddtemp.db|' doc/hddtemp.8
chmod -x contribs/analyze/*
rm COPYING ; cp -p GPL-2 COPYING
cp -p debian/changelog changelog.debian
%build
%configure --disable-dependency-tracking
%make_build
%install
%make_install
install -Dpm 644 %{SOURCE1} $RPM_BUILD_ROOT/usr/share/misc/hddtemp.db
install -Dpm 644 %{SOURCE2} $RPM_BUILD_ROOT%{_unitdir}/hddtemp.service
install -Dpm 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/hddtemp
install -dm 755 $RPM_BUILD_ROOT%{_bindir}
ln -s consolehelper $RPM_BUILD_ROOT%{_bindir}/hddtemp
install -Dpm 644 %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/hddtemp
install -Dpm 644 %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/security/console.apps/hddtemp
%find_lang %{name}
%post
%systemd_post hddtemp.service
%preun
%systemd_preun hddtemp.service
%postun
%systemd_postun_with_restart hddtemp.service
%files -f %{name}.lang
%doc ChangeLog changelog.debian COPYING README TODO contribs/
%config(noreplace) %{_sysconfdir}/sysconfig/hddtemp
%config(noreplace) %{_sysconfdir}/pam.d/hddtemp
%config(noreplace) %{_sysconfdir}/security/console.apps/hddtemp
%{_unitdir}/hddtemp.service
%{_bindir}/hddtemp
%{_sbindir}/hddtemp
%config(noreplace) /usr/share/misc/hddtemp.db
%{_mandir}/man8/hddtemp.8*
%changelog
* Mon Jan 02 2023 lin zhang <lin.zhang@turbolinux.com.cn> - 0.3-0.52.beta15
- update to 0.3-0.52
* Tue Jul 7 2020 Dillon Chen <dillon.chen@turbolinux.com.cn> - 0.3-1.beta15
- package from Fedora
- Update Debian patch set to 0.3-beta15-53

5
hddtemp.sysconfig Normal file
View File

@ -0,0 +1,5 @@
#
# hddtemp(8) daemon options. If no disks are specified here, the service
# will try to autodetect and start monitoring all of them.
#
HDDTEMP_OPTIONS="-l 127.0.0.1"

5
hddtemp.yaml Normal file
View File

@ -0,0 +1,5 @@
version_control: ftp
src_repo: http://download.savannah.nongnu.org/releases/hddtemp
tag_prefix:
tag_pattern: "hddtemp-(.*)-beta15.tar.bz2"
seperator: "."

Binary file not shown.

11
ru.po.patch Normal file
View File

@ -0,0 +1,11 @@
--- po/ru.po.orig 2019-05-05 14:56:48.213240623 +0700
+++ po/ru.po 2019-05-05 14:57:09.047473626 +0700
@@ -50,7 +50,7 @@
#: src/hddtemp.c:235
#, c-format
msgid "%s: %s: drive is sleeping\n"
-msgstr "%s: %s: ÎÅÔ ÄÁÔÞÉËÁ\n"
+msgstr "%s: %s: ÄÉÓË × ÓÏÓÔÏÑÎÉÉ ÓÎÁ\n"
#: src/hddtemp.c:242
#, fuzzy, c-format