From 6b65a11e4e1e351a85cddd86f18b320addec49fb Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Wed, 18 Nov 2009 01:16:57 +0000 Subject: booster: implement creat64. 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 | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'booster') diff --git a/booster/src/booster.c b/booster/src/booster.c index 43c84890b04..2e0d8de9d53 100644 --- a/booster/src/booster.c +++ b/booster/src/booster.c @@ -104,6 +104,7 @@ write (int fd, const void *buf, size_t count); static int (*real_open) (const char *pathname, int flags, ...); static int (*real_open64) (const char *pathname, int flags, ...); static int (*real_creat) (const char *pathname, mode_t mode); +static int (*real_creat64) (const char *pathname, mode_t mode); /* read, readv, pread, pread64 */ static ssize_t (*real_read) (int fd, void *buf, size_t count); @@ -607,6 +608,8 @@ out: int __REDIRECT (booster_false_creat, (const char *pathname, mode_t mode), creat) __nonnull ((1)); +int __REDIRECT (booster_false_creat64, (const char *pathname, mode_t mode), + creat64) __nonnull ((1)); int booster_false_creat (const char *pathname, mode_t mode) @@ -651,6 +654,49 @@ out: } +int +booster_false_creat64 (const char *pathname, mode_t mode) +{ + int ret = -1; + if (!pathname) { + errno = EINVAL; + goto out; + } + + gf_log ("booster", GF_LOG_TRACE, "Create: %s", pathname); + ret = vmp_creat (pathname, mode); + + if ((ret == -1) && (errno != ENODEV)) { + gf_log ("booster", GF_LOG_ERROR, "VMP create failed: %s", + strerror (errno)); + goto out; + } + + if (ret > 0) { + gf_log ("booster", GF_LOG_TRACE, "File created"); + goto out; + } + + if (real_creat64 == NULL) { + errno = ENOSYS; + ret = -1; + goto out; + } + + ret = real_creat64 (pathname, mode); + + if (ret != -1) { + do_open (ret, pathname, GF_O_WRONLY | GF_O_TRUNC, mode, + BOOSTER_CREAT); + } else + gf_log ("booster", GF_LOG_ERROR, "real create failed: %s", + strerror (errno)); + +out: + return ret; +} + + /* pread */ ssize_t @@ -2907,6 +2953,7 @@ booster_lib_init (void) RESOLVE (open); RESOLVE (open64); RESOLVE (creat); + RESOLVE (creat64); RESOLVE (read); RESOLVE (readv); -- cgit