summaryrefslogtreecommitdiffstats
path: root/booster/src
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@zresearch.com>2009-05-05 15:59:40 +0530
committerAnand V. Avati <avati@amp.gluster.com>2009-05-05 17:43:03 +0530
commitf0bef18b788c8beadc4131c5a6534761857c7f46 (patch)
treefa9aa6116d2990a4b0ee7bd5744a3d955cc80367 /booster/src
parentd470dd599c8dbf609411e52e587ea5c171214b21 (diff)
booster: Support VMP-based creat
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'booster/src')
-rw-r--r--booster/src/booster.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/booster/src/booster.c b/booster/src/booster.c
index 026e03ce31c..dd157f78aae 100644
--- a/booster/src/booster.c
+++ b/booster/src/booster.c
@@ -631,9 +631,54 @@ 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;
}