mirror of
https://github.com/MidnightCommander/mc
synced 2025-04-01 12:42:57 +03:00
Thu May 28 16:42:31 1998 Pavel Machek <pavel@bug.mj.gts.cz>
* extfs.c, shared.c, tar.c: I changed semantics in my previous patch - _get_path() now modifies strings passed to it. I thought that I were carefull enough not to introduce bugs. You guessed it - I was not. [Many tar_ and extfs_ functions modify strings passed to them, but as they are only called from vfs layer, it does not matter much.] So I renamed function to alert everyone that semantics changed. Fixed bugs in timestamping (and segfaults) when you entered tar inside zip file or similar. * vfs.c (mc_open): Die if the filesystem doesn't support open
This commit is contained in:
parent
af333ebc14
commit
39ad0b489a
@ -1,3 +1,18 @@
|
||||
Thu May 28 16:42:31 1998 Pavel Machek <pavel@bug.mj.gts.cz>
|
||||
|
||||
* extfs.c, shared.c, tar.c: I changed semantics in my previous
|
||||
patch - _get_path() now modifies strings passed to it. I thought
|
||||
that I were carefull enough not to introduce bugs. You guessed it -
|
||||
I was not. [Many tar_ and extfs_ functions modify strings passed
|
||||
to them, but as they are only called from vfs layer, it does not
|
||||
matter much.]
|
||||
So I renamed function to alert everyone that semantics changed.
|
||||
|
||||
Fixed bugs in timestamping (and segfaults) when you entered tar
|
||||
inside zip file or similar.
|
||||
|
||||
* vfs.c (mc_open): Die if the filesystem doesn't support open
|
||||
|
||||
1998-05-26 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* vfs.c (MC_DIROP): Macro now returns the proper value.
|
||||
|
16
vfs/extfs.c
16
vfs/extfs.c
@ -374,8 +374,13 @@ int read_extfs_archive (int fstype, char *name, struct extfs_archive **pparc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Returns allocated path inside the archive or NULL */
|
||||
static char *extfs_get_path (char *inname, struct extfs_archive **archive, int is_dir,
|
||||
int do_not_open);
|
||||
|
||||
/* Returns path inside argument. Returned char* is inside inname, which is mangled
|
||||
* by this operation (so you must not free it's return value)
|
||||
*/
|
||||
static char *extfs_get_path_mangle (char *inname, struct extfs_archive **archive, int is_dir,
|
||||
int do_not_open)
|
||||
{
|
||||
char *local, *archive_name, *op;
|
||||
@ -571,7 +576,7 @@ static void *extfs_open (char *file, int flags, int mode)
|
||||
int local_handle;
|
||||
const int do_create = (flags & O_ACCMODE) != O_RDONLY;
|
||||
|
||||
if ((q = extfs_get_path (file, &archive, 0, 0)) == NULL)
|
||||
if ((q = extfs_get_path_mangle (file, &archive, 0, 0)) == NULL)
|
||||
return NULL;
|
||||
entry = extfs_find_entry (archive->root_entry, q, 0, do_create);
|
||||
if (entry == NULL)
|
||||
@ -704,6 +709,7 @@ static int extfs_close (void *data)
|
||||
#define X_entry extfs_entry
|
||||
#define X_archive extfs_archive
|
||||
#define X_get_path extfs_get_path
|
||||
#define X_get_path_mangle extfs_get_path_mangle
|
||||
#define X_find_entry extfs_find_entry
|
||||
#define X_resolve_symlinks extfs_resolve_symlinks
|
||||
#define X_inode extfs_inode
|
||||
@ -753,7 +759,7 @@ static int extfs_chdir (char *path)
|
||||
struct extfs_entry *entry;
|
||||
|
||||
extfserrno = ENOTDIR;
|
||||
if ((q = extfs_get_path (path, &archive, 1, 0)) == NULL)
|
||||
if ((q = extfs_get_path_mangle (path, &archive, 1, 0)) == NULL)
|
||||
return -1;
|
||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (!entry)
|
||||
@ -805,10 +811,12 @@ static vfsid extfs_getid (char *path, struct vfs_stamping **parent)
|
||||
vfs *v;
|
||||
vfsid id;
|
||||
struct vfs_stamping *par;
|
||||
char *p;
|
||||
|
||||
*parent = NULL;
|
||||
if (!extfs_get_path (path, &archive, 1, 1))
|
||||
if (!(p = extfs_get_path (path, &archive, 1, 1)))
|
||||
return (vfsid) -1;
|
||||
free(p);
|
||||
if (archive->name){
|
||||
v = vfs_type (archive->name);
|
||||
id = (*v->getid) (archive->name, &par);
|
||||
|
18
vfs/shared.c
18
vfs/shared.c
@ -5,6 +5,18 @@
|
||||
* 1998 Pavel Machek
|
||||
*/
|
||||
|
||||
static char *X_get_path (char *inname, struct X_archive **archive, int is_dir,
|
||||
int do_not_open)
|
||||
{
|
||||
char *buf = strdup( inname );
|
||||
char *res = X_get_path_mangle( buf, archive, is_dir, do_not_open );
|
||||
char *res2 = NULL;
|
||||
if (res)
|
||||
res2 = strdup(res);
|
||||
free(buf);
|
||||
return res2;
|
||||
}
|
||||
|
||||
static struct X_entry*
|
||||
__X_find_entry (struct X_entry *dir, char *name,
|
||||
struct X_loop_protect *list, int make_dirs, int make_file)
|
||||
@ -108,7 +120,7 @@ static void * s_opendir (char *dirname)
|
||||
struct X_entry *entry;
|
||||
struct X_entry **info;
|
||||
|
||||
if ((q = X_get_path (dirname, &archive, 1, 0)) == NULL)
|
||||
if ((q = X_get_path_mangle (dirname, &archive, 1, 0)) == NULL)
|
||||
return NULL;
|
||||
entry = X_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (entry == NULL)
|
||||
@ -214,7 +226,7 @@ char debugbuf[10240];
|
||||
strcpy( debugbuf, path );
|
||||
|
||||
|
||||
if ((q = X_get_path (path, &archive, 0, 0)) == NULL)
|
||||
if ((q = X_get_path_mangle (path, &archive, 0, 0)) == NULL)
|
||||
return -1;
|
||||
entry = X_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (entry == NULL)
|
||||
@ -253,7 +265,7 @@ static int s_readlink (char *path, char *buf, int size)
|
||||
int i;
|
||||
struct X_entry *entry;
|
||||
|
||||
if ((q = X_get_path (path, &archive, 0, 0)) == NULL)
|
||||
if ((q = X_get_path_mangle (path, &archive, 0, 0)) == NULL)
|
||||
return -1;
|
||||
entry = X_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (entry == NULL)
|
||||
|
20
vfs/tar.c
20
vfs/tar.c
@ -793,8 +793,13 @@ int read_tar_archive (char *name, struct tarfs_archive **pparc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Returns allocated path inside the archive or NULL */
|
||||
static char *tarfs_get_path (char *inname, struct tarfs_archive **archive, int is_dir,
|
||||
int do_not_open);
|
||||
|
||||
/* Returns path inside argument. Returned char* is inside inname, which is mangled
|
||||
* by this operation (so you must not free it's return value)
|
||||
*/
|
||||
static char *tarfs_get_path_mangle (char *inname, struct tarfs_archive **archive, int is_dir,
|
||||
int do_not_open)
|
||||
{
|
||||
char *local, *archive_name;
|
||||
@ -807,7 +812,7 @@ static char *tarfs_get_path (char *inname, struct tarfs_archive **archive, int i
|
||||
archive_name = inname;
|
||||
vfs_split( inname, &local, NULL );
|
||||
if (!local)
|
||||
local = "";
|
||||
local = "";
|
||||
|
||||
mc_stat (archive_name, &stat_buf);
|
||||
|
||||
@ -917,7 +922,7 @@ static void *tar_open (char *file, int flags, int mode)
|
||||
char *q;
|
||||
struct tarfs_entry *entry;
|
||||
|
||||
if ((q = tarfs_get_path (file, &archive, 0, 0)) == NULL)
|
||||
if ((q = tarfs_get_path_mangle (file, &archive, 0, 0)) == NULL)
|
||||
return NULL;
|
||||
entry = tarfs_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (entry == NULL)
|
||||
@ -1030,6 +1035,7 @@ static int tar_close (void *data)
|
||||
#define X_entry tarfs_entry
|
||||
#define X_archive tarfs_archive
|
||||
#define X_get_path tarfs_get_path
|
||||
#define X_get_path_mangle tarfs_get_path_mangle
|
||||
#define X_find_entry tarfs_find_entry
|
||||
#define X_resolve_symlinks tarfs_resolve_symlinks
|
||||
#define X_inode tarfs_inode
|
||||
@ -1076,7 +1082,7 @@ static int tar_chdir (char *path)
|
||||
struct tarfs_entry *entry;
|
||||
|
||||
tarerrno = ENOTDIR;
|
||||
if ((q = tarfs_get_path (path, &archive, 1, 0)) == NULL)
|
||||
if ((q = tarfs_get_path_mangle (path, &archive, 1, 0)) == NULL)
|
||||
return -1;
|
||||
entry = tarfs_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (!entry)
|
||||
@ -1137,9 +1143,9 @@ static vfsid tar_getid (char *path, struct vfs_stamping **parent)
|
||||
struct vfs_stamping *par;
|
||||
|
||||
*parent = NULL;
|
||||
if ((p = tarfs_get_path (path, &archive, 0, 1)) == NULL) {
|
||||
if (!(p = tarfs_get_path (path, &archive, 0, 1)))
|
||||
return (vfsid) -1;
|
||||
}
|
||||
free(p);
|
||||
v = vfs_type (archive->name);
|
||||
id = (*v->getid) (archive->name, &par);
|
||||
if (id != (vfsid)-1) {
|
||||
@ -1210,7 +1216,7 @@ static char *tar_getlocalcopy (char *path)
|
||||
char buf[MC_MAXPATHLEN];
|
||||
|
||||
strcpy( buf, path );
|
||||
if ((q = tarfs_get_path (path, &archive, 1, 0)) == NULL)
|
||||
if ((q = tarfs_get_path_mangle (path, &archive, 1, 0)) == NULL)
|
||||
return NULL;
|
||||
entry = tarfs_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (entry == NULL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user