linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Li Guifu via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: linux-erofs@lists.ozlabs.org
Subject: [PATCH v1 1/2] erofs-utils: add list_replace from linux kernel for dirs sorted later
Date: Wed,  5 May 2021 22:26:14 +0800	[thread overview]
Message-ID: <20210505142615.38306-1-bluce.lee@aliyun.com> (raw)

A temp list head will be replaced to inode i_subdirs.

Signed-off-by: Li Guifu <bluce.lee@aliyun.com>
---
 include/erofs/list.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/erofs/list.h b/include/erofs/list.h
index 3572726..7238418 100644
--- a/include/erofs/list.h
+++ b/include/erofs/list.h
@@ -67,6 +67,22 @@ static inline int list_empty(struct list_head *head)
 	return head->next == head;
 }
 
+/**
+ * list_replace - replace old entry by new one
+ * @old : the element to be replaced
+ * @new : the new element to insert
+ *
+ * If @old was empty, it will be overwritten.
+ */
+static inline void list_replace(struct list_head *old,
+				struct list_head *new)
+{
+	new->next = old->next;
+	new->next->prev = new;
+	new->prev = old->prev;
+	new->prev->next = new;
+}
+
 #define list_entry(ptr, type, member) container_of(ptr, type, member)
 
 #define list_first_entry(ptr, type, member)                                    \
-- 
2.17.1


             reply	other threads:[~2021-05-05 14:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 14:26 Li Guifu via Linux-erofs [this message]
2021-05-05 14:26 ` [PATCH v1 2/2] erofs-utils: introduce erofs_subdirs to one dir for sort Li Guifu via Linux-erofs
2021-05-07  7:09   ` Gao Xiang
2021-05-09 14:30     ` Li GuiFu via Linux-erofs
2021-05-10  1:06       ` Gao Xiang

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=20210505142615.38306-1-bluce.lee@aliyun.com \
    --to=linux-erofs@lists.ozlabs.org \
    --cc=bluce.lee@aliyun.com \
    --subject='Re: [PATCH v1 1/2] erofs-utils: add list_replace from linux kernel for dirs sorted later' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).