From owner-freebsd-ports@FreeBSD.ORG Mon May 12 21:35:57 2014 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2D3B3BD5 for ; Mon, 12 May 2014 21:35:57 +0000 (UTC) Received: from mx1a.lautre.net (eyra.lautre.net [80.67.160.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.lautre.net", Issuer "StartCom Class 2 Primary Intermediate Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DF7C223AB for ; Mon, 12 May 2014 21:35:55 +0000 (UTC) Received: from graf.pompo.net (graf.pompo.net [78.225.128.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: thierry@pompo.net) by mx1a.lautre.net (Postfix) with ESMTPSA id 7F9DF414B1 for ; Mon, 12 May 2014 23:35:52 +0200 (CEST) Received: by graf.pompo.net (Postfix, from userid 1001) id D5DDF71E556; Mon, 12 May 2014 23:35:51 +0200 (CEST) Date: Mon, 12 May 2014 23:35:51 +0200 From: Thierry Thomas To: freebsd-ports@freebsd.org Subject: Patch wanted: VmRSS, VmSize and VmStk in /proc/pid/status Message-ID: <20140512213551.GE60374@graf.pompo.net> Mail-Followup-To: freebsd-ports@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: FreeBSD 10.0-STABLE amd64 Organization: Kabbale Eros X-Face: (hRbQnK~Pt7$ct`!fupO(`y_WL4^-Iwn4@ly-.,[4xC4xc; y=\ipKMNm<1J>lv@PP~7Z<.t KjAnXLs: X-PGP: 0xF1C516B3C8359753 User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 May 2014 21:35:57 -0000 Hello, In the new versions of french/aster, there is this piece of Linux code: ----------------------------------------------------------- static char filename[80]; static char sbuf[1024]; char* S; int fd, num_read; long lmem; pid_t numpro; pid_t getpid(void); numpro = getpid(); sprintf(filename, "/proc/%ld/status", (long)numpro); fd = open(filename, O_RDONLY, 0); if (fd==-1) return -1; num_read=read(fd,sbuf,(sizeof sbuf)-1); close(fd); S=strstr(sbuf,"VmData:")+8; val[0] = (INTEGER)atoi(S); S=strstr(sbuf,"VmSize:")+8; val[1] = (INTEGER)atoi(S); if ( strstr(sbuf,"VmPeak:") != NULL ) { S=strstr(sbuf,"VmPeak:")+8; val[2] = atoi(S); } else { val[2] = -1 ; } S=strstr(sbuf,"VmRSS:")+7; val[3] = (INTEGER)atoi(S); S=strstr(sbuf,"VmStk:")+7; lmem = atoi(S); return lmem ; ----------------------------------------------------------- Of course, it does'nt work on FreeBSD, because our status has a different structure. As a quick & dirty work-around, I patched it to replace /proc by /compat/linux/proc and it works. Unfortunately, this is not a good solution, because this port is no more packageable (this piece of code is run at the end of the build). It's why I'm looking for help here: does somebody knows how the corresponding values of these Vm... can be found in FreeBSD? Thanks, -- Th. Thomas.