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 <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Vinod Koul 2015-11-18 19:12:46 +05:30 committed by Takashi Iwai
parent 57ae61ce27
commit 9b09a3d500

View file

@ -260,7 +260,7 @@ int snd_tplg_build_file(snd_tplg_t *tplg, const char *infile,
int err = 0; int err = 0;
tplg->out_fd = 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) { if (tplg->out_fd < 0) {
SNDERR("error: failed to open %s err %d\n", SNDERR("error: failed to open %s err %d\n",
outfile, -errno); outfile, -errno);
@ -328,7 +328,7 @@ int snd_tplg_build(snd_tplg_t *tplg, const char *outfile)
int err; int err;
tplg->out_fd = 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) { if (tplg->out_fd < 0) {
SNDERR("error: failed to open %s err %d\n", SNDERR("error: failed to open %s err %d\n",
outfile, -errno); outfile, -errno);