From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 17 18:51:14 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 698F51065679 for ; Wed, 17 Feb 2010 18:51:14 +0000 (UTC) (envelope-from fernando.apesteguia@gmail.com) Received: from mail-ew0-f225.google.com (mail-ew0-f225.google.com [209.85.219.225]) by mx1.freebsd.org (Postfix) with ESMTP id 03A638FC12 for ; Wed, 17 Feb 2010 18:51:13 +0000 (UTC) Received: by ewy25 with SMTP id 25so919910ewy.3 for ; Wed, 17 Feb 2010 10:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=BDUWLBbr0lffE2VbFqwT/UTWMySh5BDywgLpmcVN0S0=; b=Oovw5/v+bMXqeN58qsLdZpY3pozczdNgIIyWXuVyao5V9ENvzV0XdHB4QCN3MKVFyb PJ11+I0ZItvwhIQBR6rqWVo5KOH/Zh/nGRdFcbIWPeQcajhhgYEauqvLOKutmXfmMVJO V5PqdFW5g2HHeQsf6dkZfe1mE2F1NtKt1NBCs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=dp1+RYIq+lADcHFPv8uWgX/kHy30FZwE30d3aioUzIlhCd62QZIr+2Tm+zf2XNzmju y9TUMpQNd+GRvIJ+9nvS7/pc44Wx6Pp0J8SZr30saedzHpC5LSutY1F2OIAU2w9EJ2Pw ui/udmIGh+gDXMSJDRCNpyoATF3qJf4yyGwSY= MIME-Version: 1.0 Received: by 10.213.109.74 with SMTP id i10mr3104492ebp.61.1266432666343; Wed, 17 Feb 2010 10:51:06 -0800 (PST) Date: Wed, 17 Feb 2010 19:51:06 +0100 Message-ID: <1bd550a01002171051n7117895avb5cf57fb7fbb9388@mail.gmail.com> From: =?ISO-8859-1?Q?Fernando_Apestegu=EDa?= To: FreeBSD Hackers Content-Type: text/plain; charset=ISO-8859-1 Subject: linprocfs proc/pid/environ patch & list question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 18:51:14 -0000 Hi, I have a small patch (against 8.0-RELEASE-p2) that _should_ implement the /proc/pid/environ file under linprocfs. However, it seems it does not work properly but I don't know what I'm doing wrong. Is this list the place to ask for help? I tried in the forums[1] but got no answer. Don't we have a 'kernel newbies'-like list? Thanks in advance. [1] http://forums.freebsd.org/showthread.php?t=11329 --- sys/compat/linprocfs/linprocfs.c.orig 2009-10-25 02:10:29.000000000 +0100 +++ sys/compat/linprocfs/linprocfs.c 2010-02-16 19:38:36.000000000 +0100 @@ -939,8 +939,38 @@ static int linprocfs_doprocenviron(PFS_FILL_ARGS) { + int i, error; + struct ps_strings pss; + char **ps_envstr; - sbuf_printf(sb, "doprocenviron\n%c", '\0'); + PROC_LOCK(p); + if (p_cansee(td, p) != 0) + return (0); + PROC_UNLOCK(p); + + error = copyin((void *)p->p_sysent->sv_psstrings, &pss, + sizeof(pss)); + if (error) + return (error); + + ps_envstr = malloc(pss.ps_nenvstr * sizeof(char *), + M_TEMP, M_WAITOK); + + error = copyin((void *)pss.ps_envstr, ps_envstr, + pss.ps_nenvstr * sizeof(char *)); + + if (error) { + free(ps_envstr, M_TEMP); + return (error); + } + + /* NULL separated list of variable=value pairs */ + + for (i = 0; i < pss.ps_nenvstr; i++) { + sbuf_copyin(sb, ps_envstr[i], 0); + } + + free(ps_envstr, M_TEMP); return (0); }