Re: [PATCH, REWORKED 01/11] Add initial checksum support for the gdt_checksum/uninit_group feature

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mar 17, 2008  09:28 -0400, Theodore Ts'o wrote:
> +STATIC __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group)
> +{
> +	__u16 crc = 0;
> +	struct ext2_group_desc *desc;
> +
> +	desc = &fs->group_desc[group];
> +
> +	if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) {
> +		int offset = offsetof(struct ext2_group_desc, bg_checksum);
> +
> +#ifdef WORDS_BIGENDIAN
> +		struct ext2_group_desc swabdesc = *desc;
> +
> +		/* Have to swab back to little-endian to do the checksum */
> +		ext2fs_swap_group_desc(&swabdesc);
> +		desc = &swabdesc;
> +
> +		group = ext2fs_swab32(group);
> +#endif
> +		crc = crc16(~0, fs->super->s_uuid, sizeof(fs->super->s_uuid));
> +		crc = crc16(crc, &group, sizeof(group));
> +		crc = crc16(crc, desc, offset);
> +		offset += sizeof(desc->bg_checksum); /* skip checksum */
> +		assert(offset == sizeof(*desc));

Note that this assertion needs to be removed when the group descriptor
becomes larger, unless ext2_group_desc never changes in the future..

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux