mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 05:52:27 +01:00
00aaa9a3d4
into ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.0-marvel BitKeeper/deleted/.del-_dynrec.c~48dd758f5a5450df: Auto merged BitKeeper/deleted/.del-_page.c~148b1a613d052ee8: Auto merged BitKeeper/deleted/.del-_search.c~f509292aa1ff18ff: Auto merged BitKeeper/deleted/.del-close.c~fd62629496ee5bcc: Auto merged BitKeeper/deleted/.del-delete.c~65ee8daaa75a14b6: Auto merged BitKeeper/deleted/.del-my_tempnam.c~a8562f15dad3012f: Auto merged BitKeeper/deleted/.del-open.c~95b3b75042fae00a: Auto merged BitKeeper/deleted/.del-rkey.c~cc54c6498352f999: Auto merged client/mysql.cc: Auto merged client/mysqldump.c: Auto merged include/my_sys.h: Auto merged include/raid.h: Auto merged myisam/mi_close.c: Auto merged BitKeeper/deleted/.del-sort.c~e2e56b5a37ce86f4: Auto merged BitKeeper/deleted/.del-write.c~8f1918b1f6770e54: Auto merged myisam/mi_page.c: Auto merged myisam/myisamchk.c: Auto merged mysys/default.c: Auto merged mysys/mf_keycaches.c: Auto merged mysys/my_dup.c: Auto merged mysys/my_fopen.c: Auto merged mysys/my_handler.c: Auto merged mysys/my_malloc.c: Auto merged mysys/my_static.c: Auto merged mysys/my_write.c: Auto merged mysys/safemalloc.c: Auto merged mysys/tree.c: Auto merged mysys/typelib.c: Auto merged regex/regexec.c: Auto merged sql/item.cc: Auto merged sql/item_cmpfunc.cc: Auto merged sql/opt_range.cc: Auto merged sql/sql_repl.cc: Auto merged sql-common/my_time.c: Auto merged BitKeeper/deleted/.del-compiler_warnings.supp: Delete: support-files/compiler_warnings.supp client/mysqlbinlog.cc: Manual merge from 4.1. client/sql_string.cc: Manual merge from 4.1. extra/perror.c: Manual merge from 4.1. heap/_check.c: Manual merge from 4.1. heap/hp_delete.c: Manual merge from 4.1. heap/hp_hash.c: Manual merge from 4.1. heap/hp_open.c: Manual merge from 4.1. heap/hp_rkey.c: Manual merge from 4.1. heap/hp_rrnd.c: Manual merge from 4.1. heap/hp_write.c: Manual merge from 4.1. libmysql/libmysql.c: Manual merge from 4.1. libmysqld/libmysqld.c: Manual merge from 4.1. myisam/mi_delete.c: Manual merge from 4.1. myisam/mi_dynrec.c: Manual merge from 4.1. myisam/mi_keycache.c: Manual merge from 4.1. myisam/mi_statrec.c: Manual merge from 4.1. myisammrg/myrg_extra.c: Manual merge from 4.1. mysys/hash.c: Manual merge from 4.1. mysys/list.c: Manual merge from 4.1. mysys/mf_iocache.c: Manual merge from 4.1. mysys/mf_keycache.c: Manual merge from 4.1. mysys/my_alloc.c: Manual merge from 4.1. mysys/my_fstream.c: Manual merge from 4.1. mysys/my_getwd.c: Manual merge from 4.1. mysys/my_lib.c: Manual merge from 4.1. mysys/my_lread.c: Manual merge from 4.1. mysys/my_lwrite.c: Manual merge from 4.1. mysys/my_pread.c: Manual merge from 4.1. mysys/my_read.c: Manual merge from 4.1. mysys/my_realloc.c: Manual merge from 4.1. mysys/my_seek.c: Manual merge from 4.1. mysys/raid.cc: Manual merge from 4.1. mysys/thr_lock.c: Manual merge from 4.1. ndb/src/mgmclient/CommandInterpreter.cpp: Manual merge from 4.1. sql/ha_archive.cc: Manual merge from 4.1. sql/ha_innodb.cc: Manual merge from 4.1. sql/ha_ndbcluster.cc: Manual merge from 4.1. sql/item_subselect.cc: Manual merge from 4.1. sql/log.cc: Manual merge from 4.1. sql/log_event.cc: Manual merge from 4.1. sql/mysqld.cc: Manual merge from 4.1. sql/net_serv.cc: Manual merge from 4.1. sql/slave.cc: Manual merge from 4.1. sql/sql_cache.cc: Manual merge from 4.1. sql/sql_class.cc: Manual merge from 4.1. sql/sql_delete.cc: Manual merge from 4.1. sql/sql_parse.cc: Manual merge from 4.1. sql/sql_prepare.cc: Manual merge from 4.1. sql-common/client.c: Manual merge from 4.1. sql/sql_select.cc: Manual merge from 4.1. sql/sql_table.cc: Manual merge from 4.1. sql/sql_update.cc: Manual merge from 4.1. sql/strfunc.cc: Manual merge from 4.1. sql/table.cc: Manual merge from 4.1. sql/tztime.cc: Manual merge from 4.1. sql/unireg.cc: Manual merge from 4.1. tests/mysql_client_test.c: Manual merge from 4.1.
91 lines
2.8 KiB
C
91 lines
2.8 KiB
C
/* 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"
|
|
|
|
/*
|
|
Seek to a position in a file.
|
|
|
|
ARGUMENTS
|
|
File fd The file descriptor
|
|
my_off_t pos The expected position (absolute or relative)
|
|
int whence A direction parameter and one of
|
|
{SEEK_SET, SEEK_CUR, SEEK_END}
|
|
myf MyFlags Not used.
|
|
|
|
DESCRIPTION
|
|
The my_seek function is a wrapper around the system call lseek and
|
|
repositions the offset of the file descriptor fd to the argument
|
|
offset according to the directive whence as follows:
|
|
SEEK_SET The offset is set to offset bytes.
|
|
SEEK_CUR The offset is set to its current location plus offset bytes
|
|
SEEK_END The offset is set to the size of the file plus offset bytes
|
|
|
|
RETURN VALUE
|
|
my_off_t newpos The new position in the file.
|
|
MY_FILEPOS_ERROR An error was encountered while performing
|
|
the seek. my_errno is set to indicate the
|
|
actual error.
|
|
*/
|
|
|
|
my_off_t my_seek(File fd, my_off_t pos, int whence,
|
|
myf MyFlags __attribute__((unused)))
|
|
{
|
|
reg1 os_off_t newpos;
|
|
DBUG_ENTER("my_seek");
|
|
DBUG_PRINT("my",("Fd: %d Hpos: %lu Pos: %lu Whence: %d MyFlags: %d",
|
|
fd, (ulong) (((ulonglong) pos) >> 32), (ulong) pos,
|
|
whence, MyFlags));
|
|
DBUG_ASSERT(pos != MY_FILEPOS_ERROR); /* safety check */
|
|
|
|
/*
|
|
Make sure we are using a valid file descriptor!
|
|
*/
|
|
DBUG_ASSERT(fd != -1);
|
|
|
|
newpos= lseek(fd, pos, whence);
|
|
|
|
if (newpos == (os_off_t) -1)
|
|
{
|
|
my_errno=errno;
|
|
DBUG_PRINT("error",("lseek: %lu errno: %d", (ulong) newpos,errno));
|
|
DBUG_RETURN(MY_FILEPOS_ERROR);
|
|
}
|
|
if ((my_off_t) newpos != pos)
|
|
{
|
|
DBUG_PRINT("exit",("pos: %lu", (ulong) newpos));
|
|
}
|
|
DBUG_RETURN((my_off_t) newpos);
|
|
} /* my_seek */
|
|
|
|
|
|
/* Tell current position of file */
|
|
/* ARGSUSED */
|
|
|
|
my_off_t my_tell(File fd, myf MyFlags __attribute__((unused)))
|
|
{
|
|
os_off_t pos;
|
|
DBUG_ENTER("my_tell");
|
|
DBUG_PRINT("my",("Fd: %d MyFlags: %d",fd, MyFlags));
|
|
#ifdef HAVE_TELL
|
|
pos=tell(fd);
|
|
#else
|
|
pos=lseek(fd, 0L, MY_SEEK_CUR);
|
|
#endif
|
|
if (pos == (os_off_t) -1)
|
|
my_errno=errno;
|
|
DBUG_PRINT("exit",("pos: %lu", (ulong) pos));
|
|
DBUG_RETURN((my_off_t) pos);
|
|
} /* my_tell */
|