about summary refs log tree commit homepage
path: root/fs.h
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-03-17 21:47:32 +0000
committerEric Wong <normalperson@yhbt.net>2012-03-17 21:50:55 +0000
commit9356be7590f196a55d2f440fca124299964a1ff1 (patch)
tree02b4a6e86100a58b1af29f56cecfecb8015d0ab0 /fs.h
parent92a35ce663d3c399656bc467cd507b63483cdfda (diff)
downloadcmogstored-9356be7590f196a55d2f440fca124299964a1ff1.tar.gz
It's too hard to test ENOSYS fallbacks reliably and rebuilding
cmogstored on the correct platform should NEVER be a difficult
task.
Diffstat (limited to 'fs.h')
-rw-r--r--fs.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/fs.h b/fs.h
new file mode 100644
index 0000000..0fc674d
--- /dev/null
+++ b/fs.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2012, Eric Wong <normalperson@yhbt.net>
+ * License: GPLv3 or later (see COPYING for details)
+ */
+#ifdef HAVE_FSTATAT
+static inline int
+mog_stat(struct mog_svc *svc, const char *path, struct stat *sb)
+{
+        return fstatat(svc->docroot_fd, path + 1, sb, 0);
+}
+#else  /* HAVE_FSTATAT */
+int mog_stat(struct mog_svc *svc, const char *path, struct stat *sb);
+#endif /* HAVE_FSTATAT */
+
+#ifdef HAVE_UNLINKAT
+static inline int mog_unlink(struct mog_svc *svc, const char *path)
+{
+        return unlinkat(svc->docroot_fd, path + 1, 0);
+}
+#else /* HAVE_UNLINKAT */
+int mog_unlink(struct mog_svc *svc, const char *path);
+#endif /* HAVE_UNLINKAT */
+
+#ifdef HAVE_RENAMEAT
+static inline
+int mog_rename(struct mog_svc *svc, const char *old, const char *new)
+{
+        return renameat(svc->docroot_fd, old + 1, svc->docroot_fd, new + 1);
+}
+#else  /* !HAVE_RENAMEAT */
+int mog_rename(struct mog_svc *svc, const char *old, const char *new);
+#endif /* !HAVE_RENAMEAT */
+
+#ifdef HAVE_MKDIRAT
+static inline int mog_mkdir(struct mog_svc *svc, const char *path, mode_t mode)
+{
+        return mkdirat(svc->docroot_fd, path + 1, mode);
+}
+#else  /* !HAVE_MKDIRAT */
+int mog_mkdir(struct mog_svc *svc, const char *path, mode_t mode);
+#endif /* !HAVE_MKDIRAT */
+
+int mog_open_put(struct mog_svc *svc, const char *path, int flags);
+int mog_open_read(struct mog_svc *svc, const char *path);
+#ifdef O_CLOEXEC
+void mog_cloexec_works(void);
+#endif