1
1
/* ****************************************************************************
2
2
3
- Copyright (c) 1995, 2015 , Oracle and/or its affiliates. All Rights Reserved.
3
+ Copyright (c) 1995, 2016 , Oracle and/or its affiliates. All Rights Reserved.
4
4
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
@@ -3047,8 +3047,6 @@ fil_create_link_file(
3047
3047
const char * tablename, /* !< in: tablename */
3048
3048
const char * filepath) /* !< in: pathname of tablespace */
3049
3049
{
3050
- os_file_t file;
3051
- ibool success;
3052
3050
dberr_t err = DB_SUCCESS;
3053
3051
char * link_filepath;
3054
3052
char * prev_filepath = fil_read_link_file (tablename);
@@ -3067,13 +3065,24 @@ fil_create_link_file(
3067
3065
3068
3066
link_filepath = fil_make_isl_name (tablename);
3069
3067
3070
- file = os_file_create_simple_no_error_handling (
3071
- innodb_file_data_key, link_filepath,
3072
- OS_FILE_CREATE, OS_FILE_READ_WRITE, &success);
3068
+ /* * Check if the file already exists. */
3069
+ FILE* file = NULL ;
3070
+ ibool exists;
3071
+ os_file_type_t ftype;
3073
3072
3074
- if (!success) {
3075
- /* The following call will print an error message */
3076
- ulint error = os_file_get_last_error (true );
3073
+ bool success = os_file_status (link_filepath, &exists, &ftype);
3074
+
3075
+ ulint error = 0 ;
3076
+ if (success && !exists) {
3077
+ file = fopen (link_filepath, " w" );
3078
+ if (file == NULL ) {
3079
+ /* This call will print its own error message */
3080
+ error = os_file_get_last_error (true );
3081
+ }
3082
+ } else {
3083
+ error = OS_FILE_ALREADY_EXISTS;
3084
+ }
3085
+ if (error != 0 ) {
3077
3086
3078
3087
ut_print_timestamp (stderr);
3079
3088
fputs (" InnoDB: Cannot create file " , stderr);
@@ -3098,13 +3107,17 @@ fil_create_link_file(
3098
3107
return (err);
3099
3108
}
3100
3109
3101
- if (!os_file_write (link_filepath, file, filepath, 0 ,
3102
- strlen (filepath))) {
3110
+ ulint rbytes = fwrite (filepath, 1 , strlen (filepath), file);
3111
+ if (rbytes != strlen (filepath)) {
3112
+ os_file_get_last_error (true );
3113
+ ib_logf (IB_LOG_LEVEL_ERROR,
3114
+ " cannot write link file "
3115
+ " %s" ,filepath);
3103
3116
err = DB_ERROR;
3104
3117
}
3105
3118
3106
3119
/* Close the file, we only need it at startup */
3107
- os_file_close (file);
3120
+ fclose (file);
3108
3121
3109
3122
mem_free (link_filepath);
3110
3123
0 commit comments