mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Baeuerle, Florian" <Florian.Baeuerle@allegion.com>
To: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: [PATCH 2/2] envfs: new flag for sorting env before saving
Date: Tue, 18 Dec 2018 13:22:52 +0000	[thread overview]
Message-ID: <20181218132233.23669-2-florian.baeuerle@allegion.com> (raw)
In-Reply-To: <20181218132233.23669-1-florian.baeuerle@allegion.com>

The resulting environment was dependend of the build machines'
filesystem, i.e. the order in which readdir returns dirents depends on
the filesystem implementation.

Use the new flag in scripts/bareboxenv.c for generating a reproducible
built-in environment.

Signed-off-by: Florian Bäuerle <florian.baeuerle@allegion.com>
---
 common/environment.c | 8 ++++++--
 include/envfs.h      | 1 +
 scripts/bareboxenv.c | 2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/common/environment.c b/common/environment.c
index 56a030eda..cea55f313 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -257,6 +257,7 @@ int envfs_save(const char *filename, const char *dirname, unsigned flags)
 	void *buf = NULL, *wbuf;
 	struct envfs_entry *env;
 	const char *defenv_path = default_environment_path_get();
+	int recursive_flags = ACTION_RECURSE;
 
 	if (!filename)
 		filename = defenv_path;
@@ -276,10 +277,13 @@ int envfs_save(const char *filename, const char *dirname, unsigned flags)
 	if (flags & ENVFS_FLAGS_FORCE_BUILT_IN) {
 		size = 0; /* force no content */
 	} else {
+		if (flags & ENVFS_FLAGS_SORTED)
+			recursive_flags |= ACTION_SORT;
+
 		/* first pass: calculate size */
-		recursive_action(dirname, ACTION_RECURSE, file_action,
+		recursive_action(dirname, recursive_flags, file_action,
 				NULL, &data, 0);
-		recursive_action("/.defaultenv", ACTION_RECURSE,
+		recursive_action("/.defaultenv", recursive_flags,
 				file_remove_action, NULL, &data, 0);
 		size = 0;
 
diff --git a/include/envfs.h b/include/envfs.h
index 27c4b42c6..fa12c60a8 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -45,6 +45,7 @@ struct envfs_super {
 	uint16_t future;		/* reserved for future use */
 	uint32_t flags;			/* feature flags */
 #define ENVFS_FLAGS_FORCE_BUILT_IN	(1 << 0)
+#define ENVFS_FLAGS_SORTED		(1 << 1)
 	uint32_t sb_crc;		/* crc for the superblock */
 };
 
diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
index de57c2fce..3e7c736b9 100644
--- a/scripts/bareboxenv.c
+++ b/scripts/bareboxenv.c
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
 	int opt;
 	int save = 0, load = 0, pad = 0, err = 0, fd;
 	char *filename = NULL, *dirname = NULL;
-	unsigned envfs_flags = 0;
+	unsigned envfs_flags = ENVFS_FLAGS_SORTED;
 	int verbose = 0;
 
 	while((opt = getopt(argc, argv, "slp:vz")) != -1) {
-- 
2.19.2

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2018-12-18 13:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13 15:47 bareboxenv -s: output depends on filesystem Baeuerle, Florian
2018-12-17 10:53 ` Sascha Hauer
2018-12-18 13:22   ` [PATCH 1/2] recursive_action: add ACTION_SORT flag Baeuerle, Florian
2018-12-18 13:22     ` Baeuerle, Florian [this message]
2018-12-19 12:42     ` Baeuerle, Florian
2018-12-19 14:02     ` [PATCH v2 " Baeuerle, Florian
2018-12-19 14:02       ` [PATCH v2 2/2] envfs: new flag for sorting env before saving Baeuerle, Florian
2019-01-03 10:59       ` [PATCH v2 1/2] recursive_action: add ACTION_SORT flag Sascha Hauer
2019-01-03 11:53         ` Baeuerle, Florian
2019-01-07  7:58           ` s.hauer
2019-01-08  9:47             ` Baeuerle, Florian
2019-01-08  9:48               ` [PATCH 1/2] envfs: fix problem #1 Baeuerle, Florian
2019-01-08  9:48                 ` [PATCH 2/2] envfs: fix problem #2 Baeuerle, Florian
2019-01-08 15:40               ` [PATCH v2 1/2] recursive_action: add ACTION_SORT flag s.hauer

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=20181218132233.23669-2-florian.baeuerle@allegion.com \
    --to=florian.baeuerle@allegion.com \
    --cc=barebox@lists.infradead.org \
    /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