summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Ørbekk <orbekk@pvv.ntnu.no>2007-11-20 23:04:48 +0100
committerKjetil Ørbekk <orbekk@pvv.ntnu.no>2007-11-20 23:04:48 +0100
commit27d123855524a2c63e9e696539a30513e0e2308c (patch)
tree4c422606dbc55055015c07417e5eb5193c28099d
parentfc7cc6a33814da2640505ba525dc7280796e1d1f (diff)
- Added basic "hello world" functionality
-rwxr-xr-xsrc/mp3_vnops.c60
-rwxr-xr-xsrc/mp3fs.c15
2 files changed, 67 insertions, 8 deletions
diff --git a/src/mp3_vnops.c b/src/mp3_vnops.c
index f70cea8..b9e191a 100755
--- a/src/mp3_vnops.c
+++ b/src/mp3_vnops.c
@@ -1,4 +1,62 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+#include "mp3_vnops.h"
+
+#define FUSE_USE_VERSION 26
+
+#include <fuse.h>
#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+static int mp3_getattr (const char *path, struct stat *stbuf)
+{
+ memset (stbuf, 0, sizeof (struct stat));
+ if (strcmp (path, "/") == 0) {
+ stbuf->st_mode = S_IFDIR | 0755;
+ stbuf->st_nlink = 2;
+ return 0;
+ }
+ if (strcmp (path, "/MP3Z") == 0) {
+ stbuf->st_mode = S_IFREG | 0444;
+ stbuf->st_nlink = 1;
+ stbuf->st_size = 12;
+ return 0;
+ }
+
+ return -ENOENT;
+}
+
+static int mp3_readdir (const char *path, void *buf, fuse_fill_dir_t filler,
+ off_t offset, struct fuse_file_info *fi)
+{
+ if (strcmp (path, "/") != 0)
+ return -ENOENT;
+
+ filler (buf, ".", NULL, 0);
+ filler (buf, "..", NULL, 0);
+ filler (buf, "MP3Z", NULL, 0);
+
+ return 0;
+}
+
+static int mp3_open (const char *path, struct fuse_file_info *fi)
+{
+ if (strcmp (path, "/MP3Z") == 0)
+ return 0;
+
+ return -ENOENT;
+}
+
+static int mp3_read (const char *path, char *buf, size_t size, off_t offset,
+ struct fuse_file_info *fi)
+{
+ if (strcmp (path, "/MP3Z") == 0) {
+ memcpy (buf, "Oh you wish\n", 12);
+ return 12;
+ }
+
+ return -ENOENT;
+}
static struct fuse_operations mp3_oper = {
.getattr = mp3_getattr,
@@ -6,5 +64,3 @@ static struct fuse_operations mp3_oper = {
.open = mp3_open,
.read = mp3_read,
};
-
-
diff --git a/src/mp3fs.c b/src/mp3fs.c
index 38abd77..6d6beb6 100755
--- a/src/mp3fs.c
+++ b/src/mp3fs.c
@@ -1,13 +1,16 @@
-#include <stdio.h>
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+#define FUSE_USE_VERSION 26
-static struct fuse_module mp3_mod {
- "MP3FS"
+#include <stdio.h>
+#include <fuse.h>
+#include "mp3_vnops.c"
-};
+/* static struct fuse_module mp3_mod { */
+/* .name = "MP3FS" */
+/* }; */
int
main(int argc, char **argv)
{
-
- return (0);
+ return fuse_main (argc, argv, &mp3_oper);
}