From fe6a39da3cd7370e9a7d9f7908e06cbdce64ce6a Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Tue, 5 May 2009 16:04:15 +0530 Subject: booster: Add statfs API Signed-off-by: Anand V. Avati --- booster/src/booster.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ booster/src/booster_stat.c | 18 ++++++++++++++++++ 2 files changed, 64 insertions(+) (limited to 'booster') diff --git a/booster/src/booster.c b/booster/src/booster.c index 60213210e9d..8081a81a153 100644 --- a/booster/src/booster.c +++ b/booster/src/booster.c @@ -40,6 +40,7 @@ #include #include #include +#include #ifndef GF_UNIT_KB #define GF_UNIT_KB 1024 @@ -182,6 +183,8 @@ static int (*real___lxstat) (int ver, const char *path, struct stat *buf); static int (*real___lxstat64) (int ver, const char *path, struct stat64 *buf); static int (*real_lstat) (const char *path, struct stat *buf); static int (*real_lstat64) (const char *path, struct stat64 *buf); +static int (*real_statfs) (const char *path, struct statfs *buf); +static int (*real_statfs64) (const char *path, struct statfs64 *buf); #define RESOLVE(sym) do { \ @@ -1881,6 +1884,47 @@ out: return ret; } +int +booster_statfs (const char *pathname, struct statfs *buf) +{ + int ret = -1; + + ret = glusterfs_statfs (pathname, buf); + if (((ret == -1) && (errno != ENODEV)) || (ret == 0)) + goto out; + + if (real_statfs == NULL) { + ret = -1; + errno = ENOSYS; + goto out; + } + + ret = real_statfs (pathname, buf); + +out: + return ret; +} + +int +booster_statfs64 (const char *pathname, struct statfs64 *buf) +{ + int ret = -1; + + ret = glusterfs_statfs (pathname, (struct statfs *)buf); + if (((ret == -1) && (errno != ENODEV)) || (ret == 0)) + goto out; + + if (real_statfs64 == NULL) { + ret = -1; + errno = ENOSYS; + goto out; + } + + ret = real_statfs64 (pathname, buf); + +out: + return ret; +} pid_t fork (void) @@ -1964,6 +2008,8 @@ _init (void) RESOLVE (__lxstat64); RESOLVE (lstat); RESOLVE (lstat64); + RESOLVE (statfs); + RESOLVE (statfs64); /* 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 0d4e7c41f9a..2abbdf76e67 100644 --- a/booster/src/booster_stat.c +++ b/booster/src/booster_stat.c @@ -49,6 +49,11 @@ extern int booster_lxstat64 (int ver, const char *path, void *buf); +extern int +booster_statfs (const char *path, void *buf); +extern int +booster_statfs64 (const char *path, void *buf); + int stat (const char *path, void *buf) { @@ -120,3 +125,16 @@ __lxstat64 (int ver, const char *path, void *buf) { return booster_lxstat64 (ver, path, buf); } + +int +statfs (const char *pathname, void *buf) +{ + return booster_statfs (pathname, buf); +} + +int +statfs64 (const char *pathname, void *buf) +{ + return booster_statfs64 (pathname, buf); +} + -- cgit