static const char * sfs_redirect (struct vfs_class *me, const char *name) { struct cachedfile *cur = head; char *cache; int handle; while (cur) { if (!strcmp (name, cur->name)) { vfs_stamp (&vfs_sfs_ops, cur); return cur->cache; } cur = cur->next; } handle = vfs_mkstemps (&cache, "sfs", name); if (handle == -1) { return "/SOMEONE_PLAYING_DIRTY_TMP_TRICKS_ON_US"; } close (handle); if (!sfs_vfmake (me, name, cache)) { cur = g_new (struct cachedfile, 1); cur->name = g_strdup (name); cur->cache = cache; cur->next = head; head = cur; vfs_stamp_create (&vfs_sfs_ops, head); return cache; }
/* * Dissect the path and create corresponding superblock. Note that inname * can be changed and the result may point inside the original string. */ static char * extfs_get_path_mangle (struct vfs_class *me, char *inname, struct archive **archive, int do_not_open) { char *local, *op; const char *archive_name; int result = -1; struct archive *parc; int fstype; archive_name = inname; vfs_split (inname, &local, &op); fstype = extfs_which (me, op); if (fstype == -1) return NULL; if (!local) local = inname + strlen (inname); /* * All filesystems should have some local archive, at least * it can be '/'. */ for (parc = first_archive; parc != NULL; parc = parc->next) if (parc->name) { if (!strcmp (parc->name, archive_name)) { vfs_stamp (&vfs_extfs_ops, (vfsid) parc); goto return_success; } } result = do_not_open ? -1 : extfs_read_archive (fstype, archive_name, &parc); if (result == -1) ERRNOR (EIO, NULL); return_success: *archive = parc; return local; }
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 */ if (strcmp (parc->name, archive_name)) return 0; if (vfs_uid && (!(archive_stat->st_mode & 0004))) if ((archive_stat->st_gid != vfs_gid) || !(archive_stat->st_mode & 0040)) if ((archive_stat->st_uid != vfs_uid) || !(archive_stat->st_mode & 0400)) 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_rmstamp (&vfs_tarfs_ops, (vfsid) parc, 0); return 2; } /* Hasn't been modified, give it a new timeout */ vfs_stamp (&vfs_tarfs_ops, (vfsid) parc); return 1; }