Use make_bak_dir() if we get ENOENT while trying to open an
authorWayne Davison <wayned@samba.org>
Sun, 23 Sep 2007 19:45:22 +0000 (19:45 +0000)
committerWayne Davison <wayned@samba.org>
Sun, 23 Sep 2007 19:45:22 +0000 (19:45 +0000)
inplace backup file.

generator.c

index f711ffdbee572f733b0c04a91674a80f105100ac..271b55faba9faf757200c55cbec65eed31c553dd 100644 (file)
@@ -1709,8 +1709,9 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                        close(fd);
                        goto cleanup;
                }
-               if ((f_copy = do_open(backupptr,
-                   O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600)) < 0) {
+               if ((f_copy = do_open(backupptr, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600)) < 0
+                && (errno != ENOENT || make_bak_dir(backupptr) < 0
+                 || (f_copy = do_open(backupptr, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600)) < 0)) {
                        rsyserr(FERROR, errno, "open %s",
                                full_fname(backupptr));
                        unmake_file(back_file);