Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966943AbcKXPkB (ORCPT ); Thu, 24 Nov 2016 10:40:01 -0500 Received: from mail-oi0-f65.google.com ([209.85.218.65]:34433 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966506AbcKXPj7 (ORCPT ); Thu, 24 Nov 2016 10:39:59 -0500 MIME-Version: 1.0 X-Originating-IP: [217.173.44.24] In-Reply-To: <20161124152342.GA9751@proton.igk.intel.com> References: <1476274060-1785-1-git-send-email-tomasz.majchrzak@intel.com> <20161031093221.GA23528@proton.igk.intel.com> <20161102091147.GC8412@veci.piliscsaba.szeredi.hu> <20161124152342.GA9751@proton.igk.intel.com> From: Miklos Szeredi Date: Thu, 24 Nov 2016 16:39:57 +0100 Message-ID: Subject: Re: [PATCH v2][RESEND] seq_file: don't set read position for invalid iterator To: Tomasz Majchrzak Cc: LKML , dan.j.williams@intel.com, Al Viro , aleksey.obitotskiy@intel.com, pawel.baldysiak@intel.com, artur.paszkiewicz@intel.com, maksymilian.kunt@intel.com Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 956 Lines: 26 On Thu, Nov 24, 2016 at 4:23 PM, Tomasz Majchrzak wrote: > I don't understand it. Is it possible to map file position to the index > (record)? I think there is no way to determine record size without actually > reading it. Right. So don't update m->index when a zero size record is read. This will result in m->index always pointing to the first record at the given offset. You use this property for the single record case and zero offset, but I'd consider behavior consistent if this was not just done for this special case. >> But I doubt that we actually need to do that. For example just special casing >> the zero offset (always translating to zero index) would be conceptually simpler >> and equivalent to your patch for the sysfs case. > > Do you mean such piece of code? > > if (ppos == 0) > m->index = 0; Yes. Which is a special case, but it's at least simple and easy to prove right. Thanks, Miklos