Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Mass rename of vcachefs to mongodbfs

  • Loading branch information...
commit b0ee1767b5b205363a336cc4af2ca64364938db0 1 parent 3f81e65
@paulcbetts authored
View
46 README
@@ -1,46 +0,0 @@
-What is vcachefs?
------------------
-
-Video/Audio Caching Filesystem (vcachefs) is a FUSE-based filesystem for *nix
-and Mac OS X that is designed to mirror a remote filesystem while caching a
-certain number of files locally. Essentially, its goal is to solve the "iTunes
-sucks balls over 802.11" problem.
-
-The idea is that you will give it a target directory to mirror and a mountpoint,
-and you point media apps toward the mountpoint instead of the net filesystem
-itself. I am planning to implement two kinds of caches:
-
- * A file-atomic cache
- * A block-based cache for the first 1k of the file and the STAT struct
-
-The latter allows media apps who are only querying tag information / file stats
-to run quickly without requiring the entire file to be on-disk.
-
-
-To build:
-----------
-
-# If MacFuse
-export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/local/lib/pkgconfig
-
-./autogen.sh --prefix=/usr/local
-make && sudo make install
-
-Requires:
- * pkg-config, autotools
- * glib >= 2.9
- * A recent version of FUSE (API >= v27)
-
-
-To run
---------
-
-./vcachefs /target/mount/point
-
-
-Known Issues
---------------
-
-* vcachefs doesn't do very smart things wrt permissions in the cache folder -
- we'll probably have to fix this in the future (but for music/video caching, it
- doesn't matter much
View
8 configure.ac
@@ -2,7 +2,7 @@ AC_PREREQ(2.51)
AC_INIT(README)
AC_CANONICAL_HOST
-AM_INIT_AUTOMAKE(vcachefs, 0.1)
+AM_INIT_AUTOMAKE(mongodbfs, 0.1)
AM_PROG_LIBTOOL
@@ -42,11 +42,11 @@ fi
GLIB_REQUIRED=2.9.0
-PKG_CHECK_MODULES(VCACHEFS, glib-2.0 >= $GLIB_REQUIRED
+PKG_CHECK_MODULES(MONGODBFS, glib-2.0 >= $GLIB_REQUIRED
fuse )
-AC_SUBST(VCACHEFS_CFLAGS)
-AC_SUBST(VCACHEFS_LIBS)
+AC_SUBST(MONGODBFS_CFLAGS)
+AC_SUBST(MONGODBFS_LIBS)
AC_OUTPUT([
Makefile
View
10 src/Makefile.am
@@ -3,18 +3,18 @@
INCLUDES = \
-DFUSE_USE_VERSION=27 \
-I. -Wall -Werror \
- $(VCACHEFS_CFLAGS)
+ $(MONGODBFS_CFLAGS)
-bin_PROGRAMS = vcachefs
+bin_PROGRAMS = mongodbfs
AM_CFLAGS = -std=c99 -g -O0
## HACK HACK HACK: We're adding libevent here, without ever actually checking for it!
-vcachefs_LDADD = $(VCACHEFS_LIBS) -lgthread-2.0 -lpthread \
+mongodbfs_LDADD = $(MONGODBFS_LIBS) -lgthread-2.0 -lpthread \
#-levent
-vcachefs_SOURCES = \
- vcachefs.c \
+mongodbfs_SOURCES = \
+ mongodbfs.c \
stats.c \
queue.c \
cachemgr.c
View
380 src/cachemgr.c
@@ -1,380 +0,0 @@
-/*
- * cachemgr.c - Cache size manager
- *
- * Copyright 2008 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 "stdafx.h"
-#include "stats.h"
-#include "cachemgr.h"
-
-#define CACHEITEM_TAG 'tIaC'
-
-struct CacheManager {
- char* cache_root;
-
- CMCanDeleteCallback can_delete_callback;
- gpointer user_context;
-
- GSList* cached_file_list;
- GStaticRWLock cached_file_list_rwlock;
-};
-
-/* FIXME: This code is porta-tarded */
-struct CacheItemHeader {
- unsigned long tag;
- size_t struct_size;
- time_t mtime;
- guint64 filesize;
-};
-
-struct CacheItem {
- struct CacheItemHeader h;
- char* path;
-};
-
-static struct CacheItem* cacheitem_new(const char* full_path)
-{
- /* We will only return a new item if this is a valid path, and not
- * something other than a file */
- struct stat st;
- if(lstat(full_path, &st) != 0 || !S_ISREG(st.st_mode))
- return NULL;
-
- struct CacheItem* ret = g_new0(struct CacheItem, 1);
- ret->path = g_strdup(full_path);
- ret->h.tag = CACHEITEM_TAG;
- ret->h.mtime = st.st_mtime;
- ret->h.filesize = st.st_size;
- ret->h.struct_size = sizeof(struct CacheItemHeader) + ((strlen(full_path) + 1) * sizeof(char));
- return ret;
-}
-
-static struct CacheItem* cacheitem_load(int fd)
-{
- char* buf = NULL;
- struct CacheItem* ret = g_new0(struct CacheItem, 1);
-
- if(read(fd, ret, sizeof(struct CacheItemHeader)) != sizeof(struct CacheItemHeader))
- goto failed;
-
- if(ret->h.tag != CACHEITEM_TAG)
- goto failed;
-
- if(ret->h.struct_size <= sizeof(struct CacheItemHeader))
- goto failed;
-
- size_t to_read = ret->h.struct_size - sizeof(struct CacheItemHeader);
- buf = g_new0(char, to_read);
- if(read(fd, buf, to_read) != to_read)
- goto failed;
-
- ret->path = buf;
- return ret;
-
-failed:
- if(buf != NULL)
- g_free(buf);
- if(ret != NULL)
- g_free(ret);
- return NULL;
-}
-
-static int cacheitem_save(int fd, struct CacheItem* obj)
-{
- if(write(fd, &obj->h, sizeof(struct CacheItemHeader)) != sizeof(struct CacheItemHeader))
- return -errno;
-
- size_t to_write = obj->h.struct_size - sizeof(struct CacheItemHeader);
- if(write(fd, obj->path, to_write) != to_write)
- return -errno;
-
- return 0;
-}
-
-static void cacheitem_free(struct CacheItem* obj)
-{
- if (!obj)
- return;
-
- g_free(obj->path);
- g_free(obj);
-}
-
-static void cacheitem_free_list(GSList* to_free)
-{
- if (!to_free)
- return;
-
- GSList* iter = to_free;
- while (iter) {
- if (iter->data)
- cacheitem_free(iter->data);
- iter = g_slist_next(iter);
- }
- g_slist_free(to_free);
-}
-
-#if FALSE
-static void cacheitem_touch(struct CacheItem* this)
-{
- this->h.mtime = time(NULL);
-
- /* Attempt to touch the file itself */
- int fd;
- if ( (fd = open(this->path, O_RDWR)) < 0)
- return;
-
- int bytes_read;
- char buf[512];
- if ( (bytes_read = read(fd, buf, 512 * sizeof(char))) < 0)
- goto out;
- lseek(fd, 0, SEEK_SET);
- write(fd, buf, bytes_read);
-
-out:
- if (fd >= 0)
- close(fd);
-}
-
-#endif
-
-static gint cache_item_sortfunc(gconstpointer lhs, gconstpointer rhs)
-{
- time_t lhs_t = ((struct CacheItem*)lhs)->h.mtime;
- time_t rhs_t = ((struct CacheItem*)rhs)->h.mtime;
-
- if (lhs_t == rhs_t)
- return 0;
- return (lhs_t < rhs_t ? 1 : -1);
-}
-
-static void rebuild_cacheitem_list_from_root_helper(GSList** list, const char* root_path, GDir* root)
-{
- const gchar* entry = NULL;
- while ( (entry = g_dir_read_name(root)) ) {
- gchar* full_path = g_build_filename(root_path, entry, NULL);
-
- /* If this is a file in the cache, add it, sorted by mtime */
- struct CacheItem* item = cacheitem_new(full_path);
- if (item) {
- *list = g_slist_insert_sorted(*list, item, cache_item_sortfunc);
- goto done;
- }
-
- /* If this is a directory, recurse through it */
- GDir* subdir = NULL;
- if ( (subdir = g_dir_open(full_path, 0, NULL)) ) {
- rebuild_cacheitem_list_from_root_helper(list, full_path, subdir);
- g_dir_close(subdir);
- }
-done:
- g_free(full_path);
- }
-}
-
-static void rebuild_cacheitem_list_from_root(struct CacheManager* this, const char* root_path)
-{
- GSList* ret = NULL;
- GDir* root = g_dir_open(root_path, 0, NULL);
- if (!root)
- return;
-
- rebuild_cacheitem_list_from_root_helper(&ret, root_path, root);
- g_dir_close(root);
-
- /* Switch out the list and trash the old one */
- g_static_rw_lock_writer_lock(&this->cached_file_list_rwlock);
- GSList* to_free = this->cached_file_list;
- this->cached_file_list = ret;
- g_static_rw_lock_writer_unlock(&this->cached_file_list_rwlock);
-
- cacheitem_free_list(to_free);
-}
-
-struct CacheManager* cache_manager_new(const char* cache_root, CMCanDeleteCallback callback, gpointer context)
-{
- struct CacheManager* ret = g_new0(struct CacheManager, 1);
- if (!ret)
- goto failed;
- ret->cache_root = g_strdup(cache_root);
- ret->can_delete_callback = callback; ret->user_context = context;
-
- g_static_rw_lock_init(&ret->cached_file_list_rwlock);
-
- rebuild_cacheitem_list_from_root(ret, cache_root);
-
- return ret;
-
-failed:
- if (ret) {
- if (ret->cache_root)
- g_free(ret->cache_root);
- g_free(ret);
- }
- return NULL;
-}
-
-void cache_manager_free(struct CacheManager* obj)
-{
- if (!obj)
- return;
-
- cacheitem_free_list(obj->cached_file_list);
- g_free(obj->cache_root);
- g_free(obj);
-}
-
-guint64 cache_manager_get_size(struct CacheManager* this)
-{
- if (!this)
- return 0;
-
- /* Run through the list and sum the sizes */
- guint64 ret = 0;
- g_static_rw_lock_reader_lock(&this->cached_file_list_rwlock);
- GSList* iter = this->cached_file_list;
- while (iter) {
- ret += ((struct CacheItem*)iter->data)->h.filesize;
- iter = g_slist_next(iter);
- }
- g_static_rw_lock_reader_unlock(&this->cached_file_list_rwlock);
-
- return ret;
-}
-
-
-int cache_manager_loadstate(struct CacheManager* this, const char* path)
-{
- int fd;
- if ((fd = open(path, O_RDONLY)) < 0)
- return -errno;
-
- g_static_rw_lock_writer_lock(&this->cached_file_list_rwlock);
-
- struct CacheItem* item;
- cacheitem_free_list(this->cached_file_list);
- while( (item = cacheitem_load(fd)) ) {
- this->cached_file_list = g_slist_insert_sorted(this->cached_file_list, item, cache_item_sortfunc);
- }
-
- g_static_rw_lock_writer_unlock(&this->cached_file_list_rwlock);
- close(fd);
- return 0;
-}
-
-int cache_manager_savestate(struct CacheManager* this, const char* path)
-{
- int ret = 0;
- int fd;
- if ((fd = open(path, O_WRONLY)) < 0)
- return -errno;
-
- g_static_rw_lock_reader_lock(&this->cached_file_list_rwlock);
-
- GSList* iter = this->cached_file_list;
- while (iter) {
- struct CacheItem* item = iter->data;
-
- if ((ret = cacheitem_save(fd, item)))
- goto out;
-
- iter = g_slist_next(iter);
- }
-
-out:
- g_static_rw_lock_reader_unlock(&this->cached_file_list_rwlock);
-
- close(fd);
- return ret;
-}
-
-void cache_manager_notify_added(struct CacheManager* this, const char* full_path)
-{
- struct CacheItem* item = NULL;
- if (! (item = cacheitem_new(full_path)) )
- return;
-
- g_static_rw_lock_writer_lock(&this->cached_file_list_rwlock);
- this->cached_file_list = g_slist_insert_sorted(this->cached_file_list, item, cache_item_sortfunc);
- g_static_rw_lock_writer_unlock(&this->cached_file_list_rwlock);
-}
-
-guint64 cache_manager_reclaim_space(struct CacheManager* this, guint64 max_size)
-{
- guint64 current_size = cache_manager_get_size(this);
- if (current_size <= max_size)
- return 0;
-
- GSList* remove_list = NULL;
- guint64 removed_size = 0;
- guint64 remove_at_least = current_size;
-
- /* Iterate through the sorted list, looking for files we can delete */
- g_static_rw_lock_reader_lock(&this->cached_file_list_rwlock);
- GSList* iter = this->cached_file_list;
- while (iter && removed_size < remove_at_least) {
- struct CacheItem* item = iter->data;
-
- if ( item && (this->can_delete_callback)(item->path, this->user_context) ) {
- remove_list = g_slist_prepend(remove_list, item);
- unlink(item->path);
- removed_size += item->h.filesize;
- }
-
- iter = g_slist_next(iter);
- }
- g_static_rw_lock_reader_unlock(&this->cached_file_list_rwlock);
-
- /* Remove the list of deleted items from the cache manager and free
- * the delete list */
- g_static_rw_lock_writer_lock(&this->cached_file_list_rwlock);
- iter = remove_list;
- while (iter) {
- this->cached_file_list = g_slist_remove(this->cached_file_list, iter->data);
- iter = g_slist_next(iter);
- }
- g_static_rw_lock_writer_unlock(&this->cached_file_list_rwlock);
-
- cacheitem_free_list(remove_list);
-
- return removed_size;
-}
-
-void cache_manager_touch_file(struct CacheManager* this, const char* full_path)
-{
- g_static_rw_lock_writer_lock(&this->cached_file_list_rwlock);
-
- GSList* iter = this->cached_file_list;
- struct CacheItem* item = iter->data;
- while (iter) {
- item = iter->data;
- if (!strcmp(item->path, full_path))
- break;
-
- iter = g_slist_next(iter);
- }
-
- if (iter != NULL) {
- this->cached_file_list = g_slist_remove_link(this->cached_file_list, iter);
- }
-
- g_static_rw_lock_writer_unlock(&this->cached_file_list_rwlock);
-}
View
45 src/cachemgr.h
@@ -1,45 +0,0 @@
-/*
- * cachemgr.h - Userspace video caching filesystem
- *
- * Copyright 2008 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
- */
-
-#ifndef _CACHEMGR_H
-#define _CACHEMGR_H
-
-#include "stdafx.h"
-#include "queue.h"
-
-typedef gboolean (*CMCanDeleteCallback) (const char* path, gpointer context);
-typedef void (*CMShouldCacheCallback) (const char* path, gpointer context);
-
-struct CacheManager;
-
-struct CacheManager* cache_manager_new(const char* cache_root, CMCanDeleteCallback callback, gpointer context);
-void cache_manager_free(struct CacheManager* obj);
-int cache_manager_loadstate(struct CacheManager* obj, const char* path);
-int cache_manager_savestate(struct CacheManager* obj, const char* path);
-guint64 cache_manager_get_size(struct CacheManager* this);
-void cache_manager_notify_added(struct CacheManager* this, const char* full_path);
-void cache_manager_notify_opened(struct CacheManager* this, const char* full_path);
-guint64 cache_manager_reclaim_space(struct CacheManager* this, guint64 max_size);
-void cache_manager_touch_file(struct CacheManager* this, const char* full_path);
-
-#endif
View
122 src/vcachefs.c → src/mongodbfs.c
@@ -1,7 +1,7 @@
/*
- * vcachefs.c - Userspace video caching filesystem
+ * mongodbfs.c - Userspace filesystem for MongoDB's GridFS
*
- * Copyright 2008 Paul Betts <paul.betts@gmail.com>
+ * Copyright 2010 Paul Betts <paul.betts@gmail.com>
*
*
* License:
@@ -39,7 +39,7 @@
#include <glib.h>
#include "stdafx.h"
-#include "vcachefs.h"
+#include "mongodbfs.h"
#include "stats.h"
#include "queue.h"
#include "cachemgr.h"
@@ -52,27 +52,27 @@ GIOChannel* stats_file = NULL;
* Utility Routines
*/
-static struct vcachefs_mount* get_current_mountinfo(void)
+static struct mongodbfs_mount* get_current_mountinfo(void)
{
/* NOTE: This function *only* works inside a FUSE callout */
struct fuse_context* ctx = fuse_get_context();
return (ctx ? ctx->private_data : NULL);
}
-static struct vcachefs_fdentry* fdentry_new(void)
+static struct mongodbfs_fdentry* fdentry_new(void)
{
- struct vcachefs_fdentry* ret = g_new0(struct vcachefs_fdentry, 1);
+ struct mongodbfs_fdentry* ret = g_new0(struct mongodbfs_fdentry, 1);
ret->refcnt = 1;
return ret;
}
-static struct vcachefs_fdentry* fdentry_ref(struct vcachefs_fdentry* obj)
+static struct mongodbfs_fdentry* fdentry_ref(struct mongodbfs_fdentry* obj)
{
g_atomic_int_inc(&obj->refcnt);
return obj;
}
-static void fdentry_unref(struct vcachefs_fdentry* obj)
+static void fdentry_unref(struct mongodbfs_fdentry* obj)
{
if(g_atomic_int_dec_and_test(&obj->refcnt)) {
if(obj->source_fd > 0)
@@ -84,10 +84,10 @@ static void fdentry_unref(struct vcachefs_fdentry* obj)
}
}
-static struct vcachefs_fdentry* fdentry_from_fd(uint fd)
+static struct mongodbfs_fdentry* fdentry_from_fd(uint fd)
{
- struct vcachefs_fdentry* ret = NULL;
- struct vcachefs_mount* mount_obj = get_current_mountinfo();
+ struct mongodbfs_fdentry* ret = NULL;
+ struct mongodbfs_mount* mount_obj = get_current_mountinfo();
g_static_rw_lock_reader_lock(&mount_obj->fd_table_rwlock);
ret = g_hash_table_lookup(mount_obj->fd_table, &fd);
@@ -98,12 +98,12 @@ static struct vcachefs_fdentry* fdentry_from_fd(uint fd)
static char* build_cache_path(const char* source_path)
{
- const char* env = getenv("VCACHEFS_CACHEPATH");
+ const char* env = getenv("MONGODBFS_CACHEPATH");
char* cache_root;
if (env) {
cache_root = g_strdup(env);
} else {
- cache_root = g_build_filename(getenv("HOME"), ".vcachefs", NULL);
+ cache_root = g_build_filename(getenv("HOME"), ".mongodbfs", NULL);
}
// Calculate the MD5 of the source path
@@ -193,7 +193,7 @@ static void add_cache_fd_to_item(gpointer key, gpointer value, gpointer cache_en
{
/* NOTE: Since we've grabbed the fd table lock before this function, we don't need
* to grab a reference to the fd entry */
- struct vcachefs_fdentry* fde = value;
+ struct mongodbfs_fdentry* fde = value;
struct cache_entry* ce = cache_entry;
if (strcmp(fde->relative_path, ce->relative_path))
return;
@@ -214,7 +214,7 @@ static void add_cache_fd_to_item(gpointer key, gpointer value, gpointer cache_en
static gpointer file_cache_copy_thread(gpointer data)
{
- struct vcachefs_mount* mount_obj = data;
+ struct mongodbfs_mount* mount_obj = data;
g_debug("Starting cache copy thread...");
while(g_atomic_int_get(&mount_obj->quitflag_atomic) == 0) {
@@ -281,7 +281,7 @@ static gpointer file_cache_copy_thread(gpointer data)
gboolean can_delete_cached_file(const char* path, gpointer context)
{
/* Blowing away files who we have an open handle to is probably bad */
- struct vcachefs_mount* mount_obj = context;
+ struct mongodbfs_mount* mount_obj = context;
gboolean ret;
g_static_rw_lock_reader_lock(&mount_obj->fd_table_rwlock);
@@ -292,7 +292,7 @@ gboolean can_delete_cached_file(const char* path, gpointer context)
return ret;
}
-static void insert_fdtable_entry(struct vcachefs_mount* mount_obj, struct vcachefs_fdentry* fde)
+static void insert_fdtable_entry(struct mongodbfs_mount* mount_obj, struct mongodbfs_fdentry* fde)
{
g_hash_table_insert(mount_obj->fd_table, &fde->fd, fde);
@@ -322,7 +322,7 @@ static void trash_fdtable_byname_item(gpointer key, gpointer val, gpointer dontc
static void trash_fdtable_item(gpointer key, gpointer val, gpointer dontcare)
{
- fdentry_unref((struct vcachefs_fdentry*)val);
+ fdentry_unref((struct mongodbfs_fdentry*)val);
}
@@ -331,16 +331,16 @@ static void trash_fdtable_item(gpointer key, gpointer val, gpointer dontcare)
* FUSE callouts
*/
-static void* vcachefs_init(struct fuse_conn_info *conn)
+static void* mongodbfs_init(struct fuse_conn_info *conn)
{
- struct vcachefs_mount* mount_object = g_new0(struct vcachefs_mount, 1);
- mount_object->source_path = g_strdup(getenv("VCACHEFS_TARGET"));
+ struct mongodbfs_mount* mount_object = g_new0(struct mongodbfs_mount, 1);
+ mount_object->source_path = g_strdup(getenv("MONGODBFS_TARGET"));
mount_object->cache_path = build_cache_path(mount_object->source_path);
/* TODO: This is actually a config param */
mount_object->max_cache_size = 20 * 1024 * 1024;
- if (getenv("VCACHEFS_PASSTHROUGH"))
+ if (getenv("MONGODBFS_PASSTHROUGH"))
mount_object->pass_through = 1;
g_thread_init(NULL);
@@ -365,9 +365,9 @@ static void* vcachefs_init(struct fuse_conn_info *conn)
return mount_object;
}
-static void vcachefs_destroy(void *mount_object_ptr)
+static void mongodbfs_destroy(void *mount_object_ptr)
{
- struct vcachefs_mount* mount_object = mount_object_ptr;
+ struct mongodbfs_mount* mount_object = mount_object_ptr;
/* Kick off a watchdog thread; this is our last chance to bail; while
* Mac and Linux both support async IO for reads/writes, if a remote FS
@@ -409,17 +409,17 @@ static void vcachefs_destroy(void *mount_object_ptr)
g_debug("Finished cleanup");
}
-static int is_quitting(struct vcachefs_mount* mount_obj)
+static int is_quitting(struct mongodbfs_mount* mount_obj)
{
return (g_atomic_int_get(&mount_obj->quitflag_atomic) != 0);
}
/* File ops callouts */
-static int vcachefs_getattr(const char *path, struct stat *stbuf)
+static int mongodbfs_getattr(const char *path, struct stat *stbuf)
{
int ret = 0;
- struct vcachefs_mount* mount_obj = get_current_mountinfo();
+ struct mongodbfs_mount* mount_obj = get_current_mountinfo();
if(path == NULL || strlen(path) == 0) {
return -ENOENT;
@@ -441,10 +441,10 @@ static int vcachefs_getattr(const char *path, struct stat *stbuf)
return (ret ? -errno : 0);
}
-static int vcachefs_open(const char *path, struct fuse_file_info *fi)
+static int mongodbfs_open(const char *path, struct fuse_file_info *fi)
{
- struct vcachefs_mount* mount_obj = get_current_mountinfo();
- struct vcachefs_fdentry* fde = NULL;
+ struct mongodbfs_mount* mount_obj = get_current_mountinfo();
+ struct mongodbfs_fdentry* fde = NULL;
if(path == NULL || strlen(path) == 0) {
return -ENOENT;
@@ -513,12 +513,12 @@ static int read_from_fd(int fd, off_t* cur_offset, char* buf, size_t size, off_t
return ret;
}
-static int vcachefs_read(const char *path, char *buf, size_t size, off_t offset,
+static int mongodbfs_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
int ret = 0;
- struct vcachefs_mount* mount_obj = get_current_mountinfo();
- struct vcachefs_fdentry* fde = fdentry_from_fd(fi->fh);
+ struct mongodbfs_mount* mount_obj = get_current_mountinfo();
+ struct mongodbfs_fdentry* fde = fdentry_from_fd(fi->fh);
if(!fde)
return -ENOENT;
@@ -541,9 +541,9 @@ static int vcachefs_read(const char *path, char *buf, size_t size, off_t offset,
return (ret < 0 ? -errno : ret);
}
-static int vcachefs_statfs(const char *path, struct statvfs *stat)
+static int mongodbfs_statfs(const char *path, struct statvfs *stat)
{
- struct vcachefs_mount* mount_obj = get_current_mountinfo();
+ struct mongodbfs_mount* mount_obj = get_current_mountinfo();
/* On shutdown, fail new requests */
if(is_quitting(mount_obj))
@@ -552,10 +552,10 @@ static int vcachefs_statfs(const char *path, struct statvfs *stat)
return statvfs(mount_obj->source_path, stat);
}
-static int vcachefs_release(const char *path, struct fuse_file_info *info)
+static int mongodbfs_release(const char *path, struct fuse_file_info *info)
{
- struct vcachefs_mount* mount_obj = get_current_mountinfo();
- struct vcachefs_fdentry* fde = NULL;
+ struct mongodbfs_mount* mount_obj = get_current_mountinfo();
+ struct mongodbfs_fdentry* fde = NULL;
/* On shutdown, fail new requests */
if(is_quitting(mount_obj))
@@ -591,10 +591,10 @@ static int vcachefs_release(const char *path, struct fuse_file_info *info)
return 0;
}
-static int vcachefs_access(const char *path, int amode)
+static int mongodbfs_access(const char *path, int amode)
{
int ret = 0;
- struct vcachefs_mount* mount_obj = get_current_mountinfo();
+ struct mongodbfs_mount* mount_obj = get_current_mountinfo();
if(path == NULL || strlen(path) == 0)
return -ENOENT;
@@ -617,13 +617,13 @@ static int vcachefs_access(const char *path, int amode)
}
-static int vcachefs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
+static int mongodbfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
int ret;
gchar* full_path = NULL;
const gchar* next_path_try;
- struct vcachefs_mount* mount_obj = get_current_mountinfo();
+ struct mongodbfs_mount* mount_obj = get_current_mountinfo();
DIR* dir = NULL;
struct dirent* dentry;
char path_buf[512];
@@ -691,33 +691,33 @@ static int vcachefs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
* Main
*/
-static struct fuse_operations vcachefs_oper = {
- .getattr = vcachefs_getattr,
- /*.readlink = vcachefs_readlink, */
- .open = vcachefs_open,
- .read = vcachefs_read,
- .statfs = vcachefs_statfs,
+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 = vcachefs_release,
- .init = vcachefs_init,
- .destroy = vcachefs_destroy,
- .access = vcachefs_access,
+ .release = mongodbfs_release,
+ .init = mongodbfs_init,
+ .destroy = mongodbfs_destroy,
+ .access = mongodbfs_access,
/* TODO: implement these later
- .getxattr = vcachefs_getxattr,
- .listxattr = vcachefs_listxattr,
- .opendir = vcachefs_opendir, */
- .readdir = vcachefs_readdir,
- /*.releasedir = vcachefs_releasedir,
- .fsyncdir = vcachefs_fsyncdir, */
+ .getxattr = mongodbfs_getxattr,
+ .listxattr = mongodbfs_listxattr,
+ .opendir = mongodbfs_opendir, */
+ .readdir = mongodbfs_readdir,
+ /*.releasedir = mongodbfs_releasedir,
+ .fsyncdir = mongodbfs_fsyncdir, */
};
int main(int argc, char *argv[])
{
/* Check for our environment variables
* FIXME: There's got to be a less dumb way to do this */
- if (!getenv("VCACHEFS_TARGET")) {
- printf(" *** Please set the VCACHEFS_TARGET environment variable to the path that "
+ if (!getenv("MONGODBFS_TARGET")) {
+ printf(" *** Please set the MONGODBFS_TARGET environment variable to the path that "
"should be mirrored! ***\n");
return -1;
}
@@ -725,5 +725,5 @@ int main(int argc, char *argv[])
/* Initialize libevent */
//ev_base = event_init();
- return fuse_main(argc, argv, &vcachefs_oper, NULL);
+ return fuse_main(argc, argv, &mongodbfs_oper, NULL);
}
View
12 src/vcachefs.h → src/mongodbfs.h
@@ -1,7 +1,7 @@
/*
- * vcachefs.h - Userspace video caching filesystem
+ * mongodbfs.h - Userspace filesystem for MongoDB's GridFS
*
- * Copyright 2008 Paul Betts <paul.betts@gmail.com>
+ * Copyright 2010 Paul Betts <paul.betts@gmail.com>
*
*
* License:
@@ -21,8 +21,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef _VCACHEFS_H
-#define _VCACHEFS_H
+#ifndef _MONGODBFS_H
+#define _MONGODBFS_H
#include <glib.h>
@@ -32,7 +32,7 @@
/* This object is the per-mount data we carry around with us throughout the
* life of the app until we release it */
-struct vcachefs_mount {
+struct mongodbfs_mount {
/* Configuration */
char* source_path;
@@ -55,7 +55,7 @@ struct vcachefs_mount {
struct WorkitemQueue* work_queue;
};
-struct vcachefs_fdentry {
+struct mongodbfs_fdentry {
gint refcnt;
char* relative_path;
View
2  src/queue.h
@@ -1,5 +1,5 @@
/*
- * queue.h - Userspace video caching filesystem
+ * queue.h - Queued workitem system
*
* Copyright 2008 Paul Betts <paul.betts@gmail.com>
*
View
2  src/stats.c
@@ -41,7 +41,7 @@
GIOChannel* stats_open_logging(void)
{
- char* path = getenv("VCACHEFS_STATS_FILE");
+ char* path = getenv("MONGODBFS_STATS_FILE");
if (!path)
return NULL;
View
2  src/stats.h
@@ -1,5 +1,5 @@
/*
- * stats.h - Userspace video caching filesystem
+ * stats.h - I/O statistics
*
* Copyright 2008 Paul Betts <paul.betts@gmail.com>
*
Please sign in to comment.
Something went wrong with that request. Please try again.