Date: Wed, 14 Oct 2009 12:25:42 GMT From: KOIE Hidetaka <koie@suri.co.jp> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/139599: sysutils/p5-BSD-Sysctl can not handle QUAD integer. Message-ID: <200910141225.n9ECPgJb042866@www.freebsd.org> Resent-Message-ID: <200910141230.n9ECU4D4073933@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 139599 >Category: ports >Synopsis: sysutils/p5-BSD-Sysctl can not handle QUAD integer. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Oct 14 12:30:04 UTC 2009 >Closed-Date: >Last-Modified: >Originator: KOIE Hidetaka >Release: FreeBSD 9.0-CURRENT amd64 >Organization: surigiken >Environment: FreeBSD guriandgura 9.0-CURRENT FreeBSD 9.0-CURRENT #0: Mon Oct 5 16:49:42 JST 2009 koie@guriandgura:/ usr/obj/usr/src/sys/GURIANDGURA amd64 >Description: I'm trying to get values under kstat.zfs. But print sysctl('kstat.zfs.misc.arcstats.c') shows empty. >How-To-Repeat: use BSD::Sysctl 'sysctl'; print sysctl('kstat.zfs.misc.arcstats.c'); >Fix: Implement 'Q'/QUAD like this patch. I don't know perl and this patch was written by imitation. I tested this patch on amd64. I supposed this patch does not work on i386, because newSVuv() generates 32bit integer. Patch attached with submission follows: diff -rpu work/BSD-Sysctl-0.09/Makefile.PL work.koie/BSD-Sysctl-0.09/Makefile.PL --- work/BSD-Sysctl-0.09/Makefile.PL 2009-09-15 04:50:42.000000000 +0900 +++ work.koie/BSD-Sysctl-0.09/Makefile.PL 2009-10-14 19:50:03.417268572 +0900 @@ -117,3 +117,4 @@ S,vmtotal 22 auto S,xinpcb 23 auto S,xvfsconf 24 auto T,struct_cdev 25 auto +Q 26 FMT_QUAD diff -rpu work/BSD-Sysctl-0.09/Sysctl.pm work.koie/BSD-Sysctl-0.09/Sysctl.pm --- work/BSD-Sysctl-0.09/Sysctl.pm 2009-09-15 02:55:20.000000000 +0900 +++ work.koie/BSD-Sysctl-0.09/Sysctl.pm 2009-10-14 19:50:26.978236337 +0900 @@ -40,6 +40,7 @@ use constant FMT_VMTOTAL => 22; use constant FMT_XINPCB => 23; use constant FMT_XVFSCONF => 24; use constant FMT_STRUCT_CDEV => 25; +use constant FMT_QUAD => 26; push @EXPORT_OK, 'sysctl'; sub sysctl { diff -rpu work/BSD-Sysctl-0.09/Sysctl.xs work.koie/BSD-Sysctl-0.09/Sysctl.xs --- work/BSD-Sysctl-0.09/Sysctl.xs 2009-09-15 05:08:40.000000000 +0900 +++ work.koie/BSD-Sysctl-0.09/Sysctl.xs 2009-10-14 20:06:33.161933261 +0900 @@ -241,6 +241,9 @@ _mib_info(const char *arg) ++f; fmt_type = *f == 'U' ? FMT_ULONG : FMT_LONG; break; + case 'Q': + fmt_type = FMT_QUAD; + break; case 'S': { if (strcmp(f,"S,clockinfo") == 0) { fmt_type = FMT_CLOCKINFO; } else if (strcmp(f,"S,loadavg") == 0) { fmt_type = FMT_LOADAVG; } @@ -452,6 +455,21 @@ _mib_lookup(const char *arg) RETVAL = newRV((SV *)c); } break; + case FMT_QUAD: + if (buflen == sizeof(int64_t)) { + RETVAL = newSVuv(*(int64_t *)buf); + } + else { + AV *c = (AV *)sv_2mortal((SV *)newAV()); + char *bptr = buf; + while (buflen >= sizeof(int64_t)) { + av_push(c, newSVuv(*(int64_t *)bptr)); + buflen -= sizeof(int64_t); + bptr += sizeof(int64_t); + } + RETVAL = newRV((SV *)c); + } + break; case FMT_CLOCKINFO: { HV *c = (HV *)sv_2mortal((SV *)newHV()); struct clockinfo *inf = (struct clockinfo *)buf; @@ -845,6 +863,7 @@ _mib_set(const char *arg, const char *va unsigned int uintval; long longval; unsigned long ulongval; + long long longlongval; void *newval = 0; size_t newsize = 0; char *endconvptr; @@ -916,6 +935,16 @@ _mib_set(const char *arg, const char *va newval = &ulongval; newsize = sizeof(ulongval); break; + + case FMT_QUAD: + longlongval = strtoll(value, &endconvptr, 0); + if (endconvptr == value || *endconvptr != '\0') { + warn("invalid long long integer: '%s'", value); + XSRETURN_UNDEF; + } + newval = &longlongval; + newsize = sizeof(longlongval); + break; } if (sysctl((int *)oid_data, oid_len, 0, 0, newval, newsize) == -1) { >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910141225.n9ECPgJb042866>