JBoss Native SVN: r1033 - in trunk/sight/native: share and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-20 02:14:06 -0400 (Thu, 20 Sep 2007)
New Revision: 1033
Modified:
trunk/sight/native/include/sight_local.h
trunk/sight/native/share/jnu.c
Log:
Add wildchar matching function
Modified: trunk/sight/native/include/sight_local.h
===================================================================
--- trunk/sight/native/include/sight_local.h 2007-09-19 09:21:52 UTC (rev 1032)
+++ trunk/sight/native/include/sight_local.h 2007-09-20 06:14:06 UTC (rev 1033)
@@ -151,6 +151,7 @@
const char *, int);
char *sight_strdup(JNIEnv *, const char *,
const char *, int);
+int sight_wmatch(const char *, const char *);
/* Array prototypes */
sight_arr_t *sight_arr_new(jsize);
Modified: trunk/sight/native/share/jnu.c
===================================================================
--- trunk/sight/native/share/jnu.c 2007-09-19 09:21:52 UTC (rev 1032)
+++ trunk/sight/native/share/jnu.c 2007-09-20 06:14:06 UTC (rev 1033)
@@ -963,3 +963,32 @@
memcpy(dst, tmp, size);
return len;
}
+
+/* Match = 0, NoMatch = 1, Abort = -1
+ * Based loosely on sections of wildmat.c by Rich Salz
+ */
+int sight_wmatch(const char *str, const char *exp)
+{
+ int x, y;
+
+ for (x = 0, y = 0; exp[y]; ++y, ++x) {
+ if (!str[x] && exp[y] != '*')
+ return -1;
+ if (exp[y] == '*') {
+ while (exp[++y] == '*');
+ if (!exp[y])
+ return 0;
+ while (str[x]) {
+ int ret;
+ if ((ret = sight_wmatch(&str[x++], &exp[y])) != 1)
+ return ret;
+ }
+ return -1;
+ }
+ else if (exp[y] != '?') {
+ if (str[x] != exp[y])
+ return 1;
+ }
+ }
+ return (str[x] != '\0');
+}
17 years, 3 months
JBoss Native SVN: r1032 - trunk/sight/native/os/linux.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-19 05:21:52 -0400 (Wed, 19 Sep 2007)
New Revision: 1032
Modified:
trunk/sight/native/os/linux/netadapter.c
Log:
Add support for IPV6 routes/gateways
Modified: trunk/sight/native/os/linux/netadapter.c
===================================================================
--- trunk/sight/native/os/linux/netadapter.c 2007-09-19 08:51:27 UTC (rev 1031)
+++ trunk/sight/native/os/linux/netadapter.c 2007-09-19 09:21:52 UTC (rev 1032)
@@ -338,6 +338,49 @@
return 0;
}
+static int get_ipv6_route(JNIEnv *_E, const char *name,
+ net_ifc_data_t *id)
+{
+ sight_arr_t *i6r;
+ net_ifc_addr_t *ca;
+ int i;
+
+ if (!id)
+ return 0; /* No rec, nothing to do */
+ if ((i6r = sight_arr_rload(PROC_NET_ROUTE6)) != NULL) {
+ for (i = 0; i < i6r->siz; i++) {
+ char iface[16], nname[64];
+ char dsta[128], neta[128], hopa[128];
+ struct in6_addr ipd, ipn, iph;
+
+ int al, iflags, metric, refcnt, use, plen, slen;
+
+ al = sscanf(i6r->arr[i],
+ "%64s %02X %64s %02X %64s %08X %08X %08X %08X %s",
+ dsta, &plen, neta, &slen, hopa, &metric, &use,
+ &refcnt, &iflags, iface);
+ if (al < 10 || !(iflags & RTF_GATEWAY))
+ continue;
+ if (strcmp(iface, name))
+ continue;
+ sprintf(nname, "%s.r6.%d", name, i);
+ /* TODO: Deal with RTF_HOST flags */
+ if (!(ca = get_ifc_addr(_E, nname, id))) {
+ sight_arr_free(i6r);
+ return 1;
+ }
+ if (ca->route)
+ continue;
+ ca->route = 1;
+ /* XXX: Is it source network or next hop ? */
+ sight_hex2bin(neta, ipd.s6_addr, 16);
+ sight_inet_ntop6(ipd.s6_addr, ca->ip6a, 64);
+ }
+ }
+ sight_arr_free(i6r);
+ return 0;
+}
+
SIGHT_EXPORT_DECLARE(jlong, NetworkAdapter, enum0)(SIGHT_STDARGS,
jlong pool)
{
@@ -497,12 +540,13 @@
else {
net_ifc_addr_t *ca;
- if (!(ca = get_ifc_addr(_E, ifr->ifr_name, id))) {
+ if (!(ca = get_ifc_addr(_E, ifi.ifr_name, id))) {
sight_arr_free(i6a);
goto cleanup;
}
strcpy(ca->ip6a, las);
}
+ get_ipv6_route(_E, ifi.ifr_name, id);
}
sight_arr_free(i6a);
}
17 years, 3 months
JBoss Native SVN: r1031 - trunk/sight/native/os/linux.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-19 04:51:27 -0400 (Wed, 19 Sep 2007)
New Revision: 1031
Modified:
trunk/sight/native/os/linux/netadapter.c
Log:
Add support for IPV4 routes/gateways
Modified: trunk/sight/native/os/linux/netadapter.c
===================================================================
--- trunk/sight/native/os/linux/netadapter.c 2007-09-14 08:57:26 UTC (rev 1030)
+++ trunk/sight/native/os/linux/netadapter.c 2007-09-19 08:51:27 UTC (rev 1031)
@@ -32,9 +32,9 @@
#include <net/if.h>
#include <net/if_arp.h>
+#include <net/route.h>
#include <sys/ioctl.h>
-
/*
* Network adapter implementation
*/
@@ -142,8 +142,10 @@
sight_unload_class(_E, &_clazzn);
}
-#define PROC_INET6_FILE "/proc/net/if_inet6"
-#define PROC_NET_DEV "/proc/net/dev"
+#define PROC_INET6_FILE "/proc/net/if_inet6"
+#define PROC_NET_DEV "/proc/net/dev"
+#define PROC_NET_ROUTE4 "/proc/net/route"
+#define PROC_NET_ROUTE6 "/proc/net/ipv6_route"
typedef struct net_ifc_addr_t {
char ip4a[64];
@@ -151,6 +153,7 @@
char mask[64];
char badr[64];
int virt;
+ int route;
} net_ifc_addr_t;
typedef struct net_ifc_data_t {
@@ -241,7 +244,7 @@
}
}
-net_ifc_data_t *new_ifc_data(JNIEnv *_E, const char *name,
+net_ifc_data_t *new_ifc_addr(JNIEnv *_E, const char *name,
net_ifc_addr_t **ca)
{
net_ifc_data_t *id;
@@ -287,6 +290,54 @@
return ca;
}
+static int get_ipv4_route(JNIEnv *_E, const char *name,
+ net_ifc_data_t *id)
+{
+ sight_arr_t *i4r;
+ net_ifc_addr_t *ca;
+ int i;
+
+ if (!id)
+ return 0; /* No rec, nothing to do */
+ if ((i4r = sight_arr_rload(PROC_NET_ROUTE4)) != NULL) {
+ for (i = 1; i < i4r->siz; i++) {
+ char iface[16], nname[64];
+ char gatea[128], neta[128], maska[128];
+ struct in_addr ipg, ipn, ipm;
+ int al, iflags, metric, refcnt, use, mss, window, irtt;
+
+ al = sscanf(i4r->arr[i],
+ "%16s %128s %128s %X %d %d %d %128s %d %d %d",
+ iface, neta, gatea, &iflags, &refcnt, &use, &metric,
+ maska, &mss, &window, &irtt);
+ if (al < 10 || !(iflags & RTF_GATEWAY))
+ continue;
+ if (strcmp(iface, name))
+ continue;
+ sprintf(nname, "%s.r4.%d", name, i);
+ /* TODO: Deal with RTF_HOST flags */
+ if (!(ca = get_ifc_addr(_E, nname, id))) {
+ sight_arr_free(i4r);
+ return 1;
+ }
+ if (ca->route)
+ continue;
+ ca->route = 1;
+
+ if (sscanf(gatea, "%X", &ipg.s_addr) != 1)
+ continue;
+ if (sscanf(neta, "%X", &ipn.s_addr) != 1)
+ continue;
+ if (sscanf(maska, "%X", &ipm.s_addr) != 1)
+ continue;
+ inet_ntop(AF_INET, &ipg, ca->ip4a, 64);
+ inet_ntop(AF_INET, &ipm, ca->mask, 64);
+ }
+ }
+ sight_arr_free(i4r);
+ return 0;
+}
+
SIGHT_EXPORT_DECLARE(jlong, NetworkAdapter, enum0)(SIGHT_STDARGS,
jlong pool)
{
@@ -352,7 +403,7 @@
if (!(id = (net_ifc_data_t *)ce->data)) {
net_ifc_addr_t *ca;
- if (!(id = new_ifc_data(_E, ifr->ifr_name, &ca))) {
+ if (!(id = new_ifc_addr(_E, ifr->ifr_name, &ca))) {
free(ifc.ifc_buf);
goto cleanup;
}
@@ -373,7 +424,7 @@
strcpy(ca->ip4a, las);
do_ifrec(id, ca, e->sd, ifr->ifr_name);
}
-
+ get_ipv4_route(_E, ifr->ifr_name, id);
}
free(ifc.ifc_buf);
@@ -389,13 +440,14 @@
if (!(id = (net_ifc_data_t *)ce->data)) {
net_ifc_addr_t *ca;
- if (!(id = new_ifc_data(_E, i4a->arr[i], &ca))) {
+ if (!(id = new_ifc_addr(_E, i4a->arr[i], &ca))) {
sight_arr_free(i4a);
goto cleanup;
}
ce->data = id;
id->type = AF_INET;
do_ifrec(id, ca, e->sd, i4a->arr[i]);
+ get_ipv4_route(_E, i4a->arr[i], id);
}
}
sight_arr_free(i4a);
@@ -425,7 +477,7 @@
if (!(id = (net_ifc_data_t *)ce->data)) {
net_ifc_addr_t *ca;
- if (!(id = new_ifc_data(_E, ifi.ifr_name, &ca))) {
+ if (!(id = new_ifc_addr(_E, ifi.ifr_name, &ca))) {
sight_arr_free(i6a);
goto cleanup;
}
@@ -472,8 +524,10 @@
UNREFERENCED_O;
if (!e)
return 0;
- else
+ else {
+ e->idx = 0;
return e->ifc->siz;
+ }
}
SIGHT_EXPORT_DECLARE(void, NetworkAdapter, enum2)(SIGHT_STDARGS,
@@ -485,7 +539,7 @@
net_ifc_addr_t *ca;
jobject addr;
jobjectArray aarr;
- jint len, idx = 0;
+ jint len, idx;
int i;
UNREFERENCED_O;
@@ -528,8 +582,11 @@
}
/* Set IP addresses */
len = 0;
+ idx = 0;
for (i = 0; i < id->addr->siz; i++) {
ca = (net_ifc_addr_t *)id->addr->list[i]->data;
+ if (ca->route)
+ continue;
if (ca->ip4a[0])
len++;
if (ca->ip6a[0])
@@ -542,6 +599,8 @@
for (i = 0; i < id->addr->siz; i++) {
ca = (net_ifc_addr_t *)id->addr->list[i]->data;
+ if (ca->route)
+ continue;
if (ca->ip4a[0]) {
addr = sight_new_netaddr_class(_E, _O);
if (!addr || (*_E)->ExceptionCheck(_E))
@@ -566,6 +625,47 @@
SET_IFIELD_O(0006, thiz, aarr);
(*_E)->DeleteLocalRef(_E, aarr);
}
+ /* Set Gateway addresses */
+ len = 0;
+ idx = 0;
+ for (i = 0; i < id->addr->siz; i++) {
+ ca = (net_ifc_addr_t *)id->addr->list[i]->data;
+ if (!ca->route)
+ continue;
+ if (ca->ip4a[0])
+ len++;
+ else if (ca->ip6a[0])
+ len++;
+ }
+ if (len) {
+ aarr = sight_new_netaddr_array(_E, _O, len);
+ if (!aarr || (*_E)->ExceptionCheck(_E))
+ goto cleanup;
+ for (i = 0; i < id->addr->siz; i++) {
+ ca = (net_ifc_addr_t *)id->addr->list[i]->data;
+
+ if (!ca->route)
+ continue;
+ addr = sight_new_netaddr_class(_E, _O);
+ if (!addr || (*_E)->ExceptionCheck(_E))
+ return;
+ if (ca->ip4a[0]) {
+ sight_netaddr_set_addr(_E, addr, ca->ip4a);
+ sight_netaddr_set_family(_E, addr, AF_INET);
+ if (ca->mask[0])
+ sight_netaddr_set_mask(_E, addr, ca->mask);
+ }
+ else if (ca->ip6a[0]) {
+ sight_netaddr_set_addr(_E, addr, ca->ip6a);
+ sight_netaddr_set_family(_E, addr, AF_INET6);
+ }
+ (*_E)->SetObjectArrayElement(_E, aarr, idx++, addr);
+ (*_E)->DeleteLocalRef(_E, addr);
+ }
+ SET_IFIELD_O(0008, thiz, aarr);
+ (*_E)->DeleteLocalRef(_E, aarr);
+ }
+
SET_IFIELD_I(0009, thiz, id->mtu);
cleanup:
17 years, 3 months
JBoss Native SVN: r1030 - in trunk/sight/native: os/linux and 2 other directories.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-14 04:57:26 -0400 (Fri, 14 Sep 2007)
New Revision: 1030
Modified:
trunk/sight/native/include/sight_local.h
trunk/sight/native/include/sight_types.h
trunk/sight/native/os/linux/module.c
trunk/sight/native/os/linux/netadapter.c
trunk/sight/native/os/linux/network.c
trunk/sight/native/os/linux/tcpstat.c
trunk/sight/native/os/linux/udpstat.c
trunk/sight/native/os/linux/volume.c
trunk/sight/native/os/posix/group.c
trunk/sight/native/os/posix/user.c
trunk/sight/native/share/jnu.c
Log:
Remove union from sight_arr_t
Modified: trunk/sight/native/include/sight_local.h
===================================================================
--- trunk/sight/native/include/sight_local.h 2007-09-14 08:30:34 UTC (rev 1029)
+++ trunk/sight/native/include/sight_local.h 2007-09-14 08:57:26 UTC (rev 1030)
@@ -158,6 +158,7 @@
void sight_arr_free(sight_arr_t *);
sight_arr_t *sight_arr_rload(const char *);
sight_arr_t *sight_arr_cload(const char *, const char *);
+sight_arr_t *sight_arr_lload(const char *, int);
#define SIGHT_FREE(x) if ((x)) free((x))
Modified: trunk/sight/native/include/sight_types.h
===================================================================
--- trunk/sight/native/include/sight_types.h 2007-09-14 08:30:34 UTC (rev 1029)
+++ trunk/sight/native/include/sight_types.h 2007-09-14 08:57:26 UTC (rev 1030)
@@ -103,10 +103,7 @@
typedef struct sight_arr_t {
jsize siz;
jsize len;
- union {
- char **ca;
- jchar **wa;
- } arr;
+ char **arr;
} sight_arr_t;
typedef struct sight_object_t sight_object_t;
Modified: trunk/sight/native/os/linux/module.c
===================================================================
--- trunk/sight/native/os/linux/module.c 2007-09-14 08:30:34 UTC (rev 1029)
+++ trunk/sight/native/os/linux/module.c 2007-09-14 08:57:26 UTC (rev 1030)
@@ -122,7 +122,7 @@
goto cleanup;
}
for (j = 0; j < amods->siz; j++) {
- if (strchr(amods->arr.ca[j], '/'))
+ if (strchr(amods->arr[j], '/'))
nmods++;
}
@@ -136,7 +136,7 @@
char *bn = NULL;
char *p;
unsigned long long b, o;
- if ((bp = strchr(amods->arr.ca[j], '/'))) {
+ if ((bp = strchr(amods->arr[j], '/'))) {
if ((bn = strrchr(bp, '/')))
bn++;
}
@@ -149,7 +149,7 @@
}
SET_IFIELD_S(0000, m, bn);
SET_IFIELD_S(0001, m, bp);
- b = strtoull(amods->arr.ca[j], &p, 16);
+ b = strtoull(amods->arr[j], &p, 16);
if (p && *p == '-')
o = strtoull(p + 1, NULL, 16) - b;
else
Modified: trunk/sight/native/os/linux/netadapter.c
===================================================================
--- trunk/sight/native/os/linux/netadapter.c 2007-09-14 08:30:34 UTC (rev 1029)
+++ trunk/sight/native/os/linux/netadapter.c 2007-09-14 08:57:26 UTC (rev 1030)
@@ -214,7 +214,7 @@
memset(&ifi, 0, sizeof(struct ifreq));
strcpy(ifi.ifr_name, name);
-
+
if (!ca->virt) {
if (!ioctl(sd, SIOCGIFINDEX, (char *)&ifi))
id->index = ifi.ifr_ifindex;
@@ -222,7 +222,7 @@
id->index = -1;
if (!ioctl(sd, SIOCGIFFLAGS, (char *)&ifi))
id->flags = ifi.ifr_flags;
- /* Can we have IPV4 without MAC address ? */
+ /* Can we have IPV4 without MAC address ? */
if (!ioctl(sd, SIOCGIFHWADDR, (char *)&ifi))
make_mac(ifi.ifr_hwaddr.sa_data, id->maca);
if (!ioctl(sd, SIOCGIFMTU, (char *)&ifi))
@@ -351,7 +351,7 @@
ce = cache_add(e->ifc, pname);
if (!(id = (net_ifc_data_t *)ce->data)) {
net_ifc_addr_t *ca;
-
+
if (!(id = new_ifc_data(_E, ifr->ifr_name, &ca))) {
free(ifc.ifc_buf);
goto cleanup;
@@ -382,20 +382,20 @@
for (i = 2; i < i4a->siz; i++) {
cache_entry_t *ce;
char *pname;
- if (!(pname = strchr(i4a->arr.ca[i], ':')))
+ if (!(pname = strchr(i4a->arr[i], ':')))
continue;
*pname = '\0';
- ce = cache_add(e->ifc, i4a->arr.ca[i]);
+ ce = cache_add(e->ifc, i4a->arr[i]);
if (!(id = (net_ifc_data_t *)ce->data)) {
net_ifc_addr_t *ca;
- if (!(id = new_ifc_data(_E, i4a->arr.ca[i], &ca))) {
+ if (!(id = new_ifc_data(_E, i4a->arr[i], &ca))) {
sight_arr_free(i4a);
goto cleanup;
}
ce->data = id;
id->type = AF_INET;
- do_ifrec(id, ca, e->sd, i4a->arr.ca[i]);
+ do_ifrec(id, ca, e->sd, i4a->arr[i]);
}
}
sight_arr_free(i4a);
@@ -409,7 +409,7 @@
char ias[64];
char las[128] = "";
struct in6_addr in6;
- al = sscanf(i6a->arr.ca[i],
+ al = sscanf(i6a->arr[i],
"%32s %02x %02x %02x %02x %16s",
ias, &ifidx, &plen, &scope, &dads, ifi.ifr_name);
if (al != 6)
Modified: trunk/sight/native/os/linux/network.c
===================================================================
--- trunk/sight/native/os/linux/network.c 2007-09-14 08:30:34 UTC (rev 1029)
+++ trunk/sight/native/os/linux/network.c 2007-09-14 08:57:26 UTC (rev 1030)
@@ -106,7 +106,7 @@
}
if ((tdns = sight_arr_rload("/etc/resolv.conf"))) {
for (i = 0; i < tdns->siz; i++) {
- if (strstr(tdns->arr.ca[i], "nameserver")) {
+ if (strstr(tdns->arr[i], "nameserver")) {
len++;
}
}
@@ -118,7 +118,7 @@
goto cleanup;
}
for (i = 0; i < tdns->siz; i++) {
- if ((pd = strstr(tdns->arr.ca[i], "nameserver"))) {
+ if ((pd = strstr(tdns->arr[i], "nameserver"))) {
pd += 10;
addr = sight_new_netaddr_class(_E, _O);
if (!addr || (*_E)->ExceptionCheck(_E)) {
Modified: trunk/sight/native/os/linux/tcpstat.c
===================================================================
--- trunk/sight/native/os/linux/tcpstat.c 2007-09-14 08:30:34 UTC (rev 1029)
+++ trunk/sight/native/os/linux/tcpstat.c 2007-09-14 08:57:26 UTC (rev 1030)
@@ -198,8 +198,8 @@
return;
}
for (i = 0; i < tnet->siz; i++) {
- if (memcmp(tnet->arr.ca[i], "TCP: inuse ", 11) == 0) {
- NumCons = atoi(tnet->arr.ca[i] + 11);
+ if (memcmp(tnet->arr[i], "TCP: inuse ", 11) == 0) {
+ NumCons = atoi(tnet->arr[i] + 11);
break;
}
}
@@ -210,8 +210,8 @@
return;
}
for (i = 0; i < tnet->siz; i++) {
- if (memcmp(tnet->arr.ca[i], "TCP6: inuse ", 12) == 0) {
- NumCons = atoi(tnet->arr.ca[i] + 12);
+ if (memcmp(tnet->arr[i], "TCP6: inuse ", 12) == 0) {
+ NumCons = atoi(tnet->arr[i] + 12);
break;
}
}
@@ -229,9 +229,9 @@
/* Get the information corresponding to the second entry Tcp: */
for (i = 0; i < tnet->siz; i++) {
- if (memcmp(tnet->arr.ca[i], "Tcp:", 4) == 0) {
- if (memcmp(tnet->arr.ca[i], "Tcp: RtoAlgorithm", 17) != 0) {
- sscanf(tnet->arr.ca[i], "Tcp: %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
+ if (memcmp(tnet->arr[i], "Tcp:", 4) == 0) {
+ if (memcmp(tnet->arr[i], "Tcp: RtoAlgorithm", 17) != 0) {
+ sscanf(tnet->arr[i], "Tcp: %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
&RtoAlgorithm, &RtoMin, &RtoMax, &MaxConn, &ActiveOpens,
&PassiveOpens, &AttemptFails, &EstabResets, &CurrEstab,
&InSegs, &OutSegs, &RetransSegs, &InErrs, &OutRsts);
@@ -345,7 +345,7 @@
/* TODO: Throw overflow */
return;
}
- num = sscanf(e->tnet->arr.ca[e->idx],
+ num = sscanf(e->tnet->arr[e->idx],
"%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %ld %512s",
&d, las, &lp, ras, &rp, &state,
&txq, &rxq, &timer_run, &timelen, &retr,
Modified: trunk/sight/native/os/linux/udpstat.c
===================================================================
--- trunk/sight/native/os/linux/udpstat.c 2007-09-14 08:30:34 UTC (rev 1029)
+++ trunk/sight/native/os/linux/udpstat.c 2007-09-14 08:57:26 UTC (rev 1030)
@@ -115,8 +115,8 @@
return;
}
for (i = 0; i < tnet->siz; i++) {
- if (memcmp(tnet->arr.ca[i], "UDP: inuse ", 11) == 0) {
- NumCons = atoi(tnet->arr.ca[i] + 11);
+ if (memcmp(tnet->arr[i], "UDP: inuse ", 11) == 0) {
+ NumCons = atoi(tnet->arr[i] + 11);
break;
}
}
@@ -127,8 +127,8 @@
return;
}
for (i = 0; i < tnet->siz; i++) {
- if (memcmp(tnet->arr.ca[i], "UDP6: inuse ", 12) == 0) {
- NumCons = atoi(tnet->arr.ca[i] + 12);
+ if (memcmp(tnet->arr[i], "UDP6: inuse ", 12) == 0) {
+ NumCons = atoi(tnet->arr[i] + 12);
break;
}
}
@@ -146,9 +146,9 @@
/* Get the information corresponding to the second entry Tcp: */
for (i = 0; i < tnet->siz; i++) {
- if (memcmp(tnet->arr.ca[i], "Udp:", 4) == 0) {
- if (memcmp(tnet->arr.ca[i], "Udp: InDatagrams", 16) != 0) {
- sscanf(tnet->arr.ca[i], "Udp: %d %d %d %d %d %d",
+ if (memcmp(tnet->arr[i], "Udp:", 4) == 0) {
+ if (memcmp(tnet->arr[i], "Udp: InDatagrams", 16) != 0) {
+ sscanf(tnet->arr[i], "Udp: %d %d %d %d %d %d",
&InDatagrams, &NoPorts, &InErrors, &OutDatagrams,
&RcvbufErrors, &SndbufErrors);
break;
@@ -252,7 +252,7 @@
/* TODO: Throw overflow */
return;
}
- num = sscanf(e->tnet->arr.ca[e->idx],
+ num = sscanf(e->tnet->arr[e->idx],
"%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %ld %512s",
&d, las, &lp, ras, &rp, &state,
&txq, &rxq, &timer_run, &timelen, &retr,
Modified: trunk/sight/native/os/linux/volume.c
===================================================================
--- trunk/sight/native/os/linux/volume.c 2007-09-14 08:30:34 UTC (rev 1029)
+++ trunk/sight/native/os/linux/volume.c 2007-09-14 08:57:26 UTC (rev 1030)
@@ -220,7 +220,7 @@
unsigned long size, used;
int priority;
- if (sscanf(e->swaps->arr.ca[e->swap_idx],
+ if (sscanf(e->swaps->arr[e->swap_idx],
"%250s %30s %lu %lu %d",
path, type, &size, &used, &priority) == 5) {
SET_IFIELD_S(0000, thiz, path);
@@ -231,7 +231,7 @@
CALL_METHOD1(0002, thiz, SIGHT_DRIVE_SWAP);
SET_IFIELD_J(0005, thiz, size - used);
SET_IFIELD_J(0006, thiz, size);
- SET_IFIELD_J(0007, thiz, size - used);
+ SET_IFIELD_J(0007, thiz, size - used);
}
e->swap_idx++;
return;
Modified: trunk/sight/native/os/posix/group.c
===================================================================
--- trunk/sight/native/os/posix/group.c 2007-09-14 08:30:34 UTC (rev 1029)
+++ trunk/sight/native/os/posix/group.c 2007-09-14 08:57:26 UTC (rev 1030)
@@ -157,7 +157,7 @@
goto cleanup;
}
/* 1. GroupName */
- token = sight_strtok_c(tgrp->arr.ca[i], ':', &titer);
+ token = sight_strtok_c(tgrp->arr[i], ':', &titer);
SET_IFIELD_S(0000, u, token);
/* 2. Password */
token = sight_strtok_c(NULL, ':', &titer);
@@ -208,7 +208,7 @@
char *titer;
/* 1. GroupName */
- gname = sight_strtok_c(tgrp->arr.ca[i], ':', &titer);
+ gname = sight_strtok_c(tgrp->arr[i], ':', &titer);
/* 2. Password */
token = sight_strtok_c(NULL, ':', &titer);
/* 3. GID */
Modified: trunk/sight/native/os/posix/user.c
===================================================================
--- trunk/sight/native/os/posix/user.c 2007-09-14 08:30:34 UTC (rev 1029)
+++ trunk/sight/native/os/posix/user.c 2007-09-14 08:57:26 UTC (rev 1030)
@@ -171,7 +171,7 @@
goto cleanup;
}
/* 1. UserName */
- token = sight_strtok_c(tusr->arr.ca[i], ':', &titer);
+ token = sight_strtok_c(tusr->arr[i], ':', &titer);
SET_IFIELD_S(0000, u, token);
/* 2. Password */
token = sight_strtok_c(NULL, ':', &titer);
@@ -219,7 +219,7 @@
char *titer;
/* 1. UserName */
- uname = sight_strtok_c(tusr->arr.ca[i], ':', &titer);
+ uname = sight_strtok_c(tusr->arr[i], ':', &titer);
/* 2. Password */
token = sight_strtok_c(NULL, ':', &titer);
/* 3. UID */
@@ -313,7 +313,7 @@
char *titer;
/* 1. UserName */
- uname = sight_strtok_c(tusr->arr.ca[i], ':', &titer);
+ uname = sight_strtok_c(tusr->arr[i], ':', &titer);
if (strcmp(uname, tuc->list[j]->key)) {
continue;
}
Modified: trunk/sight/native/share/jnu.c
===================================================================
--- trunk/sight/native/share/jnu.c 2007-09-14 08:30:34 UTC (rev 1029)
+++ trunk/sight/native/share/jnu.c 2007-09-14 08:57:26 UTC (rev 1030)
@@ -766,7 +766,7 @@
return NULL;
a->siz = 0;
a->len = init;
- if (!(a->arr.ca = (char **)malloc(init * sizeof(char *)))) {
+ if (!(a->arr = (char **)malloc(init * sizeof(char *)))) {
int saved = errno;
free(a);
a = NULL;
@@ -780,19 +780,19 @@
if (!str || !*str)
return 0; /* Skip empty and null strings */
if (a->siz < a->len) {
- a->arr.ca[a->siz++] = strdup(str);
+ a->arr[a->siz++] = strdup(str);
}
else {
char **na;
size_t len = a->len << 2;
if (!(na = (char **)malloc(len * sizeof(char *))))
return errno;
- memcpy(na, a->arr.ca, a->siz * sizeof(char *));
- free(a->arr.ca);
+ memcpy(na, a->arr, a->siz * sizeof(char *));
+ free(a->arr);
a->len = len;
- a->arr.ca = na;
- a->arr.ca[a->siz] = strdup(str);
- if (!a->arr.ca[a->siz])
+ a->arr = na;
+ a->arr[a->siz] = strdup(str);
+ if (!a->arr[a->siz])
return errno;
else
a->siz++;
@@ -807,9 +807,9 @@
if (!a)
return;
for (i = 0; i < a->siz; i++) {
- SIGHT_FREE(a->arr.ca[i]);
+ SIGHT_FREE(a->arr[i]);
}
- free(a->arr.ca);
+ free(a->arr);
free(a);
}
@@ -880,6 +880,32 @@
return array;
}
+sight_arr_t *sight_arr_lload(const char *fname, int max_lines)
+{
+ sight_arr_t *array;
+ char buf[8192];
+ FILE *file;
+ int lc = 0;
+ if (!(file = fopen(fname, "r")))
+ return NULL;
+ if (!(array = sight_arr_new(max_lines))) {
+ fclose(file);
+ return NULL;
+ }
+ while (fgets(&buf[0], 8192, file)) {
+ char *pline = sight_trim(&buf[0]);
+ /* Skip empty lines */
+ if (pline) {
+ if (sight_arr_add(array, pline))
+ break;
+ if (++lc >= max_lines)
+ break;
+ }
+ }
+ fclose(file);
+ return array;
+}
+
char *sight_strtok_c(char *str, int sep, char **last)
{
char *sp;
17 years, 3 months
JBoss Native SVN: r1029 - trunk/sight/native/os/linux.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-14 04:30:34 -0400 (Fri, 14 Sep 2007)
New Revision: 1029
Modified:
trunk/sight/native/os/linux/netadapter.c
Log:
No need to obtain redundant data for each virtual adapter
Modified: trunk/sight/native/os/linux/netadapter.c
===================================================================
--- trunk/sight/native/os/linux/netadapter.c 2007-09-14 07:54:55 UTC (rev 1028)
+++ trunk/sight/native/os/linux/netadapter.c 2007-09-14 08:30:34 UTC (rev 1029)
@@ -150,6 +150,7 @@
char ip6a[64];
char mask[64];
char badr[64];
+ int virt;
} net_ifc_addr_t;
typedef struct net_ifc_data_t {
@@ -213,18 +214,20 @@
memset(&ifi, 0, sizeof(struct ifreq));
strcpy(ifi.ifr_name, name);
-
- if (!ioctl(sd, SIOCGIFINDEX, (char *)&ifi))
- id->index = ifi.ifr_ifindex;
- else
- id->index = -1;
-
- if (!ioctl(sd, SIOCGIFFLAGS, (char *)&ifi))
- id->flags = ifi.ifr_flags;
- /* Can we have IPV4 without MAC address ? */
- if (!id->maca[0] && !ioctl(sd, SIOCGIFHWADDR, (char *)&ifi))
- make_mac(ifi.ifr_hwaddr.sa_data, id->maca);
+ if (!ca->virt) {
+ if (!ioctl(sd, SIOCGIFINDEX, (char *)&ifi))
+ id->index = ifi.ifr_ifindex;
+ else
+ id->index = -1;
+ if (!ioctl(sd, SIOCGIFFLAGS, (char *)&ifi))
+ id->flags = ifi.ifr_flags;
+ /* Can we have IPV4 without MAC address ? */
+ if (!ioctl(sd, SIOCGIFHWADDR, (char *)&ifi))
+ make_mac(ifi.ifr_hwaddr.sa_data, id->maca);
+ if (!ioctl(sd, SIOCGIFMTU, (char *)&ifi))
+ id->mtu = ifi.ifr_mtu;
+ }
if (!ioctl(sd, SIOCGIFNETMASK, (char *)&ifi)) {
sa = (struct sockaddr_in *)&ifi.ifr_netmask;
@@ -236,8 +239,6 @@
sa = (struct sockaddr_in *)&ifi.ifr_broadaddr;
inet_ntop(AF_INET, &sa->sin_addr, ca->badr, 64);
}
- if (!ioctl(sd, SIOCGIFMTU, (char *)&ifi))
- id->mtu = ifi.ifr_mtu;
}
net_ifc_data_t *new_ifc_data(JNIEnv *_E, const char *name,
@@ -251,7 +252,7 @@
THROW_FMARK))) {
return NULL;
}
- if (!(id->addr = cache_new(16))) {
+ if (!(id->addr = cache_new(4))) {
throwAprMemoryException(_E, THROW_FMARK,
apr_get_os_error());
free(id);
@@ -304,7 +305,7 @@
THROW_FMARK))) {
return 0;
}
- if (!(e->ifc = cache_new(16))) {
+ if (!(e->ifc = cache_new(8))) {
throwAprMemoryException(_E, THROW_FMARK,
apr_get_os_error());
free(e);
@@ -335,6 +336,7 @@
char *p, las[128] = "";
char pname[IF_NAMESIZE];
struct sockaddr_in *sa;
+ int is_virtual = 0;
sa = (struct sockaddr_in *)&ifr->ifr_addr;
inet_ntop(AF_INET, &sa->sin_addr, las, 64);
@@ -344,6 +346,7 @@
* Remove everything after colon
*/
*p = '\0';
+ is_virtual = 1;
}
ce = cache_add(e->ifc, pname);
if (!(id = (net_ifc_data_t *)ce->data)) {
@@ -355,6 +358,7 @@
}
ce->data = id;
id->type = AF_INET;
+ ca->virt = is_virtual;
strcpy(ca->ip4a, las);
do_ifrec(id, ca, e->sd, ifr->ifr_name);
}
@@ -365,6 +369,7 @@
free(ifc.ifc_buf);
goto cleanup;
}
+ ca->virt = is_virtual;
strcpy(ca->ip4a, las);
do_ifrec(id, ca, e->sd, ifr->ifr_name);
}
17 years, 3 months
JBoss Native SVN: r1028 - trunk/sight/native/os/linux.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-14 03:54:55 -0400 (Fri, 14 Sep 2007)
New Revision: 1028
Modified:
trunk/sight/native/os/linux/netadapter.c
Log:
Fix virtual adapters
Modified: trunk/sight/native/os/linux/netadapter.c
===================================================================
--- trunk/sight/native/os/linux/netadapter.c 2007-09-13 10:32:37 UTC (rev 1027)
+++ trunk/sight/native/os/linux/netadapter.c 2007-09-14 07:54:55 UTC (rev 1028)
@@ -145,20 +145,20 @@
#define PROC_INET6_FILE "/proc/net/if_inet6"
#define PROC_NET_DEV "/proc/net/dev"
+typedef struct net_ifc_addr_t {
+ char ip4a[64];
+ char ip6a[64];
+ char mask[64];
+ char badr[64];
+} net_ifc_addr_t;
+
typedef struct net_ifc_data_t {
int type;
int index;
int flags;
int mtu;
- char ip4a[64];
- char ip6a[64];
char maca[64];
- char mask[64];
- char badr[64];
- char p4ds[64];
- char s4ds[64];
- char p6ds[64];
- char s6ds[64];
+ cache_table_t *addr;
} net_ifc_data_t;
typedef struct net_adapter_enum_t {
@@ -172,6 +172,7 @@
{
net_ifc_data_t *d = (net_ifc_data_t *)data;
if (d) {
+ cache_free(d->addr, NULL);
free(d);
}
}
@@ -204,7 +205,8 @@
*sp++ = '\0';
}
-static void do_ifrec(net_ifc_data_t *id, int sd, const char *name)
+static void do_ifrec(net_ifc_data_t *id, net_ifc_addr_t *ca,
+ int sd, const char *name)
{
struct ifreq ifi;
struct sockaddr_in *sa;
@@ -220,24 +222,70 @@
if (!ioctl(sd, SIOCGIFFLAGS, (char *)&ifi))
id->flags = ifi.ifr_flags;
/* Can we have IPV4 without MAC address ? */
- if (!ioctl(sd, SIOCGIFHWADDR, (char *)&ifi))
+
+ if (!id->maca[0] && !ioctl(sd, SIOCGIFHWADDR, (char *)&ifi))
make_mac(ifi.ifr_hwaddr.sa_data, id->maca);
if (!ioctl(sd, SIOCGIFNETMASK, (char *)&ifi)) {
sa = (struct sockaddr_in *)&ifi.ifr_netmask;
- inet_ntop(AF_INET, &sa->sin_addr, id->mask, 64);
+ inet_ntop(AF_INET, &sa->sin_addr, ca->mask, 64);
}
if ((id->flags & IFF_BROADCAST) &&
!ioctl(sd, SIOCGIFBRDADDR, (char *)&ifi)) {
sa = (struct sockaddr_in *)&ifi.ifr_broadaddr;
- inet_ntop(AF_INET, &sa->sin_addr, id->badr, 64);
+ inet_ntop(AF_INET, &sa->sin_addr, ca->badr, 64);
}
if (!ioctl(sd, SIOCGIFMTU, (char *)&ifi))
id->mtu = ifi.ifr_mtu;
}
+net_ifc_data_t *new_ifc_data(JNIEnv *_E, const char *name,
+ net_ifc_addr_t **ca)
+{
+ net_ifc_data_t *id;
+ cache_entry_t *ie;
+ if (!(id = (net_ifc_data_t *)sight_calloc(_E,
+ sizeof(net_ifc_data_t),
+ THROW_FMARK))) {
+ return NULL;
+ }
+ if (!(id->addr = cache_new(16))) {
+ throwAprMemoryException(_E, THROW_FMARK,
+ apr_get_os_error());
+ free(id);
+ return NULL;
+ }
+ ie = cache_add(id->addr, name);
+ if (!(*ca = (net_ifc_addr_t *)sight_calloc(_E,
+ sizeof(net_ifc_addr_t),
+ THROW_FMARK))) {
+ cache_free(id->addr, NULL);
+ return NULL;
+ }
+ ie->data = *ca;
+ return id;
+}
+
+net_ifc_addr_t *get_ifc_addr(JNIEnv *_E, const char *name,
+ net_ifc_data_t *id)
+{
+ cache_entry_t *ie;
+ net_ifc_addr_t *ca;
+
+ ie = cache_add(id->addr, name);
+ if (ie->data)
+ return ie->data;
+ if (!(ca = (net_ifc_addr_t *)sight_calloc(_E,
+ sizeof(net_ifc_addr_t),
+ THROW_FMARK))) {
+ return NULL;
+ }
+ ie->data = ca;
+ return ca;
+}
+
SIGHT_EXPORT_DECLARE(jlong, NetworkAdapter, enum0)(SIGHT_STDARGS,
jlong pool)
{
@@ -284,26 +332,41 @@
ifr = ifc.ifc_req;
for (i = 0; i < ifc.ifc_len; i += sizeof(struct ifreq), ifr++) {
cache_entry_t *ce;
- char las[128] = "";
+ char *p, las[128] = "";
+ char pname[IF_NAMESIZE];
struct sockaddr_in *sa;
sa = (struct sockaddr_in *)&ifr->ifr_addr;
inet_ntop(AF_INET, &sa->sin_addr, las, 64);
- ce = cache_add(e->ifc, ifr->ifr_name);
+ strcpy(pname, ifr->ifr_name);
+ if ((p = strchr(pname, ':'))) {
+ /* This is an virtual adapter.
+ * Remove everything after colon
+ */
+ *p = '\0';
+ }
+ ce = cache_add(e->ifc, pname);
if (!(id = (net_ifc_data_t *)ce->data)) {
- if (!(id = (net_ifc_data_t *)sight_calloc(_E,
- sizeof(net_ifc_data_t),
- THROW_FMARK))) {
+ net_ifc_addr_t *ca;
+
+ if (!(id = new_ifc_data(_E, ifr->ifr_name, &ca))) {
free(ifc.ifc_buf);
goto cleanup;
}
- do_ifrec(id, e->sd, ifr->ifr_name);
- strcpy(id->ip4a, las);
+ ce->data = id;
id->type = AF_INET;
- ce->data = id;
+ strcpy(ca->ip4a, las);
+ do_ifrec(id, ca, e->sd, ifr->ifr_name);
}
else {
- strcpy(id->ip4a, las);
+ net_ifc_addr_t *ca;
+
+ if (!(ca = get_ifc_addr(_E, ifr->ifr_name, id))) {
+ free(ifc.ifc_buf);
+ goto cleanup;
+ }
+ strcpy(ca->ip4a, las);
+ do_ifrec(id, ca, e->sd, ifr->ifr_name);
}
}
@@ -319,15 +382,15 @@
*pname = '\0';
ce = cache_add(e->ifc, i4a->arr.ca[i]);
if (!(id = (net_ifc_data_t *)ce->data)) {
- if (!(id = (net_ifc_data_t *)sight_calloc(_E,
- sizeof(net_ifc_data_t),
- THROW_FMARK))) {
+ net_ifc_addr_t *ca;
+
+ if (!(id = new_ifc_data(_E, i4a->arr.ca[i], &ca))) {
sight_arr_free(i4a);
goto cleanup;
}
- do_ifrec(id, e->sd, i4a->arr.ca[i]);
- id->type = AF_INET;
- ce->data = id;
+ ce->data = id;
+ id->type = AF_INET;
+ do_ifrec(id, ca, e->sd, i4a->arr.ca[i]);
}
}
sight_arr_free(i4a);
@@ -355,13 +418,15 @@
strcat(las, buf);
}
if (!(id = (net_ifc_data_t *)ce->data)) {
- if (!(id = (net_ifc_data_t *)sight_calloc(_E,
- sizeof(net_ifc_data_t),
- THROW_FMARK))) {
+ net_ifc_addr_t *ca;
+
+ if (!(id = new_ifc_data(_E, ifi.ifr_name, &ca))) {
sight_arr_free(i6a);
goto cleanup;
}
- strcpy(id->ip6a, las);
+ ce->data = id;
+ strcpy(ca->ip6a, las);
+
if (!ioctl(e->sd, SIOCGIFHWADDR, (char *)&ifi)) {
make_mac(ifi.ifr_hwaddr.sa_data, las);
strcpy(id->maca, las);
@@ -371,10 +436,15 @@
id->type = AF_INET6;
id->index = ifidx;
id->flags = IFF_UP;
- ce->data = id;
}
else {
- strcpy(id->ip6a, las);
+ net_ifc_addr_t *ca;
+
+ if (!(ca = get_ifc_addr(_E, ifr->ifr_name, id))) {
+ sight_arr_free(i6a);
+ goto cleanup;
+ }
+ strcpy(ca->ip6a, las);
}
}
sight_arr_free(i6a);
@@ -407,9 +477,11 @@
{
net_adapter_enum_t *e = J2P(handle, net_adapter_enum_t *);
net_ifc_data_t *id;
+ net_ifc_addr_t *ca;
jobject addr;
jobjectArray aarr;
- jint len, idx;
+ jint len, idx = 0;
+ int i;
UNREFERENCED_O;
if (!e || e->idx > e->ifc->siz)
@@ -451,35 +523,41 @@
}
/* Set IP addresses */
len = 0;
- if (id->ip4a[0])
- len++;
- if (id->ip6a[0])
- len++;
+ for (i = 0; i < id->addr->siz; i++) {
+ ca = (net_ifc_addr_t *)id->addr->list[i]->data;
+ if (ca->ip4a[0])
+ len++;
+ if (ca->ip6a[0])
+ len++;
+ }
if (len) {
- idx = 0;
aarr = sight_new_netaddr_array(_E, _O, len);
if (!aarr || (*_E)->ExceptionCheck(_E))
goto cleanup;
- if (id->ip4a[0]) {
- addr = sight_new_netaddr_class(_E, _O);
- if (!addr || (*_E)->ExceptionCheck(_E))
- return;
- sight_netaddr_set_addr(_E, addr, id->ip4a);
- sight_netaddr_set_family(_E, addr, AF_INET);
- if (id->mask[0])
- sight_netaddr_set_mask(_E, addr, id->mask);
- (*_E)->SetObjectArrayElement(_E, aarr, idx++, addr);
- (*_E)->DeleteLocalRef(_E, addr);
+ for (i = 0; i < id->addr->siz; i++) {
+ ca = (net_ifc_addr_t *)id->addr->list[i]->data;
+
+ if (ca->ip4a[0]) {
+ addr = sight_new_netaddr_class(_E, _O);
+ if (!addr || (*_E)->ExceptionCheck(_E))
+ return;
+ sight_netaddr_set_addr(_E, addr, ca->ip4a);
+ sight_netaddr_set_family(_E, addr, AF_INET);
+ if (ca->mask[0])
+ sight_netaddr_set_mask(_E, addr, ca->mask);
+ (*_E)->SetObjectArrayElement(_E, aarr, idx++, addr);
+ (*_E)->DeleteLocalRef(_E, addr);
+ }
+ if (ca->ip6a[0]) {
+ addr = sight_new_netaddr_class(_E, _O);
+ if (!addr || (*_E)->ExceptionCheck(_E))
+ return;
+ sight_netaddr_set_addr(_E, addr, ca->ip6a);
+ sight_netaddr_set_family(_E, addr, AF_INET6);
+ (*_E)->SetObjectArrayElement(_E, aarr, idx++, addr);
+ (*_E)->DeleteLocalRef(_E, addr);
+ }
}
- if (id->ip6a[0]) {
- addr = sight_new_netaddr_class(_E, _O);
- if (!addr || (*_E)->ExceptionCheck(_E))
- return;
- sight_netaddr_set_addr(_E, addr, id->ip6a);
- sight_netaddr_set_family(_E, addr, AF_INET6);
- (*_E)->SetObjectArrayElement(_E, aarr, idx++, addr);
- (*_E)->DeleteLocalRef(_E, addr);
- }
SET_IFIELD_O(0006, thiz, aarr);
(*_E)->DeleteLocalRef(_E, aarr);
}
17 years, 3 months
JBoss Native SVN: r1027 - in trunk/sight: native/include and 2 other directories.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-13 06:32:37 -0400 (Thu, 13 Sep 2007)
New Revision: 1027
Modified:
trunk/sight/java/org/jboss/sight/FileSystemType.java
trunk/sight/native/include/sight_types.h
trunk/sight/native/os/linux/volume.c
trunk/sight/native/share/jnu.c
Log:
Add SWAP filesystem detection
Modified: trunk/sight/java/org/jboss/sight/FileSystemType.java
===================================================================
--- trunk/sight/java/org/jboss/sight/FileSystemType.java 2007-09-13 07:34:56 UTC (rev 1026)
+++ trunk/sight/java/org/jboss/sight/FileSystemType.java 2007-09-13 10:32:37 UTC (rev 1027)
@@ -87,9 +87,13 @@
USBFS( 24),
/** VMware guest filesystem */
VMHGFS( 25),
+ /** VMware VMCI filesystem */
+ VMBLOCK( 26),
+ /** Swap filesystem */
+ SWAP( 27),
/** File system is mounted to nothing */
- NONE( 26);
+ NONE( 99);
private int value;
private FileSystemType(int v)
Modified: trunk/sight/native/include/sight_types.h
===================================================================
--- trunk/sight/native/include/sight_types.h 2007-09-13 07:34:56 UTC (rev 1026)
+++ trunk/sight/native/include/sight_types.h 2007-09-13 10:32:37 UTC (rev 1027)
@@ -172,7 +172,9 @@
#define SIGHT_FS_RPC 23
#define SIGHT_FS_USBFS 24
#define SIGHT_FS_VMHGFS 25
-#define SIGHT_FS_NONE 26
+#define SIGHT_FS_VMBLOCK 26
+#define SIGHT_FS_SWAP 27
+#define SIGHT_FS_NONE 99
#define SIGHT_CASE_SENSITIVE_SEARCH 0x00000001
#define SIGHT_CASE_PRESERVED_NAMES 0x00000002
Modified: trunk/sight/native/os/linux/volume.c
===================================================================
--- trunk/sight/native/os/linux/volume.c 2007-09-13 07:34:56 UTC (rev 1026)
+++ trunk/sight/native/os/linux/volume.c 2007-09-13 10:32:37 UTC (rev 1027)
@@ -144,9 +144,13 @@
sight_unload_class(_E, &_clazzn);
}
+#define PROC_SWAPS_FS "/proc/swaps"
+
typedef struct volume_enum_t {
- int num_mounts;
- FILE *fp;
+ int num_mounts;
+ FILE *fp;
+ sight_arr_t *swaps;
+ int swap_idx;
} volume_enum_t;
/* Initialize volume enumeration */
@@ -186,6 +190,13 @@
}
endmntent(e->fp);
e->fp = setmntent(MOUNTED, "r");
+ /* Now read the swaps */
+ if ((e->swaps = sight_arr_rload(PROC_SWAPS_FS))) {
+ if (e->swaps->siz) {
+ e->num_mounts += (e->swaps->siz - 1);
+ e->swap_idx = 1;
+ }
+ }
return e->num_mounts;
}
}
@@ -203,6 +214,28 @@
if (!e || !thiz)
return;
+ if (e->swaps && e->swap_idx < e->swaps->siz) {
+ char path[256];
+ char type[32];
+ unsigned long size, used;
+ int priority;
+
+ if (sscanf(e->swaps->arr.ca[e->swap_idx],
+ "%250s %30s %lu %lu %d",
+ path, type, &size, &used, &priority) == 5) {
+ SET_IFIELD_S(0000, thiz, path);
+ SET_IFIELD_S(0001, thiz, type);
+ SET_IFIELD_S(0002, thiz, "swap");
+ CALL_METHOD1(0000, thiz, SIGHT_FS_SWAP);
+ CALL_METHOD1(0001, thiz, SIGHT_READ_WRITE_VOLUME);
+ CALL_METHOD1(0002, thiz, SIGHT_DRIVE_SWAP);
+ SET_IFIELD_J(0005, thiz, size - used);
+ SET_IFIELD_J(0006, thiz, size);
+ SET_IFIELD_J(0007, thiz, size - used);
+ }
+ e->swap_idx++;
+ return;
+ }
if (getmntent_r(e->fp, &ent, buf, SIGHT_MBUFFER_LEN)) {
int flags = 0;
int dtype = sight_get_fs_type(ent.mnt_type);
@@ -234,15 +267,20 @@
case SIGHT_FS_PROC:
case SIGHT_FS_SYSFS:
case SIGHT_FS_TMPFS:
+ case SIGHT_FS_RAMFS:
CALL_METHOD1(0002, thiz, SIGHT_DRIVE_RAMDISK);
break;
case SIGHT_FS_NFS:
case SIGHT_FS_RPC:
+ case SIGHT_FS_VMBLOCK:
CALL_METHOD1(0002, thiz, SIGHT_DRIVE_REMOTE);
break;
case SIGHT_FS_USBFS:
CALL_METHOD1(0002, thiz, SIGHT_DRIVE_REMOVABLE);
break;
+ case SIGHT_FS_SWAP:
+ CALL_METHOD1(0002, thiz, SIGHT_DRIVE_SWAP);
+ break;
default:
CALL_METHOD1(0002, thiz, SIGHT_DRIVE_FIXED);
break;
@@ -268,6 +306,8 @@
if (e) {
if (e->fp)
endmntent(e->fp);
+ if (e->swaps)
+ sight_arr_free(e->swaps);
free(e);
}
}
Modified: trunk/sight/native/share/jnu.c
===================================================================
--- trunk/sight/native/share/jnu.c 2007-09-13 07:34:56 UTC (rev 1026)
+++ trunk/sight/native/share/jnu.c 2007-09-13 10:32:37 UTC (rev 1027)
@@ -501,6 +501,8 @@
return SIGHT_FS_VFAT;
if (memcmp(p, "MHGFS", 5) == 0)
return SIGHT_FS_VMHGFS;
+ if (memcmp(p, "MBLOCK", 6) == 0)
+ return SIGHT_FS_VMBLOCK;
else
return SIGHT_FS_UNKNOWN;
break;
17 years, 3 months
JBoss Native SVN: r1026 - in trunk/sight: native/include and 2 other directories.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-13 03:34:56 -0400 (Thu, 13 Sep 2007)
New Revision: 1026
Modified:
trunk/sight/java/org/jboss/sight/FileSystemType.java
trunk/sight/native/include/sight_types.h
trunk/sight/native/os/linux/common.c
trunk/sight/native/share/jnu.c
Log:
Add VMware guest filesystem
Modified: trunk/sight/java/org/jboss/sight/FileSystemType.java
===================================================================
--- trunk/sight/java/org/jboss/sight/FileSystemType.java 2007-09-13 05:50:50 UTC (rev 1025)
+++ trunk/sight/java/org/jboss/sight/FileSystemType.java 2007-09-13 07:34:56 UTC (rev 1026)
@@ -85,9 +85,11 @@
RPC( 23),
/** USB filesystem */
USBFS( 24),
+ /** VMware guest filesystem */
+ VMHGFS( 25),
/** File system is mounted to nothing */
- NONE( 25);
+ NONE( 26);
private int value;
private FileSystemType(int v)
Modified: trunk/sight/native/include/sight_types.h
===================================================================
--- trunk/sight/native/include/sight_types.h 2007-09-13 05:50:50 UTC (rev 1025)
+++ trunk/sight/native/include/sight_types.h 2007-09-13 07:34:56 UTC (rev 1026)
@@ -171,7 +171,8 @@
#define SIGHT_FS_TMPFS 22
#define SIGHT_FS_RPC 23
#define SIGHT_FS_USBFS 24
-#define SIGHT_FS_NONE 25
+#define SIGHT_FS_VMHGFS 25
+#define SIGHT_FS_NONE 26
#define SIGHT_CASE_SENSITIVE_SEARCH 0x00000001
#define SIGHT_CASE_PRESERVED_NAMES 0x00000002
Modified: trunk/sight/native/os/linux/common.c
===================================================================
--- trunk/sight/native/os/linux/common.c 2007-09-13 05:50:50 UTC (rev 1025)
+++ trunk/sight/native/os/linux/common.c 2007-09-13 07:34:56 UTC (rev 1026)
@@ -85,9 +85,14 @@
continue;
if (sb->st_ino == inode) {
/* Wow, we found it */
+ struct stat lb;
*pid = (pid_t)strtoul(pent->d_name, NULL, 10);
/* Get file times */
- lstat(fname, sb);
+ if (!lstat(fname, &lb)) {
+ sb->st_atime = lb.st_atime;
+ sb->st_ctime = lb.st_ctime;
+ sb->st_mtime = lb.st_mtime;
+ }
rv = 0;
break;
}
Modified: trunk/sight/native/share/jnu.c
===================================================================
--- trunk/sight/native/share/jnu.c 2007-09-13 05:50:50 UTC (rev 1025)
+++ trunk/sight/native/share/jnu.c 2007-09-13 07:34:56 UTC (rev 1026)
@@ -499,6 +499,8 @@
case 'V':
if (memcmp(p, "FAT", 3) == 0)
return SIGHT_FS_VFAT;
+ if (memcmp(p, "MHGFS", 5) == 0)
+ return SIGHT_FS_VMHGFS;
else
return SIGHT_FS_UNKNOWN;
break;
17 years, 3 months
JBoss Native SVN: r1025 - in trunk/sight/native: os/linux and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-13 01:50:50 -0400 (Thu, 13 Sep 2007)
New Revision: 1025
Modified:
trunk/sight/native/include/sight_types.h
trunk/sight/native/os/linux/netadapter.c
Log:
Make OperStatus as UP only if really UP and RUNNING
Modified: trunk/sight/native/include/sight_types.h
===================================================================
--- trunk/sight/native/include/sight_types.h 2007-09-12 18:16:08 UTC (rev 1024)
+++ trunk/sight/native/include/sight_types.h 2007-09-13 05:50:50 UTC (rev 1025)
@@ -218,8 +218,12 @@
#define SIGHT_IFO_UP 1
#define SIGHT_IFO_DOWN 2
+#define SIGHT_IFO_TESTING 3
+#define SIGHT_IFO_UNKNOWN 4
+#define SIGHT_IFO_DORMANT 5
+#define SIGHT_IFO_NOTPRESENT 6
+#define SIGHT_IFO_LLDOWN 7
-
#ifdef __cplusplus
}
#endif
Modified: trunk/sight/native/os/linux/netadapter.c
===================================================================
--- trunk/sight/native/os/linux/netadapter.c 2007-09-12 18:16:08 UTC (rev 1024)
+++ trunk/sight/native/os/linux/netadapter.c 2007-09-13 05:50:50 UTC (rev 1025)
@@ -441,7 +441,10 @@
}
/* Set adapter status */
if (id->flags & IFF_UP) {
- CALL_METHOD1(0001, thiz, SIGHT_IFO_UP);
+ if (id->flags & IFF_RUNNING)
+ CALL_METHOD1(0001, thiz, SIGHT_IFO_UP);
+ else
+ CALL_METHOD1(0001, thiz, SIGHT_IFO_NOTPRESENT);
}
else {
CALL_METHOD1(0001, thiz, SIGHT_IFO_DOWN);
17 years, 3 months
JBoss Native SVN: r1024 - trunk/sight/native/os/linux.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-09-12 14:16:08 -0400 (Wed, 12 Sep 2007)
New Revision: 1024
Modified:
trunk/sight/native/os/linux/udpstat.c
Log:
Fix missing udp
Modified: trunk/sight/native/os/linux/udpstat.c
===================================================================
--- trunk/sight/native/os/linux/udpstat.c 2007-09-12 18:10:32 UTC (rev 1023)
+++ trunk/sight/native/os/linux/udpstat.c 2007-09-12 18:16:08 UTC (rev 1024)
@@ -112,6 +112,7 @@
if (iftype == 1) {
if (!(tnet = sight_arr_rload(PROC_NET_FS "sockstat"))) {
throwAprException(_E, apr_get_os_error());
+ return;
}
for (i = 0; i < tnet->siz; i++) {
if (memcmp(tnet->arr.ca[i], "UDP: inuse ", 11) == 0) {
@@ -123,6 +124,7 @@
else if (iftype == 2) {
if (!(tnet = sight_arr_rload(PROC_NET_FS "sockstat6"))) {
throwAprException(_E, apr_get_os_error());
+ return;
}
for (i = 0; i < tnet->siz; i++) {
if (memcmp(tnet->arr.ca[i], "UDP6: inuse ", 12) == 0) {
17 years, 3 months