From 13a58f94a781d91ab3d7854996df66c9802d972b Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Tue, 5 May 2009 16:04:00 +0530 Subject: booster: Add fstat API Signed-off-by: Anand V. Avati --- booster/src/booster.c | 107 +++++++++++++++++++++++++++++++++++++++++++++ booster/src/booster_stat.c | 34 ++++++++++++++ 2 files changed, 141 insertions(+) (limited to 'booster/src') diff --git a/booster/src/booster.c b/booster/src/booster.c index 2c2ff0c964b..40a0ca87d83 100644 --- a/booster/src/booster.c +++ b/booster/src/booster.c @@ -174,6 +174,11 @@ 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); +static int (*real___fxstat) (int ver, int fd, struct stat *buf); +static int (*real___fxstat64) (int ver, int fd, struct stat64 *buf); +static int (*real_fstat) (int fd, struct stat *buf); +static int (*real_fstat64) (int fd , struct stat64 *buf); + #define RESOLVE(sym) do { \ if (!real_##sym) \ @@ -1689,6 +1694,104 @@ out: return ret; } +int +booster_fxstat (int ver, int fd, void *buf) +{ + struct stat *sbuf = (struct stat *)buf; + int ret = -1; + glusterfs_file_t fh = NULL; + + fh = booster_get_glfs_fd (booster_glfs_fdtable, fd); + if (!fh) { + if (real___fxstat == NULL) { + errno = ENOSYS; + ret = -1; + goto out; + } + + ret = real___fxstat (ver, fd, sbuf); + } else { + ret = glusterfs_fstat (fh, sbuf); + booster_put_glfs_fd (fh); + } + +out: + return ret; +} + +int +booster_fxstat64 (int ver, int fd, void *buf) +{ + int ret = -1; + struct stat64 *sbuf = (struct stat64 *)buf; + glusterfs_file_t fh = NULL; + + fh = booster_get_glfs_fd (booster_glfs_fdtable, fd); + if (!fh) { + if (real___fxstat64 == NULL) { + ret = -1; + errno = ENOSYS; + goto out; + } + ret = real___fxstat64 (ver, fd, sbuf); + } else { + ret = glusterfs_fstat (fh, (struct stat *)sbuf); + booster_put_glfs_fd (fh); + } + +out: + return ret; +} + +int +booster_fstat (int fd, void *buf) +{ + struct stat *sbuf = (struct stat *)buf; + int ret = -1; + glusterfs_file_t fh = NULL; + + fh = booster_get_glfs_fd (booster_glfs_fdtable, fd); + if (!fh) { + if (real_fstat == NULL) { + ret = -1; + errno = ENOSYS; + goto out; + } + + ret = real_fstat (fd, sbuf); + } else { + ret = glusterfs_fstat (fh, sbuf); + booster_put_glfs_fd (fh); + } + +out: + return ret; +} + +int +booster_fstat64 (int fd, void *buf) +{ + int ret = -1; + struct stat64 *sbuf = (struct stat64 *)buf; + glusterfs_file_t fh = NULL; + + fh = booster_get_glfs_fd (booster_glfs_fdtable, fd); + if (!fh) { + if (real_fstat64 == NULL) { + ret = -1; + errno = ENOSYS; + goto out; + } + ret = real_fstat64 (fd, sbuf); + } else { + ret = glusterfs_fstat (fh, (struct stat *)sbuf); + booster_put_glfs_fd (fh); + } + +out: + return ret; +} + pid_t fork (void) { @@ -1763,6 +1866,10 @@ _init (void) RESOLVE (__xstat64); RESOLVE (stat); RESOLVE (stat64); + RESOLVE (__fxstat); + RESOLVE (__fxstat64); + RESOLVE (fstat); + RESOLVE (fstat64); /* 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 index cdf9230e6c2..bdbb0f8f43d 100644 --- a/booster/src/booster_stat.c +++ b/booster/src/booster_stat.c @@ -30,6 +30,15 @@ booster_xstat (int ver, const char *path, void *buf); extern int booster_xstat64 (int ver, const char *path, void *buf); +extern int +booster_fxstat (int ver, int fd, void *buf); +extern int +booster_fxstat64 (int ver, int fd, void *buf); +extern int +booster_fstat (int fd, void *buf); +extern int +booster_fstat64 (int fd, void *buf); + int stat (const char *path, void *buf) { @@ -53,3 +62,28 @@ __xstat64 (int ver, const char *path, void *buf) { return booster_xstat64 (ver, path, buf); } + +int +__fxstat (int ver, int fd, void *buf) +{ + return booster_fxstat (ver, fd, buf); +} + +int +__fxstat64 (int ver, int fd, void *buf) +{ + return booster_fxstat64 (ver, fd, buf); +} + +int +fstat (int fd, void *buf) +{ + return booster_fstat (fd, buf); +} + +int +fstat64 (int fd, void *buf) +{ + return booster_fstat64 (fd, buf); +} + -- cgit