Re: by default, does seq_file start() routine start at zero offset?

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

 



On Tue, 4 Aug 2009, Bruce Rowen wrote:

>
> On Aug 4, 2009, at 2:35 PM, Robert P. J. Day wrote:
>
>
>       i realize that's a potentially dumb question but that doesn't
>       seem
>       to be explicitly stated in any of the docs i'm reading -- it
>       always
>       just seems to be assumed.
>
>        i've always assumed that if you just "cat" a /proc file that's
>       based
>       on seq_file, the offset value that's passed will always be zero,
>       so
>       you're always starting at the beginning.
>
>        however, if you look at the source for fs/proc/devices.c, you
>       read:
>
>       static void *devinfo_start(struct seq_file *f, loff_t *pos)
>       {
>              if (*pos < (BLKDEV_MAJOR_HASH_SIZE +
>       CHRDEV_MAJOR_HASH_SIZE))
>                      return pos;
>              return NULL;
>       }
>
>       note that that routine clearly checks the initial value of the
>       offset, which i assume you can affect by, say, reading the file
>       with
>       "dd" and specifying an offset, or something like that.  but
>       unless you
>       explicitly change the starting location, is it true that the
>       start()
>       routine always gets an offset of zero?
>
>
> No, it is up to the programmer to honor the provided offset "loff_t
> *pos" parameter.

  but i don't think that answers my question -- sure, i'll honour the
provided value, but what *is* that provided value by default?  in
every example i've seen, it seems to be clear that that example will
work properly only if that original start offset is zero.

  the code in fs/proc/devices.c is a good example.  if that initial
offset was something other than zero, the output would be totally
screwed and miss printing some lines, no?

rday
--


========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

        Linux Consulting, Training and Annoying Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Twitter:                                       http://twitter.com/rpjday
"Kernel Newbie Corner" column @ linux.com:          http://cli.gs/WG6WYX
========================================================================

[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