patch-2.4.23 linux-2.4.23/fs/seq_file.c
Next file: linux-2.4.23/include/acpi/acconfig.h
Previous file: linux-2.4.23/fs/reiserfs/ioctl.c
Back to the patch index
Back to the overall index
- Lines: 122
- Date:
2003-11-28 10:26:21.000000000 -0800
- Orig file:
linux-2.4.22/fs/seq_file.c
- Orig date:
2003-06-13 07:51:37.000000000 -0700
diff -urN linux-2.4.22/fs/seq_file.c linux-2.4.23/fs/seq_file.c
@@ -1,7 +1,7 @@
/*
* linux/fs/seq_file.c
*
- * helper functions for making syntetic files from sequences of records.
+ * helper functions for making synthetic files from sequences of records.
* initial implementation -- AV, Oct 2001.
*/
@@ -10,6 +10,7 @@
#include <linux/slab.h>
#include <asm/uaccess.h>
+#include <asm/page.h>
/**
* seq_open - initialize sequential file
@@ -214,7 +215,7 @@
while ((retval=traverse(m, offset)) == -EAGAIN)
;
if (retval) {
- /* with extreme perjudice... */
+ /* with extreme prejudice... */
file->f_pos = 0;
m->index = 0;
m->count = 0;
@@ -249,7 +250,7 @@
* @s: string
* @esc: set of characters that need escaping
*
- * Puts string into buffer, replacing each occurence of character from
+ * Puts string into buffer, replacing each occurrence of character from
* @esc with usual octal escape. Returns 0 in case of success, -1 - in
* case of overflow.
*/
@@ -295,3 +296,86 @@
m->count = m->size;
return -1;
}
+
+int seq_path(struct seq_file *m,
+ struct vfsmount *mnt, struct dentry *dentry,
+ char *esc)
+{
+ if (m->count < m->size) {
+ char *s = m->buf + m->count;
+ char *p = d_path(dentry, mnt, s, m->size - m->count);
+ if (!IS_ERR(p)) {
+ while (s <= p) {
+ char c = *p++;
+ if (!c) {
+ p = m->buf + m->count;
+ m->count = s - m->buf;
+ return s - p;
+ } else if (!strchr(esc, c)) {
+ *s++ = c;
+ } else if (s + 4 > p) {
+ break;
+ } else {
+ *s++ = '\\';
+ *s++ = '0' + ((c & 0300) >> 6);
+ *s++ = '0' + ((c & 070) >> 3);
+ *s++ = '0' + (c & 07);
+ }
+ }
+ }
+ }
+ m->count = m->size;
+ return -1;
+}
+
+static void *single_start(struct seq_file *p, loff_t *pos)
+{
+ return NULL + (*pos == 0);
+}
+
+static void *single_next(struct seq_file *p, void *v, loff_t *pos)
+{
+ ++*pos;
+ return NULL;
+}
+
+static void single_stop(struct seq_file *p, void *v)
+{
+}
+
+int single_open(struct file *file, int (*show)(struct seq_file *, void*), void *data)
+{
+ struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
+ int res = -ENOMEM;
+
+ if (op) {
+ op->start = single_start;
+ op->next = single_next;
+ op->stop = single_stop;
+ op->show = show;
+ res = seq_open(file, op);
+ if (!res)
+ ((struct seq_file *)file->private_data)->private = data;
+ else
+ kfree(op);
+ }
+ return res;
+}
+
+int single_release(struct inode *inode, struct file *file)
+{
+ struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
+ int res = seq_release(inode, file);
+ kfree(op);
+ return res;
+}
+
+int seq_release_private(struct inode *inode, struct file *file)
+{
+ struct seq_file *seq = file->private_data;
+
+ kfree(seq->private);
+ seq->private = NULL;
+ return seq_release(inode, file);
+}
+
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)