From f0bef18b788c8beadc4131c5a6534761857c7f46 Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Tue, 5 May 2009 15:59:40 +0530 Subject: booster: Support VMP-based creat Signed-off-by: Anand V. Avati --- booster/src/booster.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'booster/src/booster.c') diff --git a/booster/src/booster.c b/booster/src/booster.c index 026e03ce..dd157f78 100644 --- a/booster/src/booster.c +++ b/booster/src/booster.c @@ -630,10 +630,55 @@ open64 (const char *pathname, int flags, ...) } #endif +int +vmp_creat (const char *pathname, mode_t mode) +{ + int fd = -1; + glusterfs_file_t fh = NULL; + + fh = glusterfs_creat (pathname, mode); + if (!fh) + goto out; + + fd = booster_get_process_fd (); + if (fd == -1) + goto close_out; + + if ((booster_get_unused_fd (booster_glfs_fdtable, fh, fd)) == -1) + goto real_close_out; + + return fd; + +real_close_out: + real_close (fd); + fd = -1; + +close_out: + glusterfs_close (fh); + +out: + return -1; +} + int creat (const char *pathname, mode_t mode) { - int ret; + int ret = -1; + if (!pathname) { + errno = EINVAL; + goto out; + } + + ret = vmp_creat (pathname, mode); + + if (((ret == -1) && (errno != ENODEV)) || (ret > 0)) + goto out; + + if (real_creat == NULL) { + errno = ENOSYS; + ret = -1; + goto out; + } ret = real_creat (pathname, mode); @@ -641,6 +686,7 @@ creat (const char *pathname, mode_t mode) do_open (ret, GF_O_WRONLY | GF_O_TRUNC, mode); } +out: return ret; } -- cgit