Following prototypes of functions was changed in VFS-module API:

* archive_check
 * archive_same
 * open_archive

Added new functions:

 * vfs_path_element_clone()
 * vfs_path_clone()
 * vfs_path_remove_element_by_index()

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2011-06-08 16:40:36 +03:00
parent c442e5e75f
commit 922114a1d0
9 changed files with 179 additions and 60 deletions

View File

@ -40,33 +40,36 @@ struct vfs_class vfs_test_ops1, vfs_test_ops2, vfs_test_ops3;
static int static int
test1_mock_open_archive(struct vfs_class *me, struct vfs_s_super *super, test1_mock_open_archive(struct vfs_class *me, struct vfs_s_super *super,
const char *archive_name, char *op) const vfs_path_t *vpath, char *op)
{ {
struct vfs_s_inode *root; struct vfs_s_inode *root;
char *spath = vfs_path_to_str (vpath);
(void) op; (void) op;
fail_unless(strcmp("/" ETALON_VFS_NAME ARCH_NAME, archive_name) == 0, fail_unless(strcmp("/" ETALON_VFS_NAME ARCH_NAME, spath) == 0,
"etalon(%s) doesn't equal to actual(%s)", "/" ETALON_VFS_NAME ARCH_NAME, archive_name); "etalon(%s) doesn't equal to actual(%s)", "/" ETALON_VFS_NAME ARCH_NAME, spath);
super->name = g_strdup (archive_name); super->name = g_strdup (spath);
super->data = g_new (char *, 1); super->data = g_new (char *, 1);
root = vfs_s_new_inode (me, super, NULL); root = vfs_s_new_inode (me, super, NULL);
super->root = root; super->root = root;
g_free(spath);
return 0; return 0;
} }
static int static int
test1_mock_archive_same (struct vfs_class *me, struct vfs_s_super *super, test1_mock_archive_same (struct vfs_class *me, struct vfs_s_super *super,
const char *archive_name, char *op, void *cookie) const vfs_path_t *vpath, char *op, void *cookie)
{ {
vfs_path_element_t *path_element = vfs_path_get_by_index(vpath, -1);
(void) me; (void) me;
(void) super; (void) super;
(void) op; (void) op;
(void) cookie; (void) cookie;
if (strcmp(ARCH_NAME, archive_name) != 0) if (strcmp(ARCH_NAME, path_element->path) != 0)
return 0; return 0;
return 1; return 1;
} }

View File

