From a0c05848d2ed0b0600d73214594a161cbb42302c Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Wed, 18 Nov 2009 01:16:12 +0000 Subject: booster: implement ftruncate64. Signed-off-by: Raghavendra G Signed-off-by: Anand V. Avati BUG: 369 (Samba does not work with booster.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=369 --- booster/src/booster.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'booster') diff --git a/booster/src/booster.c b/booster/src/booster.c index c8414eca9cb..98f91041324 100644 --- a/booster/src/booster.c +++ b/booster/src/booster.c @@ -141,6 +141,7 @@ 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); +static int (*real_ftruncate64) (int fd, loff_t length); static int (*real_link) (const char *oldpath, const char *newname); static int (*real_rename) (const char *oldpath, const char *newpath); static int (*real_utimes) (const char *path, const struct timeval times[2]); @@ -1266,8 +1267,13 @@ fsync (int fd) return ret; } +int __REDIRECT (booster_false_ftruncate, (int fd, off_t length), + ftruncate); +int __REDIRECT (booster_false_ftruncate64, (int fd, loff_t length), + ftruncate64); + int -ftruncate (int fd, off_t length) +booster_false_ftruncate (int fd, off_t length) { int ret = -1; glusterfs_file_t fh = NULL; @@ -1291,6 +1297,31 @@ ftruncate (int fd, off_t length) return ret; } +int +booster_false_ftruncate64 (int fd, loff_t length) +{ + int ret = -1; + glusterfs_file_t fh = NULL; + + gf_log ("booster", GF_LOG_TRACE, "ftruncate: fd %d, length: %"PRIu64,fd + , length); + fh = booster_fdptr_get (booster_fdtable, fd); + if (!fh) { + gf_log ("booster", GF_LOG_TRACE, "Not a booster fd"); + if (real_ftruncate == NULL) { + errno = ENOSYS; + ret = -1; + } else + ret = real_ftruncate64 (fd, length); + } else { + gf_log ("booster", GF_LOG_TRACE, "Is a booster fd"); + ret = glusterfs_ftruncate (fh, length); + booster_fdptr_put (fh); + } + + return ret; +} + int link (const char *old, const char *new) { @@ -2830,6 +2861,7 @@ booster_lib_init (void) RESOLVE (fchown); RESOLVE (fsync); RESOLVE (ftruncate); + RESOLVE (ftruncate64); RESOLVE (link); RESOLVE (rename); RESOLVE (utimes); -- cgit