Oops when bad ef_type or uid is written to disk
This commit is contained in:
parent
5490782db3
commit
99594c1898
1 changed files with 16 additions and 1 deletions
|
@ -342,13 +342,28 @@ fillcache(struct empfile *ep, int start)
|
||||||
static int
|
static int
|
||||||
do_write(struct empfile *ep, void *buf, int id, int count)
|
do_write(struct empfile *ep, void *buf, int id, int count)
|
||||||
{
|
{
|
||||||
int n, ret;
|
int i, n, ret;
|
||||||
char *p;
|
char *p;
|
||||||
|
struct emptypedstr *elt;
|
||||||
|
|
||||||
if (CANT_HAPPEN(ep->fd < 0 || (ep->flags & EFF_PRIVATE)
|
if (CANT_HAPPEN(ep->fd < 0 || (ep->flags & EFF_PRIVATE)
|
||||||
|| id < 0 || count < 0))
|
|| id < 0 || count < 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (ep->flags & EFF_TYPED) {
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
/*
|
||||||
|
* TODO Oopses here could be due to bad data corruption.
|
||||||
|
* Fail instead of attempting to recover?
|
||||||
|
*/
|
||||||
|
elt = (struct emptypedstr *)((char *)buf + i * ep->size);
|
||||||
|
if (CANT_HAPPEN(elt->ef_type != ep->uid))
|
||||||
|
elt->ef_type = ep->uid;
|
||||||
|
if (CANT_HAPPEN(elt->uid != id + i))
|
||||||
|
elt->uid = id + i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (lseek(ep->fd, id * ep->size, SEEK_SET) == (off_t)-1) {
|
if (lseek(ep->fd, id * ep->size, SEEK_SET) == (off_t)-1) {
|
||||||
logerror("Error seeking %s (%s)", ep->file, strerror(errno));
|
logerror("Error seeking %s (%s)", ep->file, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue