diff options
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/mf_iocache.c | 12 | ||||
-rw-r--r-- | mysys/mf_iocache2.c | 14 | ||||
-rw-r--r-- | mysys/my_chsize.c | 8 | ||||
-rw-r--r-- | mysys/raid.cc | 17 |
4 files changed, 36 insertions, 15 deletions
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index b6e721cbd57..a4bf09ef7a7 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -123,7 +123,8 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, uint min_cache; my_off_t end_of_file= ~(my_off_t) 0; DBUG_ENTER("init_io_cache"); - DBUG_PRINT("enter",("type: %d pos: %ld",(int) type, (ulong) seek_offset)); + DBUG_PRINT("enter",("cache: %lx type: %d pos: %ld", + (ulong) info, (int) type, (ulong) seek_offset)); info->file= file; info->type=type; @@ -264,8 +265,9 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, pbool clear_cache) { DBUG_ENTER("reinit_io_cache"); - DBUG_PRINT("enter",("type: %d seek_offset: %lu clear_cache: %d", - type, (ulong) seek_offset, (int) clear_cache)); + DBUG_PRINT("enter",("cache: %lx type: %d seek_offset: %lu clear_cache: %d", + (ulong) info, type, (ulong) seek_offset, + (int) clear_cache)); /* One can't do reinit with the following types */ DBUG_ASSERT(type != READ_NET && info->type != READ_NET && @@ -283,11 +285,15 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, { info->read_end=info->write_pos; info->end_of_file=my_b_tell(info); + info->seek_not_done=1; } else if (type == WRITE_CACHE) { if (info->type == READ_CACHE) + { info->write_end=info->write_buffer+info->buffer_length; + info->seek_not_done=1; + } info->end_of_file = ~(my_off_t) 0; } pos=info->request_pos+(seek_offset-info->pos_in_file); diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index b19ca391672..21979b99285 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -212,6 +212,20 @@ uint my_b_gets(IO_CACHE *info, char *to, uint max_length) } +my_off_t my_b_filelength(IO_CACHE *info) +{ + if (info->type == WRITE_CACHE) + { + return my_b_tell(info); + } + else + { + info->seek_not_done=0; + return my_seek(info->file,0L,MY_SEEK_END,MYF(0)); + } +} + + /* Simple printf version. Supports '%s', '%d', '%u', "%ld" and "%lu" Used for logging in MySQL diff --git a/mysys/my_chsize.c b/mysys/my_chsize.c index 54129f12897..06e8f159f4a 100644 --- a/mysys/my_chsize.c +++ b/mysys/my_chsize.c @@ -25,17 +25,19 @@ my_chsize() fd File descriptor new_length New file size + filler If we don't have truncate, fill up all bytes after + new_length with this character MyFlags Flags DESCRIPTION - my_chsize() truncates file if shorter, else expand with zero. + my_chsize() truncates file if shorter, else fill with the filler character RETURN VALUE 0 Ok 1 Error */ -int my_chsize(File fd, my_off_t newlength, myf MyFlags) +int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags) { DBUG_ENTER("my_chsize"); DBUG_PRINT("my",("fd: %d length: %lu MyFlags: %d",fd,(ulong) newlength, @@ -81,7 +83,7 @@ int my_chsize(File fd, my_off_t newlength, myf MyFlags) } #endif /* Full file with 0 until it's as big as requested */ - bzero(buff,IO_SIZE); + bfill(buff, IO_SIZE, filler); while (newlength-oldsize > IO_SIZE) { if (my_write(fd,(byte*) buff,IO_SIZE,MYF(MY_NABP))) diff --git a/mysys/raid.cc b/mysys/raid.cc index 6196e1f1aa6..d6359dc0f93 100644 --- a/mysys/raid.cc +++ b/mysys/raid.cc @@ -75,7 +75,7 @@ #endif #include "mysys_priv.h" -#include "my_dir.h" +#include <my_dir.h> #include <m_string.h> #include <assert.h> @@ -281,7 +281,7 @@ extern "C" { DBUG_RETURN(my_close(fd, MyFlags)); } - int my_raid_chsize(File fd, my_off_t newlength, myf MyFlags) + int my_raid_chsize(File fd, my_off_t newlength, int filler, myf MyFlags) { DBUG_ENTER("my_raid_chsize"); DBUG_PRINT("enter",("Fd: %d newlength: %u MyFlags: %d", @@ -289,10 +289,10 @@ extern "C" { if (is_raid(fd)) { RaidFd *raid= (*dynamic_element(&RaidFd::_raid_map,fd,RaidFd**)); - DBUG_RETURN(raid->Chsize(fd, newlength, MyFlags)); + DBUG_RETURN(raid->Chsize(fd, newlength, filler, MyFlags)); } else - DBUG_RETURN(my_chsize(fd, newlength, MyFlags)); + DBUG_RETURN(my_chsize(fd, newlength, filler, MyFlags)); } int my_raid_rename(const char *from, const char *to, @@ -738,7 +738,7 @@ Tell(myf MyFlags) } int RaidFd:: -Chsize(File fd, my_off_t newlength, myf MyFlags) +Chsize(File fd, my_off_t newlength, int filler, myf MyFlags) { DBUG_ENTER("RaidFd::Chsize"); DBUG_PRINT("enter",("Fd: %d, newlength: %d, MyFlags: %d", @@ -752,17 +752,16 @@ Chsize(File fd, my_off_t newlength, myf MyFlags) if ( i < _this_block ) newpos = my_chsize(_fd_vector[i], _this_block * _raid_chunksize + (_rounds + 1) * - _raid_chunksize, - MyFlags); + _raid_chunksize, filler, MyFlags); else if ( i == _this_block ) newpos = my_chsize(_fd_vector[i], _this_block * _raid_chunksize + _rounds * _raid_chunksize + (newlength % _raid_chunksize), - MyFlags); + filler, MyFlags); else // this means: i > _this_block newpos = my_chsize(_fd_vector[i], _this_block * _raid_chunksize + _rounds * - _raid_chunksize, MyFlags); + _raid_chunksize, filler, MyFlags); if (newpos) DBUG_RETURN(1); } |