Update of /cvsroot/njbfs/njbfs
In directory usw-pr-cvs1:/tmp/cvs-serv10214
Modified Files:
njbfs_cache.c njbfs_cache.h njbfs_dir.c
Log Message:
Ben: Fix bug where /albums was listing multiple "<Unknown>" directories
Index: njbfs_cache.c
===================================================================
RCS file: /cvsroot/njbfs/njbfs/njbfs_cache.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** njbfs_cache.c 26 Feb 2002 02:11:47 -0000 1.2
--- njbfs_cache.c 26 Feb 2002 12:20:23 -0000 1.3
***************
*** 112,116 ****
}
! static void __njbfs_destroy_hashtable(njbfs_hash_element **table)
{
njbfs_hash_element *el, *last;
--- 112,116 ----
}
! void __njbfs_destroy_hashtable(njbfs_hash_element **table)
{
njbfs_hash_element *el, *last;
***************
*** 146,150 ****
*/
! static int njbfs_add_hash_generic(njbfs_hash_element **table, char *id, void *data)
{
njbfs_hash_element *element;
--- 146,150 ----
*/
! int njbfs_add_hash_generic(njbfs_hash_element **table, char *id, void *data)
{
njbfs_hash_element *element;
***************
*** 172,176 ****
! static void* njbfs_get_hash_generic(njbfs_hash_element **table, char *id)
{
njbfs_hash_element *walk;
--- 172,176 ----
! void* njbfs_get_hash_generic(njbfs_hash_element **table, char *id)
{
njbfs_hash_element *walk;
Index: njbfs_cache.h
===================================================================
RCS file: /cvsroot/njbfs/njbfs/njbfs_cache.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** njbfs_cache.h 24 Feb 2002 00:23:12 -0000 1.5
--- njbfs_cache.h 26 Feb 2002 12:20:23 -0000 1.6
***************
*** 216,219 ****
--- 216,224 ----
+ int njbfs_add_hash_generic(njbfs_hash_element **table, char *id, void *data);
+ void* njbfs_get_hash_generic(njbfs_hash_element **table, char *id);
+ void __njbfs_destroy_hashtable(njbfs_hash_element **);
+
+
/* the linked lists that make up the core of our cache */
extern struct njbfs_album_list *album_list_head;
Index: njbfs_dir.c
===================================================================
RCS file: /cvsroot/njbfs/njbfs/njbfs_dir.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** njbfs_dir.c 26 Feb 2002 11:29:48 -0000 1.3
--- njbfs_dir.c 26 Feb 2002 12:20:23 -0000 1.4
***************
*** 223,226 ****
--- 223,234 ----
/*
gets a dirlist node (and creates a fattr struct)
+
+ BUGS:
+ We are unable to translate bad characters (?><) etc
+ in directory names for now... because we use
+ the directory name as a direct index into the hashtables.
+
+ this should be easily cleaned once Jorge introduces the
+ njbfs_track structure.
for our virtual directories
*/
***************
*** 299,302 ****
--- 307,320 ----
/**
+ *
+ * Ok, albums are the trickiest thing to handle in a cache like this.
+ * we may have non-unique album names that we want to shove under
+ * one directory (eg _Unknown_),
+ * so we use a hashtable add/lookup method here to ensure
+ * uniqueness.
+ *
+ * sigh.
+ *
+ *
* Get "/albums" directory entries from NJB cache
*/
***************
*** 305,309 ****
--- 323,335 ----
{
struct njbfs_dirlist_node *p;
+ int hash_size = sizeof(njbfs_hash_element *) * NJBFS_GENERIC_HASH_SIZE;
+
+ njbfs_hash_element **table = kmalloc(hash_size, GFP_KERNEL);
struct njbfs_album_list *list;
+ if ( !table )
+ return -ENOMEM;
+
+ memset(table, 0, hash_size);
+
CHECK_FATTR_CACHE(info);
***************
*** 316,326 ****
--- 342,363 ----
err("loaddir: kmalloc error");
return -ENOMEM;
+
+ if ( njbfs_get_hash_generic(table, list->album->name) )
+ /* already found the album, skip. */
+ continue;
+
+ njbfs_add_hash_generic(table, list->album->name, (void *) 1);
+
}
+
memset(p, 0, sizeof(struct njbfs_dirlist_node));
SAFE_STRDUP(p->entry.name, list->album->name);
+
njbfs_dirlist_node_directories(p,info);
p->prev = NULL;
p->next = dir->head;
dir->head = p;
+
+ __njbfs_destroy_hashtable(table);
}
return 0;
***************
*** 345,351 ****
--- 382,391 ----
err("loaddir: kmalloc error");
return -ENOMEM;
+
}
+
memset(p, 0, sizeof(struct njbfs_dirlist_node));
SAFE_STRDUP(p->entry.name, list->artist->name);
+
njbfs_dirlist_node_directories(p, info);
p->prev = NULL;
***************
*** 375,380 ****
--- 415,422 ----
return -ENOMEM;
}
+
memset(p, 0, sizeof(struct njbfs_dirlist_node));
SAFE_STRDUP(p->entry.name, list->genre->name);
+
njbfs_dirlist_node_directories(p,info);
p->prev = NULL;
|