aboutsummaryrefslogtreecommitdiff
path: root/sysutils/torsmo
diff options
context:
space:
mode:
authorSergey Matveychuk <sem@FreeBSD.org>2004-12-25 22:53:00 +0000
committerSergey Matveychuk <sem@FreeBSD.org>2004-12-25 22:53:00 +0000
commit135c4b95914b8235c3103667910ce9b6bb8d8915 (patch)
tree75006fd3d68fdb7e88f45aac59c48ba345fddb80 /sysutils/torsmo
parentfdae77ad9d1480e79ca48fd0d1f7c355c6d047ff (diff)
downloadports-135c4b95914b8235c3103667910ce9b6bb8d8915.tar.gz
ports-135c4b95914b8235c3103667910ce9b6bb8d8915.zip
Notes
Diffstat (limited to 'sysutils/torsmo')
-rw-r--r--sysutils/torsmo/Makefile9
-rw-r--r--sysutils/torsmo/distinfo4
-rw-r--r--sysutils/torsmo/files/freebsd.c351
-rw-r--r--sysutils/torsmo/files/patch-Makefile.am15
-rw-r--r--sysutils/torsmo/files/patch-configure.in35
-rw-r--r--sysutils/torsmo/files/patch-freebsd.c103
-rw-r--r--sysutils/torsmo/files/patch-fs.c37
-rw-r--r--sysutils/torsmo/files/patch-torsmo.c20
8 files changed, 117 insertions, 457 deletions
diff --git a/sysutils/torsmo/Makefile b/sysutils/torsmo/Makefile
index b9281dc2944b..3a0582226579 100644
--- a/sysutils/torsmo/Makefile
+++ b/sysutils/torsmo/Makefile
@@ -6,8 +6,7 @@
#
PORTNAME= torsmo
-PORTVERSION= 0.17
-PORTREVISION= 2
+PORTVERSION= 0.18
CATEGORIES= sysutils
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= ${PORTNAME}
@@ -15,8 +14,7 @@ MASTER_SITE_SUBDIR= ${PORTNAME}
MAINTAINER= bogorodskiy@inbox.ru
COMMENT= System monitor that renders text on desktop
-USE_AUTOCONF_VER=259
-USE_AUTOMAKE_VER=14
+GNU_CONFIGURE= yes
USE_X_PREFIX= yes
MAN1= torsmo.1
@@ -27,9 +25,6 @@ PORTDOCS= AUTHORS ChangeLog NEWS README
.include <bsd.port.pre.mk>
-post-extract:
- @${CP} ${FILESDIR}/freebsd.c ${WRKSRC}
-
post-install:
.if !defined(NOPORTDOCS)
@${MKDIR} ${DOCSDIR}
diff --git a/sysutils/torsmo/distinfo b/sysutils/torsmo/distinfo
index 3582d3348d50..46d85b470ea7 100644
--- a/sysutils/torsmo/distinfo
+++ b/sysutils/torsmo/distinfo
@@ -1,2 +1,2 @@
-MD5 (torsmo-0.17.tar.gz) = 8c82134cd78f9d4a7b6f6721ee2c16f9
-SIZE (torsmo-0.17.tar.gz) = 80286
+MD5 (torsmo-0.18.tar.gz) = 88bd8f627637d785a1d681f4f15f00b6
+SIZE (torsmo-0.18.tar.gz) = 84020
diff --git a/sysutils/torsmo/files/freebsd.c b/sysutils/torsmo/files/freebsd.c
deleted file mode 100644
index 19916df13dab..000000000000
--- a/sysutils/torsmo/files/freebsd.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Copyright (c) 2004 Roman Bogorodskiy <bogorodskiy@inbox.ru>
- *
- * $FreeBSD$
- */
-
-#include "torsmo.h"
-#include <fcntl.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <kvm.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/sysctl.h>
-#include <sys/vmmeter.h>
-#include <sys/dkstat.h>
-#include <unistd.h>
-#include <sys/user.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <net/if_mib.h>
-#include <sys/socket.h>
-#include <ifaddrs.h>
-
-#define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
-#define KELVTOC(x) ((x - 2732) / 10.0)
-
-static int getsysctl(char *name, void *ptr, size_t len)
-{
- size_t nlen = len;
- if (sysctlbyname(name, ptr, &nlen, NULL, 0) == -1) {
- return -1;
- }
-
- if (nlen != len) {
- return -1;
- }
-
- return 0;
-}
-
-static kvm_t *kd = NULL;
-struct ifmibdata *data = NULL;
-size_t len = 0;
-
-static int swapmode(int *retavail, int *retfree)
-{
- int n;
- int pagesize = getpagesize();
- struct kvm_swap swapary[1];
- static int kd_init = 1;
-
- if(kd_init) {
- kd_init = 0;
- if ((kd = kvm_open("/dev/null", "/dev/null", "/dev/null",
- O_RDONLY, "kvm_open")) == NULL) {
- (void)fprintf(stderr, "Cannot read kvm\n");
- return -1;
- }
- }
-
- if(kd == NULL) {
- return -1;
- }
-
- *retavail = 0;
- *retfree = 0;
-
-#define CONVERT(v) ((quad_t)(v) * pagesize / 1024)
-
- n = kvm_getswapinfo(kd, swapary, 1, 0);
- if (n < 0 || swapary[0].ksw_total == 0)
- return(0);
-
- *retavail = CONVERT(swapary[0].ksw_total);
- *retfree = CONVERT(swapary[0].ksw_total - swapary[0].ksw_used);
-
- n = (int)((double)swapary[0].ksw_used * 100.0 /
- (double)swapary[0].ksw_total);
-
- return n;
-}
-
-
-void prepare_update() {
-}
-
-double get_uptime()
-{
- int mib[2] = {CTL_KERN, KERN_BOOTTIME};
- struct timeval boottime;
- time_t now;
- size_t size = sizeof(boottime);
- double uptime;
-
- if((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1) && (boottime.tv_sec != 0)) {
- time(&now);
- uptime = now - boottime.tv_sec;
- } else {
- (void)fprintf(stderr, "Could not get uptime\n");
- uptime = 0;
- }
-
- return uptime;
-}
-
-
-void update_meminfo() {
- int total_pages,
- inactive_pages,
- free_pages;
- int swap_avail,
- swap_free;
-
- int pagesize = getpagesize();
-
- if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages))
- (void)fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_page_count\"\n");
-
- if (GETSYSCTL("vm.stats.vm.v_free_count", free_pages))
- (void)fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_free_count\"\n");
-
- if (GETSYSCTL("vm.stats.vm.v_inactive_count", inactive_pages))
- (void)fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_inactive_count\"\n");
-
- memmax = (total_pages*pagesize) >> 10;
- mem = ((total_pages-free_pages-inactive_pages) * pagesize) >> 10;
-
-
- if ((swapmode(&swap_avail, &swap_free)) >= 0) {
- swapmax = swap_avail;
- swap = (swap_avail - swap_free);
- } else {
- swapmax = 0;
- swap = 0;
- }
-}
-
-void update_net_stats() {
- struct net_stat *ns;
- double delta;
- long long r, t, last_recv, last_trans;
- struct ifaddrs *ifap, *ifa;
- struct if_data *ifd;
-
-
- /* get delta */
- delta = current_update_time - last_update_time;
- if (delta <= 0.0001)
- return;
-
- if (getifaddrs(&ifap) < 0)
- return;
-
- for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
- ns = get_net_stat((const char *)ifa->ifa_name);
-
- if (ifa->ifa_flags & IFF_UP) {
- last_recv = ns->recv;
- last_trans = ns->trans;
-
- if (ifa->ifa_addr->sa_family != AF_LINK)
- continue;
-
- ifd = (struct if_data *)ifa->ifa_data;
- r = ifd->ifi_ibytes;
- t = ifd->ifi_obytes;
-
- if (r < ns->last_read_recv)
- ns->recv += ((long long) 4294967295U - ns->last_read_recv) + r;
- else
- ns->recv += (r - ns->last_read_recv);
-
- ns->last_read_recv = r;
-
- if (t < ns->last_read_trans)
- ns->trans += ((long long) 4294967295U - ns->last_read_trans) + t;
- else
- ns->trans += (t - ns->last_read_trans);
-
- ns->last_read_trans = t;
-
-
- /* calculate speeds */
- ns->recv_speed = (ns->recv - last_recv) / delta;
- ns->trans_speed = (ns->trans - last_trans) / delta;
- }
- }
-
- freeifaddrs(ifap);
-}
-
-
-int get_total_processes() {
- /* It's easier to use kvm here than sysctl */
-
- int n_processes;
- static int kd_init = 1;
-
- if (kd_init) {
- kd_init = 0;
- if ((kd = kvm_open("/dev/null", "/dev/null", "/dev/null",
- O_RDONLY, "kvm_open")) == NULL) {
- (void)fprintf(stderr, "Cannot read kvm\n");
- return 0;
- }
- }
-
-
- if (kd != NULL)
- kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
- else
- return 0;
-
- return n_processes;
-}
-
-int get_running_processes() {
- static int kd_init = 1;
- struct kinfo_proc *p;
- int n_processes;
- int i,
- cnt = 0;
-
- if(kd_init) {
- kd_init = 0;
- if ((kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY, "kvm_open")) == NULL) {
- (void)fprintf(stderr, "Cannot read kvm\n");
- return 0;
- }
- }
-
- if (kd != NULL) {
- p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
- for (i = 0; i<n_processes; i++) {
-#if __FreeBSD__ < 5
- if (p[i].kp_proc.p_stat == SRUN)
-#else
- if (p[i].ki_stat == SRUN)
-#endif
- cnt++;
- }
- } else
- return 0;
-
- return cnt;
-}
-
-struct cpu_load_struct {
- unsigned long load[5];
-};
-
-struct cpu_load_struct fresh = {{0, 0, 0, 0, 0}};
-long cpu_used, oldtotal, oldused;
-
-void update_cpu_usage() {
- long used, total;
- long cp_time[CPUSTATES];
- size_t len = sizeof(cp_time);
-
- if (sysctlbyname("kern.cp_time", &cp_time, &len, NULL, 0) < 0) {
- (void)fprintf(stderr, "Cannot get kern.cp_time");
- }
-
- fresh.load[0] = cp_time[CP_USER];
- fresh.load[1] = cp_time[CP_NICE];
- fresh.load[2] = cp_time[CP_SYS];
- fresh.load[3] = cp_time[CP_IDLE];
- fresh.load[4] = cp_time[CP_IDLE];
-
- used = fresh.load[0] + fresh.load[1] + fresh.load[2];
- total = fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
-
- if ((total - oldtotal) != 0)
- {
- cpu_usage = ((double)(used - oldused)) / (double)(total - oldtotal);
- } else {
- cpu_usage = 0;
- }
-
- oldused = used;
- oldtotal = total;
-}
-
-double get_i2c_info(int fd, int div) {
- return 0;
-}
-
-void get_load_average(double v[3]) {
- getloadavg(v, 3);
-}
-
-double get_acpi_temperature(int fd) {
- int temp;
-
- if (GETSYSCTL("hw.acpi.thermal.tz0.temperature", temp)) {
- (void)fprintf(stderr, "Cannot read sysctl \"hw.acpi.thermal.tz0.temperature\"\n");
- temp = -1.0;
- }
-
- return KELVTOC(temp);
-}
-
-void get_battery_stuff(char *buf, unsigned int n, int b) {
- int battime;
-
- if (GETSYSCTL("hw.acpi.battery.time", battime))
- (void)fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.time\"\n");
-
- if (battime != -1)
- snprintf(buf, n, "Discharging, remaining %d:%2.2d", battime / 60, battime % 60);
- else
- snprintf(buf, n, "Battery is charging");
-
-}
-
-int open_i2c_sensor(const char *dev, const char *type, int n, int *div)
-{
- return 0;
-}
-
-int open_acpi_temperature(const char *name) {
- return 0;
-}
-
-char* get_acpi_ac_adapter(void)
-{
- int state;
- char *acstate = (char*)malloc(100);
-
- if (GETSYSCTL("hw.acpi.acline", state)) {
- (void)fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
- return "n\\a";
- }
-
- if (state)
- strcpy(acstate,"Running on AC Power");
- else
- strcpy(acstate, "Running on battery");
-
- return acstate;
-}
-
-char* get_acpi_fan() {
-
- return "";
-}
diff --git a/sysutils/torsmo/files/patch-Makefile.am b/sysutils/torsmo/files/patch-Makefile.am
deleted file mode 100644
index 067a421610cf..000000000000
--- a/sysutils/torsmo/files/patch-Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
---- Makefile.am.orig Thu Jul 29 08:32:01 2004
-+++ Makefile.am Thu Jul 29 08:32:10 2004
-@@ -8,7 +8,11 @@
- solaris = solaris.c
- endif
-
--torsmo_SOURCES = torsmo.c torsmo.h fs.c $(linux) $(solaris)
-+if BUILD_FREEBSD
-+freebsd = freebsd.c
-+endif
-+
-+torsmo_SOURCES = torsmo.c torsmo.h fs.c $(linux) $(solaris) $(freebsd)
-
- torsmo_LDFLAGS = $(X11_LIBS)
-
diff --git a/sysutils/torsmo/files/patch-configure.in b/sysutils/torsmo/files/patch-configure.in
deleted file mode 100644
index 1db7fab5336c..000000000000
--- a/sysutils/torsmo/files/patch-configure.in
+++ /dev/null
@@ -1,35 +0,0 @@
---- configure.in.orig Thu Jul 29 08:30:12 2004
-+++ configure.in Thu Jul 29 08:30:23 2004
-@@ -9,7 +9,9 @@
- Linux*)
- WANT_SYSINFO=yes
- ;;
--
-+ FreeBSD*)
-+ WANT_KVM=yes
-+ ;;
- # Solaris doesn't work at all right now
- # SunOS*)
- # WANT_KSTAT=yes
-@@ -24,6 +26,8 @@
-
- AM_CONDITIONAL(BUILD_LINUX, test x$uname = xLinux)
- AM_CONDITIONAL(BUILD_SOLARIS, test x$uname = xSunOS)
-+AM_CONDITIONAL(BUILD_FREEBSD, test x$uname = xFreeBSD)
-+
-
- dnl OWN_WINDOW option
-
-@@ -108,6 +112,12 @@
- fi
- fi
-
-+if test x$WANT_KVM = xyes; then
-+ AC_CHECK_LIB(kvm, kvm_open,
-+ LIBS="$LIBS -lkvm",
-+ AC_MSG_ERROR([Could not find kvm_open in -lkvm.])
-+ )
-+fi
- dnl Check getloadavg
-
- AC_MSG_CHECKING(for getloadavg)
diff --git a/sysutils/torsmo/files/patch-freebsd.c b/sysutils/torsmo/files/patch-freebsd.c
new file mode 100644
index 000000000000..baab383a4419
--- /dev/null
+++ b/sysutils/torsmo/files/patch-freebsd.c
@@ -0,0 +1,103 @@
+--- freebsd.c.orig Wed Dec 22 20:52:33 2004
++++ freebsd.c Wed Dec 22 21:34:40 2004
+@@ -4,14 +4,12 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <time.h>
+-#include <sys/time.h>
+ #include <kvm.h>
+ #include <sys/param.h>
+-#include <sys/resource.h>
+-#include <sys/sysctl.h>
+ #include <sys/types.h>
+ #include <sys/time.h>
++#include <sys/resource.h>
++#include <sys/sysctl.h>
+ #include <sys/vmmeter.h>
+ #include <sys/dkstat.h>
+ #include <unistd.h>
+@@ -19,11 +17,48 @@
+ #include <sys/socket.h>
+ #include <net/if.h>
+ #include <net/if_mib.h>
++#include <sys/socket.h>
+ #include <ifaddrs.h>
+
+ #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
+ #define KELVTOC(x) ((x - 2732) / 10.0)
+
++static unsigned int get_timer();
++static unsigned int get_cpu_speed(void);
++static inline unsigned long long int rdtsc( void );
++
++/* cpu frequency detection code based on mplayer's one */
++
++static unsigned int get_timer() {
++ struct timeval tv;
++ struct timezone tz;
++ gettimeofday(&tv,&tz);
++
++ return (tv.tv_sec*1000000+tv.tv_usec);
++}
++
++static inline unsigned long long int rdtsc( void )
++{
++ unsigned long long int retval;
++ __asm __volatile ("rdtsc":"=A"(retval)::"memory");
++ return retval;
++}
++
++static unsigned int get_cpu_speed(void)
++{
++ unsigned long long int tscstart, tscstop;
++ unsigned int start, stop;
++
++ tscstart = rdtsc();
++ start = get_timer();
++ usleep(50000);
++ stop = get_timer();
++ tscstop = rdtsc();
++
++ return((tscstop-tscstart)/((stop-start)/1000.0));
++}
++
++
+ static int getsysctl(char *name, void *ptr, size_t len)
+ {
+ size_t nlen = len;
+@@ -344,4 +379,34 @@
+
+ char* get_acpi_fan() {
+ return "";
++}
++
++char* get_adt746x_cpu() {
++ return "";
++}
++
++char* get_adt746x_fan() {
++ return "";
++}
++
++char* get_freq() {
++ int i;
++ char *cpuspeed;
++
++ if ((cpuspeed = (char *)malloc(16)) == NULL)
++ exit(1);
++
++ i = 0;
++ if ((i = get_cpu_speed()) > 0) {
++ if (i < 1000000) {
++ i += 50; /* for rounding */
++ snprintf(cpuspeed, 15, "%d.%d MHz", i/1000, (i/100)%10);
++ } else {
++ snprintf(cpuspeed, 15, "%d MHz", i/1000);
++ }
++ } else {
++ cpuspeed = "";
++ }
++
++ return cpuspeed;
+ }
diff --git a/sysutils/torsmo/files/patch-fs.c b/sysutils/torsmo/files/patch-fs.c
deleted file mode 100644
index 206307a97006..000000000000
--- a/sysutils/torsmo/files/patch-fs.c
+++ /dev/null
@@ -1,37 +0,0 @@
---- fs.c.orig Thu Aug 5 19:59:50 2004
-+++ fs.c Thu Aug 5 20:01:50 2004
-@@ -3,10 +3,12 @@
- #include <stdlib.h>
- #include <string.h>
- #include <errno.h>
--#include <sys/statvfs.h>
- #include <sys/types.h>
- #include <fcntl.h>
-
-+#include <sys/param.h>
-+#include <sys/mount.h>
-+
- /* TODO: benchmark which is faster, fstatvfs() or pre-opened fd and
- * statvfs() (fstatvfs() would handle mounts I think...) */
-
-@@ -15,16 +17,16 @@
-
- void update_fs_stats() {
- unsigned int i;
-- struct statvfs s;
-+ struct statfs s;
- for (i=0; i<16; i++) {
- if (fs_stats[i].fd <= 0)
- break;
-
-- fstatvfs(fs_stats[i].fd, &s);
-+ fstatfs(fs_stats[i].fd, &s);
-
-- fs_stats[i].size = (long long) s.f_blocks * s.f_frsize;
-+ fs_stats[i].size = (long long) s.f_blocks * s.f_bsize;
- /* bfree (root) or bavail (non-roots) ? */
-- fs_stats[i].avail = (long long) s.f_bavail * s.f_frsize;
-+ fs_stats[i].avail = (long long) s.f_bavail * s.f_bsize;
- }
- }
-
diff --git a/sysutils/torsmo/files/patch-torsmo.c b/sysutils/torsmo/files/patch-torsmo.c
index 2d041d13a02f..d0c476dd6b22 100644
--- a/sysutils/torsmo/files/patch-torsmo.c
+++ b/sysutils/torsmo/files/patch-torsmo.c
@@ -1,6 +1,6 @@
---- torsmo.c.orig Wed Oct 13 17:31:57 2004
-+++ torsmo.c Wed Oct 13 17:35:45 2004
-@@ -376,7 +376,7 @@
+--- torsmo.c.orig Wed Dec 22 01:14:46 2004
++++ torsmo.c Wed Dec 22 21:49:27 2004
+@@ -272,7 +272,7 @@
snprintf(buf, 255, "%.1fM", m);
}
else if (a >= 1024)
@@ -9,33 +9,33 @@
else
snprintf(buf, 255, "%Ld", a);
}
-@@ -998,7 +998,7 @@
+@@ -883,7 +883,7 @@
}
OBJ(acpitemp) {
/* does anyone have decimals in acpi temperature? */
- snprintf(p, n, "%d", (int) get_acpi_temperature(obj->data.i));
+ snprintf(p, n, "%0.1f", (float)get_acpi_temperature(obj->data.i));
}
- OBJ(acpifan) {
- snprintf(p, n, "%s", get_acpi_fan());
-@@ -2248,8 +2248,8 @@
+ OBJ(freq) {
+ snprintf(p, n, "%s", get_freq());
+@@ -2223,8 +2223,8 @@
/* handle other command line arguments */
- optind = 0;
-
-+ optind = optreset = 1;
++ optind = optreset = 1;
+
while (1) {
int c = getopt(argc, argv, getopt_string);
if(c == -1) break;
-@@ -2353,8 +2353,7 @@
+@@ -2319,8 +2319,7 @@
default:
fprintf(stderr, "torsmo: forked to background, pid is %d\n", ret);
- exit(0);
- break;
-+ return 0;
++ return 0;
}
}