Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S263448AbTKQJza (ORCPT ); Mon, 17 Nov 2003 04:55:30 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S263460AbTKQJza (ORCPT ); Mon, 17 Nov 2003 04:55:30 -0500 Received: from parcelfarce.linux.theplanet.co.uk ([195.92.249.252]:29408 "EHLO www.linux.org.uk") by vger.kernel.org with ESMTP id S263448AbTKQJz3 (ORCPT ); Mon, 17 Nov 2003 04:55:29 -0500 Date: Mon, 17 Nov 2003 09:55:28 +0000 From: viro@parcelfarce.linux.theplanet.co.uk To: Tigran Aivazian Cc: William Lee Irwin III , linux-kernel@vger.kernel.org Subject: Re: seq_file and exporting dynamically allocated data Message-ID: <20031117095528.GV24159@parcelfarce.linux.theplanet.co.uk> References: <20031117090339.GC22764@holomorphy.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 973 Lines: 21 On Mon, Nov 17, 2003 at 09:42:09AM +0000, Tigran Aivazian wrote: > Here are two files: simple.c kernel module and user.c user test program. > If you (or anyone) believe it is possible to return more than a single > page on a read(2) please change them accordingly and let me know. > while (1) { > len = read(fd, procs, MAXPROCS*PROCLEN); > nproc = len/PROCLEN; Broken userland code. You expect read() to return a multiple of PROCLEN, for one thing. For another, you have (several lines below) a broken loop termination logics. EOF had been reached when read() returns 0. Until then read() returns an arbitrary amount of bytes between 1 and 'size' argument. Since you are using read(2) directly, use it correctly... - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/