mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
* ext.c: Fixed FIXME by passing around a reference to a VFS.
This commit is contained in:
parent
88812bee22
commit
a0aef5042d
@ -1,3 +1,7 @@
|
|||||||
|
2004-12-07 Roland Illig <roland.illig@gmx.de>
|
||||||
|
|
||||||
|
* ext.c: Fixed FIXME by passing around a reference to a VFS.
|
||||||
|
|
||||||
2004-12-01 Pavel Tsekov <ptsekov@gmx.net>
|
2004-12-01 Pavel Tsekov <ptsekov@gmx.net>
|
||||||
|
|
||||||
* tar.c (tar_read_header): Skip over records containing
|
* tar.c (tar_read_header): Skip over records containing
|
||||||
|
43
vfs/extfs.c
43
vfs/extfs.c
@ -430,7 +430,7 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc)
|
|||||||
* can be changed and the result may point inside the original string.
|
* can be changed and the result may point inside the original string.
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
extfs_get_path_mangle (char *inname, struct archive **archive, int is_dir,
|
extfs_get_path_mangle (struct vfs_class *me, char *inname, struct archive **archive, int is_dir,
|
||||||
int do_not_open)
|
int do_not_open)
|
||||||
{
|
{
|
||||||
char *local, *op;
|
char *local, *op;
|
||||||
@ -442,11 +442,7 @@ extfs_get_path_mangle (char *inname, struct archive **archive, int is_dir,
|
|||||||
archive_name = inname;
|
archive_name = inname;
|
||||||
vfs_split (inname, &local, &op);
|
vfs_split (inname, &local, &op);
|
||||||
|
|
||||||
/*
|
fstype = extfs_which (me, op);
|
||||||
* FIXME: we really should pass self pointer. But as we know that
|
|
||||||
* extfs_which does not touch struct vfs_class *me, it does not matter for now
|
|
||||||
*/
|
|
||||||
fstype = extfs_which (NULL, op);
|
|
||||||
|
|
||||||
if (fstype == -1)
|
if (fstype == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -482,11 +478,11 @@ extfs_get_path_mangle (char *inname, struct archive **archive, int is_dir,
|
|||||||
* The result should be freed.
|
* The result should be freed.
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
extfs_get_path (const char *inname, struct archive **archive, int is_dir,
|
extfs_get_path (struct vfs_class *me, const char *inname, struct archive **archive, int is_dir,
|
||||||
int do_not_open)
|
int do_not_open)
|
||||||
{
|
{
|
||||||
char *buf = g_strdup (inname);
|
char *buf = g_strdup (inname);
|
||||||
char *res = extfs_get_path_mangle (buf, archive, is_dir, do_not_open);
|
char *res = extfs_get_path_mangle (me, buf, archive, is_dir, do_not_open);
|
||||||
char *res2 = NULL;
|
char *res2 = NULL;
|
||||||
if (res)
|
if (res)
|
||||||
res2 = g_strdup (res);
|
res2 = g_strdup (res);
|
||||||
@ -632,13 +628,13 @@ extfs_cmd (const char *extfs_cmd, struct archive *archive,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
extfs_run (const char *file)
|
extfs_run (struct vfs_class *me, const char *file)
|
||||||
{
|
{
|
||||||
struct archive *archive;
|
struct archive *archive;
|
||||||
char *p, *q, *archive_name, *mc_extfsdir;
|
char *p, *q, *archive_name, *mc_extfsdir;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
|
|
||||||
if ((p = extfs_get_path (file, &archive, 0, 0)) == NULL)
|
if ((p = extfs_get_path (me, file, &archive, 0, 0)) == NULL)
|
||||||
return;
|
return;
|
||||||
q = name_quote (p, 0);
|
q = name_quote (p, 0);
|
||||||
g_free (p);
|
g_free (p);
|
||||||
@ -664,7 +660,7 @@ extfs_open (struct vfs_class *me, const char *file, int flags, int mode)
|
|||||||
int local_handle;
|
int local_handle;
|
||||||
int created = 0;
|
int created = 0;
|
||||||
|
|
||||||
if ((q = extfs_get_path (file, &archive, 0, 0)) == NULL)
|
if ((q = extfs_get_path (me, file, &archive, 0, 0)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||||
if (entry == NULL && (flags & O_CREAT)) {
|
if (entry == NULL && (flags & O_CREAT)) {
|
||||||
@ -867,7 +863,7 @@ static void * extfs_opendir (struct vfs_class *me, const char *dirname)
|
|||||||
struct entry *entry;
|
struct entry *entry;
|
||||||
struct entry **info;
|
struct entry **info;
|
||||||
|
|
||||||
if ((q = extfs_get_path (dirname, &archive, 1, 0)) == NULL)
|
if ((q = extfs_get_path (me, dirname, &archive, 1, 0)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||||
g_free (q);
|
g_free (q);
|
||||||
@ -929,7 +925,7 @@ static void extfs_stat_move( struct stat *buf, struct inode *inode )
|
|||||||
buf->st_ctime = inode->ctime;
|
buf->st_ctime = inode->ctime;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int extfs_internal_stat (const char *path, struct stat *buf, int resolve)
|
static int extfs_internal_stat (struct vfs_class *me, const char *path, struct stat *buf, int resolve)
|
||||||
{
|
{
|
||||||
struct archive *archive;
|
struct archive *archive;
|
||||||
char *q;
|
char *q;
|
||||||
@ -938,7 +934,7 @@ static int extfs_internal_stat (const char *path, struct stat *buf, int resolve)
|
|||||||
char *path2 = g_strdup(path);
|
char *path2 = g_strdup(path);
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
||||||
if ((q = extfs_get_path_mangle (path2, &archive, 0, 0)) == NULL)
|
if ((q = extfs_get_path_mangle (me, path2, &archive, 0, 0)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||||
if (entry == NULL)
|
if (entry == NULL)
|
||||||
@ -955,12 +951,12 @@ cleanup:
|
|||||||
|
|
||||||
static int extfs_stat (struct vfs_class *me, const char *path, struct stat *buf)
|
static int extfs_stat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||||
{
|
{
|
||||||
return extfs_internal_stat (path, buf, 1);
|
return extfs_internal_stat (me, path, buf, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int extfs_lstat (struct vfs_class *me, const char *path, struct stat *buf)
|
static int extfs_lstat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||||
{
|
{
|
||||||
return extfs_internal_stat (path, buf, 0);
|
return extfs_internal_stat (me, path, buf, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int extfs_fstat (void *data, struct stat *buf)
|
static int extfs_fstat (void *data, struct stat *buf)
|
||||||
@ -983,7 +979,7 @@ extfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size)
|
|||||||
char *mpath = g_strdup (path);
|
char *mpath = g_strdup (path);
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
||||||
if ((q = extfs_get_path_mangle (mpath, &archive, 0, 0)) == NULL)
|
if ((q = extfs_get_path_mangle (me, mpath, &archive, 0, 0)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||||
if (entry == NULL)
|
if (entry == NULL)
|
||||||
@ -1022,7 +1018,7 @@ static int extfs_unlink (struct vfs_class *me, const char *file)
|
|||||||
struct entry *entry;
|
struct entry *entry;
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
||||||
if ((q = extfs_get_path_mangle (mpath, &archive, 0, 0)) == NULL)
|
if ((q = extfs_get_path_mangle (me, mpath, &archive, 0, 0)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||||
if (entry == NULL)
|
if (entry == NULL)
|
||||||
@ -1051,7 +1047,7 @@ static int extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode)
|
|||||||
struct entry *entry;
|
struct entry *entry;
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
||||||
if ((q = extfs_get_path_mangle (mpath, &archive, 0, 0)) == NULL)
|
if ((q = extfs_get_path_mangle (me, mpath, &archive, 0, 0)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||||
if (entry != NULL) {
|
if (entry != NULL) {
|
||||||
@ -1086,7 +1082,7 @@ static int extfs_rmdir (struct vfs_class *me, const char *path)
|
|||||||
struct entry *entry;
|
struct entry *entry;
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
||||||
if ((q = extfs_get_path_mangle (mpath, &archive, 0, 0)) == NULL)
|
if ((q = extfs_get_path_mangle (me, mpath, &archive, 0, 0)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||||
if (entry == NULL)
|
if (entry == NULL)
|
||||||
@ -1117,7 +1113,7 @@ extfs_chdir (struct vfs_class *me, const char *path)
|
|||||||
struct entry *entry;
|
struct entry *entry;
|
||||||
|
|
||||||
my_errno = ENOTDIR;
|
my_errno = ENOTDIR;
|
||||||
if ((q = extfs_get_path (path, &archive, 1, 0)) == NULL)
|
if ((q = extfs_get_path (me, path, &archive, 1, 0)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||||
g_free (q);
|
g_free (q);
|
||||||
@ -1143,7 +1139,7 @@ extfs_getid (struct vfs_class *me, const char *path)
|
|||||||
struct archive *archive;
|
struct archive *archive;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (!(p = extfs_get_path (path, &archive, 1, 1)))
|
if (!(p = extfs_get_path (me, path, &archive, 1, 1)))
|
||||||
return NULL;
|
return NULL;
|
||||||
g_free (p);
|
g_free (p);
|
||||||
return (vfsid) archive;
|
return (vfsid) archive;
|
||||||
@ -1331,7 +1327,6 @@ static int extfs_init (struct vfs_class *me)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do NOT use me argument in this function */
|
|
||||||
static int extfs_which (struct vfs_class *me, const char *path)
|
static int extfs_which (struct vfs_class *me, const char *path)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -1355,7 +1350,7 @@ static int
|
|||||||
extfs_setctl (struct vfs_class *me, const char *path, int ctlop, void *arg)
|
extfs_setctl (struct vfs_class *me, const char *path, int ctlop, void *arg)
|
||||||
{
|
{
|
||||||
if (ctlop == VFS_SETCTL_RUN) {
|
if (ctlop == VFS_SETCTL_RUN) {
|
||||||
extfs_run (path);
|
extfs_run (me, path);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user