Ticket #2501: continue split of VFS core library and VFS plugins.

Use GList for list of vfs_s_super objects in vfs_s_subclass.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Andrew Borodin 2011-03-28 14:18:21 +03:00
parent 6b09134a01
commit 401aaa5014
4 changed files with 36 additions and 38 deletions

View File

@ -332,15 +332,10 @@ vfs_s_new_super (struct vfs_class *me)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static void static inline void
vfs_s_insert_super (struct vfs_class *me, struct vfs_s_super *super) vfs_s_insert_super (struct vfs_class *me, struct vfs_s_super *super)
{ {
super->next = MEDATA->supers; MEDATA->supers = g_list_prepend (MEDATA->supers, super);
super->prevp = &MEDATA->supers;
if (MEDATA->supers != NULL)
MEDATA->supers->prevp = &super->next;
MEDATA->supers = super;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -364,12 +359,7 @@ vfs_s_free_super (struct vfs_class *me, struct vfs_s_super *super)
message (D_ERROR, "Direntry warning", "%s", "Super has want_stale set"); message (D_ERROR, "Direntry warning", "%s", "Super has want_stale set");
#endif #endif
if (super->prevp) MEDATA->supers = g_list_remove (MEDATA->supers, super);
{
*super->prevp = super->next;
if (super->next)
super->next->prevp = super->prevp;
}
CALL (free_archive) (me, super); CALL (free_archive) (me, super);
g_free (super->name); g_free (super->name);
@ -721,16 +711,17 @@ vfs_s_print_stats (const char *fs_name, const char *action,
static void static void
vfs_s_fill_names (struct vfs_class *me, fill_names_f func) vfs_s_fill_names (struct vfs_class *me, fill_names_f func)
{ {
struct vfs_s_super *a = MEDATA->supers; GList *iter;
for (iter = MEDATA->supers; iter != NULL; iter = g_list_next (iter))
{
const struct vfs_s_super *super = (const struct vfs_s_super *) iter->data;
char *name; char *name;
while (a) name = g_strconcat (super->name, "#", me->prefix, "/",
{ /* super->current_dir->name, */ (char *) NULL);
name = g_strconcat (a->name, "#", me->prefix, "/", func (name);
/* a->current_dir->name, */ (char *) NULL);
(*func) (name);
g_free (name); g_free (name);
a = a->next;
} }
} }
@ -1031,6 +1022,7 @@ vfs_s_find_inode (struct vfs_class *me, const struct vfs_s_super *super,
const char * const char *
vfs_s_get_path_mangle (struct vfs_class *me, char *inname, struct vfs_s_super **archive, int flags) vfs_s_get_path_mangle (struct vfs_class *me, char *inname, struct vfs_s_super **archive, int flags)
{ {
GList *iter;
const char *retval; const char *retval;
char *local, *op; char *local, *op;
const char *archive_name; const char *archive_name;
@ -1049,15 +1041,18 @@ vfs_s_get_path_mangle (struct vfs_class *me, char *inname, struct vfs_s_super **
return NULL; return NULL;
} }
for (super = MEDATA->supers; super != NULL; super = super->next) for (iter = MEDATA->supers; iter != NULL; iter = g_list_next (iter))
{ {
int i;
super = (struct vfs_s_super *) iter->data;
/* 0 == other, 1 == same, return it, 2 == other but stop scanning */ /* 0 == other, 1 == same, return it, 2 == other but stop scanning */
int i = MEDATA->archive_same (me, super, archive_name, op, cookie); i = MEDATA->archive_same (me, super, archive_name, op, cookie);
if (i != 0) if (i != 0)
{ {
if (i == 1) if (i == 1)
goto return_success; goto return_success;
else
break; break;
} }
} }

View File

@ -11,6 +11,8 @@
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include "lib/global.h" /* GList */
/*** typedefs(not structures) and defined constants **********************************************/ /*** typedefs(not structures) and defined constants **********************************************/
#define LINK_FOLLOW 15 #define LINK_FOLLOW 15
@ -52,7 +54,6 @@
/* Single connection or archive */ /* Single connection or archive */
struct vfs_s_super struct vfs_s_super
{ {
struct vfs_s_super **prevp, *next;
struct vfs_class *me; struct vfs_class *me;
struct vfs_s_inode *root; struct vfs_s_inode *root;
char *name; /* My name, whatever it means */ char *name; /* My name, whatever it means */
@ -182,7 +183,7 @@ struct vfs_s_fh
*/ */
struct vfs_s_subclass struct vfs_s_subclass
{ {
struct vfs_s_super *supers; GList *supers;
int inode_counter; int inode_counter;
int flags; /* whether the subclass is remove, read-only etc */ int flags; /* whether the subclass is remove, read-only etc */
dev_t rdev; dev_t rdev;

View File

@ -1385,14 +1385,16 @@ fish_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags, mode_t mode)
static void static void
fish_fill_names (struct vfs_class *me, fill_names_f func) fish_fill_names (struct vfs_class *me, fill_names_f func)
{ {
struct vfs_s_super *super = MEDATA->supers; GList *iter;
char *name;
char gbuf[10]; for (iter = MEDATA->supers; iter != NULL; iter = g_list_next (iter))
while (super)
{ {
const struct vfs_s_super *super = (const struct vfs_s_super *) iter->data;
char *name;
char gbuf[10];
const char *flags = ""; const char *flags = "";
switch (SUP.flags) switch (SUP.flags)
{ {
case FISH_FLAG_RSH: case FISH_FLAG_RSH:
@ -1411,9 +1413,8 @@ fish_fill_names (struct vfs_class *me, fill_names_f func)
} }
name = g_strconcat ("/#sh:", SUP.user, "@", SUP.host, flags, "/", SUP.cwdir, (char *) NULL); name = g_strconcat ("/#sh:", SUP.user, "@", SUP.host, flags, "/", SUP.cwdir, (char *) NULL);
(*func) (name); func (name);
g_free (name); g_free (name);
super = super->next;
} }
} }

View File

@ -2202,15 +2202,16 @@ ftpfs_done (struct vfs_class *me)
static void static void
ftpfs_fill_names (struct vfs_class *me, fill_names_f func) ftpfs_fill_names (struct vfs_class *me, fill_names_f func)
{ {
struct vfs_s_super *super = MEDATA->supers; GList *iter;
for (iter = MEDATA->supers; iter != NULL; iter = g_list_next (iter))
{
const struct vfs_s_super *super = (const struct vfs_s_super *) iter->data;
char *name; char *name;
while (super)
{
name = g_strconcat ("/#ftp:", SUP.user, "@", SUP.host, "/", SUP.cwdir, (char *) NULL); name = g_strconcat ("/#ftp:", SUP.user, "@", SUP.host, "/", SUP.cwdir, (char *) NULL);
(*func) (name); func (name);
g_free (name); g_free (name);
super = super->next;
} }
} }