linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Ritesh Harjani <riteshh@codeaurora.org>
To: linux-mtd@lists.infradead.org, richard@nod.at,
	david.oberhollenzer@sigma-star.at
Cc: Ritesh Harjani <riteshh@codeaurora.org>
Subject: [RFC PATCH 1/2] mkfs.ubifs: add_xattr is not depending on host XATTR support
Date: Wed,  6 Jun 2018 15:08:59 +0530	[thread overview]
Message-ID: <1528277940-30919-2-git-send-email-riteshh@codeaurora.org> (raw)
In-Reply-To: <1528277940-30919-1-git-send-email-riteshh@codeaurora.org>

add_xattr adds the xattr to the ubifs image and has nothing
to do with host XATTR support.

Now that we are adding support where selinux interfaces
may use this API even when host OS(where ubi/ubifs image
is being created) does not support XATTR -so remove it
from WITHOUT_XATTR #ifdef.

Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
---
 ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 80 ++++++++++++++++++-------------------
 1 file changed, 40 insertions(+), 40 deletions(-)

diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
index 6323dd4..2333dde 100644
--- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
+++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
@@ -1007,46 +1007,6 @@ static int add_node(union ubifs_key *key, char *name, void *node, int len)
 	return 0;
 }
 
-#ifdef WITHOUT_XATTR
-static inline int create_inum_attr(ino_t inum, const char *name)
-{
-	(void)inum;
-	(void)name;
-
-	return 0;
-}
-
-static inline int inode_add_xattr(struct ubifs_ino_node *host_ino,
-				  const char *path_name, struct stat *st, ino_t inum)
-{
-	(void)host_ino;
-	(void)path_name;
-	(void)st;
-	(void)inum;
-
-	return 0;
-}
-#else
-static int create_inum_attr(ino_t inum, const char *name)
-{
-	char *str;
-	int ret;
-
-	if (!do_create_inum_attr)
-		return 0;
-
-	ret = asprintf(&str, "%llu", (unsigned long long)inum);
-	if (ret < 0)
-		return -1;
-
-	ret = lsetxattr(name, "user.image-inode-number", str, ret, 0);
-
-	free(str);
-
-	return ret;
-}
-
-
 static int add_xattr(struct stat *st, ino_t inum, const void *data,
 		     unsigned int data_len, struct qstr *nm)
 {
@@ -1117,6 +1077,46 @@ out:
 	return ret;
 }
 
+#ifdef WITHOUT_XATTR
+static inline int create_inum_attr(ino_t inum, const char *name)
+{
+	(void)inum;
+	(void)name;
+
+	return 0;
+}
+
+static inline int inode_add_xattr(struct ubifs_ino_node *host_ino,
+				  const char *path_name,
+				  struct stat *st, ino_t inum)
+{
+	(void)host_ino;
+	(void)path_name;
+	(void)st;
+	(void)inum;
+
+	return 0;
+}
+#else
+static int create_inum_attr(ino_t inum, const char *name)
+{
+	char *str;
+	int ret;
+
+	if (!do_create_inum_attr)
+		return 0;
+
+	ret = asprintf(&str, "%llu", (unsigned long long)inum);
+	if (ret < 0)
+		return ret;
+
+	ret = lsetxattr(name, "user.image-inode-number", str, ret, 0);
+
+	free(str);
+
+	return ret;
+}
+
 static int inode_add_xattr(struct ubifs_ino_node *host_ino,
 			   const char *path_name, struct stat *st, ino_t inum)
 {
-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
a Linux Foundation Collaborative Project.

  reply	other threads:[~2018-06-06  9:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-06  9:38 [RFC PATCH 0/2] mkfs.ubifs: Implement selinux labelling support Ritesh Harjani
2018-06-06  9:38 ` Ritesh Harjani [this message]
2018-06-06  9:39 ` [RFC PATCH 2/2] mkfs.ubifs: Implement selinux labelling support in mkfs.ubifs Ritesh Harjani
2018-06-11  4:27 ` [RFC PATCH 0/2] mkfs.ubifs: Implement selinux labelling support Ritesh Harjani
2018-06-11  7:00   ` Richard Weinberger
2018-06-11 11:23     ` Ritesh Harjani
2018-06-14  7:33 ` David Oberhollenzer
2018-06-14 11:31   ` Ritesh Harjani

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=1528277940-30919-2-git-send-email-riteshh@codeaurora.org \
    --to=riteshh@codeaurora.org \
    --cc=david.oberhollenzer@sigma-star.at \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    /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;
as well as URLs for NNTP newsgroup(s).