diff options
author | unknown <monty@mysql.com/narttu.mysql.fi> | 2008-01-03 09:45:46 +0200 |
---|---|---|
committer | unknown <monty@mysql.com/narttu.mysql.fi> | 2008-01-03 09:45:46 +0200 |
commit | c719e1fd335f20bc068e3174cea097101ab4cf2a (patch) | |
tree | 5f706a3316f1cd3eee945fc5c444d6ba2039428b /mysys | |
parent | f8b3e118ba6511c9c20993ccf5604a6890daffd6 (diff) | |
download | mariadb-git-c719e1fd335f20bc068e3174cea097101ab4cf2a.tar.gz |
Added wrapper for chmod(): my_chmod()
Automaticly disable ma_test_recovery if not compiled with debugging. This fixes that make test works in Maria.
Fixed wrong merge of ma_init.c from 5.1
Portability fixes:
- Use my_chmod() instead of my_chmod()
- Use my_access() instead of my_stat() to test if file exists
- Don't test result value of pthread_mutex_lock() and pthread_mutex_unlock() as this is not portable
- No reason to test if file exists before we delete it
include/my_sys.h:
Added my_chmod
include/mysys_err.h:
Added error for my_chmod
mysys/Makefile.am:
Added my_chmod
mysys/errors.c:
Added error for my_chmod
mysys/my_init.c:
Syncronize with 5.1 to fix setting of QueryPerformanceFrequency()
storage/maria/ma_test1.c:
Changed short option of --skip-delete and --skip-update to be more logical
storage/maria/ma_test_recovery.expected:
Updated results after adding more tests
storage/maria/ma_test_recovery:
Abort test nicely if we are runnning without debugging
Added more tests
Changed temporary file names so that one can run maria_chk on them
Removed some old comments
storage/maria/maria_read_log.c:
Added note if maria_read_log will not be able to create byte-to-byte identical tables compared to normal execution
storage/maria/unittest/ma_pagecache_consist.c:
Removed wrong setting of buff that caused memory overwrite
Use my_chmod() instead of chmod()
Don't test result value of pthread_mutex_lock() and pthread_mutex_unlock() as this is not portable
storage/maria/unittest/ma_pagecache_single.c:
Use my_chmod() instead of chmod()
Don't test result value of pthread_mutex_lock() and pthread_mutex_unlock() as this is not portable
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
No reason to test if file exists before we delete it
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Don't test result value of pthread_mutex_lock() and pthread_mutex_unlock() as this is not portable
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
No reason to test if file exists before we delete it
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Use my_access() instead of my_stat() to test if file exists
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
No reason to test if file exists before we delete it
chmod -> my_chmod
mysys/my_chmod.c:
Added wrapper for chmod()
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/Makefile.am | 2 | ||||
-rw-r--r-- | mysys/errors.c | 4 | ||||
-rw-r--r-- | mysys/my_chmod.c | 48 | ||||
-rw-r--r-- | mysys/my_init.c | 45 |
4 files changed, 76 insertions, 23 deletions
diff --git a/mysys/Makefile.am b/mysys/Makefile.am index 10200fde8be..27cae5c6363 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -45,7 +45,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \ tree.c trie.c list.c hash.c array.c string.c typelib.c \ my_copy.c my_append.c my_lib.c \ my_delete.c my_rename.c my_redel.c \ - my_chsize.c my_clock.c \ + my_chsize.c my_chmod.c my_clock.c \ my_quick.c my_lockmem.c my_static.c \ my_sync.c my_getopt.c my_mkdir.c \ default_modify.c default.c \ diff --git a/mysys/errors.c b/mysys/errors.c index 889cf6d7fe3..db63667fb77 100644 --- a/mysys/errors.c +++ b/mysys/errors.c @@ -49,7 +49,8 @@ const char * NEAR globerrs[GLOBERRS]= "Can't sync file '%s' to disk (Errcode: %d)", "Collation '%s' is not a compiled collation and is not specified in the '%s' file", "File '%s' not found (Errcode: %d)", - "File '%s' (fileno: %d) was not closed" + "File '%s' (fileno: %d) was not closed", + "Can't change mode for file '%s' to 0x%lx (Error: %d)" }; void init_glob_errs(void) @@ -90,5 +91,6 @@ void init_glob_errs() EE(EE_UNKNOWN_COLLATION)= "Collation '%s' is not a compiled collation and is not specified in the %s file"; EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %d)"; EE(EE_FILE_NOT_CLOSED) = "File '%s' (fileno: %d) was not closed"; + EE(EE_CANT_CHMOD) = "Can't change mode for file '%s' to 0x%lx (Error: %d)"; } #endif diff --git a/mysys/my_chmod.c b/mysys/my_chmod.c new file mode 100644 index 00000000000..afdea758833 --- /dev/null +++ b/mysys/my_chmod.c @@ -0,0 +1,48 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "mysys_priv.h" +#include "mysys_err.h" + +/** + @brief Change mode of file. + + @fn my_chmod() + @param name Filename + @param mode_t Mode + @param my_flags Flags + + @notes + The mode of the file given by path or referenced by fildes is changed + + @retval 0 Ok + @retval # Error +*/ + +int my_chmod(const char *name, mode_t mode, myf my_flags) +{ + DBUG_ENTER("my_chmod"); + DBUG_PRINT("my",("name: %s mode: %lu flags: %d", name, (ulong) mode, + my_flags)); + + if (chmod(name, mode)) + { + my_errno= errno; + if (my_flags & MY_WME) + my_error(EE_CANT_CHMOD, MYF(0), name, (ulong) mode, my_errno); + DBUG_RETURN(1); + } + DBUG_RETURN(0); +} diff --git a/mysys/my_init.c b/mysys/my_init.c index 145a435b4b6..a153275f87e 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -356,6 +356,30 @@ static void my_win_init(void) _tzset(); + /* The following is used by time functions */ +#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10) +#define MS 10000000 + { + FILETIME ft; + LARGE_INTEGER li, t_cnt; + DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency)); + if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency) == 0) + query_performance_frequency= 0; + else + { + GetSystemTimeAsFileTime(&ft); + li.LowPart= ft.dwLowDateTime; + li.HighPart= ft.dwHighDateTime; + query_performance_offset= li.QuadPart-OFFSET_TO_EPOC; + QueryPerformanceCounter(&t_cnt); + query_performance_offset-= (t_cnt.QuadPart / + query_performance_frequency * MS + + t_cnt.QuadPart % + query_performance_frequency * MS / + query_performance_frequency); + } + } + /* apre la chiave HKEY_LOCAL_MACHINES\software\MySQL */ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,(LPCTSTR)targetKey,0, KEY_READ,&hSoftMysql) != ERROR_SUCCESS) @@ -393,27 +417,6 @@ static void my_win_init(void) /* chiude la chiave */ RegCloseKey(hSoftMysql) ; - /* The following is used by time functions */ -#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10) -#define MS 10000000 - { - FILETIME ft; - LARGE_INTEGER li, t_cnt; - DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency)); - if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency)) - query_performance_frequency= 0; - else - { - GetSystemTimeAsFileTime(&ft); - li.LowPart= ft.dwLowDateTime; - li.HighPart= ft.dwHighDateTime; - query_performance_offset= li.QuadPart-OFFSET_TO_EPOC; - QueryPerformanceCounter(&t_cnt); - query_performance_offset-= (t_cnt.QuadPart / query_performance_frequency * MS + - t_cnt.QuadPart % query_performance_frequency * MS / - query_performance_frequency); - } - } DBUG_VOID_RETURN ; } |