summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Ørbekk <orbekk@pvv.ntnu.no>2008-08-15 21:51:16 +0200
committerKjetil Ørbekk <orbekk@pvv.ntnu.no>2008-08-15 21:51:16 +0200
commitcbb7e3194b3bc66812f1b638bec0fb8403a9aacb (patch)
tree39af1c758d92a7edd5b897773c16cf590284ab2e
parent97b8102bd1d1da7e99276abfc1c823a220dfa7e5 (diff)
Changed dbpath to ~/.mfs.db
-rw-r--r--include/musicfs.h4
-rw-r--r--src/mfs_subr.c19
-rwxr-xr-xsrc/mfs_vnops.c7
3 files changed, 15 insertions, 15 deletions
diff --git a/include/musicfs.h b/include/musicfs.h
index 21fd0b4..8443198 100644
--- a/include/musicfs.h
+++ b/include/musicfs.h
@@ -22,10 +22,8 @@
#define _MP3FS_H_
struct fuse_args;
-#define DBNAME "music.db"
-
int mfs_run(int, char **);
-int mfs_initscan(char *);
+int mfs_initscan();
/*
diff --git a/src/mfs_subr.c b/src/mfs_subr.c
index 2ac8537..d3d3c0b 100644
--- a/src/mfs_subr.c
+++ b/src/mfs_subr.c
@@ -50,6 +50,7 @@ struct lookuphandle {
lookup_fn_t *lookup;
};
+char *db_path;
sqlite3 *handle;
/*
@@ -130,12 +131,18 @@ mfs_reload_config()
{
int res, len;
char *mfsrc = mfs_get_home_path(".mfsrc");
- FILE *f = fopen(mfsrc, "r");
char line[4096];
struct lookuphandle *lh;
sqlite3 *handle;
+ FILE *f = fopen(mfsrc, "r");
+
+ if (f == NULL) {
+ warnx("Couldn't open configuration file %s\n",
+ mfsrc);
+ return (-1);
+ }
- res = sqlite3_open(DBNAME, &handle);
+ res = sqlite3_open(db_path, &handle);
if (res) {
warnx("Can't open database: %s\n", sqlite3_errmsg(handle));
sqlite3_close(handle);
@@ -168,12 +175,12 @@ mfs_reload_config()
}
int
-mfs_initscan(char *musicpath)
+mfs_initscan()
{
int error;
-
+ db_path = mfs_get_home_path(".mfs.db");
/* Open database. */
- error = sqlite3_open(DBNAME, &handle);
+ error = sqlite3_open(db_path, &handle);
if (error) {
warnx("Can't open database: %s\n", sqlite3_errmsg(handle));
sqlite3_close(handle);
@@ -432,7 +439,7 @@ mfs_lookup_start(int field, void *data, lookup_fn_t *fn, const char *query)
lh->lookup = fn;
/* Open database. */
- error = sqlite3_open(DBNAME, &lh->handle);
+ error = sqlite3_open(db_path, &lh->handle);
if (error) {
warnx("Can't open database: %s\n", sqlite3_errmsg(lh->handle));
sqlite3_close(lh->handle);
diff --git a/src/mfs_vnops.c b/src/mfs_vnops.c
index 1b71b38..e182be2 100755
--- a/src/mfs_vnops.c
+++ b/src/mfs_vnops.c
@@ -39,9 +39,6 @@
#include <musicfs.h>
#include <debug.h>
-char musicpath[MAXPATHLEN]; // = "/home/lulf/dev/musicfs/music";
-char *logpath = "/home/lulf/dev/musicfs/musicfs.log";
-
static int mfs_getattr (const char *path, struct stat *stbuf)
{
struct file_data fd;
@@ -366,7 +363,6 @@ mfs_run(int argc, char **argv)
{
int ret;
- /* Update tables. */
if (argc < 1) {
fprintf(stderr, "Usage: %s <mountpoint>\n", argv[0]);
return (-1);
@@ -377,8 +373,7 @@ mfs_run(int argc, char **argv)
if (fuse_opt_parse(&args, NULL, NULL, musicfs_opt_proc) != 0)
exit (1);
- DEBUG("musicpath: %s\n", musicpath);
- mfs_initscan(musicpath);
+ mfs_initscan();
ret = 0;
ret = fuse_main(args.argc, args.argv, &mfs_ops, NULL);