From owner-freebsd-hackers@FreeBSD.ORG Sat Mar 16 22:57:05 2013 Return-Path: Delivered-To: freebsd-hackers@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 5823E8EE; Sat, 16 Mar 2013 22:57:05 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-ee0-f48.google.com (mail-ee0-f48.google.com [74.125.83.48]) by mx1.freebsd.org (Postfix) with ESMTP id 339DF77B; Sat, 16 Mar 2013 22:57:03 +0000 (UTC) Received: by mail-ee0-f48.google.com with SMTP id t10so2142119eei.21 for ; Sat, 16 Mar 2013 15:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=byN/Nyf5tlXFatput1nbSeqaeKDBO5JHfoGf9ghMg/U=; b=yHtOOPbMZkipuHeDrLWYci0fx8x+WPTt439CPteDIurf3VSGCrC7bCyGfx+QHHeLDM F4KwDJcYKMzHgGAHQ33MVg3zCEQ8+N145pY7jjuffYuBeBYZwoyxzne4ljy5W9IC/Jiz 5smiCF8lMTLXCbxaTihV2PXEtzF0ysp//s9VkDE4rUApQLnkMo+pZAFVDilsrW63/c34 oi+wYaYvEb3qx9HRjNbzyDOD5Sg+kP08z6H1LmdAX9vWEur3b1IKaaZ5aw+5aifsqGKq G/uY0ljBIgSF4cvXpNrHfzPk+SOSFiAELJlglEakBdWgyzVKQJ/c+k6barH68AS2rKeK efKg== X-Received: by 10.14.3.70 with SMTP id 46mr33081372eeg.2.1363474616964; Sat, 16 Mar 2013 15:56:56 -0700 (PDT) Received: from localhost ([178.150.115.244]) by mx.google.com with ESMTPS id 44sm18425816eek.5.2013.03.16.15.56.55 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 16 Mar 2013 15:56:56 -0700 (PDT) Sender: Mikolaj Golub Date: Sun, 17 Mar 2013 00:56:52 +0200 From: Mikolaj Golub To: Konstantin Belousov Subject: Re: libprocstat(3): retrieve process command line args and environment Message-ID: <20130316225651.GB3534@gmail.com> References: <20130119151253.GB88025@gmail.com> <201301251531.43540.jhb@freebsd.org> <20130212215054.GA9839@gmail.com> <201302200904.15324.jhb@freebsd.org> <20130220195801.GA8679@gmail.com> <20130316180915.GA91146@gmail.com> <20130316191605.GJ3794@kib.kiev.ua> <20130316223339.GA3534@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130316223339.GA3534@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Stanislav Sedov , Attilio Rao , "Robert N. M. Watson" , freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Mar 2013 22:57:05 -0000 On Sun, Mar 17, 2013 at 12:35:20AM +0200, Mikolaj Golub wrote: > Ah, this is a thing I wanted to discuss but forgot! As I understand > the idea of the 'ABI hack' is: if the output buffer is less than the > size of data we have, truncate our data to the last successfully > written kinfo_file structure and return without error. > > In my code I do reset ENOMEM to 0 (see sysctl_kern_proc_filedesc), but > I don't see a way how using sbuf interface I can truncate req->oldidx > to the last successfully written file: sbuf_bcat() (to internal > buffer) may be successful and the error might appear only later, when > draining. I suspect it will break things if I return with a partial > kinfo_file, but haven't come with a solution yet... A solution I am going to try is to provide maxlen argument to kern_proc_filedesc_out(), and if it is not 0, output files that do not exceed the limit, so sysctl_kern_proc_filedesc would call: kern_proc_filedesc_out(p, &sb, req->oldlen); -- Mikolaj Golub