diff options
author | lulf@carrot.studby.ntnu.no <lulf@carrot.studby.ntnu.no> | 2008-04-25 14:09:23 +0200 |
---|---|---|
committer | lulf@carrot.studby.ntnu.no <lulf@carrot.studby.ntnu.no> | 2008-04-25 14:09:23 +0200 |
commit | b72c4650d1bc4dde150ee9ff4f0457394b7bf4a3 (patch) | |
tree | 9740c53d7548af92ec87578d09d55cf6c08d509b /src | |
parent | 0e11f57efb4ccb0460db3f045b21fc9729b6b656 (diff) | |
parent | 0463d0da9b7f118a6c2abe5065140913a50a6e76 (diff) |
- Merge.
Diffstat (limited to 'src')
-rwxr-xr-x | src/mp3_vnops.c | 31 | ||||
-rwxr-xr-x | src/mp3fs.c | 18 |
2 files changed, 26 insertions, 23 deletions
diff --git a/src/mp3_vnops.c b/src/mp3_vnops.c index 8348064..29069c0 100755 --- a/src/mp3_vnops.c +++ b/src/mp3_vnops.c @@ -13,7 +13,9 @@ #include <id3.h> #include <mp3fs.h> -char *musicpath = "/home/lulf/dev/mp3fs/music"; +#include <debug.h> + +char musicpath[MAXPATHLEN]; // = "/home/lulf/dev/mp3fs/music"; static int mp3_getattr (const char *path, struct stat *stbuf) { @@ -108,6 +110,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) { @@ -117,11 +133,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); -} |