diff options
author | marko@hundin.mysql.fi <> | 2004-05-05 15:54:28 +0300 |
---|---|---|
committer | marko@hundin.mysql.fi <> | 2004-05-05 15:54:28 +0300 |
commit | d15b0b577d9bc4a6827d1f679d09eb27e3186a36 (patch) | |
tree | d39c68b7ae22c2cf5072e992e03afcf12836d64b | |
parent | e51887b05082622a1882217b7f8ec8ae7f6b4598 (diff) | |
download | mariadb-git-d15b0b577d9bc4a6827d1f679d09eb27e3186a36.tar.gz |
InnoDB portability fix: new function os_file_set_eof()
-rw-r--r-- | innobase/include/os0file.h | 8 | ||||
-rw-r--r-- | innobase/os/os0file.c | 17 | ||||
-rw-r--r-- | innobase/srv/srv0srv.c | 6 | ||||
-rw-r--r-- | sql/ha_innodb.cc | 2 |
4 files changed, 27 insertions, 6 deletions
diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h index 108cf5520f1..de17e2302ae 100644 --- a/innobase/include/os0file.h +++ b/innobase/include/os0file.h @@ -227,6 +227,14 @@ os_file_set_size( size */ ulint size_high);/* in: most significant 32 bits of size */ /*************************************************************************** +Truncates a file at its current position. */ + +ibool +os_file_set_eof( +/*============*/ + /* out: TRUE if success */ + FILE* file); /* in: file to be truncated */ +/*************************************************************************** Flushes the write buffers of a given file to the disk. */ ibool diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 904ddf13c8f..833703e38dd 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -1032,6 +1032,23 @@ error_handling: } /*************************************************************************** +Truncates a file at its current position. */ + +ibool +os_file_set_eof( +/*============*/ + /* out: TRUE if success */ + FILE* file) /* in: file to be truncated */ +{ +#ifdef __WIN__ + HANDLE h = (HANDLE) _get_osfhandle(fileno(file)); + return(SetEndOfFile(h)); +#else /* __WIN__ */ + return(!ftruncate(fileno(file), ftell(file))); +#endif /* __WIN__ */ +} + +/*************************************************************************** Flushes the write buffers of a given file to the disk. */ ibool diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 76197fd8fe0..ba1f72d0a58 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -1609,11 +1609,7 @@ loop: mutex_enter(&srv_monitor_file_mutex); rewind(srv_monitor_file); srv_printf_innodb_monitor(srv_monitor_file); -#ifdef __WIN__ - chsize(fileno(srv_monitor_file), ftell(srv_monitor_file)); -#else /* __WIN__ */ - ftruncate(fileno(srv_monitor_file), ftell(srv_monitor_file)); -#endif /* __WIN__ */ + os_file_set_eof(srv_monitor_file); mutex_exit(&srv_monitor_file_mutex); if (srv_print_innodb_tablespace_monitor diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 690e83b2a4b..ac7ccf5c11a 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -4648,7 +4648,7 @@ innodb_show_status( rewind(srv_monitor_file); srv_printf_innodb_monitor(srv_monitor_file); flen = ftell(srv_monitor_file); - my_chsize(fileno(srv_monitor_file), flen, 0, MYF(0)); + os_file_set_eof(srv_monitor_file); if(flen > 64000 - 1) { flen = 64000 - 1; } |