[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: does a seq_file "offset" always start at zero?



On Tue, 5 Jun 2007, Ratnadeep Joshi wrote:

> >
> > i *realize* how the offset value might/will increase across subsequent
> > calls.  what i was asking about was this routine from p. 87 of LDD3:
> >
> > static void *scull_seq_start(struct seq_file *s, loff_t *pos)
> > {
> >     if (*pos >= scull_nr_devs)
> >         return NULL;   /* No more to read */
> >     return scull_devices + *pos;
> > }
> >
> > why would the *start* routine be checking if the offset was already
> > out of range if it should begin at zero?
>
>
>
> It does not begin at zero :) 'Start' does not mean start reading
> from the 'first position'. It means start reading from the position
> where we left last time (previous calls to read i.e. 1 start
> call/multiple next calls).

ah, based on previous calls to "read", gotcha.  for some reason, i was
hung up on just doing open/read/close in a single operation.  thanks.

rday
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