From 9b012b098915c8bdbdcb8a4c38fb353fa39e82d4 Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Tue, 5 May 2009 16:02:02 +0530 Subject: booster: Add ftruncate API Signed-off-by: Anand V. Avati --- booster/src/booster.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'booster') diff --git a/booster/src/booster.c b/booster/src/booster.c index 3e84d5502..a7a11edff 100644 --- a/booster/src/booster.c +++ b/booster/src/booster.c @@ -155,6 +155,7 @@ static int (*real_chown) (const char *pathname, uid_t owner, gid_t group); static int (*real_fchmod) (int fd, mode_t mode); static int (*real_fchown) (int fd, uid_t, gid_t gid); static int (*real_fsync) (int fd); +static int (*real_ftruncate) (int fd, off_t length); #define RESOLVE(sym) do { \ if (!real_##sym) \ @@ -1268,6 +1269,27 @@ fsync (int fd) return ret; } +int +ftruncate (int fd, off_t length) +{ + int ret = -1; + glusterfs_file_t fh = NULL; + + fh = booster_get_glfs_fd (booster_glfs_fdtable, fd); + if (!fh) { + if (real_ftruncate == NULL) { + errno = ENOSYS; + ret = -1; + } else + ret = real_ftruncate (fd, length); + } else { + ret = glusterfs_ftruncate (fh, length); + booster_put_glfs_fd (fh); + } + + return ret; +} + pid_t fork (void) { @@ -1324,6 +1346,7 @@ _init (void) RESOLVE (fchmod); RESOLVE (fchown); RESOLVE (fsync); + RESOLVE (ftruncate); /* This must be called after resolving real functions * above so that the socket based IO calls in libglusterfsclient -- cgit