[Ocfs2-tools-devel] [PATCH] libocfs2: check sectsize after return from ocfs2_get_device_sectsize()
Joel Becker
Joel.Becker at oracle.com
Wed Mar 4 18:09:07 PST 2009
On Fri, Feb 27, 2009 at 06:02:10PM +0800, Coly Li wrote:
> In ocfs2_get_device_sectsize(), if BLKSSZGET is undefined, *sectsize is set to 0. This is
> problematic in ocfs2_fill_heartbeat_desc() where
> sectsize_bits = ffs(sectsize) - 1;
> will gets sectsize_bits to be ~0. Though the execution flow is safe, the logic is not correct.
>
> This patch check paramter sectsize after return from ocfs2_get_device_sectsize(), if sectsize is set
> to 0, goto leave.
ocfs2_get_device_sectsize() is our own code. In fact, it claims
to return an errcode_t when it does not.
I'd rather you define a new error in ocfs2_err.et
OCFS2_ET_CANNOT_DETERMINE_SECTOR_SIZE. Then have
ocfs2_get_device_sectsize() return that for all errors (open(2) and
ioctl(2)). That way, you don't have to change heartbeat.c at all.
Joel
--
Life's Little Instruction Book #24
"Drink champagne for no reason at all."
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
More information about the Ocfs2-tools-devel
mailing list