memstick: fix MSProHG 8-bit interface mode support
[pandora-kernel.git] / Documentation / filesystems / seq_file.txt
index 92975ee..b843743 100644 (file)
@@ -92,7 +92,7 @@ implementations; in most cases the start() function should check for a
 "past end of file" condition and return NULL if need be.
 
 For more complicated applications, the private field of the seq_file
-structure can be used. There is also a special value whch can be returned
+structure can be used. There is also a special value which can be returned
 by the start() function called SEQ_START_TOKEN; it can be used if you wish
 to instruct your show() function (described below) to print a header at the
 top of the output. SEQ_START_TOKEN should only be used if the offset is
@@ -107,8 +107,8 @@ complete. Here's the example version:
 
        static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos)
        {
-               loff_t *spos = (loff_t *) v;
-               *pos = ++(*spos);
+               loff_t *spos = v;
+               *pos = ++*spos;
                return spos;
        }
 
@@ -122,21 +122,26 @@ stop() is the place to free it.
        }
 
 Finally, the show() function should format the object currently pointed to
-by the iterator for output. It should return zero, or an error code if
-something goes wrong. The example module's show() function is:
+by the iterator for output.  The example module's show() function is:
 
        static int ct_seq_show(struct seq_file *s, void *v)
        {
-               loff_t *spos = (loff_t *) v;
-               seq_printf(s, "%Ld\n", *spos);
+               loff_t *spos = v;
+               seq_printf(s, "%lld\n", (long long)*spos);
                return 0;
        }
 
+If all is well, the show() function should return zero.  A negative error
+code in the usual manner indicates that something went wrong; it will be
+passed back to user space.  This function can also return SEQ_SKIP, which
+causes the current item to be skipped; if the show() function has already
+generated output before returning SEQ_SKIP, that output will be dropped.
+
 We will look at seq_printf() in a moment. But first, the definition of the
 seq_file iterator is finished by creating a seq_operations structure with
 the four functions we have just defined:
 
-       static struct seq_operations ct_seq_ops = {
+       static const struct seq_operations ct_seq_ops = {
                .start = ct_seq_start,
                .next  = ct_seq_next,
                .stop  = ct_seq_stop,
@@ -146,7 +151,7 @@ the four functions we have just defined:
 This structure will be needed to tie our iterator to the /proc file in
 a little bit.
 
-It's worth noting that the interator value returned by start() and
+It's worth noting that the iterator value returned by start() and
 manipulated by the other functions is considered to be completely opaque by
 the seq_file code. It can thus be anything that is useful in stepping
 through the data to be output. Counters can be useful, but it could also be
@@ -182,12 +187,18 @@ The first two output a single character and a string, just like one would
 expect. seq_escape() is like seq_puts(), except that any character in s
 which is in the string esc will be represented in octal form in the output.
 
-There is also a function for printing filenames:
+There is also a pair of functions for printing filenames:
 
        int seq_path(struct seq_file *m, struct path *path, char *esc);
+       int seq_path_root(struct seq_file *m, struct path *path,
+                         struct path *root, char *esc)
 
 Here, path indicates the file of interest, and esc is a set of characters
-which should be escaped in the output.
+which should be escaped in the output.  A call to seq_path() will output
+the path relative to the current process's filesystem root.  If a different
+root is desired, it can be used with seq_path_root().  Note that, if it
+turns out that path cannot be reached from root, the value of root will be
+changed in seq_file_root() to a root which *does* work.
 
 
 Making it all work
@@ -204,7 +215,7 @@ line, as in the example module:
        static int ct_open(struct inode *inode, struct file *file)
        {
                return seq_open(file, &ct_seq_ops);
-       };
+       }
 
 Here, the call to seq_open() takes the seq_operations structure we created
 before, and gets set up to iterate through the virtual file.
@@ -219,7 +230,7 @@ The other operations of interest - read(), llseek(), and release() - are
 all implemented by the seq_file code itself. So a virtual file's
 file_operations structure will look like:
 
-       static struct file_operations ct_file_ops = {
+       static const struct file_operations ct_file_ops = {
                .owner   = THIS_MODULE,
                .open    = ct_open,
                .read    = seq_read,
@@ -262,7 +273,7 @@ routines useful:
 
 These helpers will interpret pos as a position within the list and iterate
 accordingly.  Your start() and next() functions need only invoke the
-seq_list_* helpers with a pointer to the appropriate list_head structure.  
+seq_list_* helpers with a pointer to the appropriate list_head structure.
 
 
 The extra-simple version