diff options
-rw-r--r-- | booster/src/Makefile.am | 2 | ||||
-rw-r--r-- | booster/src/booster.c | 98 | ||||
-rw-r--r-- | booster/src/booster_stat.c | 55 |
3 files changed, 153 insertions, 2 deletions
diff --git a/booster/src/Makefile.am b/booster/src/Makefile.am index 9b6e77f9..1b3be737 100644 --- a/booster/src/Makefile.am +++ b/booster/src/Makefile.am @@ -2,7 +2,7 @@ xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/performance ldpreload_PROGRAMS = glusterfs-booster.so ldpreloaddir = $(libdir)/glusterfs/ -glusterfs_booster_so_SOURCES = booster.c +glusterfs_booster_so_SOURCES = booster.c booster_stat.c glusterfs_booster_so_CFLAGS = -I$(top_srcdir)/libglusterfsclient/src/ -D_GNU_SOURCE -D$(GF_HOST_OS) -fPIC -Wall \ -pthread $(GF_BOOSTER_CFLAGS) glusterfs_booster_so_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE \ diff --git a/booster/src/booster.c b/booster/src/booster.c index ef866cb8..2c2ff0c9 100644 --- a/booster/src/booster.c +++ b/booster/src/booster.c @@ -24,7 +24,6 @@ #include <dlfcn.h> #include <sys/types.h> -#include <sys/stat.h> #include <sys/uio.h> #include <stdio.h> #include <stdarg.h> @@ -171,6 +170,10 @@ static char * (*real_realpath) (const char *path, char *resolved); static DIR * (*real_opendir) (const char *path); static struct dirent * (*real_readdir) (DIR *dir); static int (*real_closedir) (DIR *dh); +static int (*real___xstat) (int ver, const char *path, struct stat *buf); +static int (*real___xstat64) (int ver, const char *path, struct stat64 *buf); +static int (*real_stat) (const char *path, struct stat *buf); +static int (*real_stat64) (const char *path, struct stat64 *buf); #define RESOLVE(sym) do { \ if (!real_##sym) \ @@ -1597,6 +1600,95 @@ out: return ret; } +/* The real stat functions reside in booster_stat.c to + * prevent clash with the statX prototype and functions + * declared from sys/stat.h + */ +int +booster_xstat (int ver, const char *path, void *buf) +{ + struct stat *sbuf = (struct stat *)buf; + int ret = -1; + + ret = glusterfs_stat (path, sbuf); + if (((ret == -1) && (errno != ENODEV)) || (ret == 0)) + goto out; + + if (real___xstat == NULL) { + ret = -1; + errno = ENOSYS; + goto out; + } + + ret = real___xstat (ver, path, sbuf); +out: + return ret; +} + +int +booster_xstat64 (int ver, const char *path, void *buf) +{ + int ret = -1; + struct stat64 *sbuf = (struct stat64 *)buf; + + ret = glusterfs_stat (path, (struct stat *)sbuf); + if (((ret == -1) && (errno != ENODEV)) || (ret == 0)) + goto out; + + if (real___xstat64 == NULL) { + errno = ENOSYS; + ret = -1; + goto out; + } + + ret = real___xstat64 (ver, path, sbuf); +out: + return ret; +} + +int +booster_stat (const char *path, void *buf) +{ + struct stat *sbuf = (struct stat *)buf; + int ret = -1; + + ret = glusterfs_stat (path, sbuf); + if (((ret == -1) && (errno != ENODEV)) || (ret == 0)) + goto out; + + if (real_stat == NULL) { + errno = ENOSYS; + ret = -1; + goto out; + } + + ret = real_stat (path, sbuf); + +out: + return ret; +} + +int +booster_stat64 (const char *path, void *buf) +{ + int ret = -1; + struct stat64 *sbuf = (struct stat64 *)buf; + + ret = glusterfs_stat (path, (struct stat *)sbuf); + if (((ret == -1) && (errno != ENODEV)) || (ret == 0)) + goto out; + + if (real_stat64 == NULL) { + errno = ENOSYS; + ret = -1; + goto out; + } + + ret = real_stat64 (path, sbuf); +out: + return ret; +} + pid_t fork (void) { @@ -1667,6 +1759,10 @@ _init (void) RESOLVE (opendir); RESOLVE (readdir); RESOLVE (closedir); + RESOLVE (__xstat); + RESOLVE (__xstat64); + RESOLVE (stat); + RESOLVE (stat64); /* This must be called after resolving real functions * above so that the socket based IO calls in libglusterfsclient diff --git a/booster/src/booster_stat.c b/booster/src/booster_stat.c new file mode 100644 index 00000000..cdf9230e --- /dev/null +++ b/booster/src/booster_stat.c @@ -0,0 +1,55 @@ +/* + Copyright (c) 2007-2009 Z RESEARCH, Inc. <http://www.zresearch.com> + This file is part of GlusterFS. + + GlusterFS 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; either version 3 of the License, + or (at your option) any later version. + + GlusterFS 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, see + <http://www.gnu.org/licenses/>. +*/ + + +extern int +booster_stat (const char *path, void *buf); + +extern int +booster_stat64 (const char *path, void *buf); + +extern int +booster_xstat (int ver, const char *path, void *buf); + +extern int +booster_xstat64 (int ver, const char *path, void *buf); + +int +stat (const char *path, void *buf) +{ + return booster_stat (path, buf); +} + +int +stat64 (const char *path, void *buf) +{ + return booster_stat64 (path, buf); +} + +int +__xstat (int ver, const char *path, void *buf) +{ + return booster_xstat (ver, path, buf); +} + +int +__xstat64 (int ver, const char *path, void *buf) +{ + return booster_xstat64 (ver, path, buf); +} |