Skip to content
Snippets Groups Projects
Commit 24b8329a authored by Marek Vavrusa's avatar Marek Vavrusa
Browse files

Recommited patch to allow recreation of journal files.

parent d1bfab29
Branches
Tags
No related merge requests found
......@@ -434,6 +434,12 @@ journal_t* journal_open(const char *fn, size_t fslimit, int mode, uint16_t bflag
/* Open journal file for r/w (returns error if not exists). */
int fd = open(fn, O_RDWR);
if (fd < 0) {
if (errno == ENOENT) {
if(journal_create(fn, JOURNAL_NCOUNT) == KNOTD_EOK) {
return journal_open(fn, fslimit, mode, bflags);
}
}
return NULL;
}
......@@ -479,8 +485,10 @@ journal_t* journal_open(const char *fn, size_t fslimit, int mode, uint16_t bflag
"it will be flushed.\n", fn);
fcntl(fd, F_SETLK, &fl);
close(fd);
journal_create(fn, JOURNAL_NCOUNT);
return journal_open(fn, fslimit, mode, bflags);
if (journal_create(fn, JOURNAL_NCOUNT) == KNOTD_EOK) {
return journal_open(fn, fslimit, mode, bflags);
}
return NULL;
}
crc_t crc = 0;
if (!sfread(&crc, sizeof(crc_t), fd)) {
......@@ -506,8 +514,10 @@ journal_t* journal_open(const char *fn, size_t fslimit, int mode, uint16_t bflag
"it will be flushed.\n", fn);
fcntl(fd, F_SETLK, &fl);
close(fd);
journal_create(fn, JOURNAL_NCOUNT);
return journal_open(fn, fslimit, mode, bflags);
if (journal_create(fn, JOURNAL_NCOUNT) == KNOTD_EOK) {
return journal_open(fn, fslimit, mode, bflags);
}
return NULL;
}
/* Check for lazy mode. */
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment