1/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
2 Copyright (c) 2009, 2016, MariaDB
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
17#include "mysys_priv.h"
18#include "mysys_err.h"
19
20#ifndef SHARED_LIBRARY
21
22const char *globerrs[GLOBERRS]=
23{
24 "Can't create/write to file '%s' (Errcode: %M)",
25 "Error reading file '%s' (Errcode: %M)",
26 "Error writing file '%s' (Errcode: %M)",
27 "Error on close of '%s' (Errcode: %M)",
28 "Out of memory (Needed %u bytes)",
29 "Error on delete of '%s' (Errcode: %M)",
30 "Error on rename of '%s' to '%s' (Errcode: %M)",
31 "",
32 "Unexpected end-of-file found when reading file '%s' (Errcode: %M)",
33 "Can't lock file (Errcode: %M)",
34 "Can't unlock file (Errcode: %M)",
35 "Can't read dir of '%s' (Errcode: %M)",
36 "Can't get stat of '%s' (Errcode: %M)",
37 "Can't change size of file (Errcode: %M)",
38 "Can't open stream from handle (Errcode: %M)",
39 "Can't get working directory (Errcode: %M)",
40 "Can't change dir to '%s' (Errcode: %M)",
41 "Warning: '%s' had %d links",
42 "Warning: %d files and %d streams is left open\n",
43 "Disk is full writing '%s' (Errcode: %M). Waiting for someone to free space... (Expect up to %d secs delay for server to continue after freeing disk space)",
44 "Can't create directory '%s' (Errcode: %M)",
45 "Character set '%s' is not a compiled character set and is not specified in the '%s' file",
46 "Out of resources when opening file '%s' (Errcode: %M)",
47 "Can't read value for symlink '%s' (Errcode: %M)",
48 "Can't create symlink '%s' pointing at '%s' (Errcode: %M)",
49 "Error on realpath() on '%s' (Errcode: %M)",
50 "Can't sync file '%s' to disk (Errcode: %M)",
51 "Collation '%s' is not a compiled collation and is not specified in the '%s' file",
52 "File '%s' not found (Errcode: %M)",
53 "File '%s' (fileno: %d) was not closed",
54 "Can't change ownership of the file '%s' (Errcode: %M)",
55 "Can't change permissions of the file '%s' (Errcode: %M)",
56 "Can't seek in file '%s' (Errcode: %M)",
57 "Can't change mode for file '%s' to 0x%lx (Errcode: %M)",
58 "Warning: Can't copy ownership for file '%s' (Errcode: %M)"
59};
60
61void init_glob_errs(void)
62{
63 /* This is now done statically. */
64}
65
66#else
67
68void init_glob_errs()
69{
70 EE(EE_CANTCREATEFILE) = "Can't create/write to file '%s' (Errcode: %M)";
71 EE(EE_READ) = "Error reading file '%s' (Errcode: %M)";
72 EE(EE_WRITE) = "Error writing file '%s' (Errcode: %M)";
73 EE(EE_BADCLOSE) = "Error on close of '%'s (Errcode: %M)";
74 EE(EE_OUTOFMEMORY) = "Out of memory (Needed %u bytes)";
75 EE(EE_DELETE) = "Error on delete of '%s' (Errcode: %M)";
76 EE(EE_LINK) = "Error on rename of '%s' to '%s' (Errcode: %M)";
77 EE(EE_EOFERR) = "Unexpected eof found when reading file '%s' (Errcode: %M)";
78 EE(EE_CANTLOCK) = "Can't lock file (Errcode: %M)";
79 EE(EE_CANTUNLOCK) = "Can't unlock file (Errcode: %M)";
80 EE(EE_DIR) = "Can't read dir of '%s' (Errcode: %M)";
81 EE(EE_STAT) = "Can't get stat of '%s' (Errcode: %M)";
82 EE(EE_CANT_CHSIZE) = "Can't change size of file (Errcode: %M)";
83 EE(EE_CANT_OPEN_STREAM)= "Can't open stream from handle (Errcode: %M)";
84 EE(EE_GETWD) = "Can't get working directory (Errcode: %M)";
85 EE(EE_SETWD) = "Can't change dir to '%s' (Errcode: %M)";
86 EE(EE_LINK_WARNING) = "Warning: '%s' had %d links";
87 EE(EE_OPEN_WARNING) = "Warning: %d files and %d streams is left open\n";
88 EE(EE_DISK_FULL) = "Disk is full writing '%s' (Errcode: %M). Waiting for someone to free space... (Expect up to %d secs delay for server to continue after freeing disk space)",
89 EE(EE_CANT_MKDIR) ="Can't create directory '%s' (Errcode: %M)";
90 EE(EE_UNKNOWN_CHARSET)= "Character set '%s' is not a compiled character set and is not specified in the %s file";
91 EE(EE_OUT_OF_FILERESOURCES)="Out of resources when opening file '%s' (Errcode: %M)";
92 EE(EE_CANT_READLINK)= "Can't read value for symlink '%s' (Errcode: %M)";
93 EE(EE_CANT_SYMLINK)= "Can't create symlink '%s' pointing at '%s' (Errcode: %M)";
94 EE(EE_REALPATH)= "Error on realpath() on '%s' (Errcode: %M)";
95 EE(EE_SYNC)= "Can't sync file '%s' to disk (Errcode: %M)";
96 EE(EE_UNKNOWN_COLLATION)= "Collation '%s' is not a compiled collation and is not specified in the %s file";
97 EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %M)";
98 EE(EE_FILE_NOT_CLOSED) = "File '%s' (fileno: %d) was not closed";
99 EE(EE_CHANGE_OWNERSHIP) = "Can't change ownership of the file '%s' (Errcode: %M)";
100 EE(EE_CHANGE_PERMISSIONS) = "Can't change permissions of the file '%s' (Errcode: %M)";
101 EE(EE_CANT_SEEK) = "Can't seek in file '%s' (Errcode: %M)";
102 EE(EE_CANT_CHMOD) = "Can't change mode for file '%s' to 0x%lx (Errcode: %M)";
103 EE(EE_CANT_COPY_OWNERSHIP)= "Warning: Can't copy ownership for file '%s' (Errcode: %M)";
104}
105#endif
106
107void wait_for_free_space(const char *filename, int errors)
108{
109 if (errors == 0)
110 my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH | ME_JUST_WARNING),
111 filename,my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
112 if (!(errors % MY_WAIT_GIVE_USER_A_MESSAGE))
113 my_printf_error(EE_DISK_FULL,
114 "Retry in %d secs. Message reprinted in %d secs",
115 MYF(ME_BELL | ME_NOREFRESH | ME_JUST_WARNING),
116 MY_WAIT_FOR_USER_TO_FIX_PANIC,
117 MY_WAIT_GIVE_USER_A_MESSAGE * MY_WAIT_FOR_USER_TO_FIX_PANIC );
118 (void) sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC);
119}
120
121const char **get_global_errmsgs(int nr __attribute__((unused)))
122{
123 return globerrs;
124}
125