@ -1052,26 +1052,28 @@ vfs_s_get_path_mangle (const vfs_path_t * vpath, struct vfs_s_super **archive, i
{ {
GList *iter; GList *iter;
const char *retval; const char *retval;
char *archive_name;
int result = -1; int result = -1;
struct vfs_s_super *super; struct vfs_s_super *super;
void *cookie = NULL; void *cookie = NULL;
vfs_path_element_t *path_element; vfs_path_element_t *path_element;
vfs_path_t *vpath_archive;
struct vfs_s_subclass *subclass; struct vfs_s_subclass *subclass;
path_element = vfs_path_get_by_index (vpath, -1); path_element = vfs_path_get_by_index (vpath, -1);
subclass = ((struct vfs_s_subclass *) path_element->class->data); subclass = ((struct vfs_s_subclass *) path_element->class->data);
archive_name = vfs_path_to_str_elements_count (vpath, -1); vpath_archive = vfs_path_clone (vpath);
vfs_path_remove_element_by_index (vpath_archive, -1);
retval = (path_element->path != NULL) ? path_element->path : ""; retval = (path_element->path != NULL) ? path_element->path : "";
if (subclass->archive_check != NULL) if (subclass->archive_check != NULL)
{ {
cookie = cookie =
subclass->archive_check (path_element->class, archive_name, path_element->raw_url_str); subclass->archive_check (path_element->class, vpath_archive, path_element->raw_url_str);
if (cookie == NULL) if (cookie == NULL)
{ {
g_free (archive_name); vfs_path_free (vpath_archive);
return NULL; return NULL;
} }
} }
@ -1083,7 +1085,7 @@ vfs_s_get_path_mangle (const vfs_path_t * vpath, struct vfs_s_super **archive, i
super = (struct vfs_s_super *) iter->data; 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 */
i = subclass->archive_same (path_element->class, super, archive_name, i = subclass->archive_same (path_element->class, super, vpath_archive,
path_element->raw_url_str, cookie); path_element->raw_url_str, cookie);
if (i != 0) if (i != 0)
{ {
@ -1096,20 +1098,20 @@ vfs_s_get_path_mangle (const vfs_path_t * vpath, struct vfs_s_super **archive, i
if (flags & FL_NO_OPEN) if (flags & FL_NO_OPEN)
{ {
path_element->class->verrno = EIO; path_element->class->verrno = EIO;
g_free (archive_name); vfs_path_free (vpath_archive);
return NULL; return NULL;
} }
super = vfs_s_new_super (path_element->class); super = vfs_s_new_super (path_element->class);
if (subclass->open_archive != NULL) if (subclass->open_archive != NULL)
result = result =
subclass->open_archive (path_element->class, super, archive_name, subclass->open_archive (path_element->class, super, vpath_archive,
path_element->raw_url_str); path_element->raw_url_str);
if (result == -1) if (result == -1)
{ {
vfs_s_free_super (path_element->class, super); vfs_s_free_super (path_element->class, super);
path_element->class->verrno = EIO; path_element->class->verrno = EIO;
g_free (archive_name); vfs_path_free (vpath_archive);
return NULL; return NULL;
} }
if (!super->name) if (!super->name)
@ -1122,7 +1124,7 @@ vfs_s_get_path_mangle (const vfs_path_t * vpath, struct vfs_s_super **archive, i
return_success: return_success:
*archive = super; *archive = super;
g_free (archive_name); vfs_path_free (vpath_archive);
return retval; return retval;
} }

View File

@ -398,10 +398,35 @@ vfs_path_get_by_index (const vfs_path_t * vpath, int element_index)
if (vpath == NULL) if (vpath == NULL)
return NULL; return NULL;
if (element_index >= 0) if (element_index < 0)
return g_list_nth_data (vpath->path, element_index); element_index = vfs_path_elements_count (vpath) + element_index;
return g_list_nth_data (vpath->path, vfs_path_elements_count (vpath) + element_index); return g_list_nth_data (vpath->path, element_index);
}
/* --------------------------------------------------------------------------------------------- */
/*
* Clone one path element
*
* @param element pointer to vfs_path_element_t object
*
* @return Newly allocated path element
*/
vfs_path_element_t *
vfs_path_element_clone (const vfs_path_element_t * element)
{
vfs_path_element_t *new_element = g_new0 (vfs_path_element_t, 1);
memcpy (new_element, element, sizeof (vfs_path_element_t));
new_element->user = g_strdup (element->user);
new_element->password = g_strdup (element->password);
new_element->host = g_strdup (element->host);
new_element->path = g_strdup (element->path);
new_element->encoding = g_strdup (element->encoding);
return new_element;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -432,6 +457,36 @@ vfs_path_element_free (vfs_path_element_t * element)
g_free (element); g_free (element);
} }
/* --------------------------------------------------------------------------------------------- */
/*
* Clone path
*
* @param vpath pointer to vfs_path_t object
*
* @return Newly allocated path object
*/
vfs_path_t *
vfs_path_clone (const vfs_path_t * vpath)
{
vfs_path_t *new_vpath;
int vpath_element_index;
if (vpath == NULL)
return NULL;
new_vpath = vfs_path_new ();
for (vpath_element_index = 0; vpath_element_index < vfs_path_elements_count (vpath);
vpath_element_index++)
{
new_vpath->path =
g_list_append (new_vpath->path,
vfs_path_element_clone (vfs_path_get_by_index
(vpath, vpath_element_index)));
}
return new_vpath;
}
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/* /*
* Free vfs_path_t object. * Free vfs_path_t object.
@ -450,6 +505,31 @@ vfs_path_free (vfs_path_t * path)
g_free (path); g_free (path);
} }
/* --------------------------------------------------------------------------------------------- */
/*
* Remove one path element by index
*
* @param vpath pointer to vfs_path_t object
* @param element_index element index. May have negative value (in this case count was started at the end of list).
*
*/
void
vfs_path_remove_element_by_index (vfs_path_t * vpath, int element_index)
{
vfs_path_element_t *element;
if ((vpath == NULL) || (vfs_path_elements_count (vpath) == 1))
return;
if (element_index < 0)
element_index = vfs_path_elements_count (vpath) + element_index;
element = g_list_nth_data (vpath->path, element_index);
vpath->path = g_list_remove (vpath->path, element);
vfs_path_element_free (element);
}
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/** Return VFS class for the given prefix */ /** Return VFS class for the given prefix */

View File

@ -41,6 +41,8 @@ typedef struct
/*** declarations of public functions ************************************************************/ /*** declarations of public functions ************************************************************/
vfs_path_t *vfs_path_new (void); vfs_path_t *vfs_path_new (void);
vfs_path_t *vfs_path_clone (const vfs_path_t * vpath);
void vfs_path_remove_element_by_index (vfs_path_t * vpath, int element_index);
void vfs_path_free (vfs_path_t * path); void vfs_path_free (vfs_path_t * path);
int vfs_path_elements_count (const vfs_path_t * path); int vfs_path_elements_count (const vfs_path_t * path);
@ -49,6 +51,7 @@ char *vfs_path_to_str_elements_count (const vfs_path_t * path, int elements_coun
vfs_path_t *vfs_path_from_str (const char *path_str); vfs_path_t *vfs_path_from_str (const char *path_str);
vfs_path_element_t *vfs_path_get_by_index (const vfs_path_t * path, int element_index); vfs_path_element_t *vfs_path_get_by_index (const vfs_path_t * path, int element_index);
vfs_path_element_t *vfs_path_element_clone (const vfs_path_element_t * element);
void vfs_path_element_free (vfs_path_element_t * element); void vfs_path_element_free (vfs_path_element_t * element);
struct vfs_class *vfs_prefix_to_class (const char *prefix); struct vfs_class *vfs_prefix_to_class (const char *prefix);

View File

@ -124,11 +124,11 @@ struct vfs_s_subclass
void (*free_inode) (struct vfs_class * me, struct vfs_s_inode * ino); /* optional */ void (*free_inode) (struct vfs_class * me, struct vfs_s_inode * ino); /* optional */
int (*init_entry) (struct vfs_class * me, struct vfs_s_entry * entry); /* optional */ int (*init_entry) (struct vfs_class * me, struct vfs_s_entry * entry); /* optional */
void *(*archive_check) (struct vfs_class * me, const char *name, char *op); /* optional */ void *(*archive_check) (struct vfs_class * me, const vfs_path_t * vpath, char *op); /* optional */
int (*archive_same) (struct vfs_class * me, struct vfs_s_super * psup, int (*archive_same) (struct vfs_class * me, struct vfs_s_super * psup,
const char *archive_name, char *op, void *cookie); const vfs_path_t * vpath, char *op, void *cookie);
int (*open_archive) (struct vfs_class * me, struct vfs_s_super * psup, int (*open_archive) (struct vfs_class * me, struct vfs_s_super * psup,
const char *archive_name, char *op); const vfs_path_t * vpath, char *op);
void (*free_archive) (struct vfs_class * me, struct vfs_s_super * psup); void (*free_archive) (struct vfs_class * me, struct vfs_s_super * psup);
int (*fh_open) (struct vfs_class * me, vfs_file_handler_t * fh, int flags, mode_t mode); int (*fh_open) (struct vfs_class * me, vfs_file_handler_t * fh, int flags, mode_t mode);

View File

@ -392,7 +392,7 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super, struct stat
if ((st->st_nlink > 1) && ((arch->type == CPIO_NEWC) || (arch->type == CPIO_CRC))) if ((st->st_nlink > 1) && ((arch->type == CPIO_NEWC) || (arch->type == CPIO_CRC)))
{ /* For case of hardlinked files */ { /* For case of hardlinked files */
defer_inode i = {st->st_ino, st->st_dev, NULL}; defer_inode i = { st->st_ino, st->st_dev, NULL };
GSList *l; GSList *l;
l = g_slist_find_custom (arch->deferred, &i, cpio_defer_find); l = g_slist_find_custom (arch->deferred, &i, cpio_defer_find);
@ -714,14 +714,19 @@ cpio_read_crc_head (struct vfs_class *me, struct vfs_s_super *super)
/** Need to CPIO_SEEK_CUR to skip the file at the end of add entry!!!! */ /** Need to CPIO_SEEK_CUR to skip the file at the end of add entry!!!! */
static int static int
cpio_open_archive (struct vfs_class *me, struct vfs_s_super *super, const char *name, char *op) cpio_open_archive (struct vfs_class *me, struct vfs_s_super *super, const vfs_path_t * vpath,
char *op)
{ {
int status = STATUS_START; int status = STATUS_START;
char *archive_name = vfs_path_to_str (vpath);
(void) op; (void) op;
if (cpio_open_cpio_file (me, super, name) == -1) if (cpio_open_cpio_file (me, super, archive_name) == -1)
{
g_free (archive_name);
return -1; return -1;
}
while (TRUE) while (TRUE)
{ {
@ -730,7 +735,7 @@ cpio_open_archive (struct vfs_class *me, struct vfs_s_super *super, const char *
switch (status) switch (status)
{ {
case STATUS_EOF: case STATUS_EOF:
message (D_ERROR, MSG_ERROR, _("Unexpected end of file\n%s"), name); message (D_ERROR, MSG_ERROR, _("Unexpected end of file\n%s"), archive_name);
return 0; return 0;
case STATUS_OK: case STATUS_OK:
continue; continue;
@ -740,6 +745,7 @@ cpio_open_archive (struct vfs_class *me, struct vfs_s_super *super, const char *
break; break;
} }
g_free (archive_name);
return 0; return 0;
} }
@ -747,29 +753,38 @@ cpio_open_archive (struct vfs_class *me, struct vfs_s_super *super, const char *
/** Remaining functions are exactly same as for tarfs (and were in fact just copied) */ /** Remaining functions are exactly same as for tarfs (and were in fact just copied) */
static void * static void *
cpio_super_check (struct vfs_class *me, const char *archive_name, char *op) cpio_super_check (struct vfs_class *me, const vfs_path_t * vpath, char *op)
{ {
static struct stat sb; static struct stat sb;
char *archive_name = vfs_path_to_str (vpath);
int stat_result;
(void) me; (void) me;
(void) op; (void) op;
return (mc_stat (archive_name, &sb) == 0 ? &sb : NULL); stat_result = mc_stat (archive_name, &sb);
g_free (archive_name);
return (stat_result == 0 ? &sb : NULL);
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static int
cpio_super_same (struct vfs_class *me, struct vfs_s_super *parc, cpio_super_same (struct vfs_class *me, struct vfs_s_super *parc,
const char *archive_name, char *op, void *cookie) const vfs_path_t * vpath, char *op, void *cookie)
{ {
struct stat *archive_stat = cookie; /* stat of main archive */ struct stat *archive_stat = cookie; /* stat of main archive */
char *archive_name = vfs_path_to_str (vpath);
(void) me; (void) me;
(void) op; (void) op;
if (strcmp (parc->name, archive_name)) if (strcmp (parc->name, archive_name))
{
g_free (archive_name);
return 0; return 0;
}
g_free (archive_name);
/* Has the cached archive been changed on the disk? */ /* Has the cached archive been changed on the disk? */
if (((cpio_super_data_t *) parc->data)->st.st_mtime < archive_stat->st_mtime) if (((cpio_super_data_t *) parc->data)->st.st_mtime < archive_stat->st_mtime)
@ -810,7 +825,7 @@ cpio_read (void *fh, char *buffer, size_t count)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static int
cpio_fh_open (struct vfs_class *me, vfs_file_handler_t *fh, int flags, mode_t mode) cpio_fh_open (struct vfs_class *me, vfs_file_handler_t * fh, int flags, mode_t mode)
{ {
(void) mode; (void) mode;

View File

@ -582,9 +582,9 @@ fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
static int static int
fish_open_archive (struct vfs_class *me, struct vfs_s_super *super, fish_open_archive (struct vfs_class *me, struct vfs_s_super *super,
const char *archive_name, char *op) const vfs_path_t * vpath, char *op)
{ {
(void) archive_name; (void) vpath;
super->data = g_new0 (fish_super_data_t, 1); super->data = g_new0 (fish_super_data_t, 1);
super->path_element = vfs_url_split (strchr (op, ':') + 1, 0, URL_NOSLASH | URL_USE_ANONYMOUS); super->path_element = vfs_url_split (strchr (op, ':') + 1, 0, URL_NOSLASH | URL_USE_ANONYMOUS);
@ -638,13 +638,13 @@ fish_open_archive (struct vfs_class *me, struct vfs_s_super *super,
static int static int
fish_archive_same (struct vfs_class *me, struct vfs_s_super *super, fish_archive_same (struct vfs_class *me, struct vfs_s_super *super,
const char *archive_name, char *op, void *cookie) const vfs_path_t * vpath, char *op, void *cookie)
{ {
vfs_path_element_t *path_element; vfs_path_element_t *path_element;
int result; int result;
(void) me; (void) me;
(void) archive_name; (void) vpath;
(void) cookie; (void) cookie;
path_element = vfs_url_split (strchr (op, ':') + 1, 0, URL_NOSLASH | URL_USE_ANONYMOUS); path_element = vfs_url_split (strchr (op, ':') + 1, 0, URL_NOSLASH | URL_USE_ANONYMOUS);

View File

@ -960,9 +960,9 @@ ftpfs_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
static int static int
ftpfs_open_archive (struct vfs_class *me, struct vfs_s_super *super, ftpfs_open_archive (struct vfs_class *me, struct vfs_s_super *super,
const char *archive_name, char *op) const vfs_path_t * vpath, char *op)
{ {
(void) archive_name; (void) vpath;
super->data = g_new0 (ftp_super_data_t, 1); super->data = g_new0 (ftp_super_data_t, 1);
@ -984,13 +984,13 @@ ftpfs_open_archive (struct vfs_class *me, struct vfs_s_super *super,
static int static int
ftpfs_archive_same (struct vfs_class *me, struct vfs_s_super *super, ftpfs_archive_same (struct vfs_class *me, struct vfs_s_super *super,
const char *archive_name, char *op, void *cookie) const vfs_path_t * vpath, char *op, void *cookie)
{ {
vfs_path_element_t *path_element; vfs_path_element_t *path_element;
int result; int result;
(void) me; (void) me;
(void) archive_name; (void) vpath;
(void) cookie; (void) cookie;
path_element = ftpfs_split_url (strchr (op, ':') + 1); path_element = ftpfs_split_url (strchr (op, ':') + 1);

View File

@ -275,29 +275,31 @@ tar_free_archive (struct vfs_class *me, struct vfs_s_super *archive)
/* Returns fd of the open tar file */ /* Returns fd of the open tar file */
static int static int
tar_open_archive_int (struct vfs_class *me, const char *name, struct vfs_s_super *archive) tar_open_archive_int (struct vfs_class *me, const vfs_path_t * vpath, struct vfs_s_super *archive)
{ {
int result, type; int result, type;
tar_super_data_t *arch; tar_super_data_t *arch;
mode_t mode; mode_t mode;
struct vfs_s_inode *root; struct vfs_s_inode *root;
char *archive_name = vfs_path_to_str (vpath);
result = mc_open (name, O_RDONLY); result = mc_open (archive_name, O_RDONLY);
if (result == -1) if (result == -1)
{ {
message (D_ERROR, MSG_ERROR, _("Cannot open tar archive\n%s"), name); message (D_ERROR, MSG_ERROR, _("Cannot open tar archive\n%s"), archive_name);
g_free(archive_name);
ERRNOR (ENOENT, -1); ERRNOR (ENOENT, -1);
} }
archive->name = g_strdup (name); archive->name = archive_name;
archive->data = g_new (tar_super_data_t, 1); archive->data = g_new (tar_super_data_t, 1);
arch = (tar_super_data_t *) archive->data; arch = (tar_super_data_t *) archive->data;
mc_stat (name, &arch->st); mc_stat (archive_name, &arch->st);
arch->fd = -1; arch->fd = -1;
arch->type = TAR_UNKNOWN; arch->type = TAR_UNKNOWN;
/* Find out the method to handle this tar file */ /* Find out the method to handle this tar file */
type = get_compression_type (result, name); type = get_compression_type (result, archive_name);
mc_lseek (result, 0, SEEK_SET); mc_lseek (result, 0, SEEK_SET);
if (type != COMPRESSION_NONE) if (type != COMPRESSION_NONE)
{ {
@ -395,12 +397,12 @@ tar_fill_stat (struct vfs_s_super *archive, struct stat *st, union record *heade
case TAR_GNU: case TAR_GNU:
st->st_uid = st->st_uid =
*header->header.uname ? vfs_finduid (header->header.uname) : tar_from_oct (8, *header->header.uname ? vfs_finduid (header->header.uname) : tar_from_oct (8,
header-> header->header.
header.uid); uid);
st->st_gid = st->st_gid =
*header->header.gname ? vfs_findgid (header->header.gname) : tar_from_oct (8, *header->header.gname ? vfs_findgid (header->header.gname) : tar_from_oct (8,
header-> header->header.
header.gid); gid);
switch (header->header.linkflag) switch (header->header.linkflag)
{ {
case LF_BLK: case LF_BLK:
@ -727,7 +729,8 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si
* Returns 0 on success, -1 on error. * Returns 0 on success, -1 on error.
*/ */
static int static int
tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive, const char *name, char *op) tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive, const vfs_path_t * vpath,
char *op)
{ {
/* Initial status at start of archive */ /* Initial status at start of archive */
ReadStatus status = STATUS_EOFMARK; ReadStatus status = STATUS_EOFMARK;
@ -738,7 +741,7 @@ tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive, const char
current_tar_position = 0; current_tar_position = 0;
/* Open for reading */ /* Open for reading */
tard = tar_open_archive_int (me, name, archive); tard = tar_open_archive_int (me, vpath, archive);
if (tard == -1) if (tard == -1)
return -1; return -1;
@ -768,10 +771,15 @@ tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive, const char
/* Error on first record */ /* Error on first record */
case STATUS_EOFMARK: case STATUS_EOFMARK:
message (D_ERROR, MSG_ERROR, _("%s\ndoesn't look like a tar archive."), name); {
/* FALL THRU */ char *archive_name = vfs_path_to_str(vpath);
message (D_ERROR, MSG_ERROR, _("%s\ndoesn't look like a tar archive."),
archive_name);
g_free(archive_name);
/* FALL THRU */
/* Error after header rec */ /* Error after header rec */
}
case STATUS_SUCCESS: case STATUS_SUCCESS:
/* Error after error */ /* Error after error */
@ -798,31 +806,39 @@ tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive, const char
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static void * static void *
tar_super_check (struct vfs_class *me, const char *archive_name, char *op) tar_super_check (struct vfs_class *me, const vfs_path_t * vpath, char *op)
{ {
static struct stat stat_buf; static struct stat stat_buf;
char *archive_name = vfs_path_to_str(vpath);
int stat_result;
(void) me; (void) me;
(void) op; (void) op;
if (mc_stat (archive_name, &stat_buf)) stat_result = mc_stat (archive_name, &stat_buf);
return NULL; g_free(archive_name);
return &stat_buf;
return (stat_result != 0) ? NULL : &stat_buf;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static int
tar_super_same (struct vfs_class *me, struct vfs_s_super *parc, tar_super_same (struct vfs_class *me, struct vfs_s_super *parc,
const char *archive_name, char *op, void *cookie) const vfs_path_t * vpath, char *op, void *cookie)
{ {
struct stat *archive_stat = cookie; /* stat of main archive */ struct stat *archive_stat = cookie; /* stat of main archive */
char *archive_name = vfs_path_to_str(vpath);
(void) me; (void) me;
(void) op; (void) op;
if (strcmp (parc->name, archive_name)) if (strcmp (parc->name, archive_name) != 0)
{
g_free(archive_name);
return 0; return 0;
}
g_free(archive_name);
/* Has the cached archive been changed on the disk? */ /* Has the cached archive been changed on the disk? */
if (((tar_super_data_t *) parc->data)->st.st_mtime < archive_stat->st_mtime) if (((tar_super_data_t *) parc->data)->st.st_mtime < archive_stat->st_mtime)
@ -863,7 +879,7 @@ tar_read (void *fh, char *buffer, size_t count)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static int
tar_fh_open (struct vfs_class *me, vfs_file_handler_t *fh, int flags, mode_t mode) tar_fh_open (struct vfs_class *me, vfs_file_handler_t * fh, int flags, mode_t mode)
{ {
(void) fh; (void) fh;
(void) mode; (void) mode;