Merge branch '1909_extfs_d_plugin_name'

* 1909_extfs_d_plugin_name:
  Fixed of GSList item deallocation.
  Ticket #1909: don't interpret trailing '+' as a plugin name.
This commit is contained in:
Andrew Borodin 2010-03-05 17:30:01 +03:00
commit 23c17deecc
2 changed files with 38 additions and 25 deletions

View File

@ -583,16 +583,22 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc)
static int
extfs_which (struct vfs_class *me, const char *path)
{
size_t path_len;
size_t i;
(void) me;
path_len = strlen (path);
for (i = 0; i < extfs_plugins->len; i++)
{
extfs_plugin_info_t *info;
info = &g_array_index (extfs_plugins, extfs_plugin_info_t, i);
if (strcmp (path, info->prefix) == 0)
if ((strncmp (path, info->prefix, path_len) == 0)
&& ((info->prefix[path_len] == '\0')
|| (info->prefix[path_len] == '+')))
return i;
}
return -1;
@ -700,7 +706,7 @@ extfs_resolve_symlinks_int (struct entry *entry, GSList * list)
looping = g_slist_prepend (list, entry);
pent = extfs_find_entry_int (entry->dir, entry->inode->linkname, looping, FALSE, FALSE);
g_free (looping); /* It is OK here, no any leaks */
g_slist_delete_link (looping, looping);
if (pent == NULL)
my_errno = ENOENT;
@ -1470,16 +1476,13 @@ extfs_get_plugins (const char *where, gboolean silent)
* file system does not require an archive to work
*/
len = strlen (filename);
if (filename[len - 1] != '+')
info.need_archive = TRUE;
else
{
info.need_archive = FALSE;
len--;
}
info.need_archive = (filename[len - 1] != '+');
info.path = g_strconcat (dirname, PATH_SEP_STR, (char *) NULL);
info.prefix = g_strndup (filename, len);
info.prefix = g_strdup (filename);
/* prepare to compare file names without trailing '+' */
if (!info.need_archive)
info.prefix[len - 1] = '\0';
/* don't overload already found plugin */
for (i = 0; i < extfs_plugins->len; i++)
@ -1503,7 +1506,12 @@ extfs_get_plugins (const char *where, gboolean silent)
g_free (info.prefix);
}
else
{
/* restore file name */
if (!info.need_archive)
info.prefix[len - 1] = '+';
g_array_append_val (extfs_plugins, info);
}
}
}
}

View File

@ -6,31 +6,36 @@ Starting with version 3.1, the Midnight Commander comes with so called
extfs, which is one of the virtual filesystems. This system makes it
possible to create new virtual filesystems for the GNU MC very easily.
Such work has two basic steps:
To handle requests, create a shell/perl/python/etc script/program
(with executable permissions) in $(libexecdir)/mc/extfs.d
or in ~/.mc/extfs.d.
Editing $(libdir)/extfs/extfs.ini.
Creating a shell script/program to handle requests.
(Note: $(libdir) should be substituted for actual libdir path stored when
configured or compiled, like /usr/local/lib/mc or /usr/lib/mc).
(Note: $(libexecdir) should be substituted for actual libexecdir path
stored when configured or compiled, like /usr/local/libexec or /usr/libexec).
The first one is very easy:
You assign a vfs suffix. For example, if you have .zip file, and would
like to see what's inside it, path will be
Assign a vfs suffix. For example, if you have .zip file, and would like
to see what's inside it, path will be
/anypath/my.zip#uzip/some_path/...
Then you add a line extfs.ini file containing just that extension. If
your vfs does not require file to work on, add ':' to the end of name.
In this example, .zip is suffix, but I call vfs 'uzip'. Why? Well,
what this vfs essentially does is UNzip. UN is too long, so I choosed
U. Note that sometime in future filesystem like zip may exist: It will
take whole tree and create .zip file from it. So /usr#zip will be
zipfile containing whole /usr tree.
The second one may require some your knowledge of shell/c programming:
You have to create a program (with executable permissions) prefix in
$(libdir)/extfs (in our example $(libdir)/extfs/uzip).
If your vfs does not require file to work on, add '+' to the end of name.
Note, that trailing '+' in file name is not a part of vfs name, it is
just an vfs attribue. So you have not use it in vfs commands:
cd #rpms
is correct command, and
cd #rpms+
is incorrect command.
* Commands that should be implemented by your shell script
----------------------------------------------------------