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

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

 



On Tue, 5 Jun 2007, Ratnadeep Joshi wrote:

> >   i'm reading LDD3 and i can see the prototype for the "start" method
> > for a seq_file:
> >
> >   void* start(struct seq_file *sfile, loff_t *pos) ;
> >
> > does that offset position always start at zero for a seq_file?
> > everything suggests it does, but the book doesn't come right out
> > and say it.  and if it doesn't, how as a programmer could you open
> > a seq_file to start at some other offset?  thanks.
> >
> > rday
>
> No. the offset position is not zero always. It will be zero at the
> 'first read' after an open call to the file. For consequent calls to
> 'read', start is called each time with the updates positions.

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?

i can see how you want to do that kind of checking with the *next*
routine.

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


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux