diff options
Diffstat (limited to 'Documentation/filesystems')
-rw-r--r-- | Documentation/filesystems/seq_file.txt | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Documentation/filesystems/seq_file.txt b/Documentation/filesystems/seq_file.txt index 7fb8e6dc62bf..b843743aa0b5 100644 --- a/Documentation/filesystems/seq_file.txt +++ b/Documentation/filesystems/seq_file.txt | |||
@@ -122,8 +122,7 @@ stop() is the place to free it. | |||
122 | } | 122 | } |
123 | 123 | ||
124 | Finally, the show() function should format the object currently pointed to | 124 | Finally, the show() function should format the object currently pointed to |
125 | by the iterator for output. It should return zero, or an error code if | 125 | by the iterator for output. The example module's show() function is: |
126 | something goes wrong. The example module's show() function is: | ||
127 | 126 | ||
128 | static int ct_seq_show(struct seq_file *s, void *v) | 127 | static int ct_seq_show(struct seq_file *s, void *v) |
129 | { | 128 | { |
@@ -132,6 +131,12 @@ something goes wrong. The example module's show() function is: | |||
132 | return 0; | 131 | return 0; |
133 | } | 132 | } |
134 | 133 | ||
134 | If all is well, the show() function should return zero. A negative error | ||
135 | code in the usual manner indicates that something went wrong; it will be | ||
136 | passed back to user space. This function can also return SEQ_SKIP, which | ||
137 | causes the current item to be skipped; if the show() function has already | ||
138 | generated output before returning SEQ_SKIP, that output will be dropped. | ||
139 | |||
135 | We will look at seq_printf() in a moment. But first, the definition of the | 140 | We will look at seq_printf() in a moment. But first, the definition of the |
136 | seq_file iterator is finished by creating a seq_operations structure with | 141 | seq_file iterator is finished by creating a seq_operations structure with |
137 | the four functions we have just defined: | 142 | the four functions we have just defined: |
@@ -182,12 +187,18 @@ The first two output a single character and a string, just like one would | |||
182 | expect. seq_escape() is like seq_puts(), except that any character in s | 187 | expect. seq_escape() is like seq_puts(), except that any character in s |
183 | which is in the string esc will be represented in octal form in the output. | 188 | which is in the string esc will be represented in octal form in the output. |
184 | 189 | ||
185 | There is also a function for printing filenames: | 190 | There is also a pair of functions for printing filenames: |
186 | 191 | ||
187 | int seq_path(struct seq_file *m, struct path *path, char *esc); | 192 | int seq_path(struct seq_file *m, struct path *path, char *esc); |
193 | int seq_path_root(struct seq_file *m, struct path *path, | ||
194 | struct path *root, char *esc) | ||
188 | 195 | ||
189 | Here, path indicates the file of interest, and esc is a set of characters | 196 | Here, path indicates the file of interest, and esc is a set of characters |
190 | which should be escaped in the output. | 197 | which should be escaped in the output. A call to seq_path() will output |
198 | the path relative to the current process's filesystem root. If a different | ||
199 | root is desired, it can be used with seq_path_root(). Note that, if it | ||
200 | turns out that path cannot be reached from root, the value of root will be | ||
201 | changed in seq_file_root() to a root which *does* work. | ||
191 | 202 | ||
192 | 203 | ||
193 | Making it all work | 204 | Making it all work |