On Sat, Jul 29, 2006, Keith Bennett wrote:
> > >
> > > eg. (using vanilla lkarmafs-0.1.7)
> > >
> > > $ ls /mnt/karma/tune/A-Ha/Hunting\ High\ And\ Low/
> > > Take On Me.ogg Take On Me.ogg Take On Me.ogg Take On Me.ogg
> >
> > But this is very strange, or just impossible situation, isn't it?
> > AFAIK, typical filesystems don't support multiple, different
> > files with identical name under the same directory...
>
> No, they don't. The lkarmafs filesystem does though!
> I'll submit a bugfix later this evening.
This patch fixes it.
Keith.
diff -ur lkarmafs-0.1.7.orig/lkarmafs.c lkarmafs-0.1.7/lkarmafs.c
--- lkarmafs-0.1.7.orig/lkarmafs.c 2006-07-29 23:03:17.000000000 +0100
+++ lkarmafs-0.1.7/lkarmafs.c 2006-07-29 23:08:26.000000000 +0100
@@ -547,25 +547,44 @@
/* --------------------------------------------------------------------------
*/
static int kfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi) {
- int j, lname, ret=0;
+#define REPMAX 16384
+ int j, lname=0, lrep=0, ret=0;
uint32_t fid, *vc=NULL, *vp=NULL;
char *type=NULL, *genre=NULL, *artist=NULL;
char *source=NULL, *title=NULL, *codec=NULL;
char *key=NULL, *name=NULL, *myPath;
- char *aux=NULL, rep[16384]="\n";
+ char *aux=NULL, *rcodec=NULL, rep[REPMAX] = "\n";
(void) offset; (void) fi;
FPRINTF(stderr, "==> READDIR: %s\n", path);
filler(buf, ".", NULL, 0); filler(buf, "..", NULL, 0);
myPath = strdup(path);
- if(myPath) { type = strchr(myPath,
'/');}
- if(type) {*(type) = '\0'; type++; if(G) genre = strchr(type,
'/');
- else artist = strchr(type,
'/');}
- if(G && genre) {*(genre) = '\0'; genre++; artist = strchr(genre,
'/');}
- if(artist) {*(artist) = '\0'; artist++; source = strchr(artist,
'/');}
- if(source) {*(source) = '\0'; source++; title = strchr(source,
'/');}
- /* if type is taxi or playlist: genre, artist and source are useless
*/
+ if (!myPath)
+ return -ENOENT;
+
+ type = strchr(myPath, '/');
+ if(type) {
+ *type++ = '\0';
+ if(G) {
+ genre = strchr(type, '/');
+ if(genre) {
+ *genre++ = '\0';
+ artist = strchr(genre, '/');
+ }
+ } else
+ artist = strchr(type, '/');
+ if(artist) {
+ *artist++ = '\0';
+ source = strchr(artist, '/');
+ if(source) {
+ *source++ = '\0';
+ title = strchr(source, '/');
+ }
+ }
+ }
+
+ /* if type is taxi or playlist: genre, artist and source are useless */
/* printf("--> %s : %s : %s : %s : %s\n", myPath,type,genre,artist,source); */
if((!type) || (type[0]=='\0')) {
@@ -604,33 +623,45 @@
} else {
lname = strlen(UnkName);
name = malloc(2*lname+6);
- memcpy(name, UnkName, lname+16);
+ memcpy(name, UnkName, lname+1);
}
/// if(aux) name = strlen(aux)?strdup(aux):strdup(UnkName);
/// else name = NULL;
free(aux);
/* fprintf(stderr, "-1-> %d %d %s %s\n", j, fid, key, name); */
- if(name) {
- aux = malloc(lname + 9); aux[0] = '\0';
- strcat(aux, "\n"); strcat(aux, name);
- if(codec) strcat(aux, codec); strcat(aux, "\n");
- if(!strstr(rep, aux)) { /* if not prevously seen (to avoid reps.) */
- if(strlen(rep) < 16200) {strcat(rep, name); strcat(rep,"\n");}
- else fprintf(stderr, "*Warning: too many repeated names\n");
- if(strcmp(type, "taxi") && strcmp(type, "playlist"))
- escape(name, editPathStr1, editPathStr2);
- if (source) {
- if(codec) free(codec); codec = getPropCS(fid, "codec");
- if (codec) {
- strcat(name, ".");
- strncat(name, strcmp(codec, "vorbis")?codec:"ogg", 15);
- }
- }
-/* fprintf(stderr, "-2-> %d %d %s\n", j, fid, name); */
- if (filler(buf, name, NULL, 0)) break;
- }
- free(name); free(aux);
- }
+ if (!name) continue;
+
+ if(strcmp(type, "taxi") && strcmp(type, "playlist")) {
+ escape(name, editPathStr1, editPathStr2);
+ lname = strlen(name);
+ }
+ if (source) {
+ if(codec) free(codec); codec = getPropCS(fid, "codec");
+ if (codec) {
+ rcodec = strcmp(codec, "vorbis")?codec:"ogg";
+ name[lname] = '.';
+ memcpy(name+lname+1, rcodec, strlen(rcodec));
+ lname += strlen(rcodec)+1;
+ }
+ }
+
+ name[lname] = '\n';
+ name[lname+1] = '\0';
+ /* if not prevously seen (to avoid reps.) */
+ if (strstr(rep, name) != NULL)
+ continue;
+ name[lname] = '\0';
+/* fprintf(stderr, "-2-> %d %d %s\n", j, fid, name); */
+ if (filler(buf, name, NULL, 0)) break;
+
+ if(lrep+lname+2 < REPMAX) {
+ memcpy(rep+lrep, name, lname);
+ lrep += lname+1;
+ rep[lrep-1] = '\n';
+ rep[lrep] = '\0';
+ } else
+ fprintf(stderr, "*Warning: too many repeated names\n");
+ free(name);
}
free(vc); ret = 0;
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
linux-karma-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-karma-devel