diff options
author | Kjetil Ørbekk <orbekk@pvv.ntnu.no> | 2008-08-14 18:20:52 +0200 |
---|---|---|
committer | Kjetil Ørbekk <orbekk@pvv.ntnu.no> | 2008-08-14 18:20:52 +0200 |
commit | cfe2daca8b53d3bffe7e5566f7ed87dfa5093548 (patch) | |
tree | 35ddcb0b99e44fc207b13b5ac5d3a80faed75740 | |
parent | 1ecfff071d64d5b788bd718c2606ffc8428e1a02 (diff) |
- Added /paths
- Return an informative message when reading from it
-rwxr-xr-x | src/mfs_vnops.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/mfs_vnops.c b/src/mfs_vnops.c index 60c9ad6..4a11c2c 100755 --- a/src/mfs_vnops.c +++ b/src/mfs_vnops.c @@ -41,6 +41,12 @@ char musicpath[MAXPATHLEN]; // = "/home/lulf/dev/musicfs/music"; char *logpath = "/home/lulf/dev/musicfs/musicfs.log"; +/* Information when reading /paths */ +const char* paths_info = +"# This is the paths I've registered for your music collection.\n" +"# Add additional paths on their own line in this file, and I'll\n" +"# scan them.\n"; + static int mfs_getattr (const char *path, struct stat *stbuf) { struct file_data fd; @@ -50,12 +56,19 @@ static int mfs_getattr (const char *path, struct stat *stbuf) int status = 0; memset (stbuf, 0, sizeof (struct stat)); - if (strcmp (path, "/") == 0) { + if (strcmp(path, "/") == 0) { stbuf->st_mode = S_IFDIR | 0755; stbuf->st_nlink = 2; return 0; } + if (strcmp(path, "/paths") == 0) { + stbuf->st_mode = S_IFREG | 0744; + stbuf->st_nlink = 2; + stbuf->st_size = strlen(paths_info); + return 0; + } + enum mfs_filetype type = mfs_get_filetype(path); switch (type) { case MFS_DIRECTORY: @@ -102,6 +115,7 @@ static int mfs_readdir (const char *path, void *buf, fuse_fill_dir_t filler, filler(buf, "Genres", NULL, 0); filler(buf, "Tracks", NULL, 0); filler(buf, "Albums", NULL, 0); + filler(buf, "paths", NULL, 0); return (0); } @@ -136,6 +150,9 @@ static int mfs_open (const char *path, struct fuse_file_info *fi) fd.fd = -1; fd.found = 0; + if (strcmp(path, "/paths") == 0) + return (0); + int status = mfs_file_data_for_path(path, &fd); if (status != 0) return (status); @@ -164,8 +181,18 @@ static int mfs_read (const char *path, char *buf, size_t size, off_t offset, struct file_data fd; fd.fd = -1; fd.found = 0; + int len; size_t bytes; + if (strcmp(path, "/paths") == 0) { + DEBUG("read from paths, offset(%d), size(%d)\n", offset, size); + len = strlen(paths_info); + if (size > (len - offset)) + size = len - offset; + strncpy(buf, paths_info + offset, size); + return (size); + } + int status = mfs_file_data_for_path(path, &fd); if (status != 0) return (status); |