wanting to clarify a last few things about sequence files

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

 



  i (sort of) have a handle on sequence files, but i want to clarify a
few details.  all of this is based on the idea that all i want to do
is cat the file as it shows up under /proc, nothing more (at least,
for the moment).

  first, the start method:

    void *start(struct seq_file *sfile, loff_t *pos);

  as i read it, this will be called once (at the beginning) when the
file is first read.  most examples i've seen do nothing with the
"sfile" argument since, normally, there *is* nothing to do in the
start method with that argument.

  now, is the value of *pos guaranteed to be zero when this routine is
first called?  i've tested this and it would seem to be, but are there
circumstances when it would be some other value in that initial call?

  finally, i'm assuming that a normal result of calling the start
routine would be to return that void pointer to the first "data
object" to be processed when we get into the "show" routine.  is all
that about right?  am i missing any other important duties sometimes
done by the start method?  in the end, all i'm after is returning the
address of the "first" object to display, to start the whole process.

  next, we get into the "show" method:

    int show(struct seq_file *sfile, void *v);

this one's easy enough -- take whatever object is pointed at by "v",
and "display" it using some combination of seq_printf, seq_puts, etc.
that's pretty much it.

  now, about the "next" method:

    void *next(struct seq_file *sfile, void *v, loff_t *pos);

this is the one i need the most clarification on.  the objective is,
given the "current" object, somehow calculate the address of the
"next" one and return it.  this might involve using either or both of
the arguments v and/or pos, right?

  it might be that you can do all of that calculation using nothing
but the value in "v", and you can ignore "pos" entirely, is that
correct?  at the other extreme, it might be that you can figure out
what to return strictly based on "pos" and ignore the value in "v"
completely, yes?

  put another way, you *can* take advantage of constantly incrementing
"pos" to keep track of your current position, but nothing says you
*have* to.  if you can do everything you need based only on the value
in "v" handed to you as an argument, is there anything wrong with
doing that?

  and that's about it.  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


[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