mirror of
https://github.com/MidnightCommander/mc
synced 2025-04-09 00:22:55 +03:00
* gc.c: Eliminate all code for timestamping parent filesystems.
It's broken and undocumented. Adjust all dependencies.
This commit is contained in:
parent
645eeb8118
commit
6ffd35bf07
@ -1,3 +1,8 @@
|
|||||||
|
2003-11-26 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* gc.c: Eliminate all code for timestamping parent filesystems.
|
||||||
|
It's broken and undocumented. Adjust all dependencies.
|
||||||
|
|
||||||
2003-11-24 Andrew V. Samoilov <sav@bcs.zp.ua>
|
2003-11-24 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||||
|
|
||||||
* direntry.c (vfs_s_resolve_symlink): Eliminate
|
* direntry.c (vfs_s_resolve_symlink): Eliminate
|
||||||
|
@ -559,7 +559,7 @@ cpio_super_same (struct vfs_class *me, struct vfs_s_super *parc,
|
|||||||
if (parc->u.arch.st.st_mtime < archive_stat->st_mtime) {
|
if (parc->u.arch.st.st_mtime < archive_stat->st_mtime) {
|
||||||
/* Yes, reload! */
|
/* Yes, reload! */
|
||||||
(*vfs_cpiofs_ops.free) ((vfsid) parc);
|
(*vfs_cpiofs_ops.free) ((vfsid) parc);
|
||||||
vfs_rmstamp (&vfs_cpiofs_ops, (vfsid) parc, 0);
|
vfs_rmstamp (&vfs_cpiofs_ops, (vfsid) parc);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
/* Hasn't been modified, give it a new timeout */
|
/* Hasn't been modified, give it a new timeout */
|
||||||
|
@ -475,7 +475,7 @@ vfs_s_get_path_mangle (struct vfs_class *me, char *inname,
|
|||||||
vfs_die ("You have to fill root inode\n");
|
vfs_die ("You have to fill root inode\n");
|
||||||
|
|
||||||
vfs_s_insert_super (me, super);
|
vfs_s_insert_super (me, super);
|
||||||
vfs_stamp_create (me, super, archive_name);
|
vfs_stamp_create (me, super);
|
||||||
|
|
||||||
return_success:
|
return_success:
|
||||||
*archive = super;
|
*archive = super;
|
||||||
@ -767,7 +767,7 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* i.e. we had no open files and now we have one */
|
/* i.e. we had no open files and now we have one */
|
||||||
vfs_rmstamp (me, (vfsid) super, 1);
|
vfs_rmstamp (me, (vfsid) super);
|
||||||
super->fd_usage++;
|
super->fd_usage++;
|
||||||
fh->ino->st.st_nlink++;
|
fh->ino->st.st_nlink++;
|
||||||
return fh;
|
return fh;
|
||||||
@ -850,7 +850,7 @@ vfs_s_close (void *fh)
|
|||||||
|
|
||||||
FH_SUPER->fd_usage--;
|
FH_SUPER->fd_usage--;
|
||||||
if (!FH_SUPER->fd_usage)
|
if (!FH_SUPER->fd_usage)
|
||||||
vfs_stamp_create (me, FH_SUPER, FH_SUPER->name);
|
vfs_stamp_create (me, FH_SUPER);
|
||||||
|
|
||||||
if (FH->linear == LS_LINEAR_OPEN)
|
if (FH->linear == LS_LINEAR_OPEN)
|
||||||
MEDATA->linear_close (me, fh);
|
MEDATA->linear_close (me, fh);
|
||||||
@ -1043,27 +1043,14 @@ vfs_s_setctl (struct vfs_class *me, char *path, int ctlop, void *arg)
|
|||||||
/* ----------------------------- Stamping support -------------------------- */
|
/* ----------------------------- Stamping support -------------------------- */
|
||||||
|
|
||||||
static vfsid
|
static vfsid
|
||||||
vfs_s_getid (struct vfs_class *me, const char *path, struct vfs_stamping **parent)
|
vfs_s_getid (struct vfs_class *me, const char *path)
|
||||||
{
|
{
|
||||||
struct vfs_s_super *archive;
|
struct vfs_s_super *archive;
|
||||||
struct vfs_class *v;
|
|
||||||
char *p;
|
char *p;
|
||||||
vfsid id;
|
|
||||||
struct vfs_stamping *par;
|
|
||||||
|
|
||||||
*parent = NULL;
|
|
||||||
if (!(p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN)))
|
if (!(p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN)))
|
||||||
return NULL;
|
return NULL;
|
||||||
g_free(p);
|
g_free(p);
|
||||||
v = vfs_get_class (archive->name);
|
|
||||||
id = vfs_getid (v, archive->name, &par);
|
|
||||||
if (id) {
|
|
||||||
*parent = g_new (struct vfs_stamping, 1);
|
|
||||||
(*parent)->v = v;
|
|
||||||
(*parent)->id = id;
|
|
||||||
(*parent)->parent = par;
|
|
||||||
(*parent)->next = NULL;
|
|
||||||
}
|
|
||||||
return (vfsid) archive;
|
return (vfsid) archive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
vfs/extfs.c
29
vfs/extfs.c
@ -468,9 +468,6 @@ extfs_get_path_mangle (char *inname, struct archive **archive, int is_dir,
|
|||||||
if (result == -1)
|
if (result == -1)
|
||||||
ERRNOR (EIO, NULL);
|
ERRNOR (EIO, NULL);
|
||||||
|
|
||||||
if (archive_name)
|
|
||||||
vfs_stamp_create (&vfs_extfs_ops, parc, archive_name);
|
|
||||||
|
|
||||||
return_success:
|
return_success:
|
||||||
*archive = parc;
|
*archive = parc;
|
||||||
return local;
|
return local;
|
||||||
@ -713,7 +710,7 @@ extfs_open (struct vfs_class *me, const char *file, int flags, int mode)
|
|||||||
extfs_info->local_handle = local_handle;
|
extfs_info->local_handle = local_handle;
|
||||||
|
|
||||||
/* i.e. we had no open files and now we have one */
|
/* i.e. we had no open files and now we have one */
|
||||||
vfs_rmstamp (&vfs_extfs_ops, (vfsid) archive, 1);
|
vfs_rmstamp (&vfs_extfs_ops, (vfsid) archive);
|
||||||
archive->fd_usage++;
|
archive->fd_usage++;
|
||||||
return extfs_info;
|
return extfs_info;
|
||||||
}
|
}
|
||||||
@ -753,10 +750,8 @@ extfs_close (void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
file->archive->fd_usage--;
|
file->archive->fd_usage--;
|
||||||
if (!file->archive->fd_usage) {
|
if (!file->archive->fd_usage)
|
||||||
vfs_stamp_create (&vfs_extfs_ops, file->archive,
|
vfs_stamp_create (&vfs_extfs_ops, file->archive);
|
||||||
file->archive->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (data);
|
g_free (data);
|
||||||
if (errno_code)
|
if (errno_code)
|
||||||
@ -1108,29 +1103,15 @@ static int extfs_lseek (void *data, off_t offset, int whence)
|
|||||||
return lseek (file->local_handle, offset, whence);
|
return lseek (file->local_handle, offset, whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
static vfsid extfs_getid (struct vfs_class *me, const char *path, struct vfs_stamping **parent)
|
static vfsid
|
||||||
|
extfs_getid (struct vfs_class *me, const char *path)
|
||||||
{
|
{
|
||||||
struct archive *archive;
|
struct archive *archive;
|
||||||
struct vfs_class *v;
|
|
||||||
vfsid id;
|
|
||||||
struct vfs_stamping *par;
|
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
*parent = NULL;
|
|
||||||
if (!(p = extfs_get_path (path, &archive, 1, 1)))
|
if (!(p = extfs_get_path (path, &archive, 1, 1)))
|
||||||
return NULL;
|
return NULL;
|
||||||
g_free (p);
|
g_free (p);
|
||||||
if (archive->name){
|
|
||||||
v = vfs_get_class (archive->name);
|
|
||||||
id = vfs_getid (v, archive->name, &par);
|
|
||||||
if (id) {
|
|
||||||
*parent = g_new (struct vfs_stamping, 1);
|
|
||||||
(*parent)->v = v;
|
|
||||||
(*parent)->id = id;
|
|
||||||
(*parent)->parent = par;
|
|
||||||
(*parent)->next = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (vfsid) archive;
|
return (vfsid) archive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,7 +687,7 @@ fish_send_command(struct vfs_class *me, struct vfs_s_super *super, char *cmd, in
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = fish_command (me, super, WAIT_REPLY, cmd);
|
r = fish_command (me, super, WAIT_REPLY, cmd);
|
||||||
vfs_stamp_create (&vfs_fish_ops, super, NULL);
|
vfs_stamp_create (&vfs_fish_ops, super);
|
||||||
if (r != COMPLETE) ERRNOR (E_REMOTE, -1);
|
if (r != COMPLETE) ERRNOR (E_REMOTE, -1);
|
||||||
if (flags & OPT_FLUSH)
|
if (flags & OPT_FLUSH)
|
||||||
vfs_s_invalidate(me, super);
|
vfs_s_invalidate(me, super);
|
||||||
|
@ -1455,7 +1455,7 @@ ftpfs_send_command(struct vfs_class *me, char *filename, char *cmd, int flags)
|
|||||||
p = ftpfs_translate_path (me, super, rpath);
|
p = ftpfs_translate_path (me, super, rpath);
|
||||||
r = ftpfs_command (me, super, WAIT_REPLY, cmd, p);
|
r = ftpfs_command (me, super, WAIT_REPLY, cmd, p);
|
||||||
g_free (p);
|
g_free (p);
|
||||||
vfs_stamp_create (&vfs_ftpfs_ops, super, NULL);
|
vfs_stamp_create (&vfs_ftpfs_ops, super);
|
||||||
if (flags & OPT_IGNORE_ERROR)
|
if (flags & OPT_IGNORE_ERROR)
|
||||||
r = COMPLETE;
|
r = COMPLETE;
|
||||||
if (r != COMPLETE)
|
if (r != COMPLETE)
|
||||||
|
171
vfs/gc.c
171
vfs/gc.c
@ -45,7 +45,7 @@ static struct vfs_stamping *stamps;
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vfs_addstamp (struct vfs_class *v, vfsid id, struct vfs_stamping *parent)
|
vfs_addstamp (struct vfs_class *v, vfsid id)
|
||||||
{
|
{
|
||||||
if (!(v->flags & VFSF_LOCAL) && id != NULL) {
|
if (!(v->flags & VFSF_LOCAL) && id != NULL) {
|
||||||
struct vfs_stamping *stamp;
|
struct vfs_stamping *stamp;
|
||||||
@ -61,17 +61,6 @@ vfs_addstamp (struct vfs_class *v, vfsid id, struct vfs_stamping *parent)
|
|||||||
stamp = g_new (struct vfs_stamping, 1);
|
stamp = g_new (struct vfs_stamping, 1);
|
||||||
stamp->v = v;
|
stamp->v = v;
|
||||||
stamp->id = id;
|
stamp->id = id;
|
||||||
if (parent) {
|
|
||||||
struct vfs_stamping *st = stamp;
|
|
||||||
while (parent) {
|
|
||||||
st->parent = g_new (struct vfs_stamping, 1);
|
|
||||||
*st->parent = *parent;
|
|
||||||
parent = parent->parent;
|
|
||||||
st = st->parent;
|
|
||||||
}
|
|
||||||
st->parent = 0;
|
|
||||||
} else
|
|
||||||
stamp->parent = 0;
|
|
||||||
|
|
||||||
gettimeofday (&(stamp->time), NULL);
|
gettimeofday (&(stamp->time), NULL);
|
||||||
stamp->next = 0;
|
stamp->next = 0;
|
||||||
@ -94,44 +83,20 @@ vfs_stamp (struct vfs_class *v, vfsid id)
|
|||||||
|
|
||||||
for (stamp = stamps; stamp != NULL; stamp = stamp->next)
|
for (stamp = stamps; stamp != NULL; stamp = stamp->next)
|
||||||
if (stamp->v == v && stamp->id == id) {
|
if (stamp->v == v && stamp->id == id) {
|
||||||
|
|
||||||
gettimeofday (&(stamp->time), NULL);
|
gettimeofday (&(stamp->time), NULL);
|
||||||
if (stamp->parent != NULL)
|
|
||||||
vfs_stamp (stamp->parent->v, stamp->parent->id);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
vfs_rm_parents (struct vfs_stamping *stamp)
|
|
||||||
{
|
|
||||||
struct vfs_stamping *parent;
|
|
||||||
|
|
||||||
while (stamp) {
|
|
||||||
parent = stamp->parent;
|
|
||||||
g_free (stamp);
|
|
||||||
stamp = parent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
vfs_rmstamp (struct vfs_class *v, vfsid id, int removeparents)
|
vfs_rmstamp (struct vfs_class *v, vfsid id)
|
||||||
{
|
{
|
||||||
struct vfs_stamping *stamp, *st1;
|
struct vfs_stamping *stamp, *st1;
|
||||||
|
|
||||||
for (stamp = stamps, st1 = NULL; stamp != NULL;
|
for (stamp = stamps, st1 = NULL; stamp != NULL;
|
||||||
st1 = stamp, stamp = stamp->next)
|
st1 = stamp, stamp = stamp->next)
|
||||||
if (stamp->v == v && stamp->id == id) {
|
if (stamp->v == v && stamp->id == id) {
|
||||||
if (stamp->parent != NULL) {
|
|
||||||
if (removeparents)
|
|
||||||
vfs_rmstamp (stamp->parent->v, stamp->parent->id, 1);
|
|
||||||
vfs_rm_parents (stamp->parent);
|
|
||||||
stamp->parent = NULL;
|
|
||||||
continue; /* rescan the tree */
|
|
||||||
}
|
|
||||||
if (st1 == NULL) {
|
if (st1 == NULL) {
|
||||||
stamps = stamp->next;
|
stamps = stamp->next;
|
||||||
} else {
|
} else {
|
||||||
@ -146,14 +111,12 @@ vfs_rmstamp (struct vfs_class *v, vfsid id, int removeparents)
|
|||||||
|
|
||||||
/* Wrapper around getid methods */
|
/* Wrapper around getid methods */
|
||||||
vfsid
|
vfsid
|
||||||
vfs_getid (struct vfs_class *vclass, const char *path,
|
vfs_getid (struct vfs_class *vclass, const char *path)
|
||||||
struct vfs_stamping **parent)
|
|
||||||
{
|
{
|
||||||
vfsid id = NULL;
|
vfsid id = NULL;
|
||||||
|
|
||||||
*parent = NULL;
|
|
||||||
if (vclass->getid)
|
if (vclass->getid)
|
||||||
id = (*vclass->getid) (vclass, path, parent);
|
id = (*vclass->getid) (vclass, path);
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -161,96 +124,38 @@ vfs_getid (struct vfs_class *vclass, const char *path,
|
|||||||
|
|
||||||
/* Same as vfs_getid, but append slash to the path if needed */
|
/* Same as vfs_getid, but append slash to the path if needed */
|
||||||
vfsid
|
vfsid
|
||||||
vfs_ncs_getid (struct vfs_class *nvfs, const char *dir,
|
vfs_ncs_getid (struct vfs_class *nvfs, const char *dir)
|
||||||
struct vfs_stamping **par)
|
|
||||||
{
|
{
|
||||||
vfsid nvfsid;
|
vfsid nvfsid;
|
||||||
char *dir1;
|
char *dir1;
|
||||||
|
|
||||||
dir1 = concat_dir_and_file (dir, "");
|
dir1 = concat_dir_and_file (dir, "");
|
||||||
nvfsid = vfs_getid (nvfs, dir1, par);
|
nvfsid = vfs_getid (nvfs, dir1);
|
||||||
g_free (dir1);
|
g_free (dir1);
|
||||||
return nvfsid;
|
return nvfsid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create a new timestamp item by VFS class and VFS id.
|
|
||||||
* If parent_name is provided, get ID for it and make it our parent.
|
|
||||||
* This should be an archive name, so that the parent archive could be
|
|
||||||
* freed in the same time as the VFS object for the given VFS id.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
vfs_stamp_create (struct vfs_class *vclass, vfsid id,
|
|
||||||
const char *parent_name)
|
|
||||||
{
|
|
||||||
struct vfs_stamping *parent, *pparent;
|
|
||||||
struct vfs_class *pclass;
|
|
||||||
vfsid par_id;
|
|
||||||
|
|
||||||
parent = NULL;
|
|
||||||
if (parent_name) {
|
|
||||||
pclass = vfs_get_class (parent_name);
|
|
||||||
par_id = vfs_getid (pclass, parent_name, &pparent);
|
|
||||||
if (par_id) {
|
|
||||||
parent = g_new (struct vfs_stamping, 1);
|
|
||||||
parent->v = pclass;
|
|
||||||
parent->next = 0;
|
|
||||||
parent->id = par_id;
|
|
||||||
parent->parent = pparent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vfs_add_noncurrent_stamps (vclass, id, parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
is_parent (struct vfs_class *nvfs, vfsid nvfsid,
|
|
||||||
struct vfs_stamping *parent)
|
|
||||||
{
|
|
||||||
struct vfs_stamping *stamp;
|
|
||||||
|
|
||||||
for (stamp = parent; stamp; stamp = stamp->parent)
|
|
||||||
if (stamp->v == nvfs && stamp->id == nvfsid)
|
|
||||||
break;
|
|
||||||
|
|
||||||
return (stamp ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vfs_stamp_path (char *path)
|
vfs_stamp_path (char *path)
|
||||||
{
|
{
|
||||||
struct vfs_class *vfs;
|
struct vfs_class *vfs;
|
||||||
vfsid id;
|
vfsid id;
|
||||||
struct vfs_stamping *par, *stamp;
|
|
||||||
|
|
||||||
vfs = vfs_get_class (path);
|
vfs = vfs_get_class (path);
|
||||||
id = vfs_ncs_getid (vfs, path, &par);
|
id = vfs_ncs_getid (vfs, path);
|
||||||
vfs_addstamp (vfs, id, par);
|
vfs_addstamp (vfs, id);
|
||||||
|
|
||||||
for (stamp = par; stamp != NULL; stamp = stamp->parent)
|
|
||||||
vfs_addstamp (stamp->v, stamp->id, stamp->parent);
|
|
||||||
vfs_rm_parents (par);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
/*
|
||||||
_vfs_add_noncurrent_stamps (struct vfs_class *oldvfs, vfsid oldvfsid,
|
* Create a new timestamp item by VFS class and VFS id.
|
||||||
struct vfs_stamping *parent)
|
*/
|
||||||
|
void
|
||||||
|
vfs_stamp_create (struct vfs_class *oldvfs, vfsid oldvfsid)
|
||||||
{
|
{
|
||||||
struct vfs_class *nvfs, *n2vfs, *n3vfs;
|
struct vfs_class *nvfs, *n2vfs, *n3vfs;
|
||||||
vfsid nvfsid, n2vfsid, n3vfsid;
|
vfsid nvfsid, n2vfsid, n3vfsid;
|
||||||
struct vfs_stamping *par, *stamp;
|
|
||||||
int f;
|
|
||||||
|
|
||||||
/* FIXME: As soon as we convert to multiple panels, this stuff
|
|
||||||
has to change. It works like this: We do not time out the
|
|
||||||
vfs's which are current in any panel and on the other
|
|
||||||
side we add the old directory with all its parents which
|
|
||||||
are not in any panel (if we find such one, we stop adding
|
|
||||||
parents to the time-outing structure. */
|
|
||||||
|
|
||||||
/* There are three directories we have to take care of: current_dir,
|
/* There are three directories we have to take care of: current_dir,
|
||||||
current_panel->cwd and other_panel->cwd. Athough most of the time either
|
current_panel->cwd and other_panel->cwd. Athough most of the time either
|
||||||
@ -261,22 +166,17 @@ _vfs_add_noncurrent_stamps (struct vfs_class *oldvfs, vfsid oldvfsid,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
nvfs = vfs_get_class (vfs_get_current_dir ());
|
nvfs = vfs_get_class (vfs_get_current_dir ());
|
||||||
nvfsid = vfs_ncs_getid (nvfs, vfs_get_current_dir (), &par);
|
nvfsid = vfs_ncs_getid (nvfs, vfs_get_current_dir ());
|
||||||
vfs_rmstamp (nvfs, nvfsid, 1);
|
vfs_rmstamp (nvfs, nvfsid);
|
||||||
|
|
||||||
f = is_parent (oldvfs, oldvfsid, par);
|
if ((nvfs == oldvfs && nvfsid == oldvfsid) || oldvfsid == NULL) {
|
||||||
vfs_rm_parents (par);
|
|
||||||
if ((nvfs == oldvfs && nvfsid == oldvfsid) || oldvfsid == NULL
|
|
||||||
|| f) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_current_type () == view_listing) {
|
if (get_current_type () == view_listing) {
|
||||||
n2vfs = vfs_get_class (current_panel->cwd);
|
n2vfs = vfs_get_class (current_panel->cwd);
|
||||||
n2vfsid = vfs_ncs_getid (n2vfs, current_panel->cwd, &par);
|
n2vfsid = vfs_ncs_getid (n2vfs, current_panel->cwd);
|
||||||
f = is_parent (oldvfs, oldvfsid, par);
|
if (n2vfs == oldvfs && n2vfsid == oldvfsid)
|
||||||
vfs_rm_parents (par);
|
|
||||||
if ((n2vfs == oldvfs && n2vfsid == oldvfsid) || f)
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
n2vfs = NULL;
|
n2vfs = NULL;
|
||||||
@ -285,10 +185,8 @@ _vfs_add_noncurrent_stamps (struct vfs_class *oldvfs, vfsid oldvfsid,
|
|||||||
|
|
||||||
if (get_other_type () == view_listing) {
|
if (get_other_type () == view_listing) {
|
||||||
n3vfs = vfs_get_class (other_panel->cwd);
|
n3vfs = vfs_get_class (other_panel->cwd);
|
||||||
n3vfsid = vfs_ncs_getid (n3vfs, other_panel->cwd, &par);
|
n3vfsid = vfs_ncs_getid (n3vfs, other_panel->cwd);
|
||||||
f = is_parent (oldvfs, oldvfsid, par);
|
if (n3vfs == oldvfs && n3vfsid == oldvfsid)
|
||||||
vfs_rm_parents (par);
|
|
||||||
if ((n3vfs == oldvfs && n3vfsid == oldvfsid) || f)
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
n3vfs = NULL;
|
n3vfs = NULL;
|
||||||
@ -298,25 +196,7 @@ _vfs_add_noncurrent_stamps (struct vfs_class *oldvfs, vfsid oldvfsid,
|
|||||||
if (!oldvfs->nothingisopen || !(*oldvfs->nothingisopen) (oldvfsid))
|
if (!oldvfs->nothingisopen || !(*oldvfs->nothingisopen) (oldvfsid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vfs_addstamp (oldvfs, oldvfsid, parent);
|
vfs_addstamp (oldvfs, oldvfsid);
|
||||||
for (stamp = parent; stamp != NULL; stamp = stamp->parent) {
|
|
||||||
if ((stamp->v == nvfs && stamp->id == nvfsid)
|
|
||||||
|| (stamp->v == n2vfs && stamp->id == n2vfsid)
|
|
||||||
|| (stamp->v == n3vfs && stamp->id == n3vfsid)
|
|
||||||
|| !stamp->id || !stamp->v->nothingisopen
|
|
||||||
|| !(*stamp->v->nothingisopen) (stamp->id))
|
|
||||||
break;
|
|
||||||
vfs_addstamp (stamp->v, stamp->id, stamp->parent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
vfs_add_noncurrent_stamps (struct vfs_class *oldvfs, vfsid oldvfsid,
|
|
||||||
struct vfs_stamping *parent)
|
|
||||||
{
|
|
||||||
_vfs_add_noncurrent_stamps (oldvfs, oldvfsid, parent);
|
|
||||||
vfs_rm_parents (parent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -370,7 +250,7 @@ vfs_expire (int now)
|
|||||||
st = stamp->next;
|
st = stamp->next;
|
||||||
if (stamp->v->free)
|
if (stamp->v->free)
|
||||||
(*stamp->v->free) (stamp->id);
|
(*stamp->v->free) (stamp->id);
|
||||||
vfs_rmstamp (stamp->v, stamp->id, 0);
|
vfs_rmstamp (stamp->v, stamp->id);
|
||||||
stamp = st;
|
stamp = st;
|
||||||
} else
|
} else
|
||||||
stamp = stamp->next;
|
stamp = stamp->next;
|
||||||
@ -403,11 +283,10 @@ vfs_release_path (const char *dir)
|
|||||||
{
|
{
|
||||||
struct vfs_class *oldvfs;
|
struct vfs_class *oldvfs;
|
||||||
vfsid oldvfsid;
|
vfsid oldvfsid;
|
||||||
struct vfs_stamping *parent;
|
|
||||||
|
|
||||||
oldvfs = vfs_get_class (dir);
|
oldvfs = vfs_get_class (dir);
|
||||||
oldvfsid = vfs_ncs_getid (oldvfs, dir, &parent);
|
oldvfsid = vfs_ncs_getid (oldvfs, dir);
|
||||||
vfs_add_noncurrent_stamps (oldvfs, oldvfsid, parent);
|
vfs_stamp_create (oldvfs, oldvfsid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -426,5 +305,5 @@ vfs_gc_done (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (stamps)
|
if (stamps)
|
||||||
vfs_rmstamp (stamps->v, stamps->id, 1);
|
vfs_rmstamp (stamps->v, stamps->id);
|
||||||
}
|
}
|
||||||
|
18
vfs/gc.h
18
vfs/gc.h
@ -4,28 +4,22 @@
|
|||||||
struct vfs_stamping {
|
struct vfs_stamping {
|
||||||
struct vfs_class *v;
|
struct vfs_class *v;
|
||||||
vfsid id;
|
vfsid id;
|
||||||
struct vfs_stamping *parent;
|
|
||||||
struct vfs_stamping *next;
|
struct vfs_stamping *next;
|
||||||
struct timeval time;
|
struct timeval time;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int vfs_timeout;
|
extern int vfs_timeout;
|
||||||
|
|
||||||
void vfs_stamp (struct vfs_class *, vfsid);
|
void vfs_stamp (struct vfs_class *v, vfsid id);
|
||||||
void vfs_rmstamp (struct vfs_class *, vfsid, int);
|
void vfs_rmstamp (struct vfs_class *v, vfsid id);
|
||||||
void vfs_add_noncurrent_stamps (struct vfs_class *, vfsid,
|
void vfs_stamp_create (struct vfs_class *vclass, vfsid id);
|
||||||
struct vfs_stamping *);
|
|
||||||
void vfs_stamp_create (struct vfs_class *vclass, vfsid id,
|
|
||||||
const char *parent_name);
|
|
||||||
void vfs_add_current_stamps (void);
|
void vfs_add_current_stamps (void);
|
||||||
void vfs_timeout_handler (void);
|
void vfs_timeout_handler (void);
|
||||||
void vfs_expire (int);
|
void vfs_expire (int now);
|
||||||
int vfs_timeouts (void);
|
int vfs_timeouts (void);
|
||||||
void vfs_release_path (const char *dir);
|
void vfs_release_path (const char *dir);
|
||||||
vfsid vfs_getid (struct vfs_class *vclass, const char *path,
|
vfsid vfs_getid (struct vfs_class *vclass, const char *path);
|
||||||
struct vfs_stamping **parent);
|
vfsid vfs_ncs_getid (struct vfs_class *nvfs, const char *dir);
|
||||||
vfsid vfs_ncs_getid (struct vfs_class *nvfs, const char *dir,
|
|
||||||
struct vfs_stamping **par);
|
|
||||||
void vfs_gc_done (void);
|
void vfs_gc_done (void);
|
||||||
|
|
||||||
#endif /* __GC_H */
|
#endif /* __GC_H */
|
||||||
|
32
vfs/sfs.c
32
vfs/sfs.c
@ -173,7 +173,7 @@ sfs_redirect (struct vfs_class *me, const char *name)
|
|||||||
cur->next = head;
|
cur->next = head;
|
||||||
head = cur;
|
head = cur;
|
||||||
|
|
||||||
vfs_stamp_create (&vfs_sfs_ops, head, NULL);
|
vfs_stamp_create (&vfs_sfs_ops, head);
|
||||||
|
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
@ -241,14 +241,9 @@ static int sfs_readlink (struct vfs_class *me, char *path, char *buf, int size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static vfsid
|
static vfsid
|
||||||
sfs_getid (struct vfs_class *me, const char *path,
|
sfs_getid (struct vfs_class *me, const char *path)
|
||||||
struct vfs_stamping **parent)
|
|
||||||
{
|
{
|
||||||
struct vfs_class *v;
|
|
||||||
vfsid id;
|
|
||||||
struct vfs_stamping *par;
|
|
||||||
struct cachedfile *cur = head;
|
struct cachedfile *cur = head;
|
||||||
char *path2;
|
|
||||||
|
|
||||||
while (cur) {
|
while (cur) {
|
||||||
if (!strcmp (path, cur->name))
|
if (!strcmp (path, cur->name))
|
||||||
@ -256,29 +251,6 @@ sfs_getid (struct vfs_class *me, const char *path,
|
|||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
*parent = NULL;
|
|
||||||
|
|
||||||
if (!cur)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
path2 = g_strdup (path);
|
|
||||||
|
|
||||||
/* Strip suffix which led to this being sfs */
|
|
||||||
v = vfs_split (path2, NULL, NULL);
|
|
||||||
|
|
||||||
/* ... and learn whoever was the parent system */
|
|
||||||
v = vfs_split (path2, NULL, NULL);
|
|
||||||
|
|
||||||
id = vfs_getid (v, path2, &par);
|
|
||||||
g_free (path2);
|
|
||||||
|
|
||||||
if (id) {
|
|
||||||
*parent = g_new (struct vfs_stamping, 1);
|
|
||||||
(*parent)->v = v;
|
|
||||||
(*parent)->id = id;
|
|
||||||
(*parent)->parent = par;
|
|
||||||
(*parent)->next = NULL;
|
|
||||||
}
|
|
||||||
return (vfsid) cur;
|
return (vfsid) cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,7 +608,7 @@ tar_super_same (struct vfs_class *me, struct vfs_s_super *parc,
|
|||||||
if (parc->u.arch.st.st_mtime < archive_stat->st_mtime) {
|
if (parc->u.arch.st.st_mtime < archive_stat->st_mtime) {
|
||||||
/* Yes, reload! */
|
/* Yes, reload! */
|
||||||
(*vfs_tarfs_ops.free) ((vfsid) parc);
|
(*vfs_tarfs_ops.free) ((vfsid) parc);
|
||||||
vfs_rmstamp (&vfs_tarfs_ops, (vfsid) parc, 0);
|
vfs_rmstamp (&vfs_tarfs_ops, (vfsid) parc);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
/* Hasn't been modified, give it a new timeout */
|
/* Hasn't been modified, give it a new timeout */
|
||||||
|
@ -655,13 +655,10 @@ undelfs_lseek(void *vfs_info, off_t offset, int whence)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static vfsid
|
static vfsid
|
||||||
undelfs_getid (struct vfs_class *me, const char *path,
|
undelfs_getid (struct vfs_class *me, const char *path)
|
||||||
struct vfs_stamping **parent)
|
|
||||||
{
|
{
|
||||||
char *fname, *fsname;
|
char *fname, *fsname;
|
||||||
|
|
||||||
/* We run only on the local fs */
|
|
||||||
*parent = NULL;
|
|
||||||
undelfs_get_path (path, &fsname, &fname);
|
undelfs_get_path (path, &fsname, &fname);
|
||||||
|
|
||||||
if (!fsname)
|
if (!fsname)
|
||||||
|
@ -669,7 +669,6 @@ mc_chdir (const char *path)
|
|||||||
char *new_dir;
|
char *new_dir;
|
||||||
struct vfs_class *old_vfs, *new_vfs;
|
struct vfs_class *old_vfs, *new_vfs;
|
||||||
vfsid old_vfsid;
|
vfsid old_vfsid;
|
||||||
struct vfs_stamping *parent;
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
new_dir = vfs_canon (path);
|
new_dir = vfs_canon (path);
|
||||||
@ -685,7 +684,7 @@ mc_chdir (const char *path)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
old_vfsid = vfs_ncs_getid (current_vfs, current_dir, &parent);
|
old_vfsid = vfs_ncs_getid (current_vfs, current_dir);
|
||||||
old_vfs = current_vfs;
|
old_vfs = current_vfs;
|
||||||
|
|
||||||
/* Actually change directory */
|
/* Actually change directory */
|
||||||
@ -694,7 +693,7 @@ mc_chdir (const char *path)
|
|||||||
current_vfs = new_vfs;
|
current_vfs = new_vfs;
|
||||||
|
|
||||||
/* This function uses the new current_dir implicitly */
|
/* This function uses the new current_dir implicitly */
|
||||||
vfs_add_noncurrent_stamps (old_vfs, old_vfsid, parent);
|
vfs_stamp_create (old_vfs, old_vfsid);
|
||||||
|
|
||||||
/* Sometimes we assume no trailing slash on cwd */
|
/* Sometimes we assume no trailing slash on cwd */
|
||||||
if (*current_dir) {
|
if (*current_dir) {
|
||||||
|
@ -57,8 +57,7 @@ struct vfs_class {
|
|||||||
int (*lseek) (void *vfs_info, off_t offset, int whence);
|
int (*lseek) (void *vfs_info, off_t offset, int whence);
|
||||||
int (*mknod) (struct vfs_class *me, char *path, int mode, int dev);
|
int (*mknod) (struct vfs_class *me, char *path, int mode, int dev);
|
||||||
|
|
||||||
vfsid (*getid) (struct vfs_class *me, const char *path,
|
vfsid (*getid) (struct vfs_class *me, const char *path);
|
||||||
struct vfs_stamping ** parent);
|
|
||||||
|
|
||||||
int (*nothingisopen) (vfsid id);
|
int (*nothingisopen) (vfsid id);
|
||||||
void (*free) (vfsid id);
|
void (*free) (vfsid id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user