1
1

* extfs.h: Remove "extfsstat" from struct archive - it's unused

outside open_archive().  Adjust the dependencies.
* extfs.c: Make hstat local variable.
Этот коммит содержится в:
Pavel Roskin 2002-12-06 03:14:41 +00:00
родитель 271a2564fd
Коммит 03b1481cda
3 изменённых файлов: 97 добавлений и 87 удалений

Просмотреть файл

@ -1,5 +1,9 @@
2002-12-05 Pavel Roskin <proski@gnu.org> 2002-12-05 Pavel Roskin <proski@gnu.org>
* extfs.h: Remove "extfsstat" from struct archive - it's unused
outside open_archive(). Adjust the dependencies.
* extfs.c: Make hstat local variable.
* sfs.c: Remove "uid" from struct cachedfile - it's unused now. * sfs.c: Remove "uid" from struct cachedfile - it's unused now.
* vfs.h: Remove vfs_uid and vfs_gid. Fix all dependencies. * vfs.h: Remove vfs_uid and vfs_gid. Fix all dependencies.

Просмотреть файл

@ -85,7 +85,6 @@ static void remove_entry (struct entry *e);
static struct archive *first_archive = NULL; static struct archive *first_archive = NULL;
static int my_errno = 0; static int my_errno = 0;
static struct stat hstat; /* Stat struct corresponding */
#define MAXEXTFS 32 #define MAXEXTFS 32
static char *extfs_prefixes [MAXEXTFS]; static char *extfs_prefixes [MAXEXTFS];
@ -199,7 +198,8 @@ static void free_archive (struct archive *archive)
g_free (archive); g_free (archive);
} }
static FILE *open_archive (int fstype, char *name, struct archive **pparc) static FILE *
open_archive (int fstype, char *name, struct archive **pparc)
{ {
static dev_t __extfs_no = 0; static dev_t __extfs_no = 0;
FILE *result; FILE *result;
@ -210,9 +210,9 @@ static FILE *open_archive (int fstype, char *name, struct archive **pparc)
struct archive *current_archive; struct archive *current_archive;
struct entry *root_entry; struct entry *root_entry;
char *local_name = NULL, *tmp = 0; char *local_name = NULL, *tmp = 0;
int uses_archive = extfs_need_archive [fstype]; int uses_archive = extfs_need_archive[fstype];
if (uses_archive){ if (uses_archive) {
if (mc_stat (name, &mystat) == -1) if (mc_stat (name, &mystat) == -1)
return NULL; return NULL;
if (!vfs_file_is_local (name)) { if (!vfs_file_is_local (name)) {
@ -224,8 +224,9 @@ static FILE *open_archive (int fstype, char *name, struct archive **pparc)
} }
mc_extfsdir = concat_dir_and_file (mc_home, "extfs/"); mc_extfsdir = concat_dir_and_file (mc_home, "extfs/");
cmd = g_strconcat (mc_extfsdir, extfs_prefixes [fstype], cmd =
" list ", local_name ? local_name : tmp, NULL); g_strconcat (mc_extfsdir, extfs_prefixes[fstype], " list ",
local_name ? local_name : tmp, NULL);
if (tmp) if (tmp)
g_free (tmp); g_free (tmp);
g_free (mc_extfsdir); g_free (mc_extfsdir);
@ -241,18 +242,17 @@ static FILE *open_archive (int fstype, char *name, struct archive **pparc)
current_archive = g_new (struct archive, 1); current_archive = g_new (struct archive, 1);
current_archive->fstype = fstype; current_archive->fstype = fstype;
current_archive->name = name ? g_strdup (name): name; current_archive->name = name ? g_strdup (name) : name;
current_archive->local_name = local_name; current_archive->local_name = local_name;
if (local_name != NULL) if (local_name != NULL)
mc_stat (local_name, &current_archive->local_stat); mc_stat (local_name, &current_archive->local_stat);
current_archive->__inode_counter = 0; current_archive->__inode_counter = 0;
current_archive->fd_usage = 0; current_archive->fd_usage = 0;
current_archive->extfsstat = mystat;
current_archive->rdev = __extfs_no++; current_archive->rdev = __extfs_no++;
current_archive->next = first_archive; current_archive->next = first_archive;
first_archive = current_archive; first_archive = current_archive;
mode = current_archive->extfsstat.st_mode & 07777; mode = mystat.st_mode & 07777;
if (mode & 0400) if (mode & 0400)
mode |= 0100; mode |= 0100;
if (mode & 0040) if (mode & 0040)
@ -261,11 +261,11 @@ static FILE *open_archive (int fstype, char *name, struct archive **pparc)
mode |= 0001; mode |= 0001;
mode |= S_IFDIR; mode |= S_IFDIR;
root_entry = generate_entry (current_archive, "/", NULL, mode); root_entry = generate_entry (current_archive, "/", NULL, mode);
root_entry->inode->uid = current_archive->extfsstat.st_uid; root_entry->inode->uid = mystat.st_uid;
root_entry->inode->gid = current_archive->extfsstat.st_gid; root_entry->inode->gid = mystat.st_gid;
root_entry->inode->atime = current_archive->extfsstat.st_atime; root_entry->inode->atime = mystat.st_atime;
root_entry->inode->ctime = current_archive->extfsstat.st_ctime; root_entry->inode->ctime = mystat.st_ctime;
root_entry->inode->mtime = current_archive->extfsstat.st_mtime; root_entry->inode->mtime = mystat.st_mtime;
current_archive->root_entry = root_entry; current_archive->root_entry = root_entry;
current_archive->current_dir = root_entry; current_archive->current_dir = root_entry;
@ -278,24 +278,27 @@ static FILE *open_archive (int fstype, char *name, struct archive **pparc)
* Main loop for reading an archive. * Main loop for reading an archive.
* Returns 0 on success, -1 on error. * Returns 0 on success, -1 on error.
*/ */
static int read_archive (int fstype, char *name, struct archive **pparc) static int
read_archive (int fstype, char *name, struct archive **pparc)
{ {
FILE *extfsd; FILE *extfsd;
char *buffer; char *buffer;
struct archive *current_archive; struct archive *current_archive;
char *current_file_name, *current_link_name; char *current_file_name, *current_link_name;
if ((extfsd = open_archive (fstype, name, &current_archive)) == NULL) { if ((extfsd = open_archive (fstype, name, &current_archive)) == NULL) {
message_3s (1, MSG_ERROR, _("Couldn't open %s archive\n%s"), message_3s (1, MSG_ERROR, _("Couldn't open %s archive\n%s"),
extfs_prefixes [fstype], name); extfs_prefixes[fstype], name);
return -1; return -1;
} }
buffer = g_malloc (4096); buffer = g_malloc (4096);
while (fgets (buffer, 4096, extfsd) != NULL) { while (fgets (buffer, 4096, extfsd) != NULL) {
struct stat hstat;
current_link_name = NULL; current_link_name = NULL;
if (vfs_parse_ls_lga (buffer, &hstat, &current_file_name, &current_link_name)) { if (vfs_parse_ls_lga
(buffer, &hstat, &current_file_name, &current_link_name)) {
struct entry *entry, *pent; struct entry *entry, *pent;
struct inode *inode; struct inode *inode;
char *p, *q, *cfn = current_file_name; char *p, *q, *cfn = current_file_name;
@ -314,10 +317,10 @@ static int read_archive (int fstype, char *name, struct archive **pparc)
*(p++) = 0; *(p++) = 0;
q = cfn; q = cfn;
} }
if (S_ISDIR (hstat.st_mode) && if (S_ISDIR (hstat.st_mode)
(!strcmp (p, ".") || !strcmp (p, ".."))) && (!strcmp (p, ".") || !strcmp (p, "..")))
goto read_extfs_continue; goto read_extfs_continue;
pent = find_entry (current_archive->root_entry, q, 1, 0) ; pent = find_entry (current_archive->root_entry, q, 1, 0);
if (pent == NULL) { if (pent == NULL) {
/* FIXME: Should clean everything one day */ /* FIXME: Should clean everything one day */
g_free (buffer); g_free (buffer);
@ -330,18 +333,21 @@ static int read_archive (int fstype, char *name, struct archive **pparc)
entry->next_in_dir = NULL; entry->next_in_dir = NULL;
entry->dir = pent; entry->dir = pent;
if (pent != NULL) { if (pent != NULL) {
if (pent->inode->last_in_subdir){ if (pent->inode->last_in_subdir) {
pent->inode->last_in_subdir->next_in_dir = entry; pent->inode->last_in_subdir->next_in_dir = entry;
pent->inode->last_in_subdir = entry; pent->inode->last_in_subdir = entry;
} }
} }
if (!S_ISLNK (hstat.st_mode) && current_link_name != NULL) { if (!S_ISLNK (hstat.st_mode) && current_link_name != NULL) {
pent = find_entry (current_archive->root_entry, current_link_name, 0, 0); pent =
find_entry (current_archive->root_entry,
current_link_name, 0, 0);
if (pent == NULL) { if (pent == NULL) {
/* FIXME: Should clean everything one day */ /* FIXME: Should clean everything one day */
g_free (buffer); g_free (buffer);
pclose (extfsd); pclose (extfsd);
close_error_pipe (1, _("Inconsistent extfs archive")); close_error_pipe (1,
_("Inconsistent extfs archive"));
return -1; return -1;
} else { } else {
entry->inode = pent->inode; entry->inode = pent->inode;
@ -367,11 +373,12 @@ static int read_archive (int fstype, char *name, struct archive **pparc)
inode->mtime = hstat.st_mtime; inode->mtime = hstat.st_mtime;
inode->atime = hstat.st_atime; inode->atime = hstat.st_atime;
inode->ctime = hstat.st_ctime; inode->ctime = hstat.st_ctime;
if (current_link_name != NULL && S_ISLNK (hstat.st_mode)) { if (current_link_name != NULL
&& S_ISLNK (hstat.st_mode)) {
inode->linkname = current_link_name; inode->linkname = current_link_name;
current_link_name = NULL; current_link_name = NULL;
} else { } else {
if (S_ISLNK( hstat.st_mode)) if (S_ISLNK (hstat.st_mode))
inode->mode &= ~S_IFLNK; /* You *DON'T* want to do this always */ inode->mode &= ~S_IFLNK; /* You *DON'T* want to do this always */
inode->linkname = NULL; inode->linkname = NULL;
} }
@ -388,7 +395,7 @@ static int read_archive (int fstype, char *name, struct archive **pparc)
pclose (extfsd); pclose (extfsd);
close_error_pipe (1, NULL); close_error_pipe (1, NULL);
#ifdef SCO_FLAVOR #ifdef SCO_FLAVOR
waitpid(-1,NULL,WNOHANG); waitpid (-1, NULL, WNOHANG);
#endif /* SCO_FLAVOR */ #endif /* SCO_FLAVOR */
*pparc = current_archive; *pparc = current_archive;
g_free (buffer); g_free (buffer);

Просмотреть файл

@ -22,7 +22,6 @@ struct archive {
int fstype; int fstype;
char *name; char *name;
char *local_name; char *local_name;
struct stat extfsstat;
struct stat local_stat; struct stat local_stat;
dev_t rdev; dev_t rdev;
int fd_usage; int fd_usage;