From owner-freebsd-ports@FreeBSD.ORG Tue May 13 08:28:25 2014 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5FFF1706 for ; Tue, 13 May 2014 08:28:25 +0000 (UTC) Received: from mail-ig0-x231.google.com (mail-ig0-x231.google.com [IPv6:2607:f8b0:4001:c05::231]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 32CA32B48 for ; Tue, 13 May 2014 08:28:25 +0000 (UTC) Received: by mail-ig0-f177.google.com with SMTP id l13so102796iga.4 for ; Tue, 13 May 2014 01:28:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=wETrvY4j+HnNZvOZdXay7d/5i7udEPYvwq5XZK7cyH0=; b=mTiFmQy47TgZBEcHgAd/nXI2GCCjBJwKwPEkWbKISzgY7Qckta7r8GLaA/VUOk6bNu BGOQqhU/g72oS/qIemOC7LYjH/7Tu35GleLz9daxEKsuiLzoT1tC0uS0XYlskofUVilC fAaAbEM8WBXi6OfGy4Bhq/6y96C5PqAXGjDMwiaw7z5iAjmutMEP/jWmj1+OULzZVIkh kkWprmHv+CYH94TeedjawmqlJklmCIVgRyMpIWpHqhVEIsy7uwWjEHO2Ua24iNGB05go fbzq78+nWtzXsqnmT8xQn33m1soN/6UA9EvJj83NUTpT7+M1J5IDhFcrAsnnIqLZi9ok tlxw== MIME-Version: 1.0 X-Received: by 10.50.126.106 with SMTP id mx10mr53629031igb.27.1399969704673; Tue, 13 May 2014 01:28:24 -0700 (PDT) Received: by 10.50.232.167 with HTTP; Tue, 13 May 2014 01:28:24 -0700 (PDT) In-Reply-To: <20140512213551.GE60374@graf.pompo.net> References: <20140512213551.GE60374@graf.pompo.net> Date: Tue, 13 May 2014 03:28:24 -0500 Message-ID: Subject: Re: Patch wanted: VmRSS, VmSize and VmStk in /proc/pid/status From: Scot Hetzel To: FreeBSD Ports Content-Type: text/plain; charset=ISO-8859-1 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: Tue, 13 May 2014 08:28:25 -0000 On Mon, May 12, 2014 at 4:35 PM, Thierry Thomas wrote: > 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? > You could try reading the source for linprocfs to see how it gets those values: https://svnweb.freebsd.org/base/head/sys/compat/linprocfs/linprocfs.c?revision=263620&view=markup#l748 -- DISCLAIMER: No electrons were maimed while sending this message. Only slightly bruised.