From owner-svn-src-user@FreeBSD.ORG Sat Apr 20 13:48:54 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id F033E8FE; Sat, 20 Apr 2013 13:48:54 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E00FA1E1F; Sat, 20 Apr 2013 13:48:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3KDms0F092050; Sat, 20 Apr 2013 13:48:54 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3KDmoHN091972; Sat, 20 Apr 2013 13:48:50 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201304201348.r3KDmoHN091972@svn.freebsd.org> From: Attilio Rao Date: Sat, 20 Apr 2013 13:48:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r249699 - in user/attilio/vmcontention: . bin/chio bin/df bin/expr cddl/contrib/opensolaris/tools/ctf/cvt contrib/tzdata lib/csu lib/libprocstat sbin/gbde sbin/geom/class sbin/hastctl s... X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Apr 2013 13:48:55 -0000 Author: attilio Date: Sat Apr 20 13:48:50 2013 New Revision: 249699 URL: http://svnweb.freebsd.org/changeset/base/249699 Log: MFC Added: user/attilio/vmcontention/lib/libprocstat/core.c - copied unchanged from r249698, head/lib/libprocstat/core.c user/attilio/vmcontention/lib/libprocstat/core.h - copied unchanged from r249698, head/lib/libprocstat/core.h user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsarguments.c - copied unchanged from r249698, head/sys/contrib/dev/acpica/components/namespace/nsarguments.c user/attilio/vmcontention/sys/dev/etherswitch/ukswitch/ - copied from r249698, head/sys/dev/etherswitch/ukswitch/ Modified: user/attilio/vmcontention/Makefile.inc1 user/attilio/vmcontention/UPDATING user/attilio/vmcontention/bin/chio/chio.c user/attilio/vmcontention/bin/df/df.c user/attilio/vmcontention/bin/expr/Makefile user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/util.c user/attilio/vmcontention/contrib/tzdata/antarctica user/attilio/vmcontention/contrib/tzdata/asia user/attilio/vmcontention/contrib/tzdata/australasia user/attilio/vmcontention/contrib/tzdata/southamerica user/attilio/vmcontention/contrib/tzdata/zone.tab user/attilio/vmcontention/lib/csu/Makefile.inc user/attilio/vmcontention/lib/libprocstat/Makefile user/attilio/vmcontention/lib/libprocstat/Symbol.map user/attilio/vmcontention/lib/libprocstat/libprocstat.3 user/attilio/vmcontention/lib/libprocstat/libprocstat.c user/attilio/vmcontention/lib/libprocstat/libprocstat.h user/attilio/vmcontention/lib/libprocstat/libprocstat_internal.h user/attilio/vmcontention/sbin/gbde/Makefile user/attilio/vmcontention/sbin/geom/class/Makefile.inc user/attilio/vmcontention/sbin/hastctl/Makefile user/attilio/vmcontention/sbin/hastd/Makefile user/attilio/vmcontention/sbin/md5/Makefile user/attilio/vmcontention/share/man/man9/DELAY.9 user/attilio/vmcontention/share/mk/bsd.sys.mk user/attilio/vmcontention/sys/cam/cam_xpt.c user/attilio/vmcontention/sys/cam/scsi/scsi_ch.c user/attilio/vmcontention/sys/cam/scsi/scsi_ch.h user/attilio/vmcontention/sys/conf/files user/attilio/vmcontention/sys/conf/options user/attilio/vmcontention/sys/contrib/dev/acpica/changes.txt (contents, props changed) user/attilio/vmcontention/sys/contrib/dev/acpica/compiler/aslpredef.c user/attilio/vmcontention/sys/contrib/dev/acpica/compiler/aslprepkg.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbdisply.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbexec.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbmethod.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbnames.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/events/evgpe.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/events/evregion.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/executer/exconfig.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/executer/exfldio.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/hardware/hwxface.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nseval.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsinit.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nspredef.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsprepkg.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsrepair.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsrepair2.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsxfeval.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/parser/psxface.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/resources/rsutils.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/uteval.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/utosi.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/utpredef.c user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/utxferror.c user/attilio/vmcontention/sys/contrib/dev/acpica/include/acconfig.h user/attilio/vmcontention/sys/contrib/dev/acpica/include/aclocal.h user/attilio/vmcontention/sys/contrib/dev/acpica/include/acmacros.h user/attilio/vmcontention/sys/contrib/dev/acpica/include/acnamesp.h user/attilio/vmcontention/sys/contrib/dev/acpica/include/acoutput.h user/attilio/vmcontention/sys/contrib/dev/acpica/include/acpixf.h user/attilio/vmcontention/sys/contrib/dev/acpica/include/acpredef.h user/attilio/vmcontention/sys/contrib/dev/acpica/include/acstruct.h user/attilio/vmcontention/sys/contrib/dev/acpica/include/acutils.h user/attilio/vmcontention/sys/dev/ath/if_ath.c user/attilio/vmcontention/sys/dev/netmap/netmap.c user/attilio/vmcontention/sys/dev/netmap/netmap_kern.h user/attilio/vmcontention/sys/dev/netmap/netmap_mem2.c user/attilio/vmcontention/sys/kern/kern_fork.c user/attilio/vmcontention/sys/kern/uipc_syscalls.c user/attilio/vmcontention/sys/modules/acpi/acpi/Makefile user/attilio/vmcontention/sys/sys/chio.h user/attilio/vmcontention/usr.bin/ar/Makefile user/attilio/vmcontention/usr.bin/bc/Makefile user/attilio/vmcontention/usr.bin/bzip2recover/Makefile user/attilio/vmcontention/usr.bin/find/Makefile user/attilio/vmcontention/usr.bin/gcore/Makefile user/attilio/vmcontention/usr.bin/gcore/elfcore.c user/attilio/vmcontention/usr.bin/indent/Makefile user/attilio/vmcontention/usr.bin/m4/Makefile user/attilio/vmcontention/usr.bin/mklocale/Makefile user/attilio/vmcontention/usr.bin/procstat/procstat.1 user/attilio/vmcontention/usr.bin/procstat/procstat.c user/attilio/vmcontention/usr.bin/procstat/procstat.h user/attilio/vmcontention/usr.bin/procstat/procstat_args.c user/attilio/vmcontention/usr.bin/procstat/procstat_auxv.c user/attilio/vmcontention/usr.bin/procstat/procstat_bin.c user/attilio/vmcontention/usr.bin/procstat/procstat_cred.c user/attilio/vmcontention/usr.bin/procstat/procstat_kstack.c user/attilio/vmcontention/usr.bin/procstat/procstat_rlimit.c user/attilio/vmcontention/usr.bin/procstat/procstat_sigs.c user/attilio/vmcontention/usr.bin/procstat/procstat_threads.c user/attilio/vmcontention/usr.bin/procstat/procstat_vm.c user/attilio/vmcontention/usr.sbin/acpi/acpidb/Makefile user/attilio/vmcontention/usr.sbin/auditdistd/Makefile user/attilio/vmcontention/usr.sbin/bluetooth/bthidd/Makefile user/attilio/vmcontention/usr.sbin/bsnmpd/modules/Makefile.inc user/attilio/vmcontention/usr.sbin/config/Makefile user/attilio/vmcontention/usr.sbin/fifolog/lib/Makefile user/attilio/vmcontention/usr.sbin/jail/Makefile Directory Properties: user/attilio/vmcontention/ (props changed) user/attilio/vmcontention/cddl/ (props changed) user/attilio/vmcontention/cddl/contrib/opensolaris/ (props changed) user/attilio/vmcontention/contrib/tzdata/ (props changed) user/attilio/vmcontention/sbin/ (props changed) user/attilio/vmcontention/sys/ (props changed) user/attilio/vmcontention/sys/conf/ (props changed) user/attilio/vmcontention/sys/contrib/dev/acpica/ (props changed) user/attilio/vmcontention/sys/contrib/dev/acpica/compiler/ (props changed) user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/ (props changed) user/attilio/vmcontention/sys/contrib/dev/acpica/components/events/ (props changed) user/attilio/vmcontention/sys/contrib/dev/acpica/components/executer/ (props changed) user/attilio/vmcontention/sys/contrib/dev/acpica/components/hardware/ (props changed) user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/ (props changed) user/attilio/vmcontention/sys/contrib/dev/acpica/components/parser/ (props changed) user/attilio/vmcontention/sys/contrib/dev/acpica/components/resources/ (props changed) user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/ (props changed) user/attilio/vmcontention/sys/contrib/dev/acpica/include/ (props changed) user/attilio/vmcontention/sys/contrib/dev/acpica/os_specific/ (props changed) user/attilio/vmcontention/usr.bin/procstat/ (props changed) user/attilio/vmcontention/usr.sbin/jail/ (props changed) Modified: user/attilio/vmcontention/Makefile.inc1 ============================================================================== --- user/attilio/vmcontention/Makefile.inc1 Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/Makefile.inc1 Sat Apr 20 13:48:50 2013 (r249699) @@ -1382,7 +1382,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1 ${_kerberos5_lib_libwind} \ ${_lib_atf_libatf_c} \ lib/libbz2 ${_libcom_err} lib/libcrypt \ - lib/libexpat \ + lib/libelf lib/libexpat \ ${_lib_libgssapi} ${_lib_libipx} \ lib/libkiconv lib/libkvm lib/liblzma lib/libmd \ lib/ncurses/ncurses lib/ncurses/ncursesw \ Modified: user/attilio/vmcontention/UPDATING ============================================================================== --- user/attilio/vmcontention/UPDATING Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/UPDATING Sat Apr 20 13:48:50 2013 (r249699) @@ -11,6 +11,11 @@ handbook: Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before running portupgrade. +NOTE: FreeBSD has switched from gcc to clang. If you have trouble bootstrapping +from older versions of FreeBSD, try WITHOUT_CLANG and WITHOUT_CLANG_IS_CC to +bootstrap to tip of head, and then rebuild without those options. The bootstrap +process from older version of current is a bit fragile. + NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW: FreeBSD 10.x has many debugging features turned on, in both the kernel and userland. These features attempt to detect incorrect use of Modified: user/attilio/vmcontention/bin/chio/chio.c ============================================================================== --- user/attilio/vmcontention/bin/chio/chio.c Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/bin/chio/chio.c Sat Apr 20 13:48:50 2013 (r249699) @@ -54,6 +54,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include "defs.h" #include "pathnames.h" @@ -81,6 +83,7 @@ static int do_status(const char *, int, static int do_ielem(const char *, int, char **); static int do_return(const char *, int, char **); static int do_voltag(const char *, int, char **); +static void print_designator(const char *, u_int8_t, u_int8_t); #ifndef CHET_VT #define CHET_VT 10 /* Completely Arbitrary */ @@ -723,6 +726,10 @@ do_status(const char *cname, int argc, c putchar('?'); putchar('>'); } + if (ces->ces_designator_length > 0) + print_designator(ces->ces_designator, + ces->ces_code_set, + ces->ces_designator_length); putchar('\n'); } @@ -1177,3 +1184,66 @@ usage(void) "arg1 arg2 [arg3 [...]]\n", getprogname()); exit(1); } + +#define UTF8CODESET "UTF-8" + +static void +print_designator(const char *designator, u_int8_t code_set, + u_int8_t designator_length) +{ + printf(" serial number: <"); + switch (code_set) { + case CES_CODE_SET_ASCII: { + /* + * The driver insures that the string is always NUL terminated. + */ + printf("%s", designator); + break; + } + case CES_CODE_SET_UTF_8: { + char *cs_native; + + setlocale(LC_ALL, ""); + cs_native = nl_langinfo(CODESET); + + /* See if we can natively print UTF-8 */ + if (strcmp(cs_native, UTF8CODESET) == 0) + cs_native = NULL; + + if (cs_native == NULL) { + /* We can natively print UTF-8, so use printf. */ + printf("%s", designator); + } else { + int i; + + /* + * We can't natively print UTF-8. We should + * convert it to the terminal's codeset, but that + * requires iconv(3) and FreeBSD doesn't have + * iconv(3) in the base system yet. So we use %XX + * notation for non US-ASCII characters instead. + */ + for (i = 0; i < designator_length && + designator[i] != '\0'; i++) { + if ((unsigned char)designator[i] < 0x80) + printf("%c", designator[i]); + else + printf("%%%02x", + (unsigned char)designator[i]); + } + } + break; + } + case CES_CODE_SET_BINARY: { + int i; + + for (i = 0; i < designator_length; i++) + printf("%02X%s", designator[i], + (i == designator_length - 1) ? "" : " "); + break; + } + default: + break; + } + printf(">"); +} Modified: user/attilio/vmcontention/bin/df/df.c ============================================================================== --- user/attilio/vmcontention/bin/df/df.c Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/bin/df/df.c Sat Apr 20 13:48:50 2013 (r249699) @@ -114,6 +114,7 @@ main(int argc, char *argv[]) fstype = "ufs"; (void)setlocale(LC_ALL, ""); + memset(&maxwidths, 0, sizeof(maxwidths)); memset(&totalbuf, 0, sizeof(totalbuf)); totalbuf.f_bsize = DEV_BSIZE; strlcpy(totalbuf.f_mntfromname, "total", MNAMELEN); @@ -200,7 +201,7 @@ main(int argc, char *argv[]) } else { /* just the filesystems specified on the command line */ mntbuf = malloc(argc * sizeof(*mntbuf)); - if (mntbuf == 0) + if (mntbuf == NULL) err(1, "malloc()"); mntsize = 0; /* continued in for loop below */ @@ -209,13 +210,13 @@ main(int argc, char *argv[]) /* iterate through specified filesystems */ for (; *argv; argv++) { if (stat(*argv, &stbuf) < 0) { - if ((mntpt = getmntpt(*argv)) == 0) { + if ((mntpt = getmntpt(*argv)) == NULL) { warn("%s", *argv); rv = 1; continue; } } else if (S_ISCHR(stbuf.st_mode)) { - if ((mntpt = getmntpt(*argv)) == 0) { + if ((mntpt = getmntpt(*argv)) == NULL) { mdev.fspec = *argv; mntpath = strdup("/tmp/df.XXXXXX"); if (mntpath == NULL) { @@ -282,7 +283,7 @@ main(int argc, char *argv[]) mntbuf[mntsize++] = statfsbuf; } - bzero(&maxwidths, sizeof(maxwidths)); + memset(&maxwidths, 0, sizeof(maxwidths)); for (i = 0; i < mntsize; i++) { if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0) { update_maxwidths(&maxwidths, &mntbuf[i]); @@ -295,6 +296,7 @@ main(int argc, char *argv[]) prtstat(&mntbuf[i], &maxwidths); if (cflag) prtstat(&totalbuf, &maxwidths); + free(mntbuf); return (rv); } @@ -309,7 +311,7 @@ getmntpt(const char *name) if (!strcmp(mntbuf[i].f_mntfromname, name)) return (mntbuf[i].f_mntonname); } - return (0); + return (NULL); } /* Modified: user/attilio/vmcontention/bin/expr/Makefile ============================================================================== --- user/attilio/vmcontention/bin/expr/Makefile Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/bin/expr/Makefile Sat Apr 20 13:48:50 2013 (r249699) @@ -4,4 +4,6 @@ PROG= expr SRCS= expr.y YFLAGS= +NO_WMISSING_VARIABLE_DECLARATIONS= + .include Modified: user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c ============================================================================== --- user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c Sat Apr 20 13:48:50 2013 (r249699) @@ -47,7 +47,7 @@ * * The value is only valid during a call to ctf_load. */ -char *curfile; +static char *curfile; #define CTF_BUF_CHUNK_SIZE (64 * 1024) #define RES_BUF_CHUNK_SIZE (64 * 1024) Modified: user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c ============================================================================== --- user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c Sat Apr 20 13:48:50 2013 (r249699) @@ -54,7 +54,7 @@ static int faketypenumber = 100000000; static tdesc_t *hash_table[BUCKETS]; static tdesc_t *name_table[BUCKETS]; -list_t *typedbitfldmems; +static list_t *typedbitfldmems; static void reset(void); static jmp_buf resetbuf; Modified: user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c ============================================================================== --- user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c Sat Apr 20 13:48:50 2013 (r249699) @@ -37,8 +37,8 @@ #include "traverse.h" #include "memory.h" -int (*tddescenders[])(tdesc_t *, tdtrav_data_t *); -tdtrav_cb_f tdnops[]; +static int (*tddescenders[])(tdesc_t *, tdtrav_data_t *); +static tdtrav_cb_f tdnops[]; void tdtrav_init(tdtrav_data_t *tdtd, int *vgenp, tdtrav_cb_f *firstops, @@ -111,7 +111,7 @@ tdtrav_assert(tdesc_t *node __unused, td return (-1); } -tdtrav_cb_f tdnops[] = { +static tdtrav_cb_f tdnops[] = { NULL, NULL, /* intrinsic */ NULL, /* pointer */ @@ -128,7 +128,7 @@ tdtrav_cb_f tdnops[] = { NULL /* restrict */ }; -int (*tddescenders[])(tdesc_t *, tdtrav_data_t *) = { +static int (*tddescenders[])(tdesc_t *, tdtrav_data_t *) = { NULL, NULL, /* intrinsic */ tdtrav_plain, /* pointer */ Modified: user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/util.c ============================================================================== --- user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/util.c Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/util.c Sat Apr 20 13:48:50 2013 (r249699) @@ -249,8 +249,8 @@ tdesc_name(tdesc_t *tdp) return (tdp->t_name == NULL ? "(anon)" : tdp->t_name); } -char *watch_address = NULL; -int watch_length = 0; +static char *watch_address = NULL; +static int watch_length = 0; void watch_set(void *addr, int len) Modified: user/attilio/vmcontention/contrib/tzdata/antarctica ============================================================================== --- user/attilio/vmcontention/contrib/tzdata/antarctica Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/contrib/tzdata/antarctica Sat Apr 20 13:48:50 2013 (r249699) @@ -53,34 +53,6 @@ Rule ChileAQ 2011 only - Aug Sun>=16 4:0 Rule ChileAQ 2012 max - Apr Sun>=23 3:00u 0 - Rule ChileAQ 2012 max - Sep Sun>=2 4:00u 1:00 S -# These rules are stolen from the `australasia' file. -Rule AusAQ 1917 only - Jan 1 0:01 1:00 - -Rule AusAQ 1917 only - Mar 25 2:00 0 - -Rule AusAQ 1942 only - Jan 1 2:00 1:00 - -Rule AusAQ 1942 only - Mar 29 2:00 0 - -Rule AusAQ 1942 only - Sep 27 2:00 1:00 - -Rule AusAQ 1943 1944 - Mar lastSun 2:00 0 - -Rule AusAQ 1943 only - Oct 3 2:00 1:00 - -Rule ATAQ 1967 only - Oct Sun>=1 2:00s 1:00 - -Rule ATAQ 1968 only - Mar lastSun 2:00s 0 - -Rule ATAQ 1968 1985 - Oct lastSun 2:00s 1:00 - -Rule ATAQ 1969 1971 - Mar Sun>=8 2:00s 0 - -Rule ATAQ 1972 only - Feb lastSun 2:00s 0 - -Rule ATAQ 1973 1981 - Mar Sun>=1 2:00s 0 - -Rule ATAQ 1982 1983 - Mar lastSun 2:00s 0 - -Rule ATAQ 1984 1986 - Mar Sun>=1 2:00s 0 - -Rule ATAQ 1986 only - Oct Sun>=15 2:00s 1:00 - -Rule ATAQ 1987 1990 - Mar Sun>=15 2:00s 0 - -Rule ATAQ 1987 only - Oct Sun>=22 2:00s 1:00 - -Rule ATAQ 1988 1990 - Oct lastSun 2:00s 1:00 - -Rule ATAQ 1991 1999 - Oct Sun>=1 2:00s 1:00 - -Rule ATAQ 1991 2005 - Mar lastSun 2:00s 0 - -Rule ATAQ 2000 only - Aug lastSun 2:00s 1:00 - -Rule ATAQ 2001 max - Oct Sun>=1 2:00s 1:00 - -Rule ATAQ 2006 only - Apr Sun>=1 2:00s 0 - -Rule ATAQ 2007 only - Mar lastSun 2:00s 0 - -Rule ATAQ 2008 max - Apr Sun>=1 2:00s 0 - - # Argentina - year-round bases # Belgrano II, Confin Coast, -770227-0343737, since 1972-02-05 # Esperanza, San Martin Land, -6323-05659, since 1952-12-17 @@ -122,10 +94,7 @@ Rule ATAQ 2008 max - Apr Sun>=1 2:00s 0 # # From Steffen Thorsen (2010-03-10): -# We got these changes from the Australian Antarctic Division: -# - Macquarie Island will stay on UTC+11 for winter and therefore not -# switch back from daylight savings time when other parts of Australia do -# on 4 April. +# We got these changes from the Australian Antarctic Division: ... # # - Casey station reverted to its normal time of UTC+8 on 5 March 2010. # The change to UTC+11 is being considered as a regular summer thing but @@ -136,9 +105,6 @@ Rule ATAQ 2008 max - Apr Sun>=1 2:00s 0 # # - Mawson station stays on UTC+5. # -# In addition to the Rule changes for Casey/Davis, it means that Macquarie -# will no longer be like Hobart and will have to have its own Zone created. -# # Background: # # http://www.timeanddate.com/news/time/antartica-time-changes-2010.html @@ -165,12 +131,6 @@ Zone Antarctica/Mawson 0 - zzz 1954 Feb 6:00 - MAWT 2009 Oct 18 2:00 # Mawson Time 5:00 - MAWT -Zone Antarctica/Macquarie 0 - zzz 1911 - 10:00 - EST 1916 Oct 1 2:00 - 10:00 1:00 EST 1917 Feb - 10:00 AusAQ EST 1967 - 10:00 ATAQ EST 2010 Apr 4 3:00 - 11:00 - MIST # Macquarie Island Time # References: # # Casey Weather (1998-02-26) Modified: user/attilio/vmcontention/contrib/tzdata/asia ============================================================================== --- user/attilio/vmcontention/contrib/tzdata/asia Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/contrib/tzdata/asia Sat Apr 20 13:48:50 2013 (r249699) @@ -2291,11 +2291,20 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # http://www.timeanddate.com/news/time/gaza-west-bank-dst-2012.html # -# From Arthur David Olson (2012-03-27): -# The timeanddate article for 2012 says that "the end date has not yet been -# announced" and that "Last year, both...paused daylight saving time during... -# Ramadan. It is not yet known [for] 2012." -# For now, assume both switch back on the last Friday in September. XXX +# From Steffen Thorsen (2013-03-26): +# The following news sources tells that Palestine will "start daylight saving +# time from midnight on Friday, March 29, 2013" (translated). +# [These are in Arabic and are for Gaza and for Ramallah, respectively.] +# http://www.samanews.com/index.php?act=Show&id=154120 +# http://safa.ps/details/news/99844/%D8%B1%D8%A7%D9%85-%D8%A7%D9%84%D9%84%D9%87-%D8%A8%D8%AF%D8%A1-%D8%A7%D9%84%D8%AA%D9%88%D9%82%D9%8A%D8%AA-%D8%A7%D9%84%D8%B5%D9%8A%D9%81%D9%8A-29-%D8%A7%D9%84%D8%AC%D8%A7%D8%B1%D9%8A.html + +# From Paul Eggert (2013-04-15): +# For future dates, guess the last Thursday in March at 24:00 through +# the first Friday on or after September 21 at 01:00. This is consistent with +# the predictions in today's editions of the following URLs, +# which are for Gaza and Hebron respectively: +# http://www.timeanddate.com/worldclock/timezone.html?n=702 +# http://www.timeanddate.com/worldclock/timezone.html?n=2364 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule EgyptAsia 1957 only - May 10 0:00 1:00 S @@ -2309,19 +2318,20 @@ Rule Palestine 1999 2005 - Apr Fri>=15 0 Rule Palestine 1999 2003 - Oct Fri>=15 0:00 0 - Rule Palestine 2004 only - Oct 1 1:00 0 - Rule Palestine 2005 only - Oct 4 2:00 0 - -Rule Palestine 2006 2008 - Apr 1 0:00 1:00 S +Rule Palestine 2006 2007 - Apr 1 0:00 1:00 S Rule Palestine 2006 only - Sep 22 0:00 0 - Rule Palestine 2007 only - Sep Thu>=8 2:00 0 - -Rule Palestine 2008 only - Aug lastFri 0:00 0 - -Rule Palestine 2009 only - Mar lastFri 0:00 1:00 S -Rule Palestine 2009 only - Sep Fri>=1 2:00 0 - -Rule Palestine 2010 only - Mar lastSat 0:01 1:00 S +Rule Palestine 2008 2009 - Mar lastFri 0:00 1:00 S +Rule Palestine 2008 only - Sep 1 0:00 0 - +Rule Palestine 2009 only - Sep Fri>=1 1:00 0 - +Rule Palestine 2010 only - Mar 26 0:00 1:00 S Rule Palestine 2010 only - Aug 11 0:00 0 - - -# From Arthur David Olson (2011-09-20): -# 2011 transitions per http://www.timeanddate.com as of 2011-09-20. -# From Paul Eggert (2012-10-12): -# 2012 transitions per http://www.timeanddate.com as of 2012-10-12. +Rule Palestine 2011 only - Apr 1 0:01 1:00 S +Rule Palestine 2011 only - Aug 1 0:00 0 - +Rule Palestine 2011 only - Aug 30 0:00 1:00 S +Rule Palestine 2011 only - Sep 30 0:00 0 - +Rule Palestine 2012 max - Mar lastThu 24:00 1:00 S +Rule Palestine 2012 max - Sep Fri>=21 1:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Gaza 2:17:52 - LMT 1900 Oct @@ -2329,26 +2339,20 @@ Zone Asia/Gaza 2:17:52 - LMT 1900 Oct 2:00 EgyptAsia EE%sT 1967 Jun 5 2:00 Zion I%sT 1996 2:00 Jordan EE%sT 1999 - 2:00 Palestine EE%sT 2011 Apr 2 12:01 - 2:00 1:00 EEST 2011 Aug 1 - 2:00 - EET 2012 Mar 30 - 2:00 1:00 EEST 2012 Sep 21 1:00 - 2:00 - EET + 2:00 Palestine EE%sT 2008 Aug 29 0:00 + 2:00 - EET 2008 Sep + 2:00 Palestine EE%sT 2010 + 2:00 - EET 2010 Mar 27 0:01 + 2:00 Palestine EE%sT 2011 Aug 1 + 2:00 - EET 2012 + 2:00 Palestine EE%sT Zone Asia/Hebron 2:20:23 - LMT 1900 Oct 2:00 Zion EET 1948 May 15 2:00 EgyptAsia EE%sT 1967 Jun 5 2:00 Zion I%sT 1996 2:00 Jordan EE%sT 1999 - 2:00 Palestine EE%sT 2008 Aug - 2:00 1:00 EEST 2008 Sep - 2:00 Palestine EE%sT 2011 Apr 1 12:01 - 2:00 1:00 EEST 2011 Aug 1 - 2:00 - EET 2011 Aug 30 - 2:00 1:00 EEST 2011 Sep 30 3:00 - 2:00 - EET 2012 Mar 30 - 2:00 1:00 EEST 2012 Sep 21 1:00 - 2:00 - EET + 2:00 Palestine EE%sT # Paracel Is # no information Modified: user/attilio/vmcontention/contrib/tzdata/australasia ============================================================================== --- user/attilio/vmcontention/contrib/tzdata/australasia Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/contrib/tzdata/australasia Sat Apr 20 13:48:50 2013 (r249699) @@ -218,9 +218,26 @@ Zone Australia/Lord_Howe 10:36:20 - LMT # no times are set # # Macquarie -# permanent occupation (scientific station) since 1948; -# sealing and penguin oil station operated 1888/1917 -# like Australia/Hobart +# Permanent occupation (scientific station) 1911-1915 and since 25 March 1948; +# sealing and penguin oil station operated Nov 1899 to Apr 1919. See the +# Tasmania Parks & Wildlife Service history of sealing at Macquarie Island +# +# . +# Guess that it was like Australia/Hobart while inhabited before 2010. +# +# From Steffen Thorsen (2010-03-10): +# We got these changes from the Australian Antarctic Division: +# - Macquarie Island will stay on UTC+11 for winter and therefore not +# switch back from daylight savings time when other parts of Australia do +# on 4 April. +Zone Antarctica/Macquarie 0 - zzz 1899 Nov + 10:00 - EST 1916 Oct 1 2:00 + 10:00 1:00 EST 1917 Feb + 10:00 Aus EST 1919 Apr + 0 - zzz 1948 Mar 25 + 10:00 Aus EST 1967 + 10:00 AT EST 2010 Apr 4 3:00 + 11:00 - MIST # Macquarie I Standard Time # Christmas # Zone NAME GMTOFF RULES FORMAT [UNTIL] Modified: user/attilio/vmcontention/contrib/tzdata/southamerica ============================================================================== --- user/attilio/vmcontention/contrib/tzdata/southamerica Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/contrib/tzdata/southamerica Sat Apr 20 13:48:50 2013 (r249699) @@ -1566,16 +1566,16 @@ Rule Para 2005 2009 - Mar Sun>=8 0:00 0 # forward 60 minutes, in all the territory of the Paraguayan Republic. # ... Rule Para 2010 max - Oct Sun>=1 0:00 1:00 S -Rule Para 2010 max - Apr Sun>=8 0:00 0 - +Rule Para 2010 2012 - Apr Sun>=8 0:00 0 - # # From Steffen Thorsen (2013-03-07): # Paraguay will end DST on 2013-03-24 00:00.... -# They do not tell if this will be a permanent change or just this year.... # http://www.ande.gov.py/interna.php?id=1075 # -# From Paul Eggert (2013-03-07): -# For now, assume it's just this year. -Rule Para 2013 only - Mar 24 0:00 0 - +# From Carlos Raul Perasso (2013-03-15): +# The change in Paraguay is now final. Decree number 10780 +# http://www.presidencia.gov.py/uploads/pdf/presidencia-3b86ff4b691c79d4f5927ca964922ec74772ce857c02ca054a52a37b49afc7fb.pdf +Rule Para 2013 max - Mar Sun>=22 0:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Asuncion -3:50:40 - LMT 1890 Modified: user/attilio/vmcontention/contrib/tzdata/zone.tab ============================================================================== --- user/attilio/vmcontention/contrib/tzdata/zone.tab Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/contrib/tzdata/zone.tab Sat Apr 20 13:48:50 2013 (r249699) @@ -42,7 +42,6 @@ AQ -6617+11031 Antarctica/Casey Casey St AQ -7824+10654 Antarctica/Vostok Vostok Station, Lake Vostok AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville Station, Terre Adelie AQ -690022+0393524 Antarctica/Syowa Syowa Station, E Ongul I -AQ -5430+15857 Antarctica/Macquarie Macquarie Island Station, Macquarie Island AR -3436-05827 America/Argentina/Buenos_Aires Buenos Aires (BA, CF) AR -3124-06411 America/Argentina/Cordoba most locations (CB, CC, CN, ER, FM, MN, SE, SF) AR -2447-06525 America/Argentina/Salta (SA, LP, NQ, RN) @@ -58,6 +57,7 @@ AR -5448-06818 America/Argentina/Ushuaia AS -1416-17042 Pacific/Pago_Pago AT +4813+01620 Europe/Vienna AU -3133+15905 Australia/Lord_Howe Lord Howe Island +AU -5430+15857 Antarctica/Macquarie Macquarie Island AU -4253+14719 Australia/Hobart Tasmania - most locations AU -3956+14352 Australia/Currie Tasmania - King Island AU -3749+14458 Australia/Melbourne Victoria Modified: user/attilio/vmcontention/lib/csu/Makefile.inc ============================================================================== --- user/attilio/vmcontention/lib/csu/Makefile.inc Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/lib/csu/Makefile.inc Sat Apr 20 13:48:50 2013 (r249699) @@ -4,4 +4,6 @@ SSP_CFLAGS= SED_FIX_NOTE = -i "" -e '/\.note\.tag/s/progbits/note/' +NO_WMISSING_VARIABLE_DECLARATIONS= + .include "../Makefile.inc" Modified: user/attilio/vmcontention/lib/libprocstat/Makefile ============================================================================== --- user/attilio/vmcontention/lib/libprocstat/Makefile Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/lib/libprocstat/Makefile Sat Apr 20 13:48:50 2013 (r249699) @@ -6,6 +6,7 @@ LIB= procstat SRCS= cd9660.c \ common_kvm.c \ + core.c \ libprocstat.c \ msdosfs.c \ udf.c @@ -17,8 +18,8 @@ INCS= libprocstat.h CFLAGS+= -I. -I${.CURDIR} -D_KVM_VNODE SHLIB_MAJOR= 1 -DPADD= ${LIBKVM} ${LIBUTIL} -LDADD= -lkvm -lutil +DPADD= ${LIBELF} ${LIBKVM} ${LIBUTIL} +LDADD= -lelf -lkvm -lutil MAN= libprocstat.3 Modified: user/attilio/vmcontention/lib/libprocstat/Symbol.map ============================================================================== --- user/attilio/vmcontention/lib/libprocstat/Symbol.map Sat Apr 20 12:41:05 2013 (r249698) +++ user/attilio/vmcontention/lib/libprocstat/Symbol.map Sat Apr 20 13:48:50 2013 (r249699) @@ -16,5 +16,22 @@ FBSD_1.2 { }; FBSD_1.3 { + procstat_freeargv; + procstat_freeauxv; + procstat_freeenvv; + procstat_freegroups; + procstat_freekstack; + procstat_freevmmap; procstat_get_shm_info; + procstat_getargv; + procstat_getauxv; + procstat_getenvv; + procstat_getgroups; + procstat_getkstack; + procstat_getosrel; + procstat_getpathname; + procstat_getrlimit; + procstat_getumask; + procstat_getvmmap; + procstat_open_core; }; Copied: user/attilio/vmcontention/lib/libprocstat/core.c (from r249698, head/lib/libprocstat/core.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/attilio/vmcontention/lib/libprocstat/core.c Sat Apr 20 13:48:50 2013 (r249699, copy of r249698, head/lib/libprocstat/core.c) @@ -0,0 +1,432 @@ +/*- + * Copyright (c) 2013 Mikolaj Golub + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core.h" + +#define PROCSTAT_CORE_MAGIC 0x012DADB8 +struct procstat_core +{ + int pc_magic; + int pc_fd; + Elf *pc_elf; + GElf_Ehdr pc_ehdr; + GElf_Phdr pc_phdr; +}; + +static bool core_offset(struct procstat_core *core, off_t offset); +static bool core_read(struct procstat_core *core, void *buf, size_t len); +static ssize_t core_read_mem(struct procstat_core *core, void *buf, + size_t len, vm_offset_t addr, bool readall); +static void *get_args(struct procstat_core *core, vm_offset_t psstrings, + enum psc_type type, void *buf, size_t *lenp); + +struct procstat_core * +procstat_core_open(const char *filename) +{ + struct procstat_core *core; + Elf *e; + GElf_Ehdr ehdr; + GElf_Phdr phdr; + size_t nph; + int fd, i; + + if (elf_version(EV_CURRENT) == EV_NONE) { + warnx("ELF library too old"); + return (NULL); + } + fd = open(filename, O_RDONLY, 0); + if (fd == -1) { + warn("open(%s)", filename); + return (NULL); + } + e = elf_begin(fd, ELF_C_READ, NULL); + if (e == NULL) { + warnx("elf_begin: %s", elf_errmsg(-1)); + goto fail; + } + if (elf_kind(e) != ELF_K_ELF) { + warnx("%s is not an ELF object", filename); + goto fail; + } + if (gelf_getehdr(e, &ehdr) == NULL) { + warnx("gelf_getehdr: %s", elf_errmsg(-1)); + goto fail; + } + if (ehdr.e_type != ET_CORE) { + warnx("%s is not a CORE file", filename); + goto fail; + } + if (elf_getphnum(e, &nph) == 0) { + warnx("program headers not found"); + goto fail; + } + for (i = 0; i < ehdr.e_phnum; i++) { + if (gelf_getphdr(e, i, &phdr) != &phdr) { + warnx("gelf_getphdr: %s", elf_errmsg(-1)); + goto fail; + } + if (phdr.p_type == PT_NOTE) + break; + } + if (i == ehdr.e_phnum) { + warnx("NOTE program header not found"); + goto fail; + } + core = malloc(sizeof(struct procstat_core)); + if (core == NULL) { + warn("malloc(%zu)", sizeof(struct procstat_core)); + goto fail; + } + core->pc_magic = PROCSTAT_CORE_MAGIC; + core->pc_fd = fd; + core->pc_elf = e; + core->pc_ehdr = ehdr; + core->pc_phdr = phdr; + + return (core); +fail: + if (e != NULL) + elf_end(e); + close(fd); + + return (NULL); +} + +void +procstat_core_close(struct procstat_core *core) +{ + + assert(core->pc_magic == PROCSTAT_CORE_MAGIC); + + elf_end(core->pc_elf); + close(core->pc_fd); + free(core); +} + +void * +procstat_core_get(struct procstat_core *core, enum psc_type type, void *buf, + size_t *lenp) +{ + Elf_Note nhdr; + off_t offset, eoffset; + vm_offset_t psstrings; + void *freebuf; + size_t len; + u_int32_t n_type; + int cstructsize, structsize; + char nbuf[8]; + + assert(core->pc_magic == PROCSTAT_CORE_MAGIC); + + switch(type) { + case PSC_TYPE_PROC: + n_type = NT_PROCSTAT_PROC; + structsize = sizeof(struct kinfo_proc); + break; + case PSC_TYPE_FILES: + n_type = NT_PROCSTAT_FILES; + structsize = sizeof(struct kinfo_file); + break; + case PSC_TYPE_VMMAP: + n_type = NT_PROCSTAT_VMMAP; + structsize = sizeof(struct kinfo_vmentry); + break; + case PSC_TYPE_GROUPS: + n_type = NT_PROCSTAT_GROUPS; + structsize = sizeof(gid_t); + break; + case PSC_TYPE_UMASK: + n_type = NT_PROCSTAT_UMASK; + structsize = sizeof(u_short); + break; + case PSC_TYPE_RLIMIT: + n_type = NT_PROCSTAT_RLIMIT; + structsize = sizeof(struct rlimit) * RLIM_NLIMITS; + break; + case PSC_TYPE_OSREL: + n_type = NT_PROCSTAT_OSREL; + structsize = sizeof(int); + break; + case PSC_TYPE_PSSTRINGS: + case PSC_TYPE_ARGV: + case PSC_TYPE_ENVV: + n_type = NT_PROCSTAT_PSSTRINGS; + structsize = sizeof(vm_offset_t); + break; + case PSC_TYPE_AUXV: + n_type = NT_PROCSTAT_AUXV; + structsize = sizeof(Elf_Auxinfo); + break; + default: + warnx("unknown core stat type: %d", type); + return (NULL); + } + + offset = core->pc_phdr.p_offset; + eoffset = offset + core->pc_phdr.p_filesz; + + while (offset < eoffset) { + if (!core_offset(core, offset)) + return (NULL); + if (!core_read(core, &nhdr, sizeof(nhdr))) + return (NULL); + + offset += sizeof(nhdr) + + roundup2(nhdr.n_namesz, sizeof(Elf32_Size)) + + roundup2(nhdr.n_descsz, sizeof(Elf32_Size)); + + if (nhdr.n_namesz == 0 && nhdr.n_descsz == 0) + break; + if (nhdr.n_type != n_type) + continue; + if (nhdr.n_namesz != 8) + continue; + if (!core_read(core, nbuf, sizeof(nbuf))) + return (NULL); + if (strcmp(nbuf, "FreeBSD") != 0) + continue; + if (nhdr.n_descsz < sizeof(cstructsize)) { + warnx("corrupted core file"); + return (NULL); + } + if (!core_read(core, &cstructsize, sizeof(cstructsize))) + return (NULL); + if (cstructsize != structsize) { + warnx("version mismatch"); + return (NULL); + } + len = nhdr.n_descsz - sizeof(cstructsize); + if (len == 0) + return (NULL); + if (buf != NULL) { + len = MIN(len, *lenp); + freebuf = NULL; + } else { + freebuf = buf = malloc(len); + if (buf == NULL) { + warn("malloc(%zu)", len); + return (NULL); + } + } + if (!core_read(core, buf, len)) { + free(freebuf); + return (NULL); + } + if (type == PSC_TYPE_ARGV || type == PSC_TYPE_ENVV) { + if (len < sizeof(psstrings)) { + free(freebuf); + return (NULL); + } + psstrings = *(vm_offset_t *)buf; + if (freebuf == NULL) + len = *lenp; + else + buf = NULL; + free(freebuf); + buf = get_args(core, psstrings, type, buf, &len); + } + *lenp = len; + return (buf); + } + + return (NULL); +} + +static bool +core_offset(struct procstat_core *core, off_t offset) +{ + + assert(core->pc_magic == PROCSTAT_CORE_MAGIC); + + if (lseek(core->pc_fd, offset, SEEK_SET) == -1) { + warn("core: lseek(%jd)", (intmax_t)offset); + return (false); + } + return (true); +} + +static bool +core_read(struct procstat_core *core, void *buf, size_t len) +{ + ssize_t n; + + assert(core->pc_magic == PROCSTAT_CORE_MAGIC); + + n = read(core->pc_fd, buf, len); + if (n == -1) { + warn("core: read"); + return (false); + } + if (n < (ssize_t)len) { + warnx("core: short read"); + return (false); + } + return (true); +} + +static ssize_t +core_read_mem(struct procstat_core *core, void *buf, size_t len, + vm_offset_t addr, bool readall) +{ + GElf_Phdr phdr; + off_t offset; + int i; + + assert(core->pc_magic == PROCSTAT_CORE_MAGIC); + + for (i = 0; i < core->pc_ehdr.e_phnum; i++) { + if (gelf_getphdr(core->pc_elf, i, &phdr) != &phdr) { + warnx("gelf_getphdr: %s", elf_errmsg(-1)); + return (-1); + } + if (phdr.p_type != PT_LOAD) + continue; + if (addr < phdr.p_vaddr || addr > phdr.p_vaddr + phdr.p_memsz) + continue; + offset = phdr.p_offset + (addr - phdr.p_vaddr); + if ((phdr.p_vaddr + phdr.p_memsz) - addr < len) { + if (readall) { + warnx("format error: " + "attempt to read out of segment"); + return (-1); + } + len = (phdr.p_vaddr + phdr.p_memsz) - addr; + } + if (!core_offset(core, offset)) + return (-1); + if (!core_read(core, buf, len)) + return (-1); + return (len); + } + warnx("format error: address %ju not found", (uintmax_t)addr); + return (-1); +} + +#define ARGS_CHUNK_SZ 256 /* Chunk size (bytes) for get_args operations. */ + +static void * +get_args(struct procstat_core *core, vm_offset_t psstrings, enum psc_type type, + void *args, size_t *lenp) +{ + struct ps_strings pss; + void *freeargs; + vm_offset_t addr; + char **argv, *p; + size_t chunksz, done, len, nchr, size; + ssize_t n; + u_int i, nstr; + + assert(type == PSC_TYPE_ARGV || type == PSC_TYPE_ENVV); + + if (core_read_mem(core, &pss, sizeof(pss), psstrings, true) == -1) + return (NULL); + if (type == PSC_TYPE_ARGV) { + addr = (vm_offset_t)pss.ps_argvstr; + nstr = pss.ps_nargvstr; + } else /* type == PSC_TYPE_ENVV */ { + addr = (vm_offset_t)pss.ps_envstr; + nstr = pss.ps_nenvstr; + } + if (addr == 0 || nstr == 0) + return (NULL); + if (nstr > ARG_MAX) { + warnx("format error"); + return (NULL); + } + size = nstr * sizeof(char *); + argv = malloc(size); + if (argv == NULL) { + warn("malloc(%zu)", size); + return (NULL); + } + done = 0; + freeargs = NULL; + if (core_read_mem(core, argv, size, addr, true) == -1) + goto fail; + if (args != NULL) { + nchr = MIN(ARG_MAX, *lenp); + } else { + nchr = ARG_MAX; + freeargs = args = malloc(nchr); + if (args == NULL) { + warn("malloc(%zu)", nchr); + goto fail; + } + } + p = args; + for (i = 0; ; i++) { + if (i == nstr) + goto done; + /* + * The program may have scribbled into its argv array, e.g. to + * remove some arguments. If that has happened, break out + * before trying to read from NULL. + */ + if (argv[i] == NULL) + goto done; + for (addr = (vm_offset_t)argv[i]; ; addr += chunksz) { + chunksz = MIN(ARGS_CHUNK_SZ, nchr - 1 - done); + if (chunksz <= 0) + goto done; + n = core_read_mem(core, p, chunksz, addr, false); + if (n == -1) + goto fail; + len = strnlen(p, chunksz); + p += len; + done += len; + if (len != chunksz) + break; + } + *p++ = '\0'; + done++; + } +fail: + free(freeargs); + args = NULL; +done: + *lenp = done; + free(argv); + return (args); +} Copied: user/attilio/vmcontention/lib/libprocstat/core.h (from r249698, head/lib/libprocstat/core.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/attilio/vmcontention/lib/libprocstat/core.h Sat Apr 20 13:48:50 2013 (r249699, copy of r249698, head/lib/libprocstat/core.h) @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 2013 Mikolaj Golub + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***