]> git.alsa-project.org Git - alsa-lib.git/commitdiff
topology: open topology files with O_TRUNC
authorVinod Koul <vinod.koul@intel.com>
Wed, 18 Nov 2015 13:42:46 +0000 (19:12 +0530)
committerTakashi Iwai <tiwai@suse.de>
Wed, 18 Nov 2015 13:54:49 +0000 (14:54 +0100)
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>
src/topology/parser.c

index 18bb9c79f3a8bcc0259c429797875c492e1bf8c5..e6798be9b79abf7598f1b979600d5139bb6f97b1 100644 (file)
@@ -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);