[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJfpegsywJWWo7ZBpN8=1uPyPpiDbF2XdN0WaEXcKr8YFdOAtQ@mail.gmail.com>
Date: Thu, 24 Nov 2016 16:39:57 +0100
From: Miklos Szeredi <miklos@...redi.hu>
To: Tomasz Majchrzak <tomasz.majchrzak@...el.com>
Cc: LKML <linux-kernel@...r.kernel.org>, dan.j.williams@...el.com,
Al Viro <viro@...iv.linux.org.uk>,
aleksey.obitotskiy@...el.com, pawel.baldysiak@...el.com,
artur.paszkiewicz@...el.com, maksymilian.kunt@...el.com
Subject: Re: [PATCH v2][RESEND] seq_file: don't set read position for invalid iterator
On Thu, Nov 24, 2016 at 4:23 PM, Tomasz Majchrzak
<tomasz.majchrzak@...el.com> 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
Powered by blists - more mailing lists