mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/3] commands: teach commands that write to files to also create them
Date: Thu,  9 Aug 2018 10:33:13 +0200	[thread overview]
Message-ID: <20180809083313.13034-3-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20180809083313.13034-1-u.kleine-koenig@pengutronix.de>

This allows to use the adapted commands on non-existing files which
failed before with

	open: No such file or directory

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 commands/memset.c | 2 +-
 commands/mm.c     | 2 +-
 commands/mw.c     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/commands/memset.c b/commands/memset.c
index f871e07c9523..f99bf86c0415 100644
--- a/commands/memset.c
+++ b/commands/memset.c
@@ -56,7 +56,7 @@ static int do_memset(int argc, char *argv[])
 	c = strtoull_suffix(argv[optind + 1], NULL, 0);
 	n = strtoull_suffix(argv[optind + 2], NULL, 0);
 
-	fd = open_and_lseek(file, mode | O_WRONLY, s);
+	fd = open_and_lseek(file, mode | O_WRONLY | O_CREAT, s);
 	if (fd < 0)
 		return 1;
 
diff --git a/commands/mm.c b/commands/mm.c
index 6d2a88789299..c7f62fca54bb 100644
--- a/commands/mm.c
+++ b/commands/mm.c
@@ -53,7 +53,7 @@ static int do_mem_mm(int argc, char *argv[])
 	value = simple_strtoull(argv[optind++], NULL, 0);
 	mask = simple_strtoull(argv[optind++], NULL, 0);
 
-	fd = open_and_lseek(filename, mode | O_RDWR, adr);
+	fd = open_and_lseek(filename, mode | O_RDWR | O_CREAT, adr);
 	if (fd < 0)
 		return 1;
 
diff --git a/commands/mw.c b/commands/mw.c
index 7ff589abb1d4..2912997a31df 100644
--- a/commands/mw.c
+++ b/commands/mw.c
@@ -52,7 +52,7 @@ static int do_mem_mw(int argc, char *argv[])
 
 	adr = strtoull_suffix(argv[optind++], NULL, 0);
 
-	fd = open_and_lseek(filename, mode | O_WRONLY, adr);
+	fd = open_and_lseek(filename, mode | O_WRONLY | O_CREAT, adr);
 	if (fd < 0)
 		return 1;
 
-- 
2.18.0


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

      parent reply	other threads:[~2018-08-09  8:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09  8:33 [PATCH 1/3] libfile: open_and_lseek: don't imply O_RDONLY Uwe Kleine-König
2018-08-09  8:33 ` [PATCH 2/3] libfile: open_and_lseek: enlarge small files enough to make lseek possible Uwe Kleine-König
2018-08-10  6:22   ` Sascha Hauer
2018-08-10  7:14     ` Uwe Kleine-König
2018-08-09  8:33 ` Uwe Kleine-König [this message]

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=20180809083313.13034-3-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --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