/* need to check parameters in calling vfs_write,
 * especially data buf 
 */
int scfs_make_header(struct dentry *scfs_dentry, struct inode *scfs_inode)
{
	struct scfs_sb_info *sbi = SCFS_S(scfs_inode->i_sb);
	struct file *lower_file = SCFS_I(scfs_inode)->lower_file;
	struct comp_footer cf;
	loff_t pos = 0;
	int ret;

	SCFS_DEBUG_START;

	if (!lower_file) {
		SCFS_PRINT_ERROR("lower_file is null\n");
		return SCFS_ERR_IO;
	}

	cf.footer_size = sizeof(struct comp_footer);
	cf.cluster_size = sbi->options.cluster_size;
	cf.original_file_size = 0;
	cf.comp_type = sbi->options.comp_type;
	cf.magic = SCFS_MAGIC;

	ret = scfs_lower_write(lower_file, (char *)&cf,
				sizeof(struct comp_footer), &pos);
	mark_inode_dirty_sync(scfs_inode); // why?

	if (ret < 0) {
		SCFS_PRINT_ERROR("error in writing header\n");
		return ret;
	}
	ret = 0;

	SCFS_DEBUG_END;

	return ret;
}
Exemple #2
0
int scfs_make_header(struct file *lower_file, struct inode *scfs_inode)
{
	struct scfs_sb_info *sbi = SCFS_S(scfs_inode->i_sb);
	struct comp_footer cf;
	loff_t pos = 0;
	int ret;

	if (!lower_file) {
		SCFS_PRINT_ERROR("lower_file is null\n");
		return -EIO;
	}

	cf.footer_size = CF_SIZE;
	cf.cluster_size = sbi->options.cluster_size;
	cf.original_file_size = 0;
	cf.comp_type = sbi->options.comp_type;
	cf.magic = SCFS_MAGIC;

	ret = scfs_lower_write(lower_file, (char *)&cf, CF_SIZE, &pos);
	mark_inode_dirty_sync(scfs_inode);

	if (ret < 0) {
		SCFS_PRINT_ERROR("error in writing header\n");
		return ret;
	}
	ret = 0;

	return ret;
}