Skip to content

Commit

Permalink
Bug #17023438 '/DEV/SDB1' NOT A REGULAR FILE
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gurusami committed Dec 2, 2013
1 parent f05ceca commit dfc103a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
5 changes: 3 additions & 2 deletions storage/innobase/include/os0file.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
43 changes: 27 additions & 16 deletions storage/innobase/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
Expand Down
3 changes: 2 additions & 1 deletion storage/innobase/srv/srv0start.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit dfc103a

Please sign in to comment.