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

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

 



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).
So, it begins at the current 'pos'. This 'pos' might have been be updated in previous calls to start/next.
Regards,
- Ratnadeep

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

rday

[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