* vfs.h: Remove vfs_uid and vfs_gid. Fix all dependencies.

This commit is contained in:
Pavel Roskin 2002-12-06 02:14:28 +00:00
parent 34e6f513ed
commit b9c6a9b3d1
6 changed files with 79 additions and 79 deletions

View File

@ -1,3 +1,7 @@
2002-12-05 Pavel Roskin <proski@gnu.org>
* vfs.h: Remove vfs_uid and vfs_gid. Fix all dependencies.
2002-12-05 Andrew V. Samoilov <sav@bcs.zp.ua> 2002-12-05 Andrew V. Samoilov <sav@bcs.zp.ua>
* extfs.c (open_archive): Use open_error_pipe before popen() and * extfs.c (open_archive): Use open_error_pipe before popen() and

View File

@ -541,18 +541,18 @@ static void *cpio_super_check(vfs *me, char *archive_name, char *op)
return &sb; return &sb;
} }
static int cpio_super_same(vfs *me, struct vfs_s_super *parc, char *archive_name, char *op, void *cookie) static int
{ cpio_super_same (vfs *me, struct vfs_s_super *parc, char *archive_name,
char *op, void *cookie)
{
struct stat *archive_stat = cookie; /* stat of main archive */ struct stat *archive_stat = cookie; /* stat of main archive */
if(strcmp(parc->name, archive_name)) return 0; if (strcmp (parc->name, archive_name))
return 0;
if(vfs_uid && (!(archive_stat->st_mode & 0004))) /* Has the cached archive been changed on the disk? */
if((archive_stat->st_gid != vfs_gid) || !(archive_stat->st_mode & 0040)) if (parc->u.cpio.stat.st_mtime < archive_stat->st_mtime) {
if((archive_stat->st_uid != vfs_uid) || !(archive_stat->st_mode & 0400)) /* Yes, reload! */
return 0;
/* Has the cached archive been changed on the disk? */
if(parc->u.cpio.stat.st_mtime < archive_stat->st_mtime) { /* 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, 0);
return 2; return 2;

View File

@ -398,11 +398,13 @@ static int read_archive (int fstype, char *name, struct archive **pparc)
static char *get_path (char *inname, struct archive **archive, int is_dir, static char *get_path (char *inname, struct archive **archive, int is_dir,
int do_not_open); 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) * Return path inside argument. Returned char* is inside inname, which is mangled
* by this operation, so don't free the return value.
*/ */
static char *get_path_mangle (char *inname, struct archive **archive, int is_dir, static char *
int do_not_open) get_path_mangle (char *inname, struct archive **archive, int is_dir,
int do_not_open)
{ {
char *local, *archive_name, *op; char *local, *archive_name, *op;
int result = -1; int result = -1;
@ -410,44 +412,38 @@ static char *get_path_mangle (char *inname, struct archive **archive, int is_dir
struct vfs_stamping *parent; struct vfs_stamping *parent;
vfs *v; vfs *v;
int fstype; int fstype;
archive_name = inname;
vfs_split( inname, &local, &op );
fstype = extfs_which( NULL, op ); /* FIXME: we really should pass
self pointer. But as we know that extfs_which does not touch vfs
*me, it does not matter for now */
if (fstype == -1)
return NULL;
if (!local)
local = "";
/* All filesystems should have some local archive, at least archive_name = inname;
vfs_split (inname, &local, &op);
/*
* FIXME: we really should pass self pointer. But as we know that
* extfs_which does not touch vfs *me, it does not matter for now
*/
fstype = extfs_which (NULL, op);
if (fstype == -1)
return NULL;
if (!local)
local = "";
/*
* All filesystems should have some local archive, at least
* it can be '/'. * it can be '/'.
*
* Actually, we should implement an alias mechanism that would
* translate: "a:" to "dos:a.
*
*/ */
for (parc = first_archive; parc != NULL; parc = parc->next) for (parc = first_archive; parc != NULL; parc = parc->next)
if (parc->name) { if (parc->name) {
if (!strcmp (parc->name, archive_name)) { if (!strcmp (parc->name, archive_name)) {
struct stat *s=&(parc->extfsstat); vfs_stamp (&vfs_extfs_ops, (vfsid) parc);
if (vfs_uid && (!(s->st_mode & 0004)))
if ((s->st_gid != vfs_gid) || !(s->st_mode & 0040))
if ((s->st_uid != vfs_uid) || !(s->st_mode & 0400))
return NULL;
/* This is not too secure - in some cases (/#mtools) files created
under user a are probably visible to everyone else since / usually
has permissions 755 */
vfs_stamp (&vfs_extfs_ops, (vfsid) parc);
goto return_success; goto return_success;
} }
} }
result = do_not_open ? -1 : read_archive (fstype, archive_name, &parc); result = do_not_open ? -1 : read_archive (fstype, archive_name, &parc);
if (result == -1) ERRNOR (EIO, NULL); if (result == -1)
ERRNOR (EIO, NULL);
if (archive_name){ if (archive_name) {
v = vfs_type (archive_name); v = vfs_type (archive_name);
if (v == &vfs_local_ops) { if (v == &vfs_local_ops) {
parent = NULL; parent = NULL;
@ -460,7 +456,7 @@ static char *get_path_mangle (char *inname, struct archive **archive, int is_dir
vfs_add_noncurrent_stamps (&vfs_extfs_ops, (vfsid) parc, parent); vfs_add_noncurrent_stamps (&vfs_extfs_ops, (vfsid) parc, parent);
vfs_rm_parents (parent); vfs_rm_parents (parent);
} }
return_success: return_success:
*archive = parc; *archive = parc;
return local; return local;
} }

View File

@ -107,18 +107,16 @@ static char *
redirect (vfs *me, char *name) redirect (vfs *me, char *name)
{ {
struct cachedfile *cur = head; struct cachedfile *cur = head;
uid_t uid = vfs_uid;
char *cache; char *cache;
int handle; int handle;
while (cur){ while (cur) {
if ((!strcmp (name, cur->name)) && /* FIXME: when not uptodate, we might want to kill cache
(uid == cur->uid) && * file immediately, not to wait until timeout. */
(uptodate (cur->name, cur->cache))) if ((!strcmp (name, cur->name)) && (cur->uid == 0)
/* FIXME: when not uptodate, we might want to kill cache && (uptodate (cur->name, cur->cache))) {
* file immediately, not to wait until timeout. */ { vfs_stamp (&vfs_sfs_ops, cur);
vfs_stamp (&vfs_sfs_ops, cur); return cur->cache;
return cur->cache;
} }
cur = cur->next; cur = cur->next;
} }
@ -131,11 +129,11 @@ redirect (vfs *me, char *name)
close (handle); close (handle);
if (!vfmake (me, name, cache)){ if (!vfmake (me, name, cache)) {
cur = g_new (struct cachedfile, 1); cur = g_new (struct cachedfile, 1);
cur->name = g_strdup (name); cur->name = g_strdup (name);
cur->cache = cache; cur->cache = cache;
cur->uid = uid; cur->uid = 0;
cur->next = head; cur->next = head;
head = cur; head = cur;
@ -144,7 +142,7 @@ redirect (vfs *me, char *name)
return cache; return cache;
} }
unlink (cache); unlink (cache);
g_free (cache); g_free (cache);
return "/I_MUST_NOT_EXIST"; return "/I_MUST_NOT_EXIST";
@ -207,16 +205,16 @@ static int sfs_readlink (vfs *me, char *path, char *buf, int size)
return readlink (path, buf, size); return readlink (path, buf, size);
} }
static vfsid sfs_getid (vfs *me, char *path, struct vfs_stamping **parent) static vfsid
{ /* FIXME: what should I do? */ sfs_getid (vfs *me, char *path, struct vfs_stamping **parent)
{ /* FIXME: what should I do? */
vfs *v; vfs *v;
vfsid id; vfsid id;
struct vfs_stamping *par; struct vfs_stamping *par;
struct cachedfile *cur = head; struct cachedfile *cur = head;
while (cur) { while (cur) {
if ((!strcmp( path, cur->name )) && if ((!strcmp (path, cur->name)) && (cur->uid == 0))
(vfs_uid == cur->uid))
break; break;
cur = cur->next; cur = cur->next;
} }
@ -224,22 +222,27 @@ static vfsid sfs_getid (vfs *me, char *path, struct vfs_stamping **parent)
*parent = NULL; *parent = NULL;
if (!cur) if (!cur)
return (vfsid)(-1); return (vfsid) (-1);
{ {
char *path2 = g_strdup (path); char *path2 = g_strdup (path);
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 */ /* 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 = (*v->getid) (v, path2, &par); id = (*v->getid) (v, path2, &par);
g_free (path2); g_free (path2);
} }
if (id != (vfsid)-1) { if (id != (vfsid) - 1) {
*parent = g_new (struct vfs_stamping, 1); *parent = g_new (struct vfs_stamping, 1);
(*parent)->v = v; (*parent)->v = v;
(*parent)->id = id; (*parent)->id = id;
(*parent)->parent = par; (*parent)->parent = par;
(*parent)->next = NULL; (*parent)->next = NULL;
} }
return (vfsid) cur; return (vfsid) cur;
} }

View File

@ -441,18 +441,18 @@ static void *tar_super_check(vfs *me, char *archive_name, char *op)
return &stat_buf; return &stat_buf;
} }
static int tar_super_same(vfs *me, struct vfs_s_super *parc, char *archive_name, char *op, void *cookie) static int
{ tar_super_same (vfs *me, struct vfs_s_super *parc, char *archive_name,
char *op, void *cookie)
{
struct stat *archive_stat = cookie; /* stat of main archive */ struct stat *archive_stat = cookie; /* stat of main archive */
if (strcmp (parc->name, archive_name)) return 0; if (strcmp (parc->name, archive_name))
return 0;
if (vfs_uid && (!(archive_stat->st_mode & 0004))) /* Has the cached archive been changed on the disk? */
if ((archive_stat->st_gid != vfs_gid) || !(archive_stat->st_mode & 0040)) if (parc->u.tar.tarstat.st_mtime < archive_stat->st_mtime) {
if ((archive_stat->st_uid != vfs_uid) || !(archive_stat->st_mode & 0400)) /* Yes, reload! */
return 0;
/* Has the cached archive been changed on the disk? */
if (parc->u.tar.tarstat.st_mtime < archive_stat->st_mtime) { /* 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, 0);
return 2; return 2;

View File

@ -355,9 +355,6 @@ extern void vfs_print_stats (const char *fs_name, const char *action,
#define MCCTL_WANT_STALE_DATA 9 #define MCCTL_WANT_STALE_DATA 9
#define MCCTL_NO_STALE_DATA 10 #define MCCTL_NO_STALE_DATA 10
#define vfs_uid 0
#define vfs_gid 0
#define FL_ALWAYS_MAGIC 1 #define FL_ALWAYS_MAGIC 1
#define FL_NO_MCFS 2 #define FL_NO_MCFS 2
#define FL_NO_FTPFS 4 #define FL_NO_FTPFS 4