Skip to contentSkip to conversation

Fix PIPE_LEN definition in 2.6.12

PATCH In review 霍志刚 2 participants 2 messages Jul 31, 2005

lore
Share & tools
lore

霍志刚

author
#0 lore raw

PATCH 1/1 Fix PIPE_LEN definition in 2.6.12

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.

================================================

pipe_fs_i.h 2005-07-31 14:41:53.000000000 +0800 renamed from pipe_fs_i.h~ 2005-07-31 13:45:38.000000000 +0800 +20 -1
@@ -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)

#1 lore raw
Quoted 4 lines · _________

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.

bix:/usr/src/linux-2.6.13-rc4> grep -r PIPE_LEN .
./include/linux/pipe_fs_i.h:#define PIPE_LEN(inode) ((inode).i_pipe->len)
bix:/usr/src/linux-2.6.13-rc4>

We can just kill it, can't we?