* direntry.c (vfs_s_stamp_me): Generalize and move ...

* gc.c (vfs_stamp_create): ... here.  Use whenever possible.
This commit is contained in:
Pavel Roskin 2003-11-13 08:03:03 +00:00
parent de12104436
commit 4b5a2a0b62
8 changed files with 53 additions and 71 deletions

View File

@ -1,3 +1,8 @@
2003-11-13 Pavel Roskin <proski@gnu.org>
* direntry.c (vfs_s_stamp_me): Generalize and move ...
* gc.c (vfs_stamp_create): ... here. Use whenever possible.
2003-11-12 Pavel Roskin <proski@gnu.org>
* gc.c: Use NULL instead of -1 for empty vfsid. Adjust all

View File

@ -426,25 +426,6 @@ vfs_s_free_super (struct vfs_class *me, struct vfs_s_super *super)
/* ------------------------------------------------------------------------= */
static void
vfs_s_stamp_me (struct vfs_class *me, struct vfs_s_super *psup,
const char *fs_name)
{
struct vfs_stamping *parent;
struct vfs_class *v;
v = vfs_get_class (fs_name);
if (v->flags & VFSF_LOCAL) {
parent = NULL;
} else {
parent = g_new (struct vfs_stamping, 1);
parent->v = v;
parent->next = 0;
parent->id = vfs_getid (v, fs_name, &(parent->parent));
}
vfs_add_noncurrent_stamps (me, (vfsid) psup, parent);
}
char *
vfs_s_get_path_mangle (struct vfs_class *me, const char *inname,
struct vfs_s_super **archive, int flags)
@ -491,7 +472,7 @@ vfs_s_get_path_mangle (struct vfs_class *me, const char *inname,
vfs_die ("You have to fill root inode\n");
vfs_s_insert_super (me, super);
vfs_s_stamp_me (me, super, archive_name);
vfs_stamp_create (me, super, archive_name);
return_success:
*archive = super;
@ -852,21 +833,9 @@ vfs_s_close (void *fh)
struct vfs_class *me = FH_SUPER->me;
FH_SUPER->fd_usage--;
if (!FH_SUPER->fd_usage){
struct vfs_stamping *parent;
struct vfs_class *v;
v = vfs_get_class (FH_SUPER->name);
if (v->flags & VFSF_LOCAL) {
parent = NULL;
} else {
parent = g_new (struct vfs_stamping, 1);
parent->v = v;
parent->next = 0;
parent->id = vfs_getid (v, FH_SUPER->name, &(parent->parent));
}
vfs_add_noncurrent_stamps (me, (vfsid) (FH_SUPER), parent);
}
if (!FH_SUPER->fd_usage)
vfs_stamp_create (me, FH_SUPER, FH_SUPER->name);
if (FH->linear == LS_LINEAR_OPEN)
MEDATA->linear_close (me, fh);
if (MEDATA->fh_close)

View File

@ -434,8 +434,6 @@ extfs_get_path_mangle (const char *inname, struct archive **archive,
const char *archive_name;
int result = -1;
struct archive *parc;
struct vfs_stamping *parent;
struct vfs_class *v;
int fstype;
archive_name = inname;
@ -470,18 +468,9 @@ extfs_get_path_mangle (const char *inname, struct archive **archive,
if (result == -1)
ERRNOR (EIO, NULL);
if (archive_name) {
v = vfs_get_class (archive_name);
if (v->flags & VFSF_LOCAL) {
parent = NULL;
} else {
parent = g_new (struct vfs_stamping, 1);
parent->v = v;
parent->next = 0;
parent->id = vfs_getid (v, archive_name, &(parent->parent));
}
vfs_add_noncurrent_stamps (&vfs_extfs_ops, (vfsid) parc, parent);
}
if (archive_name)
vfs_stamp_create (&vfs_extfs_ops, parc, archive_name);
return_success:
*archive = parc;
return local;
@ -757,22 +746,8 @@ extfs_close (void *data)
file->archive->fd_usage--;
if (!file->archive->fd_usage) {
struct vfs_stamping *parent;
struct vfs_class *v;
if (!file->archive->name || !*file->archive->name
|| (v =
vfs_get_class (file->archive->name))->flags & VFSF_LOCAL) {
parent = NULL;
} else {
parent = g_new (struct vfs_stamping, 1);
parent->v = v;
parent->next = 0;
parent->id =
vfs_getid (v, file->archive->name, &(parent->parent));
}
vfs_add_noncurrent_stamps (&vfs_extfs_ops, (vfsid) (file->archive),
parent);
vfs_stamp_create (&vfs_extfs_ops, file->archive,
file->archive->name);
}
g_free (data);

View File

@ -43,7 +43,7 @@
#include "xdirentry.h"
#include "vfs.h"
#include "gc.h" /* vfs_add_noncurrent_stamps */
#include "gc.h" /* vfs_stamp_create */
#include "tcputil.h"
#define FISH_DIRECTORY_TIMEOUT 30 * 60
@ -687,7 +687,7 @@ fish_send_command(struct vfs_class *me, struct vfs_s_super *super, char *cmd, in
int r;
r = fish_command (me, super, WAIT_REPLY, cmd);
vfs_add_noncurrent_stamps (&vfs_fish_ops, (vfsid) super, NULL);
vfs_stamp_create (&vfs_fish_ops, super, NULL);
if (r != COMPLETE) ERRNOR (E_REMOTE, -1);
if (flags & OPT_FLUSH)
vfs_s_invalidate(me, super);

View File

@ -72,7 +72,7 @@ What to do with this?
#include "xdirentry.h"
#include "vfs.h"
#include "gc.h" /* vfs_add_noncurrent_stamps */
#include "gc.h" /* vfs_stamp_create */
#include "tcputil.h"
#include "../src/setup.h" /* for load_anon_passwd */
#include "ftpfs.h"
@ -1454,7 +1454,7 @@ ftpfs_send_command(struct vfs_class *me, char *filename, char *cmd, int flags)
p = ftpfs_translate_path (me, super, rpath);
r = ftpfs_command (me, super, WAIT_REPLY, cmd, p);
g_free (p);
vfs_add_noncurrent_stamps (&vfs_ftpfs_ops, (vfsid) super, NULL);
vfs_stamp_create (&vfs_ftpfs_ops, super, NULL);
if (flags & OPT_IGNORE_ERROR)
r = COMPLETE;
if (r != COMPLETE)

View File

@ -174,6 +174,37 @@ vfs_ncs_getid (struct vfs_class *nvfs, const char *dir,
}
/*
* 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)

View File

@ -15,6 +15,8 @@ void vfs_stamp (struct vfs_class *, vfsid);
void vfs_rmstamp (struct vfs_class *, vfsid, int);
void vfs_add_noncurrent_stamps (struct vfs_class *, vfsid,
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_timeout_handler (void);
void vfs_expire (int);

View File

@ -22,7 +22,7 @@
#include "utilvfs.h"
#include "vfs.h"
#include "gc.h" /* vfs_add_noncurrent_stamps */
#include "gc.h" /* vfs_stamp_create */
#include "local.h"
#include "../src/execute.h" /* EXECUTE_AS_SHELL */
@ -147,7 +147,7 @@ sfs_redirect (struct vfs_class *me, const char *name)
cur->next = head;
head = cur;
vfs_add_noncurrent_stamps (&vfs_sfs_ops, (vfsid) head, NULL);
vfs_stamp_create (&vfs_sfs_ops, head, NULL);
return cache;
}