Skip to contentSkip to conversation

topology: open topology files with O_TRUNC

PATCH Applied Vinod Koul 2 participants 2 messages Nov 18, 2015

lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

PATCH 1/1 topology: open topology files with O_TRUNC

The topology file if exists needs to rewritten, so we need to open these files with O_TRUNC flag as well

---
 src/topology/parser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/topology/parser.c +2 -2
index 18bb9c79f3a8..ee2545aada1b 100644
@@ -260,7 +260,7 @@ int snd_tplg_build_file(snd_tplg_t *tplg, const char *infile,
 	int err = 0;
 
 	tplg->out_fd =
-		open(outfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+		open(outfile, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR );
 	if (tplg->out_fd < 0) {
 		SNDERR("error: failed to open %s err %d\n",
 			outfile, -errno);
@@ -328,7 +328,7 @@ int snd_tplg_build(snd_tplg_t *tplg, const char *outfile)
 	int err;
 
 	tplg->out_fd =
-		open(outfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+		open(outfile, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
 	if (tplg->out_fd < 0) {
 		SNDERR("error: failed to open %s err %d\n",
 			outfile, -errno);
Signature · 1 line
1.9.1
Applied
#1 lore raw
Quoted 5 lines · Vinod Koul

The topology file if exists needs to rewritten, so we need to open these files with O_TRUNC flag as well

Applied, thanks.

Takashi

Quoted 29 lines
---
 src/topology/parser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/topology/parser.c +2 -2
index 18bb9c79f3a8..ee2545aada1b 100644
@@ -260,7 +260,7 @@ int snd_tplg_build_file(snd_tplg_t *tplg, const char *infile,
 	int err = 0;
 
 	tplg->out_fd =
-		open(outfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+		open(outfile, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR );
 	if (tplg->out_fd < 0) {
 		SNDERR("error: failed to open %s err %d\n",
 			outfile, -errno);
@@ -328,7 +328,7 @@ int snd_tplg_build(snd_tplg_t *tplg, const char *outfile)
 	int err;
 
 	tplg->out_fd =
-		open(outfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+		open(outfile, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
 	if (tplg->out_fd < 0) {
 		SNDERR("error: failed to open %s err %d\n",
 			outfile, -errno);
Signature · 1 line
1.9.1