summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKjetil Ørbekk <orbekk@pvv.ntnu.no>2008-04-25 13:57:45 +0200
committerKjetil Ørbekk <orbekk@pvv.ntnu.no>2008-04-25 13:57:45 +0200
commit9a21927ac4cdd497f3fbc84df3717748c4cb10a8 (patch)
treeba0cfb9a4f4f2962a697473972f63bec35041c1c /src
parent3f5896ff3ccdea939d3586dd40d9b603d6c807f2 (diff)
- Added musicpath parsing
Order is reversed, so usage is: ./mp3fs <musicpath> <mountpoint>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/mp3_vnops.c31
-rwxr-xr-xsrc/mp3fs.c18
2 files changed, 26 insertions, 23 deletions
diff --git a/src/mp3_vnops.c b/src/mp3_vnops.c
index b04f0dc..381e66d 100755
--- a/src/mp3_vnops.c
+++ b/src/mp3_vnops.c
@@ -11,9 +11,11 @@
#include <id3.h>
+#include "debug.h"
+
#define MAXPATHLEN 100000
-char *musicpath = "/home/lulf/dev/mp3fs/music";
+char musicpath[MAXPATHLEN]; // = "/home/lulf/dev/mp3fs/music";
typedef void traverse_fn_t(char *, void *);
@@ -202,6 +204,20 @@ static struct fuse_operations mp3_ops = {
.read = mp3_read,
};
+static int mp3fs_opt_proc (void *data, const char *arg, int key,
+ struct fuse_args *outargs)
+{
+ static bool musicpath_set = false;
+
+ if (key == FUSE_OPT_KEY_NONOPT && !musicpath_set) {
+ /* The source directory isn't already set, let's do it */
+ strcpy(musicpath, arg);
+ musicpath_set = true;
+ return (0);
+ }
+ return (1);
+}
+
int
mp3_run(int argc, char **argv)
{
@@ -211,11 +227,16 @@ mp3_run(int argc, char **argv)
/* Update tables. */
if (argc < 2) {
- fprintf(stderr, "Usage: %s <mountpoint> <musicfolder>\n", argv[0]);
+ fprintf(stderr, "Usage: %s <musicfolder> <mountpoint>\n", argv[0]);
return (-1);
}
+
+ struct fuse_args args = FUSE_ARGS_INIT (argc, argv);
+
+ if (fuse_opt_parse(&args, NULL, NULL, mp3fs_opt_proc) != 0)
+ exit (1);
-/* musicpath = argv[2];*/
-
- return (fuse_main(argc, argv, &mp3_ops, NULL));
+ DEBUG("musicpath: %s\n", musicpath);
+
+ return (fuse_main(args.argc, args.argv, &mp3_ops, NULL));
}
diff --git a/src/mp3fs.c b/src/mp3fs.c
index b8f0ea1..3555d20 100755
--- a/src/mp3fs.c
+++ b/src/mp3fs.c
@@ -10,29 +10,11 @@
/* Prototypes. */
static int mp3fs_opt_proc (void *, const char *, int, struct fuse_args *);
-/* Just for testing the argument parsing. TODO: fix something better */
-const char *sourcedir = NULL;
-
int
main(int argc, char **argv)
{
-/* struct fuse_args args = FUSE_ARGS_INIT (argc, argv);
-
- if (fuse_opt_parse(&args, NULL, NULL, mp3fs_opt_proc) != 0)
- exit (1);*/
-
printf("Starting up mp3fs\n");
mp3_run(argc, argv);
printf("Shutting down mp3fs\n");
}
-static int mp3fs_opt_proc (void *data, const char *arg, int key,
- struct fuse_args *outargs)
-{
- if (key == FUSE_OPT_KEY_NONOPT && !sourcedir) {
- /* The source directory isn't already set, let's do it */
- sourcedir = arg;
- return (0);
- }
- return (-1);
-}