[PATCH] Fix PIPE_LEN definition in 2.6.12

From: éå å
Date: Sun Jul 31 2005 - 02:58:33 EST


With the introduction of the new "struct pipe_inode_info"in 2.6.11,
the definition of PIPE_LEN, PIPE_BASE, PIPE_START all become
obsolete. The new definition of PIPE_LEN is attached.

Signed-off-by: Zhigang Huo <zghuo@xxxxxxxxxx>

================================================
--- pipe_fs_i.h~ 2005-07-31 13:45:38.000000000 +0800
+++ pipe_fs_i.h 2005-07-31 14:41:53.000000000 +0800
@@ -33,6 +33,25 @@
struct fasync_struct *fasync_writers;
};

+static inline unsigned int pipe_len(struct inode inode)
+{
+ struct pipe_inode_info *info = inode.i_pipe;
+ int bufs = info->nrbufs;
+ int curbuf = info->curbuf;
+ unsigned int ret;
+
+ ret = 0;
+ while(bufs--) {
+ struct pipe_buffer *buf = info->bufs + curbuf;
+ size_t chars = buf->len;
+
+ ret += chars;
+ bufs--;
+ curbuf = (curbuf + 1) & (PIPE_BUFFERS-1);
+ }
+ return ret;
+}
+
/* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual
memory allocation, whereas PIPE_BUF makes atomicity guarantees. */
#define PIPE_SIZE PAGE_SIZE
@@ -41,7 +60,7 @@
#define PIPE_WAIT(inode) (&(inode).i_pipe->wait)
#define PIPE_BASE(inode) ((inode).i_pipe->base)
#define PIPE_START(inode) ((inode).i_pipe->start)
-#define PIPE_LEN(inode) ((inode).i_pipe->len)
+#define PIPE_LEN(inode) pipe_len(inode)
#define PIPE_READERS(inode) ((inode).i_pipe->readers)
#define PIPE_WRITERS(inode) ((inode).i_pipe->writers)
#define PIPE_WAITING_WRITERS(inode)
((inode).i_pipe->waiting_writers)



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/