Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make main() a C++ file, because apparentely C++ loses its shit if it

doesn't get to be main()
  • Loading branch information...
commit 030b3e05025972d7b067aee393dc06cd929a5ba0 1 parent bdbfba5
@paulcbetts authored
Showing with 80 additions and 42 deletions.
  1. +1 −0  src/Makefile.am
  2. +57 −0 src/main.cpp
  3. +9 −41 src/mongodbfs.c
  4. +13 −1 src/mongodbfs.h
View
1  src/Makefile.am
@@ -14,6 +14,7 @@ mongodbfs_LDADD = $(MONGODBFS_LIBS) -lgthread-2.0 -lpthread \
#-levent
mongodbfs_SOURCES = \
+ main.cpp \
mongodbfs.c \
stats.c \
queue.c
View
57 src/main.cpp
@@ -0,0 +1,57 @@
+/*
+ * main.cpp - Userspace filesystem for MongoDB's GridFS
+ *
+ * Copyright 2010 Paul Betts <paul.betts@gmail.com>
+ *
+ *
+ * License:
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this package; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <fuse.h>
+#include <glib.h>
+
+extern "C" {
+#include "stdafx.h"
+#include "mongodbfs.h"
+}
+
+static struct fuse_operations mongodbfs_oper;
+
+int main(int argc, char *argv[])
+{
+ // NB: C++ is so full of fail
+ mongodbfs_oper.getattr = mongodbfs_getattr;
+ /*mongodbfs_oper.readlink = mongodbfs_readlink, */
+ mongodbfs_oper.open = mongodbfs_open;
+ mongodbfs_oper.read = mongodbfs_read;
+ mongodbfs_oper.statfs = mongodbfs_statfs;
+ /* TODO: do we need flush? */
+ mongodbfs_oper.release = mongodbfs_release;
+ mongodbfs_oper.init = mongodbfs_init;
+ mongodbfs_oper.destroy = mongodbfs_destroy;
+ mongodbfs_oper.access = mongodbfs_access;
+
+ /* TODO: implement these later
+ mongodbfs_oper.getxattr = mongodbfs_getxattr,
+ mongodbfs_oper.listxattr = mongodbfs_listxattr,
+ mongodbfs_oper.opendir = mongodbfs_opendir, */
+ mongodbfs_oper.readdir = mongodbfs_readdir;
+ /*mongodbfs_oper.releasedir = mongodbfs_releasedir,
+ mongodbfs_oper.fsyncdir = mongodbfs_fsyncdir, */
+
+ return fuse_main(argc, argv, &mongodbfs_oper, NULL);
+}
View
50 src/mongodbfs.c
@@ -21,7 +21,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -131,7 +130,7 @@ static void trash_fdtable_item(gpointer key, gpointer val, gpointer dontcare)
* FUSE callouts
*/
-static void* mongodbfs_init(struct fuse_conn_info *conn)
+void* mongodbfs_init(struct fuse_conn_info *conn)
{
struct mongodbfs_mount* mount_object = g_new0(struct mongodbfs_mount, 1);
@@ -150,7 +149,7 @@ static void* mongodbfs_init(struct fuse_conn_info *conn)
return mount_object;
}
-static void mongodbfs_destroy(void *mount_object_ptr)
+void mongodbfs_destroy(void *mount_object_ptr)
{
struct mongodbfs_mount* mount_object = mount_object_ptr;
@@ -183,13 +182,13 @@ static int is_quitting(struct mongodbfs_mount* mount_obj)
/* File ops callouts */
-static int mongodbfs_getattr(const char *path, struct stat *stbuf)
+int mongodbfs_getattr(const char *path, struct stat *stbuf)
{
// XXX: Implement me
return -EIO;
}
-static int mongodbfs_open(const char *path, struct fuse_file_info *fi)
+int mongodbfs_open(const char *path, struct fuse_file_info *fi)
{
struct mongodbfs_mount* mount_obj = get_current_mountinfo();
struct mongodbfs_fdentry* fde = NULL;
@@ -238,7 +237,7 @@ static int read_from_fd(int fd, off_t* cur_offset, char* buf, size_t size, off_t
}
#endif
-static int mongodbfs_read(const char *path, char *buf, size_t size, off_t offset,
+int mongodbfs_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
int ret = 0;
@@ -258,7 +257,7 @@ static int mongodbfs_read(const char *path, char *buf, size_t size, off_t offset
return (ret < 0 ? -errno : ret);
}
-static int mongodbfs_statfs(const char *path, struct statvfs *stat)
+int mongodbfs_statfs(const char *path, struct statvfs *stat)
{
struct mongodbfs_mount* mount_obj = get_current_mountinfo();
@@ -270,7 +269,7 @@ static int mongodbfs_statfs(const char *path, struct statvfs *stat)
return -EIO;
}
-static int mongodbfs_release(const char *path, struct fuse_file_info *info)
+int mongodbfs_release(const char *path, struct fuse_file_info *info)
{
struct mongodbfs_mount* mount_obj = get_current_mountinfo();
struct mongodbfs_fdentry* fde = NULL;
@@ -310,7 +309,7 @@ static int mongodbfs_release(const char *path, struct fuse_file_info *info)
return 0;
}
-static int mongodbfs_access(const char *path, int amode)
+int mongodbfs_access(const char *path, int amode)
{
int ret = 0;
struct mongodbfs_mount* mount_obj = get_current_mountinfo();
@@ -328,7 +327,7 @@ static int mongodbfs_access(const char *path, int amode)
return (ret < 0 ? errno : ret);
}
-static int mongodbfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
+int mongodbfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
struct mongodbfs_mount* mount_obj = get_current_mountinfo();
@@ -347,34 +346,3 @@ static int mongodbfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler
return 0;
}
-
-
-/*
- * Main
- */
-
-static struct fuse_operations mongodbfs_oper = {
- .getattr = mongodbfs_getattr,
- /*.readlink = mongodbfs_readlink, */
- .open = mongodbfs_open,
- .read = mongodbfs_read,
- .statfs = mongodbfs_statfs,
- /* TODO: do we need flush? */
- .release = mongodbfs_release,
- .init = mongodbfs_init,
- .destroy = mongodbfs_destroy,
- .access = mongodbfs_access,
-
- /* TODO: implement these later
- .getxattr = mongodbfs_getxattr,
- .listxattr = mongodbfs_listxattr,
- .opendir = mongodbfs_opendir, */
- .readdir = mongodbfs_readdir,
- /*.releasedir = mongodbfs_releasedir,
- .fsyncdir = mongodbfs_fsyncdir, */
-};
-
-int main(int argc, char *argv[])
-{
- return fuse_main(argc, argv, &mongodbfs_oper, NULL);
-}
View
14 src/mongodbfs.h
@@ -51,4 +51,16 @@ struct mongodbfs_fdentry {
uint fd;
};
-#endif
+void* mongodbfs_init(struct fuse_conn_info *conn);
+void mongodbfs_destroy(void *mount_object_ptr);
+int mongodbfs_getattr(const char *path, struct stat *stbuf);
+int mongodbfs_open(const char *path, struct fuse_file_info *fi);
+int mongodbfs_read(const char *path, char *buf, size_t size, off_t offset,
+ struct fuse_file_info *fi);
+int mongodbfs_statfs(const char *path, struct statvfs *stat);
+int mongodbfs_release(const char *path, struct fuse_file_info *info);
+int mongodbfs_access(const char *path, int amode);
+int mongodbfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
+ off_t offset, struct fuse_file_info *fi);
+
+#endif
Please sign in to comment.
Something went wrong with that request. Please try again.