From 824c295c7aebba96d28f8aaa9da317eca3e2225f Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 24 Oct 1999 19:58:22 +0000 Subject: [PATCH] Large File Support. --- lib/config.h | 22 +++++++++++++++++++++- lib/lfs.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 lib/lfs.h diff --git a/lib/config.h b/lib/config.h index 171211c6..50bf986a 100644 --- a/lib/config.h +++ b/lib/config.h @@ -9,7 +9,13 @@ /* Version */ -#define SHER_VER "1.2" +#define SHER_VER "1.3" + +/* Features */ + +#define SHERLOCK_CONFIG_REF_WEIGHTS +#undef SHERLOCK_CONFIG_LARGE_DB +#undef SHERLOCK_CONFIG_LFS /* Types */ @@ -32,6 +38,20 @@ typedef unsigned long addr_int_t; /* Both integer and address */ typedef u32 oid_t; /* Object ID */ +#ifdef SHERLOCK_CONFIG_LFS /* off_t as passed to file functions */ +typedef s64 sh_off_t; +#define BYTES_PER_FILE_POINTER 5 +#else +typedef int sh_off_t; +#define BYTES_PER_FILE_POINTER 4 +#endif + +#ifdef SHERLOCK_CONFIG_LARGE_DB /* off_t as present in database files */ +typedef s64 sh_foff_t; +#else +typedef s32 sh_foff_t; +#endif + /* CPU characteristics */ #define CPU_LITTLE_ENDIAN diff --git a/lib/lfs.h b/lib/lfs.h new file mode 100644 index 00000000..ab9d8e71 --- /dev/null +++ b/lib/lfs.h @@ -0,0 +1,50 @@ +/* + * Sherlock Library -- Large File Support + * + * (c) 1999 Martin Mares, + */ + +#ifndef _SHERLOCK_LFS_H +#define _SHERLOCK_LFS_H + +#ifdef SHERLOCK_CONFIG_LFS + +#ifndef O_LARGEFILE +#if defined(__linux__) && defined(__i386__) +#define O_LARGEFILE 0100000 +#else +#error O_LARGEFILE unknown +#endif +#endif + +#if 0 + +/* A "do it yourself" solution */ + +#include +#include + +_syscall5(int, _llseek, int, fd, int, hi, int, lo, loff_t *, result, int, whence); + +extern inline loff_t sh_seek(int fd, sh_off_t pos, int whence) +{ + loff_t result; + int err; + + err = _llseek(fd, pos >> 32, pos, &result, whence); + return (err < 0) ? err : result; +} +#else + +/* Touching hidden places in glibc */ +extern loff_t llseek(int fd, loff_t pos, int whence); +#define sh_seek(f,o,w) llseek(f,o,w) + +#endif + +#else /* !SHERLOCK_CONFIG_LFS */ + +#define sh_seek(f,o,w) lseek(f,o,w) + +#endif /* !SHERLOCK_CONFIG_LFS */ +#endif /* !_SHERLOCK_LFS_H */ -- 2.39.5