mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: 霍志刚 <zghuo@ncic.ac.cn>
To: linux-kernel@vger.kernel.org
Cc: trivial@rustcorp.com.au
Subject: [PATCH] Fix PIPE_LEN definition in 2.6.12
Date: Sun, 31 Jul 2005 15:55:13 +0800	[thread overview]
Message-ID: <1122796514.8909.17.camel@mypad> (raw)

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@ncic.ac.cn>

================================================
--- 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)




             reply	other threads:[~2005-07-31  7:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-31  7:55 霍志刚 [this message]
2005-07-31  8:08 ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1122796514.8909.17.camel@mypad \
    --to=zghuo@ncic.ac.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=trivial@rustcorp.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®