From: Vinod Koul Date: Wed, 18 Nov 2015 13:42:46 +0000 (+0530) Subject: topology: open topology files with O_TRUNC X-Git-Tag: v1.1.1~29 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=9b09a3d500ff4d29f39d09ec2ba82b0ee561b217;p=alsa-lib.git 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 Signed-off-by: Vinod Koul Signed-off-by: Takashi Iwai --- diff --git a/src/topology/parser.c b/src/topology/parser.c index 18bb9c79..e6798be9 100644 --- a/src/topology/parser.c +++ b/src/topology/parser.c @@ -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);