[Ocfs2-tools-devel] [PATCH] return err when ocfs2_get_device_sectsize() can not determine sector size
Sunil Mushran
sunil.mushran at oracle.com
Sat Mar 7 09:11:06 PST 2009
Other than the spelling typo below, it looks ok.
On Sat, Mar 07, 2009 at 09:48:26PM +0800, Coly Li wrote:
> This patch is modified from "[PATCH] libocfs2: check sectsize after return from
> ocfs2_get_device_sectsize()" with Joel's suggestion.
>
>
> 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 adds a new error code OCFS2_ET_CANNOT_DETERMINE_SECTOR_SIZE, when
> ocfs2_get_device_sectsize() can not determine sector size, just returns this
> error code.
>
> Signed-off-by: Coly Li <coly.li at suse.de>
> Cc: Joel Becker <Joel.Becker at oracle.com>
> ---
> libocfs2/getsectsize.c | 11 +++++------
> libocfs2/ocfs2_err.et | 3 +++
> 2 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/libocfs2/getsectsize.c b/libocfs2/getsectsize.c
> index 937baa6..c487733 100644
> --- a/libocfs2/getsectsize.c
> +++ b/libocfs2/getsectsize.c
> @@ -45,6 +45,7 @@
> errcode_t ocfs2_get_device_sectsize(const char *file, int *sectsize)
> {
> int fd;
> + int ret;
>
> #ifdef HAVE_OPEN64
> fd = open64(file, O_RDONLY);
> @@ -54,15 +55,13 @@ errcode_t ocfs2_get_device_sectsize(const char *file, int
> *sectsize)
> if (fd < 0)
> return errno;
>
> + ret = OCFS2_ET_CANNOT_DETERMINE_SECTOR_SIZE;
> #ifdef BLKSSZGET
> - if (ioctl(fd, BLKSSZGET, sectsize) >= 0) {
> - close(fd);
> - return 0;
> - }
> + if (ioctl(fd, BLKSSZGET, sectsize) >= 0)
> + ret = 0;
> #endif
> - *sectsize = 0;
> close(fd);
> - return 0;
> + return ret;
> }
>
> #ifdef DEBUG_EXE
> diff --git a/libocfs2/ocfs2_err.et b/libocfs2/ocfs2_err.et
> index b169ec7..13ea933 100644
> --- a/libocfs2/ocfs2_err.et
> +++ b/libocfs2/ocfs2_err.et
> @@ -181,4 +181,7 @@ ec OCFS2_ET_UNKNOWN_FEATURE,
> ec OCFS2_ET_BAD_DIR_BLOCK_MAGIC,
> "Bad magic number in directory block"
>
> +ec OCFS2_ET_CANNOT_DETERMINE_SECTOR_SIZE,
> + "Can not determine sector size"
Cannot is one word.
> +
> end
> --
> Coly Li
> SuSE Labs
>
>
>
> _______________________________________________
> Ocfs2-tools-devel mailing list
> Ocfs2-tools-devel at oss.oracle.com
> http://oss.oracle.com/mailman/listinfo/ocfs2-tools-devel
More information about the Ocfs2-tools-devel
mailing list