* gc.c: Use NULL instead of -1 for empty vfsid. Adjust all

dependencies.
* undelfs.c (undelfs_get_path): Don't shadow static ext2_fname.
(undelfs_getid): Likewise.  Use fs for non-empty vfsid.
This commit is contained in:
Pavel Roskin 2003-11-12 23:00:16 +00:00
parent d2e2f5c544
commit de12104436
6 changed files with 44 additions and 36 deletions

View File

@ -1,3 +1,10 @@
2003-11-12 Pavel Roskin <proski@gnu.org>
* gc.c: Use NULL instead of -1 for empty vfsid. Adjust all
dependencies.
* undelfs.c (undelfs_get_path): Don't shadow static ext2_fname.
(undelfs_getid): Likewise. Use fs for non-empty vfsid.
2003-11-12 Andrew V. Samoilov <sav@bcs.zp.ua>
* cpio.c (cpio_create_entry): Fix possible buffer underflow

View File

@ -1068,11 +1068,11 @@ vfs_s_getid (struct vfs_class *me, const char *path, struct vfs_stamping **paren
*parent = NULL;
if (!(p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN)))
return (vfsid) -1;
return NULL;
g_free(p);
v = vfs_get_class (archive->name);
id = vfs_getid (v, archive->name, &par);
if (id != (vfsid)-1){
if (id) {
*parent = g_new (struct vfs_stamping, 1);
(*parent)->v = v;
(*parent)->id = id;

View File

@ -1132,12 +1132,12 @@ static vfsid extfs_getid (struct vfs_class *me, const char *path, struct vfs_sta
*parent = NULL;
if (!(p = extfs_get_path (path, &archive, 1, 1)))
return (vfsid) -1;
return NULL;
g_free(p);
if (archive->name){
v = vfs_get_class (archive->name);
id = vfs_getid (v, archive->name, &par);
if (id != (vfsid)-1) {
if (id) {
*parent = g_new (struct vfs_stamping, 1);
(*parent)->v = v;
(*parent)->id = id;

View File

@ -1,4 +1,4 @@
/* Virtual File System grabage collection code
/* Virtual File System garbage collection code
Copyright (C) 1995-2003 The Free Software Foundation
Written by: 1995 Miguel de Icaza
@ -47,7 +47,7 @@ static struct vfs_stamping *stamps;
static void
vfs_addstamp (struct vfs_class *v, vfsid id, struct vfs_stamping *parent)
{
if (!(v->flags & VFSF_LOCAL) && id != (vfsid) - 1) {
if (!(v->flags & VFSF_LOCAL) && id != NULL) {
struct vfs_stamping *stamp;
struct vfs_stamping *last_stamp = NULL;
@ -149,7 +149,7 @@ vfsid
vfs_getid (struct vfs_class *vclass, const char *path,
struct vfs_stamping **parent)
{
vfsid id = (vfsid) - 1;
vfsid id = NULL;
*parent = NULL;
if (vclass->getid)
@ -235,7 +235,7 @@ _vfs_add_noncurrent_stamps (struct vfs_class *oldvfs, vfsid oldvfsid,
f = is_parent (oldvfs, oldvfsid, par);
vfs_rm_parents (par);
if ((nvfs == oldvfs && nvfsid == oldvfsid) || oldvfsid == (vfsid) - 1
if ((nvfs == oldvfs && nvfsid == oldvfsid) || oldvfsid == NULL
|| f) {
return;
}
@ -249,7 +249,7 @@ _vfs_add_noncurrent_stamps (struct vfs_class *oldvfs, vfsid oldvfsid,
return;
} else {
n2vfs = NULL;
n2vfsid = (vfsid) - 1;
n2vfsid = NULL;
}
if (get_other_type () == view_listing) {
@ -261,7 +261,7 @@ _vfs_add_noncurrent_stamps (struct vfs_class *oldvfs, vfsid oldvfsid,
return;
} else {
n3vfs = NULL;
n3vfsid = (vfsid) - 1;
n3vfsid = NULL;
}
if (!oldvfs->nothingisopen || !(*oldvfs->nothingisopen) (oldvfsid))
@ -272,7 +272,7 @@ _vfs_add_noncurrent_stamps (struct vfs_class *oldvfs, vfsid oldvfsid,
if ((stamp->v == nvfs && stamp->id == nvfsid)
|| (stamp->v == n2vfs && stamp->id == n2vfsid)
|| (stamp->v == n3vfs && stamp->id == n3vfsid)
|| stamp->id == (vfsid) - 1 || !stamp->v->nothingisopen
|| !stamp->id || !stamp->v->nothingisopen
|| !(*stamp->v->nothingisopen) (stamp->id))
break;
vfs_addstamp (stamp->v, stamp->id, stamp->parent);

View File

@ -215,12 +215,14 @@ static int sfs_readlink (struct vfs_class *me, char *path, char *buf, int size)
}
static vfsid
sfs_getid (struct vfs_class *me, const char *path, struct vfs_stamping **parent)
{ /* FIXME: what should I do? */
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;
char *path2;
while (cur) {
if (!strcmp (path, cur->name))
@ -231,22 +233,20 @@ sfs_getid (struct vfs_class *me, const char *path, struct vfs_stamping **parent)
*parent = NULL;
if (!cur)
return (vfsid) (-1);
return NULL;
{
char *path2 = g_strdup (path);
path2 = g_strdup (path);
/* Strip suffix which led to this being sfs */
v = vfs_split (path2, NULL, NULL);
/* 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);
/* ... and learn whoever was the parent system */
v = vfs_split (path2, NULL, NULL);
id = vfs_getid (v, path2, &par);
g_free (path2);
}
id = vfs_getid (v, path2, &par);
g_free (path2);
if (id != (vfsid) - 1) {
if (id) {
*parent = g_new (struct vfs_stamping, 1);
(*parent)->v = v;
(*parent)->id = id;

View File

@ -99,7 +99,7 @@ undelfs_shutdown (void)
}
static void
undelfs_get_path (const char *dirname, char **ext2_fname, char **file)
undelfs_get_path (const char *dirname, char **fsname, char **file)
{
const char *p;
@ -108,7 +108,7 @@ undelfs_get_path (const char *dirname, char **ext2_fname, char **file)
hda5, sdb8 etc, which is assumed to live under /dev.
-- pavel@ucw.cz */
*ext2_fname = NULL;
*fsname = NULL;
if (strncmp (dirname, "/#undel:", 8))
return;
@ -134,14 +134,14 @@ undelfs_get_path (const char *dirname, char **ext2_fname, char **file)
*file = g_strdup (p+1);
tmp = g_strndup (dirname, p - dirname);
*ext2_fname = g_strconcat ("/dev/", tmp, NULL);
*fsname = g_strconcat ("/dev/", tmp, NULL);
g_free (tmp);
return;
}
p--;
}
*file = g_strdup ("");
*ext2_fname = g_strconcat ("/dev/", dirname, NULL);
*fsname = g_strconcat ("/dev/", dirname, NULL);
return;
}
@ -640,19 +640,20 @@ undelfs_lseek(void *vfs_info, off_t offset, int whence)
}
static vfsid
undelfs_getid(struct vfs_class *me, const char *path, struct vfs_stamping **parent)
undelfs_getid (struct vfs_class *me, const char *path,
struct vfs_stamping **parent)
{
char *ext2_fname, *file;
char *fname, *fsname;
/* We run only on the local fs */
*parent = NULL;
undelfs_get_path (path, &ext2_fname, &file);
undelfs_get_path (path, &fsname, &fname);
if (!ext2_fname)
return (vfsid) -1;
g_free (ext2_fname);
g_free (file);
return (vfsid)0;
if (!fsname)
return NULL;
g_free (fname);
g_free (fsname);
return (vfsid) fs;
}
static int