From dfc103a0474d1d772b52cb03c71c2821a002d89c Mon Sep 17 00:00:00 2001 From: Annamalai Gurusami Date: Mon, 2 Dec 2013 13:52:59 +0530 Subject: [PATCH] Bug #17023438 '/DEV/SDB1' NOT A REGULAR FILE Problem: The function os_file_get_status() does not handle the raw block devices. Solution: Updated the function os_file_get_status() to handle the raw block devices. rb#3989 approved by Jimmy. --- storage/innobase/include/os0file.h | 5 ++-- storage/innobase/os/os0file.cc | 43 +++++++++++++++++++----------- storage/innobase/srv/srv0start.cc | 3 ++- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index ef7503ad45ff..fb2fd8ef9188 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -1,6 +1,6 @@ /*********************************************************************** -Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. Portions of this file contain modifications contributed and copyrighted @@ -381,7 +381,8 @@ enum os_file_type_t { OS_FILE_TYPE_UNKNOWN = 0, OS_FILE_TYPE_FILE, /* regular file */ OS_FILE_TYPE_DIR, /* directory */ - OS_FILE_TYPE_LINK /* symbolic link */ + OS_FILE_TYPE_LINK, /* symbolic link */ + OS_FILE_TYPE_BLOCK /* block device */ }; /* Maximum path string length in bytes when referring to tables with in the diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 9aa8b592301e..a9ad20ade4a5 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -3150,30 +3150,41 @@ os_file_get_status( return(DB_FAIL); - } else if (S_ISDIR(statinfo.st_mode)) { + } + + switch (statinfo.st_mode & S_IFMT) { + case S_IFDIR: stat_info->type = OS_FILE_TYPE_DIR; - } else if (S_ISLNK(statinfo.st_mode)) { + break; + case S_IFLNK: stat_info->type = OS_FILE_TYPE_LINK; - } else if (S_ISREG(statinfo.st_mode)) { + break; + case S_IFBLK: + stat_info->type = OS_FILE_TYPE_BLOCK; + break; + case S_IFREG: stat_info->type = OS_FILE_TYPE_FILE; + break; + default: + stat_info->type = OS_FILE_TYPE_UNKNOWN; + } - if (check_rw_perm) { - int fh; - int access; - access = !srv_read_only_mode ? O_RDWR : O_RDONLY; + if (check_rw_perm && (stat_info->type == OS_FILE_TYPE_FILE + || stat_info->type == OS_FILE_TYPE_BLOCK)) { + int fh; + int access; - fh = ::open(path, access, os_innodb_umask); + access = !srv_read_only_mode ? O_RDWR : O_RDONLY; - if (fh == -1) { - stat_info->rw_perm = false; - } else { - stat_info->rw_perm = true; - close(fh); - } + fh = ::open(path, access, os_innodb_umask); + + if (fh == -1) { + stat_info->rw_perm = false; + } else { + stat_info->rw_perm = true; + close(fh); } - } else { - stat_info->type = OS_FILE_TYPE_UNKNOWN; } #endif /* _WIN_ */ diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 00604a896ca2..0bea5cb61fff 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -218,7 +218,8 @@ srv_file_check_mode( /* Note: stat.rw_perm is only valid of files */ - if (stat.type == OS_FILE_TYPE_FILE) { + if (stat.type == OS_FILE_TYPE_FILE + || stat.type == OS_FILE_TYPE_BLOCK) { if (!stat.rw_perm) { ib_logf(IB_LOG_LEVEL_ERROR,