integrate logfile checking with mount

(Logical change 1.672)
edge.strict_endians
void!yura 2005-01-30 18:13:25 +00:00
parent 036213cece
commit 3ca5f1fc5d
1 changed files with 42 additions and 0 deletions

View File

@ -550,6 +550,44 @@ error_exit:
return NULL;
}
/**
* ntfs_volume_check_logfile - check logfile on target volume
* @vol: volume on which to check logfile
*
* Return 0 on success and -1 on error with errno set error code.
*/
static int ntfs_volume_check_logfile(ntfs_volume *vol)
{
ntfs_inode *ni;
ntfs_attr *na = NULL;
int ret, err = 0;
if ((ni = ntfs_inode_open(vol, FILE_LogFile)) == NULL) {
Dprintf("Failed to open inode FILE_LogFile.\n");
errno = EIO;
return -1;
}
if ((na = ntfs_attr_open(ni, AT_DATA, AT_UNNAMED, 0)) == NULL) {
Dprintf("Failed to open $FILE_LogFile/$DATA\n");
ret = -1;
err = EIO;
goto exit;
}
if (ntfs_check_logfile(na) && ntfs_is_logfile_clean(na))
ret = 0;
else {
ret = -1;
err = EIO;
}
exit:
if (na)
ntfs_attr_close(na);
ntfs_inode_close(ni);
if (ret)
errno = err;
return ret;
}
/**
* ntfs_device_mount - open ntfs volume
* @dev: device to open
@ -915,6 +953,10 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long rwflag)
if (ntfs_inode_close(ni))
Dperror("Failed to close inode, leaking memory");
/* Check logfile. */
if (ntfs_volume_check_logfile(vol))
goto error_exit;
return vol;
io_error_exit:
errno = EIO;