Actually commit all my changers. Fear :>
Этот коммит содержится в:
родитель
2c1dd1ee3f
Коммит
bf81009392
@ -1,4 +1,8 @@
|
||||
Tue Jan 19 05:15:49 1999 Timur I. Bakeyev <timur@com.bat.ru>
|
||||
Thu Jan 21 00:58:12 1999 Timur I. Bakeyev <mc@bat.ru>
|
||||
|
||||
* Actually commit all changes :>
|
||||
|
||||
Tue Jan 19 05:15:49 1999 Timur I. Bakeyev <mc@bat.ru>
|
||||
|
||||
* Converted all occurences of DIR_SEP_CHAR and "/" to PATH_SEP and
|
||||
PATH_SEP_STR. Additionall cleanups of the memory code.
|
||||
@ -11,7 +15,7 @@ Tue Jan 19 05:15:49 1999 Timur I. Bakeyev <timur@com.bat.ru>
|
||||
|
||||
* vfs.h: The correct thing to use is PATH_SEP and PATH_SEP_STR
|
||||
|
||||
Sun Jan 17 16:19:48 1999 Timur I. Bakeyev <timur@com.bat.ru>
|
||||
Sun Jan 17 16:19:48 1999 Timur I. Bakeyev <mc@bat.ru>
|
||||
|
||||
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
|
||||
g_strdup()/g_free() routings. Also, copy_strings() replaced by
|
||||
@ -51,7 +55,7 @@ Sat Jan 9 19:13:28 1999 Norbert Warmuth <nwarmuth@privat.circular.de>
|
||||
|
||||
(sfs_getid): dito, return value was wrong.
|
||||
|
||||
Sat Jan 9 22:49:02 1999 Timur I. Bakeyev <timur@com.bat.ru>
|
||||
Sat Jan 9 22:49:02 1999 Timur I. Bakeyev <mc@bat.ru>
|
||||
|
||||
* vfs.c (parse_ls_lga): Rewrite function to make it more stright.
|
||||
Also, fixed some bugs in parsing (and add new ones:), which diasallowed
|
||||
@ -74,7 +78,7 @@ Thu Jan 7 06:24:25 1999 Andrej Borsenkow <borsenkow.msk@sni.de>
|
||||
in the past, it is shown without year. In this case MC assumed
|
||||
the current year which is wrong from Jan to Jun.
|
||||
|
||||
Thu Jan 7 03:47:35 1999 Timur I. Bakeyev <timur@com.bat.ru>
|
||||
Thu Jan 7 03:47:35 1999 Timur I. Bakeyev <mc@bat.ru>
|
||||
|
||||
* vfs.c (parse_ls_lga): Fixed Y2K typo pointed by Alex.
|
||||
|
||||
@ -178,7 +182,7 @@ Wed Dec 2 14:06:49 KST 1998 Sung-Hyun Nam <namsh@lgic.co.kr>
|
||||
|
||||
* direntry.c (vfs_s_new_super): Added the missing return value.
|
||||
|
||||
Sun Nov 29 02:54:54 1998 Timur I. Bakeyev <timur@com.bat.ru>
|
||||
Sun Nov 29 02:54:54 1998 Timur I. Bakeyev <mc@bat.ru>
|
||||
|
||||
* vfs.h: (Temporary?) fix to the compiling error: Some of the error
|
||||
codes, defined here are Linux specific and unknown to other systems.
|
||||
@ -644,7 +648,7 @@ Mon Jun 1 16:00:19 1998 Norbert Warmuth <k3190@fh-sw.de>
|
||||
* ftpfs.c (ftpfs_fill_names): use right character to seperate
|
||||
prefix and username
|
||||
|
||||
Mon Jun 1 14:19:20 1998 Bakeyev I. Timur <timur@comtat.kazan.ru>
|
||||
Mon Jun 1 14:19:20 1998 Bakeyev I. Timur <mc@bat.ru>
|
||||
* vfs.c (parse_ls_lga): allow a bit wider range of listings.
|
||||
|
||||
* vfs.c (is_time, is_year): new functions
|
||||
|
@ -21,8 +21,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "../src/mad.h"
|
||||
#include "../src/util.h"
|
||||
#include "utilvfs.h"
|
||||
#include "xdirentry.h"
|
||||
#include "container.h"
|
||||
|
||||
@ -32,7 +31,7 @@ linklist_init(void)
|
||||
{
|
||||
struct linklist *head;
|
||||
|
||||
head = xmalloc(sizeof(struct linklist), "struct linklist");
|
||||
head = g_new (struct linklist, 1);
|
||||
if (head) {
|
||||
head->prev = head->next = head;
|
||||
head->data = NULL;
|
||||
@ -49,9 +48,9 @@ linklist_destroy(struct linklist *head, void (*destructor) (void *))
|
||||
if (p->data && destructor)
|
||||
(*destructor) (p->data);
|
||||
q = p->next;
|
||||
free(p);
|
||||
g_free(p);
|
||||
}
|
||||
free(head);
|
||||
g_free(head);
|
||||
}
|
||||
|
||||
int
|
||||
@ -59,7 +58,7 @@ linklist_insert(struct linklist *head, void *data)
|
||||
{
|
||||
struct linklist *p;
|
||||
|
||||
p = xmalloc(sizeof(struct linklist), "struct linklist");
|
||||
p = g_new (struct linklist, 1);
|
||||
if (p == NULL)
|
||||
return 0;
|
||||
p->data = data;
|
||||
@ -78,7 +77,7 @@ linklist_delete_all(struct linklist *head, void (*destructor) (void *))
|
||||
for (p = head->next; p != head; p = q) {
|
||||
destructor(p->data);
|
||||
q = p->next;
|
||||
free(p);
|
||||
g_free(p);
|
||||
}
|
||||
head->next = head->prev = head;
|
||||
head->data = NULL;
|
||||
@ -93,7 +92,7 @@ linklist_delete(struct linklist *head, void *data)
|
||||
if (h->data == data) {
|
||||
h->prev->next = h->next;
|
||||
h->next->prev = h->prev;
|
||||
free(h);
|
||||
g_free(h);
|
||||
return 1;
|
||||
}
|
||||
h = h->next;
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
static volatile int total_inodes = 0, total_entries = 0;
|
||||
|
||||
#include "utilvfs.h"
|
||||
#include "xdirentry.h"
|
||||
|
||||
#define CALL(x) if (MEDATA->x) MEDATA->x
|
||||
@ -35,7 +36,7 @@ vfs_s_new_inode (vfs *me, vfs_s_super *super, struct stat *initstat)
|
||||
{
|
||||
vfs_s_inode *ino;
|
||||
|
||||
ino = xmalloc (sizeof (vfs_s_inode), "Dcache inode");
|
||||
ino = g_new (vfs_s_inode, 1);
|
||||
if (!ino)
|
||||
return NULL;
|
||||
|
||||
@ -44,7 +45,6 @@ vfs_s_new_inode (vfs *me, vfs_s_super *super, struct stat *initstat)
|
||||
ino->subdir = NULL;
|
||||
if (initstat)
|
||||
ino->st = *initstat;
|
||||
|
||||
ino->super = super;
|
||||
ino->ent = NULL;
|
||||
ino->flags = 0;
|
||||
@ -65,11 +65,11 @@ vfs_s_new_entry (vfs *me, char *name, vfs_s_inode *inode)
|
||||
{
|
||||
vfs_s_entry *entry;
|
||||
|
||||
entry = (struct vfs_s_entry *) xmalloc (sizeof (struct vfs_s_entry), "Dcache entry");
|
||||
entry = g_new (struct vfs_s_entry, 1);
|
||||
total_entries++;
|
||||
|
||||
if (name)
|
||||
entry->name = strdup (name);
|
||||
entry->name = g_strdup (name);
|
||||
else
|
||||
entry->name = NULL;
|
||||
entry->dir = NULL;
|
||||
@ -100,11 +100,11 @@ vfs_s_free_inode (vfs *me, vfs_s_inode *ino)
|
||||
ifree (ino->linkname);
|
||||
if (ino->localname){
|
||||
unlink (ino->localname);
|
||||
free (ino->localname);
|
||||
g_free(ino->localname);
|
||||
}
|
||||
total_inodes--;
|
||||
ino->super->ino_usage--;
|
||||
free (ino);
|
||||
g_free(ino);
|
||||
} else ino->st.st_nlink--;
|
||||
}
|
||||
|
||||
@ -112,7 +112,6 @@ void
|
||||
vfs_s_free_entry (vfs *me, vfs_s_entry *ent)
|
||||
{
|
||||
int is_dot = 0;
|
||||
|
||||
if (ent->prevp){ /* It is possible that we are deleting freshly created entry */
|
||||
*ent->prevp = ent->next;
|
||||
if (ent->next)
|
||||
@ -121,7 +120,7 @@ vfs_s_free_entry (vfs *me, vfs_s_entry *ent)
|
||||
|
||||
if (ent->name){
|
||||
is_dot = (!strcmp (ent->name, ".")) || (!strcmp (ent->name, ".."));
|
||||
free (ent->name);
|
||||
g_free (ent->name);
|
||||
ent->name = NULL;
|
||||
}
|
||||
|
||||
@ -132,7 +131,7 @@ vfs_s_free_entry (vfs *me, vfs_s_entry *ent)
|
||||
}
|
||||
|
||||
total_entries--;
|
||||
free (ent);
|
||||
g_free(ent);
|
||||
}
|
||||
|
||||
void vfs_s_insert_entry (vfs *me, vfs_s_inode *dir, vfs_s_entry *ent)
|
||||
@ -182,7 +181,7 @@ vfs_s_add_dots (vfs *me, vfs_s_inode *dir, vfs_s_inode *parent)
|
||||
vfs_s_insert_entry (me, dir, dot);
|
||||
vfs_s_insert_entry (me, dir, dotdot);
|
||||
dir->st.st_nlink--;
|
||||
parent->st.st_nlink--; /* We do not count "." and ".." into nlinks */
|
||||
parent->st.st_nlink--; /* We do not count "." and ".." into nlinks */
|
||||
}
|
||||
|
||||
struct vfs_s_entry *
|
||||
@ -239,7 +238,6 @@ vfs_s_find_entry_tree (vfs *me, vfs_s_inode *root, char *path, int follow, int f
|
||||
;
|
||||
if (!path [pseg])
|
||||
return ent;
|
||||
|
||||
path += pseg;
|
||||
|
||||
for (pseg = 0; path[pseg] && path[pseg] != PATH_SEP; pseg++)
|
||||
@ -270,9 +268,7 @@ static void
|
||||
split_dir_name (vfs *me, char *path, char **dir, char **name, char **save)
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = strrchr (path, PATH_SEP);
|
||||
|
||||
if (!s){
|
||||
*save = NULL;
|
||||
*name = path;
|
||||
@ -357,13 +353,10 @@ vfs_s_resolve_symlink (vfs *me, vfs_s_entry *entry, char *path, int follow)
|
||||
{
|
||||
if (follow == LINK_NO_FOLLOW)
|
||||
return entry;
|
||||
|
||||
if (follow == 0)
|
||||
ERRNOR (ELOOP, NULL);
|
||||
|
||||
if (!entry)
|
||||
ERRNOR (ENOENT, NULL);
|
||||
|
||||
if (!S_ISLNK (entry->ino->st.st_mode))
|
||||
return entry;
|
||||
|
||||
@ -396,8 +389,7 @@ vfs_s_new_super (vfs *me)
|
||||
{
|
||||
vfs_s_super *super;
|
||||
|
||||
super = xmalloc (sizeof (struct vfs_s_super), "Direntry: superblock");
|
||||
memset (super, 0, sizeof (struct vfs_s_super));
|
||||
super = g_new0 (struct vfs_s_super, 1);
|
||||
super->root = NULL;
|
||||
super->name = NULL;
|
||||
super->fd_usage = 0;
|
||||
@ -443,7 +435,7 @@ vfs_s_free_super (vfs *me, vfs_s_super *super)
|
||||
CALL (free_archive) (me, super);
|
||||
ifree (super->name);
|
||||
super->name = NULL;
|
||||
free (super);
|
||||
g_free(super);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------= */
|
||||
@ -458,7 +450,7 @@ vfs_s_stamp_me (vfs *me, struct vfs_s_super *psup, char *fs_name)
|
||||
if (v == &vfs_local_ops){
|
||||
parent = NULL;
|
||||
} else {
|
||||
parent = xmalloc (sizeof (struct vfs_stamping), "vfs stamping");
|
||||
parent = g_new (struct vfs_stamping, 1);
|
||||
parent->v = v;
|
||||
parent->next = 0;
|
||||
parent->id = (*v->getid) (v, fs_name, &(parent->parent));
|
||||
@ -517,14 +509,12 @@ return_success:
|
||||
char *
|
||||
vfs_s_get_path (vfs *me, char *inname, struct vfs_s_super **archive, int flags)
|
||||
{
|
||||
char *buf = strdup (inname);
|
||||
char *buf = g_strdup( inname );
|
||||
char *res = vfs_s_get_path_mangle (me, buf, archive, flags);
|
||||
char *res2 = NULL;
|
||||
|
||||
if (res)
|
||||
res2 = strdup (res);
|
||||
free (buf);
|
||||
|
||||
res2 = g_strdup(res);
|
||||
g_free(buf);
|
||||
return res2;
|
||||
}
|
||||
|
||||
@ -543,11 +533,10 @@ vfs_s_fullpath (vfs *me, vfs_s_inode *ino)
|
||||
/* For now, usable only on filesystems with _linear structure */
|
||||
if (MEDATA->find_entry != vfs_s_find_entry_linear)
|
||||
vfs_die ("Implement me!");
|
||||
|
||||
if ((!ino->ent) || (!ino->ent->dir) || (!ino->ent->dir->ent))
|
||||
ERRNOR (EAGAIN, NULL);
|
||||
|
||||
return copy_strings (ino->ent->dir->ent->name, "/", ino->ent->name, NULL);
|
||||
return copy_strings (ino->ent->dir->ent->name, PATH_SEP_STR,
|
||||
ino->ent->name, NULL);
|
||||
}
|
||||
|
||||
/* Support of archives */
|
||||
@ -601,7 +590,7 @@ void *
|
||||
if (!dir->subdir) /* This can actually happen if we allow empty directories */
|
||||
ERRNOR (EAGAIN, NULL);
|
||||
#endif
|
||||
info = (struct dirhandle *) xmalloc (sizeof (struct dirhandle), "Shared opendir");
|
||||
info = g_new (struct dirhandle, 1);
|
||||
info->cur = dir->subdir;
|
||||
info->dir = dir;
|
||||
|
||||
@ -658,7 +647,6 @@ vfs_s_seekdir (void *data, int offset)
|
||||
{
|
||||
struct dirhandle *info = (struct dirhandle *) data;
|
||||
int i;
|
||||
|
||||
info->cur = info->dir->subdir;
|
||||
for (i=0; i<offset; i++)
|
||||
vfs_s_readdir (data);
|
||||
@ -671,8 +659,7 @@ vfs_s_closedir (void *data)
|
||||
struct vfs_s_inode *dir = info->dir;
|
||||
|
||||
vfs_s_free_inode (dir->super->me, dir);
|
||||
free (data);
|
||||
|
||||
g_free (data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -715,7 +702,6 @@ int
|
||||
vfs_s_fstat (void *fh, struct stat *buf)
|
||||
{
|
||||
*buf = FH->ino->st;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -730,10 +716,8 @@ vfs_s_readlink (vfs *me, char *path, char *buf, int size)
|
||||
|
||||
if (!S_ISLNK (ino->st.st_mode))
|
||||
ERRNOR (EINVAL, -1);
|
||||
|
||||
strncpy (buf, ino->linkname, size);
|
||||
*(buf+size-1) = 0;
|
||||
|
||||
return strlen (buf);
|
||||
}
|
||||
|
||||
@ -759,7 +743,6 @@ vfs_s_open (vfs *me, char *file, int flags, int mode)
|
||||
return NULL;
|
||||
|
||||
split_dir_name (me, q, &dirname, &name, &save);
|
||||
|
||||
/* FIXME: if vfs_s_find_inode returns NULL, this will do rather bad
|
||||
things. */
|
||||
dir = vfs_s_find_inode (me, super->root, dirname, LINK_FOLLOW, FL_DIR);
|
||||
@ -775,7 +758,7 @@ vfs_s_open (vfs *me, char *file, int flags, int mode)
|
||||
if (S_ISDIR (ino->st.st_mode))
|
||||
ERRNOR (EISDIR, NULL);
|
||||
|
||||
fh = (struct vfs_s_fh *) xmalloc (sizeof (struct vfs_s_fh), "Direntry: filehandle");
|
||||
fh = g_new (struct vfs_s_fh, 1);
|
||||
fh->pos = 0;
|
||||
fh->ino = ino;
|
||||
fh->handle = -1;
|
||||
@ -783,14 +766,14 @@ vfs_s_open (vfs *me, char *file, int flags, int mode)
|
||||
fh->linear = 0;
|
||||
if (MEDATA->fh_open)
|
||||
if (MEDATA->fh_open (me, fh, flags, mode)){
|
||||
free (fh);
|
||||
g_free(fh);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fh->ino->localname){
|
||||
fh->handle = open (fh->ino->localname, flags, mode);
|
||||
if (fh->handle == -1){
|
||||
free (fh);
|
||||
g_free(fh);
|
||||
ERRNOR (errno, NULL);
|
||||
}
|
||||
}
|
||||
@ -892,7 +875,7 @@ vfs_s_close (void *fh)
|
||||
if (v == &vfs_local_ops){
|
||||
parent = NULL;
|
||||
} else {
|
||||
parent = xmalloc (sizeof (struct vfs_stamping), "vfs stamping");
|
||||
parent = g_new (struct vfs_stamping, 1);
|
||||
parent->v = v;
|
||||
parent->next = 0;
|
||||
parent->id = (*v->getid) (v, FH_SUPER->name, &(parent->parent));
|
||||
@ -916,7 +899,7 @@ vfs_s_close (void *fh)
|
||||
close (FH->handle);
|
||||
|
||||
vfs_s_free_inode (me, FH->ino);
|
||||
free (fh);
|
||||
g_free (fh);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -929,10 +912,9 @@ vfs_s_fill_names (vfs *me, void (*func)(char *))
|
||||
char *name;
|
||||
|
||||
while (a){
|
||||
name = copy_strings (a->name, "#", me->prefix, "/",
|
||||
/* a->current_dir->name, */ 0);
|
||||
name = copy_strings ( a->name, "#", me->prefix, "/", /* a->current_dir->name, */ NULL);
|
||||
(*func)(name);
|
||||
free (name);
|
||||
g_free (name);
|
||||
a = a->next;
|
||||
}
|
||||
}
|
||||
@ -961,7 +943,7 @@ vfs_s_dump (vfs *me, char *prefix, vfs_s_inode *ino)
|
||||
printf ("%s IGNORED\n", s);
|
||||
else
|
||||
vfs_s_dump (me, s, ent->ino);
|
||||
free (s);
|
||||
g_free(s);
|
||||
ent = ent->next;
|
||||
}
|
||||
}
|
||||
@ -986,10 +968,8 @@ int
|
||||
vfs_s_setctl (vfs *me, char *path, int ctlop, char *arg)
|
||||
{
|
||||
vfs_s_inode *ino = vfs_s_inode_from_path (me, path, 0);
|
||||
|
||||
if (!ino)
|
||||
return 0;
|
||||
|
||||
switch (ctlop){
|
||||
case MCCTL_WANT_STALE_DATA:
|
||||
ino->super->want_stale = 1;
|
||||
@ -1006,7 +986,6 @@ vfs_s_setctl (vfs *me, char *path, int ctlop, char *arg)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1025,14 +1004,11 @@ vfs_s_getid (vfs *me, char *path, struct vfs_stamping **parent)
|
||||
*parent = NULL;
|
||||
if (!(p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN)))
|
||||
return (vfsid) -1;
|
||||
|
||||
free (p);
|
||||
|
||||
g_free(p);
|
||||
v = vfs_type (archive->name);
|
||||
id = (*v->getid) (v, archive->name, &par);
|
||||
|
||||
if (id != (vfsid)-1){
|
||||
*parent = xmalloc (sizeof (struct vfs_stamping), "vfs stamping");
|
||||
*parent = g_new (struct vfs_stamping, 1);
|
||||
(*parent)->v = v;
|
||||
(*parent)->id = id;
|
||||
(*parent)->parent = par;
|
||||
|
152
vfs/extfs.c
152
vfs/extfs.c
@ -38,11 +38,8 @@
|
||||
#include <sys/timeb.h> /* alex: for struct timeb definition */
|
||||
#endif /* SCO_FLAVOR */
|
||||
#include <time.h>
|
||||
#include "../src/fs.h"
|
||||
#include "../src/util.h"
|
||||
#include "utilvfs.h"
|
||||
#include "../src/dialog.h"
|
||||
#include "../src/mem.h"
|
||||
#include "../src/mad.h"
|
||||
#include "../src/main.h" /* For shell_execute */
|
||||
#include "vfs.h"
|
||||
#include "extfs.h"
|
||||
@ -70,22 +67,21 @@ static void extfs_fill_names (vfs *me, void (*func)(char *))
|
||||
while (a){
|
||||
name = copy_strings (extfs_prefixes [a->fstype], "#",
|
||||
(a->name ? a->name : ""), "/",
|
||||
a->current_dir->name, 0);
|
||||
a->current_dir->name, NULL);
|
||||
(*func)(name);
|
||||
free (name);
|
||||
g_free (name);
|
||||
a = a->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void make_dot_doubledot (struct entry *ent)
|
||||
{
|
||||
struct entry *entry = (struct entry *)
|
||||
xmalloc (sizeof (struct entry), "Extfs: entry");
|
||||
struct entry *entry = g_new (struct entry, 1);
|
||||
struct entry *parentry = ent->dir;
|
||||
struct inode *inode = ent->inode, *parent;
|
||||
|
||||
parent = (parentry != NULL) ? parentry->inode : NULL;
|
||||
entry->name = strdup (".");
|
||||
entry->name = g_strdup (".");
|
||||
entry->has_changed = 0;
|
||||
entry->inode = inode;
|
||||
entry->dir = ent;
|
||||
@ -93,10 +89,9 @@ static void make_dot_doubledot (struct entry *ent)
|
||||
inode->first_in_subdir = entry;
|
||||
inode->last_in_subdir = entry;
|
||||
inode->nlink++;
|
||||
entry->next_in_dir = (struct entry *)
|
||||
xmalloc (sizeof (struct entry), "Extfs: entry");
|
||||
entry->next_in_dir = g_new (struct entry, 1);
|
||||
entry=entry->next_in_dir;
|
||||
entry->name = strdup ("..");
|
||||
entry->name = g_strdup ("..");
|
||||
entry->has_changed = 0;
|
||||
inode->last_in_subdir = entry;
|
||||
entry->next_in_dir = NULL;
|
||||
@ -119,10 +114,9 @@ static struct entry *generate_entry (struct archive *archive,
|
||||
struct entry *entry;
|
||||
|
||||
parent = (parentry != NULL) ? parentry->inode : NULL;
|
||||
entry = (struct entry *)
|
||||
xmalloc (sizeof (struct entry), "Extfs: entry");
|
||||
entry = g_new (struct entry, 1);
|
||||
|
||||
entry->name = strdup (name);
|
||||
entry->name = g_strdup (name);
|
||||
entry->has_changed = 0;
|
||||
entry->next_in_dir = NULL;
|
||||
entry->dir = parentry;
|
||||
@ -130,8 +124,7 @@ static struct entry *generate_entry (struct archive *archive,
|
||||
parent->last_in_subdir->next_in_dir = entry;
|
||||
parent->last_in_subdir = entry;
|
||||
}
|
||||
inode = (struct inode *)
|
||||
xmalloc (sizeof (struct inode), "Extfs: inode");
|
||||
inode = g_new (struct inode, 1);
|
||||
entry->inode = inode;
|
||||
inode->has_changed = 0;
|
||||
inode->local_filename = NULL;
|
||||
@ -173,8 +166,8 @@ static void free_archive (struct archive *archive)
|
||||
/* ungetlocalcopy frees local_name for us */
|
||||
}
|
||||
if (archive->name)
|
||||
free (archive->name);
|
||||
free (archive);
|
||||
g_free (archive->name);
|
||||
g_free (archive);
|
||||
}
|
||||
|
||||
static FILE *open_archive (int fstype, char *name, struct archive **pparc)
|
||||
@ -210,22 +203,21 @@ static FILE *open_archive (int fstype, char *name, struct archive **pparc)
|
||||
|
||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs/");
|
||||
cmd = copy_strings (mc_extfsdir, extfs_prefixes [fstype],
|
||||
" list ", local_name ? local_name : tmp, 0);
|
||||
" list ", local_name ? local_name : tmp, NULL);
|
||||
if (tmp)
|
||||
free (tmp);
|
||||
g_free (tmp);
|
||||
result = popen (cmd, "r");
|
||||
free (cmd);
|
||||
free (mc_extfsdir);
|
||||
g_free (cmd);
|
||||
g_free (mc_extfsdir);
|
||||
if (result == NULL) {
|
||||
if (local_name != NULL && uses_archive)
|
||||
mc_ungetlocalcopy (name, local_name, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
current_archive = (struct archive *)
|
||||
xmalloc (sizeof (struct archive), "Extfs archive");
|
||||
current_archive = g_new (struct archive, 1);
|
||||
current_archive->fstype = fstype;
|
||||
current_archive->name = name ? strdup (name): name;
|
||||
current_archive->name = name ? g_strdup (name): name;
|
||||
current_archive->local_name = local_name;
|
||||
|
||||
if (local_name != NULL)
|
||||
@ -276,7 +268,7 @@ static int read_archive (int fstype, char *name, struct archive **pparc)
|
||||
return -1;
|
||||
}
|
||||
|
||||
buffer = xmalloc (4096, "Extfs: buffer");
|
||||
buffer = g_malloc (4096);
|
||||
while (fgets (buffer, 4096, extfsd) != NULL) {
|
||||
current_link_name = NULL;
|
||||
if (vfs_parse_ls_lga (buffer, &hstat, ¤t_file_name, ¤t_link_name)) {
|
||||
@ -305,12 +297,12 @@ static int read_archive (int fstype, char *name, struct archive **pparc)
|
||||
if (pent == NULL) {
|
||||
message_1s (1, MSG_ERROR, _("Inconsistent extfs archive"));
|
||||
/* FIXME: Should clean everything one day */
|
||||
free (buffer);
|
||||
g_free (buffer);
|
||||
pclose (extfsd);
|
||||
return -1;
|
||||
}
|
||||
entry = (struct entry *) xmalloc (sizeof (struct entry), "Extfs: entry");
|
||||
entry->name = strdup (p);
|
||||
entry = g_new (struct entry, 1);
|
||||
entry->name = g_strdup (p);
|
||||
entry->has_changed = 0;
|
||||
entry->next_in_dir = NULL;
|
||||
entry->dir = pent;
|
||||
@ -325,7 +317,7 @@ static int read_archive (int fstype, char *name, struct archive **pparc)
|
||||
if (pent == NULL) {
|
||||
message_1s (1, MSG_ERROR, _("Inconsistent extfs archive"));
|
||||
/* FIXME: Should clean everything one day */
|
||||
free (buffer);
|
||||
g_free (buffer);
|
||||
pclose (extfsd);
|
||||
return -1;
|
||||
} else {
|
||||
@ -333,7 +325,7 @@ static int read_archive (int fstype, char *name, struct archive **pparc)
|
||||
pent->inode->nlink++;
|
||||
}
|
||||
} else {
|
||||
inode = (struct inode *) xmalloc (sizeof (struct inode), "Extfs: inode");
|
||||
inode = g_new (struct inode, 1);
|
||||
entry->inode = inode;
|
||||
inode->local_filename = NULL;
|
||||
inode->has_changed = 0;
|
||||
@ -366,9 +358,9 @@ static int read_archive (int fstype, char *name, struct archive **pparc)
|
||||
}
|
||||
}
|
||||
read_extfs_continue:
|
||||
free (current_file_name);
|
||||
g_free (current_file_name);
|
||||
if (current_link_name != NULL)
|
||||
free (current_link_name);
|
||||
g_free (current_link_name);
|
||||
}
|
||||
}
|
||||
pclose (extfsd);
|
||||
@ -376,7 +368,7 @@ static int read_archive (int fstype, char *name, struct archive **pparc)
|
||||
waitpid(-1,NULL,WNOHANG);
|
||||
#endif /* SCO_FLAVOR */
|
||||
*pparc = current_archive;
|
||||
free (buffer);
|
||||
g_free (buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -437,7 +429,7 @@ static char *get_path_mangle (char *inname, struct archive **archive, int is_dir
|
||||
if (v == &vfs_local_ops) {
|
||||
parent = NULL;
|
||||
} else {
|
||||
parent = xmalloc (sizeof (struct vfs_stamping), "vfs stamping");
|
||||
parent = g_new (struct vfs_stamping, 1);
|
||||
parent->v = v;
|
||||
parent->next = 0;
|
||||
parent->id = (*v->getid) (v, archive_name, &(parent->parent));
|
||||
@ -461,14 +453,14 @@ static char *get_path_from_entry (struct entry *entry)
|
||||
size_t len;
|
||||
|
||||
for (len = 0, head = 0; entry->dir; entry = entry->dir) {
|
||||
p = xmalloc (sizeof (struct list), "Extfs: list");
|
||||
p = g_new (struct list, 1);
|
||||
p->next = head;
|
||||
p->name = entry->name;
|
||||
head = p;
|
||||
len += strlen (entry->name) + 1;
|
||||
}
|
||||
|
||||
localpath = xmalloc (len, "Extfs: localpath");
|
||||
localpath = g_malloc (len);
|
||||
*localpath = '\0';
|
||||
for ( ; head; ) {
|
||||
strcat (localpath, head->name);
|
||||
@ -476,7 +468,7 @@ static char *get_path_from_entry (struct entry *entry)
|
||||
strcat (localpath, "/");
|
||||
p = head;
|
||||
head = head->next;
|
||||
free (p);
|
||||
g_free (p);
|
||||
}
|
||||
return (localpath);
|
||||
}
|
||||
@ -507,13 +499,11 @@ __resolve_symlinks (struct entry *entry,
|
||||
errloop = 1;
|
||||
return NULL;
|
||||
}
|
||||
looping = (struct loop_protect *)
|
||||
xmalloc (sizeof (struct loop_protect),
|
||||
"Extfs: symlink looping protection");
|
||||
looping = g_new (struct loop_protect, 1);
|
||||
looping->entry = entry;
|
||||
looping->next = list;
|
||||
pent = __find_entry (entry->dir, entry->inode->linkname, looping, 0, 0);
|
||||
free (looping);
|
||||
g_free (looping);
|
||||
if (pent == NULL)
|
||||
my_errno = ENOENT;
|
||||
return pent;
|
||||
@ -563,7 +553,8 @@ static char *get_archive_name (struct archive *archive)
|
||||
void extfs_run (char *file)
|
||||
{
|
||||
struct archive *archive;
|
||||
char *p, *q, *cmd, *archive_name, *mc_extfsdir;
|
||||
char *p, *q, *archive_name, *mc_extfsdir;
|
||||
char *cmd;
|
||||
|
||||
if ((p = get_path (file, &archive, 0, 0)) == NULL)
|
||||
return;
|
||||
@ -572,17 +563,17 @@ void extfs_run (char *file)
|
||||
archive_name = name_quote (get_archive_name(archive), 0);
|
||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs/");
|
||||
cmd = copy_strings (mc_extfsdir, extfs_prefixes [archive->fstype],
|
||||
" run ", archive_name, " ", q, 0);
|
||||
free (mc_extfsdir);
|
||||
free (archive_name);
|
||||
free (q);
|
||||
" run ", archive_name, " ", q, NULL);
|
||||
g_free (mc_extfsdir);
|
||||
g_free (archive_name);
|
||||
g_free (q);
|
||||
#ifndef VFS_STANDALONE
|
||||
shell_execute(cmd, 0);
|
||||
#else
|
||||
vfs_die( "shell_execute: implement me!" );
|
||||
#endif
|
||||
free(cmd);
|
||||
free(p);
|
||||
g_free(cmd);
|
||||
g_free(p);
|
||||
}
|
||||
|
||||
static void *extfs_open (vfs *me, char *file, int flags, int mode)
|
||||
@ -604,9 +595,10 @@ static void *extfs_open (vfs *me, char *file, int flags, int mode)
|
||||
return NULL;
|
||||
if (S_ISDIR (entry->inode->mode)) ERRNOR (EISDIR, NULL);
|
||||
if (entry->inode->local_filename == NULL) {
|
||||
char *cmd, *archive_name, *p;
|
||||
char *cmd;
|
||||
char *archive_name, *p;
|
||||
|
||||
entry->inode->local_filename = strdup (tempnam (NULL, "extfs"));
|
||||
entry->inode->local_filename = g_strdup (tempnam (NULL, "extfs"));
|
||||
{
|
||||
int handle;
|
||||
|
||||
@ -617,31 +609,31 @@ static void *extfs_open (vfs *me, char *file, int flags, int mode)
|
||||
}
|
||||
p = get_path_from_entry (entry);
|
||||
q = name_quote (p, 0);
|
||||
free (p);
|
||||
g_free (p);
|
||||
archive_name = name_quote (get_archive_name (archive), 0);
|
||||
|
||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs/");
|
||||
cmd = copy_strings (mc_extfsdir, extfs_prefixes [archive->fstype],
|
||||
" copyout ",
|
||||
archive_name,
|
||||
" ", q, " ", entry->inode->local_filename, 0);
|
||||
free (q);
|
||||
free (mc_extfsdir);
|
||||
free (archive_name);
|
||||
" ", q, " ", entry->inode->local_filename, NULL);
|
||||
g_free (q);
|
||||
g_free (mc_extfsdir);
|
||||
g_free (archive_name);
|
||||
if (my_system (EXECUTE_AS_SHELL | EXECUTE_SETUID | EXECUTE_WAIT, shell, cmd) && !do_create){
|
||||
free (entry->inode->local_filename);
|
||||
g_free (entry->inode->local_filename);
|
||||
entry->inode->local_filename = NULL;
|
||||
free (cmd);
|
||||
g_free (cmd);
|
||||
my_errno = EIO;
|
||||
return NULL;
|
||||
}
|
||||
free (cmd);
|
||||
g_free (cmd);
|
||||
}
|
||||
|
||||
local_handle = open (entry->inode->local_filename, flags, mode);
|
||||
if (local_handle == -1) ERRNOR (EIO, NULL);
|
||||
|
||||
extfs_info = (struct pseudofile *) xmalloc (sizeof (struct pseudofile), "Extfs: extfs_open");
|
||||
extfs_info = g_new (struct pseudofile, 1);
|
||||
extfs_info->archive = archive;
|
||||
extfs_info->entry = entry;
|
||||
extfs_info->has_changed = 0;
|
||||
@ -680,20 +672,20 @@ static int extfs_close (void *data)
|
||||
archive_name = name_quote (get_archive_name (archive), 0);
|
||||
p = get_path_from_entry (file->entry);
|
||||
file_name = name_quote (p, 0);
|
||||
free (p);
|
||||
g_free (p);
|
||||
|
||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs/");
|
||||
cmd = copy_strings (mc_extfsdir,
|
||||
extfs_prefixes [archive->fstype],
|
||||
" copyin ", archive_name, " ",
|
||||
file_name, " ",
|
||||
file->entry->inode->local_filename, 0);
|
||||
free (archive_name);
|
||||
free (file_name);
|
||||
file->entry->inode->local_filename, NULL);
|
||||
g_free (archive_name);
|
||||
g_free (file_name);
|
||||
if (my_system (EXECUTE_AS_SHELL | EXECUTE_SETUID | EXECUTE_WAIT, shell, cmd))
|
||||
errno_code = EIO;
|
||||
free (cmd);
|
||||
free (mc_extfsdir);
|
||||
g_free (cmd);
|
||||
g_free (mc_extfsdir);
|
||||
{
|
||||
struct stat file_status;
|
||||
if( stat(file->entry->inode->local_filename,&file_status) != 0 )
|
||||
@ -712,7 +704,7 @@ static int extfs_close (void *data)
|
||||
if (!file->archive->name || !*file->archive->name || (v = vfs_type (file->archive->name)) == &vfs_local_ops) {
|
||||
parent = NULL;
|
||||
} else {
|
||||
parent = xmalloc (sizeof (struct vfs_stamping), "vfs stamping");
|
||||
parent = g_new (struct vfs_stamping, 1);
|
||||
parent->v = v;
|
||||
parent->next = 0;
|
||||
parent->id = (*v->getid) (v, file->archive->name, &(parent->parent));
|
||||
@ -721,7 +713,7 @@ static int extfs_close (void *data)
|
||||
vfs_rm_parents (parent);
|
||||
}
|
||||
|
||||
free (data);
|
||||
g_free (data);
|
||||
if (errno_code) ERRNOR (EIO, -1);
|
||||
return 0;
|
||||
}
|
||||
@ -783,12 +775,12 @@ static vfsid extfs_getid (vfs *me, char *path, struct vfs_stamping **parent)
|
||||
*parent = NULL;
|
||||
if (!(p = get_path (path, &archive, 1, 1)))
|
||||
return (vfsid) -1;
|
||||
free(p);
|
||||
g_free(p);
|
||||
if (archive->name){
|
||||
v = vfs_type (archive->name);
|
||||
id = (*v->getid) (v, archive->name, &par);
|
||||
if (id != (vfsid)-1) {
|
||||
*parent = xmalloc (sizeof (struct vfs_stamping), "vfs stamping");
|
||||
*parent = g_new (struct vfs_stamping, 1);
|
||||
(*parent)->v = v;
|
||||
(*parent)->id = id;
|
||||
(*parent)->parent = par;
|
||||
@ -818,16 +810,16 @@ static void free_entry (struct entry *e)
|
||||
if (i <= 0) {
|
||||
if (e->inode->local_filename != NULL) {
|
||||
unlink (e->inode->local_filename);
|
||||
free (e->inode->local_filename);
|
||||
g_free (e->inode->local_filename);
|
||||
}
|
||||
if (e->inode->linkname != NULL)
|
||||
free (e->inode->linkname);
|
||||
free (e->inode);
|
||||
g_free (e->inode->linkname);
|
||||
g_free (e->inode);
|
||||
}
|
||||
if (e->next_in_dir != NULL)
|
||||
free_entry (e->next_in_dir);
|
||||
free (e->name);
|
||||
free (e);
|
||||
g_free (e->name);
|
||||
g_free (e);
|
||||
}
|
||||
|
||||
static void extfs_free (vfsid id)
|
||||
@ -860,7 +852,7 @@ static char *extfs_getlocalcopy (vfs *me, char *path)
|
||||
extfs_close ((void *) fp);
|
||||
return NULL;
|
||||
}
|
||||
p = strdup (fp->entry->inode->local_filename);
|
||||
p = g_strdup (fp->entry->inode->local_filename);
|
||||
fp->archive->fd_usage++;
|
||||
extfs_close ((void *) fp);
|
||||
return p;
|
||||
@ -894,7 +886,7 @@ static int extfs_init (vfs *me)
|
||||
|
||||
mc_extfsini = concat_dir_and_file (mc_home, "extfs/extfs.ini");
|
||||
cfg = fopen (mc_extfsini, "r");
|
||||
free (mc_extfsini);
|
||||
g_free (mc_extfsini);
|
||||
|
||||
if (!cfg) {
|
||||
fprintf( stderr, "Warning: " LIBDIR "extfs/extfs.ini not found\n" );
|
||||
@ -932,7 +924,7 @@ static int extfs_init (vfs *me)
|
||||
if (!(*key))
|
||||
continue;
|
||||
|
||||
extfs_prefixes [extfs_no] = strdup (key);
|
||||
extfs_prefixes [extfs_no] = g_strdup (key);
|
||||
extfs_no++;
|
||||
}
|
||||
fclose(cfg);
|
||||
@ -955,7 +947,7 @@ static void extfs_done (vfs *me)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < extfs_no; i++ )
|
||||
free (extfs_prefixes [i]);
|
||||
g_free (extfs_prefixes [i]);
|
||||
extfs_no = 0;
|
||||
}
|
||||
|
||||
|
46
vfs/fish.c
46
vfs/fish.c
@ -35,15 +35,13 @@
|
||||
|
||||
#undef HAVE_HACKED_SSH
|
||||
|
||||
#include "utilvfs.h"
|
||||
|
||||
#include "xdirentry.h"
|
||||
#include "../src/tty.h" /* enable/disable interrupt key */
|
||||
#include "../src/main.h"
|
||||
#include "../src/mem.h"
|
||||
#include "vfs.h"
|
||||
#include "tcputil.h"
|
||||
#include "container.h"
|
||||
#include "fish.h"
|
||||
#include <glib.h>
|
||||
|
||||
/*
|
||||
* Reply codes.
|
||||
@ -231,10 +229,10 @@ open_archive_int (vfs *me, vfs_s_super *super)
|
||||
p = copy_strings (" fish: Password required for ", SUP.user,
|
||||
" ", NULL);
|
||||
op = vfs_get_password (p);
|
||||
free (p);
|
||||
g_free (p);
|
||||
if (op == NULL)
|
||||
ERRNOR (EPERM, -1);
|
||||
SUP.password = strdup (op);
|
||||
SUP.password = g_strdup (op);
|
||||
wipe_password(op);
|
||||
}
|
||||
print_vfs_message( "fish: Sending password..." );
|
||||
@ -257,7 +255,7 @@ open_archive_int (vfs *me, vfs_s_super *super)
|
||||
#if 0
|
||||
super->name = copy_strings( "/#sh:", SUP.user, "@", SUP.host, "/", NULL );
|
||||
#endif
|
||||
super->name = strdup( "/" );
|
||||
super->name = g_strdup(PATH_SEP_STR);
|
||||
|
||||
super->root = vfs_s_new_inode (me, super, vfs_s_default_stat(me, S_IFDIR | 0755));
|
||||
return 0;
|
||||
@ -270,14 +268,14 @@ open_archive (vfs *me, vfs_s_super *super, char *archive_name, char *op)
|
||||
int flags;
|
||||
|
||||
vfs_split_url (strchr(op, ':')+1, &host, &user, &flags, &password, 0, URL_NOSLASH);
|
||||
SUP.host = strdup (host);
|
||||
SUP.user = strdup (user);
|
||||
SUP.host = g_strdup (host);
|
||||
SUP.user = g_strdup (user);
|
||||
SUP.flags = flags;
|
||||
if (!strncmp( op, "rsh:", 4 ))
|
||||
SUP.flags |= FISH_FLAG_RSH;
|
||||
SUP.home = NULL;
|
||||
if (password)
|
||||
SUP.password = strdup (password);
|
||||
SUP.password = g_strdup (password);
|
||||
return open_archive_int (me, super);
|
||||
}
|
||||
|
||||
@ -374,7 +372,7 @@ dir_load(vfs *me, vfs_s_inode *dir, char *remote_path)
|
||||
char *c;
|
||||
if (!strcmp(buffer+1, ".") || !strcmp(buffer+1, ".."))
|
||||
break; /* We'll do . and .. ourself */
|
||||
ent->name = strdup(buffer+1);
|
||||
ent->name = g_strdup(buffer+1);
|
||||
if ((c=strchr(ent->name, ' ')))
|
||||
*c = 0; /* this is ugly, but we can not handle " " in name */
|
||||
break;
|
||||
@ -415,7 +413,7 @@ dir_load(vfs *me, vfs_s_inode *dir, char *remote_path)
|
||||
ST.st_rdev = (maj << 8) | min;
|
||||
#endif
|
||||
}
|
||||
case 'L': ent->ino->linkname = strdup(buffer+1);
|
||||
case 'L': ent->ino->linkname = g_strdup(buffer+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -517,7 +515,7 @@ linear_abort (vfs *me, vfs_s_fh *fh)
|
||||
|
||||
print_vfs_message( "Aborting transfer..." );
|
||||
do {
|
||||
n = VFS_MIN(8192, fh->u.fish.total - fh->u.fish.got);
|
||||
n = MIN(8192, fh->u.fish.total - fh->u.fish.got);
|
||||
if (n)
|
||||
if ((n = read(SUP.sockr, buffer, n)) < 0)
|
||||
return;
|
||||
@ -534,7 +532,7 @@ linear_read (vfs *me, vfs_s_fh *fh, void *buf, int len)
|
||||
{
|
||||
vfs_s_super *super = FH_SUPER;
|
||||
int n = 0;
|
||||
len = VFS_MIN( fh->u.fish.total - fh->u.fish.got, len );
|
||||
len = MIN( fh->u.fish.total - fh->u.fish.got, len );
|
||||
disable_interrupt_key();
|
||||
while (len && ((n = read (SUP.sockr, buf, len))<0)) {
|
||||
if ((errno == EINTR) && !got_interrupt())
|
||||
@ -595,7 +593,7 @@ send_fish_command(vfs *me, vfs_s_super *super, char *cmd, int flags)
|
||||
}
|
||||
|
||||
#define PREFIX \
|
||||
char buf[999]; \
|
||||
char buf[BUF_LARGE]; \
|
||||
char *rpath; \
|
||||
vfs_s_super *super; \
|
||||
if (!(rpath = vfs_s_get_path_mangle(me, path, &super, 0))) \
|
||||
@ -608,7 +606,7 @@ static int
|
||||
fish_chmod (vfs *me, char *path, int mode)
|
||||
{
|
||||
PREFIX
|
||||
sprintf(buf, "#CHMOD %4.4o /%s\nchmod %4.4o /%s; echo '### 000'\n",
|
||||
g_snprintf(buf, sizeof(buf), "#CHMOD %4.4o /%s\nchmod %4.4o /%s; echo '### 000'\n",
|
||||
mode & 07777, rpath,
|
||||
mode & 07777, rpath);
|
||||
POSTFIX(OPT_FLUSH);
|
||||
@ -617,7 +615,7 @@ fish_chmod (vfs *me, char *path, int mode)
|
||||
#define FISH_OP(name, chk, string) \
|
||||
static int fish_##name (vfs *me, char *path1, char *path2) \
|
||||
{ \
|
||||
char buf[1024]; \
|
||||
char buf[BUF_LARGE]; \
|
||||
char *rpath1 = NULL, *rpath2 = NULL; \
|
||||
vfs_s_super *super1, *super2; \
|
||||
if (!(rpath1 = vfs_s_get_path_mangle(me, path1, &super1, 0))) \
|
||||
@ -635,7 +633,7 @@ FISH_OP(link, XTEST, "#LINK /%s /%s\nln /%s /%s; echo '### 000'" );
|
||||
static int fish_symlink (vfs *me, char *setto, char *path)
|
||||
{
|
||||
PREFIX
|
||||
sprintf(buf, "#SYMLINK %s /%s\nln -s %s /%s; echo '### 000'\n", setto, rpath, setto, rpath);
|
||||
g_snprintf(buf, sizeof(buf), "#SYMLINK %s /%s\nln -s %s /%s; echo '### 000'\n", setto, rpath, setto, rpath);
|
||||
POSTFIX(OPT_FLUSH);
|
||||
}
|
||||
|
||||
@ -646,12 +644,12 @@ fish_chown (vfs *me, char *path, int owner, int group)
|
||||
PREFIX
|
||||
sowner = getpwuid( owner )->pw_name;
|
||||
sgroup = getgrgid( group )->gr_name;
|
||||
sprintf(buf, "#CHOWN /%s /%s\nchown /%s /%s; echo '### 000'\n",
|
||||
g_snprintf(buf, sizeof(buf), "#CHOWN /%s /%s\nchown /%s /%s; echo '### 000'\n",
|
||||
sowner, rpath,
|
||||
sowner, rpath);
|
||||
send_fish_command(me, super, buf, OPT_FLUSH);
|
||||
/* FIXME: what should we report if chgrp succeeds but chown fails? */
|
||||
sprintf(buf, "#CHGRP /%s /%s\nchgrp /%s /%s; echo '### 000'\n",
|
||||
g_snprintf(buf, sizeof(buf), "#CHGRP /%s /%s\nchgrp /%s /%s; echo '### 000'\n",
|
||||
sgroup, rpath,
|
||||
sgroup, rpath);
|
||||
POSTFIX(OPT_FLUSH)
|
||||
@ -660,21 +658,21 @@ fish_chown (vfs *me, char *path, int owner, int group)
|
||||
static int fish_unlink (vfs *me, char *path)
|
||||
{
|
||||
PREFIX
|
||||
sprintf(buf, "#DELE /%s\nrm -f /%s; echo '### 000'\n", rpath, rpath);
|
||||
g_snprintf(buf, sizeof(buf), "#DELE /%s\nrm -f /%s; echo '### 000'\n", rpath, rpath);
|
||||
POSTFIX(OPT_FLUSH);
|
||||
}
|
||||
|
||||
static int fish_mkdir (vfs *me, char *path, mode_t mode)
|
||||
{
|
||||
PREFIX
|
||||
sprintf(buf, "#MKD /%s\nmkdir /%s; echo '### 000'\n", rpath, rpath);
|
||||
g_snprintf(buf, sizeof(buf), "#MKD /%s\nmkdir /%s; echo '### 000'\n", rpath, rpath);
|
||||
POSTFIX(OPT_FLUSH);
|
||||
}
|
||||
|
||||
static int fish_rmdir (vfs *me, char *path)
|
||||
{
|
||||
PREFIX
|
||||
sprintf(buf, "#RMD /%s\nrmdir /%s; echo '### 000'\n", rpath, rpath);
|
||||
g_snprintf(buf, sizeof(buf), "#RMD /%s\nrmdir /%s; echo '### 000'\n", rpath, rpath);
|
||||
POSTFIX(OPT_FLUSH);
|
||||
}
|
||||
|
||||
@ -732,7 +730,7 @@ error_3:
|
||||
close(handle);
|
||||
unlink(ino->localname);
|
||||
error_4:
|
||||
free(ino->localname);
|
||||
g_free(ino->localname);
|
||||
ino->localname = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
220
vfs/ftpfs.c
220
vfs/ftpfs.c
@ -55,11 +55,9 @@
|
||||
#if HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
#include "../src/fs.h"
|
||||
#include "../src/mad.h"
|
||||
|
||||
#include "../src/setup.h"
|
||||
#include "../src/tty.h" /* enable/disable interrupt key */
|
||||
#include "../src/main.h"
|
||||
|
||||
#include <netdb.h> /* struct hostent */
|
||||
#include <sys/socket.h> /* AF_INET */
|
||||
#include <netinet/in.h> /* struct in_addr */
|
||||
@ -73,18 +71,15 @@
|
||||
# include <sys/time.h> /* alex: this redefines struct timeval */
|
||||
#endif /* SCO_FLAVOR */
|
||||
#include <sys/param.h>
|
||||
#undef MIN
|
||||
#undef MAX
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef USE_TERMNET
|
||||
#include <termnet.h>
|
||||
#endif
|
||||
|
||||
#include "../src/mem.h"
|
||||
#include "utilvfs.h"
|
||||
|
||||
#include "vfs.h"
|
||||
#include "tcputil.h"
|
||||
#include "../src/util.h"
|
||||
#include "../src/dialog.h"
|
||||
#include "container.h"
|
||||
#include "ftpfs.h"
|
||||
@ -251,7 +246,7 @@ command (struct connection *bucket, int wait_reply, char *fmt, ...)
|
||||
got_sigpipe = 0;
|
||||
enable_interrupt_key ();
|
||||
status = write (sock, str, strlen (str));
|
||||
free (str);
|
||||
g_free (str);
|
||||
|
||||
if (status < 0){
|
||||
code = 421;
|
||||
@ -315,11 +310,11 @@ login_server (struct connection *bucket, char *netrcpass)
|
||||
|
||||
bucket->isbinary = TYPE_UNKNOWN;
|
||||
if (netrcpass)
|
||||
op = strdup (netrcpass);
|
||||
op = g_strdup (netrcpass);
|
||||
else {
|
||||
if (!strcmp (quser (bucket), "anonymous") ||
|
||||
!strcmp (quser (bucket), "ftp")) {
|
||||
op = strdup (ftpfs_anonymous_passwd);
|
||||
op = g_strdup (ftpfs_anonymous_passwd);
|
||||
anon = 1;
|
||||
} else {
|
||||
char *p;
|
||||
@ -328,19 +323,19 @@ login_server (struct connection *bucket, char *netrcpass)
|
||||
p = copy_strings (" FTP: Password required for ", quser (bucket),
|
||||
" ", NULL);
|
||||
op = vfs_get_password (p);
|
||||
free (p);
|
||||
g_free (p);
|
||||
if (op == NULL)
|
||||
ERRNOR (EPERM, 0);
|
||||
bucket->password = strdup (op);
|
||||
bucket->password = g_strdup (op);
|
||||
} else
|
||||
op = strdup (bucket->password);
|
||||
op = g_strdup (bucket->password);
|
||||
}
|
||||
}
|
||||
|
||||
if (!anon || logfile)
|
||||
pass = strdup (op);
|
||||
pass = g_strdup (op);
|
||||
else
|
||||
pass = copy_strings ("-", op, 0);
|
||||
pass = copy_strings ("-", op, NULL);
|
||||
wipe_password (op);
|
||||
|
||||
|
||||
@ -352,27 +347,27 @@ login_server (struct connection *bucket, char *netrcpass)
|
||||
p = my_get_host_and_username (ftpfs_proxy_host, &host, &proxyname,
|
||||
&port, &proxypass);
|
||||
if (p)
|
||||
free (p);
|
||||
g_free (p);
|
||||
|
||||
free (host);
|
||||
g_free (host);
|
||||
if (proxypass)
|
||||
wipe_password (proxypass);
|
||||
p = copy_strings (" Proxy: Password required for ", proxyname, " ",
|
||||
NULL);
|
||||
proxypass = vfs_get_password (p);
|
||||
free (p);
|
||||
g_free (p);
|
||||
if (proxypass == NULL) {
|
||||
wipe_password (pass);
|
||||
free (proxyname);
|
||||
g_free (proxyname);
|
||||
ERRNOR (EPERM, 0);
|
||||
}
|
||||
name = strdup (quser (bucket));
|
||||
name = g_strdup (quser (bucket));
|
||||
#else
|
||||
name = copy_strings (quser (bucket), "@",
|
||||
qhost (bucket)[0] == '!' ? qhost (bucket)+1 : qhost (bucket), 0);
|
||||
qhost (bucket)[0] == '!' ? qhost (bucket)+1 : qhost (bucket), NULL);
|
||||
#endif
|
||||
} else
|
||||
name = strdup (quser (bucket));
|
||||
name = g_strdup (quser (bucket));
|
||||
|
||||
if (get_reply (qsock (bucket), NULL, 0) == COMPLETE) {
|
||||
#if defined(HSC_PROXY)
|
||||
@ -397,13 +392,13 @@ login_server (struct connection *bucket, char *netrcpass)
|
||||
if (proxypass)
|
||||
wipe_password (proxypass);
|
||||
wipe_password (pass);
|
||||
free (proxyname);
|
||||
free (name);
|
||||
g_free (proxyname);
|
||||
g_free (name);
|
||||
ERRNOR (EPERM, 0);
|
||||
}
|
||||
if (proxypass)
|
||||
wipe_password (proxypass);
|
||||
free (proxyname);
|
||||
g_free (proxyname);
|
||||
}
|
||||
#endif
|
||||
print_vfs_message ("ftpfs: sending login name");
|
||||
@ -418,7 +413,7 @@ login_server (struct connection *bucket, char *netrcpass)
|
||||
case COMPLETE:
|
||||
print_vfs_message ("ftpfs: logged in");
|
||||
wipe_password (pass);
|
||||
free (name);
|
||||
g_free (name);
|
||||
return 1;
|
||||
|
||||
default:
|
||||
@ -434,7 +429,7 @@ login_server (struct connection *bucket, char *netrcpass)
|
||||
print_vfs_message ("ftpfs: Login incorrect for user %s ", quser (bucket));
|
||||
login_fail:
|
||||
wipe_password (pass);
|
||||
free (name);
|
||||
g_free (name);
|
||||
ERRNOR (EPERM, 0);
|
||||
}
|
||||
|
||||
@ -478,12 +473,11 @@ static void
|
||||
load_no_proxy_list ()
|
||||
{
|
||||
/* FixMe: shouldn't be hardcoded!!! */
|
||||
char s[258]; /* provide for 256 characters and nl */
|
||||
char s[BUF_LARGE]; /* provide for BUF_LARGE characters */
|
||||
struct no_proxy_entry *np, *current = 0;
|
||||
FILE *npf;
|
||||
int c;
|
||||
char *p;
|
||||
char *mc_file;
|
||||
char *p, *mc_file;
|
||||
static int loaded;
|
||||
|
||||
if (loaded)
|
||||
@ -492,9 +486,9 @@ load_no_proxy_list ()
|
||||
mc_file = concat_dir_and_file (mc_home, "mc.no_proxy");
|
||||
if (exist_file (mc_file) &&
|
||||
(npf = fopen (mc_file, "r"))) {
|
||||
while (fgets (s, 258, npf) || !(feof (npf) || ferror (npf))) {
|
||||
while (fgets (s, sizeof(s), npf) || !(feof (npf) || ferror (npf))) {
|
||||
if (!(p = strchr (s, '\n'))) { /* skip bogus entries */
|
||||
while ((c = getc (npf)) != EOF && c != '\n')
|
||||
while ((c = fgetc (npf)) != EOF && c != '\n')
|
||||
;
|
||||
continue;
|
||||
}
|
||||
@ -502,12 +496,11 @@ load_no_proxy_list ()
|
||||
if (p == s)
|
||||
continue;
|
||||
|
||||
*p = '\0';
|
||||
p = xmalloc (strlen (s), "load_no_proxy_list:1");
|
||||
np = xmalloc (sizeof (*np), "load_no_proxy_list:2");
|
||||
strcpy (p, s);
|
||||
np->domain = p;
|
||||
np->next = 0;
|
||||
*p = NULL;
|
||||
|
||||
np = g_new (struct no_proxy_entry, 1);
|
||||
np->domain = g_strdup (s);
|
||||
np->next = NULL;
|
||||
if (no_proxy)
|
||||
current->next = np;
|
||||
else
|
||||
@ -518,7 +511,7 @@ load_no_proxy_list ()
|
||||
fclose (npf);
|
||||
loaded = 1;
|
||||
}
|
||||
free (mc_file);
|
||||
g_free (mc_file);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -554,7 +547,7 @@ ftpfs_check_proxy (char *host)
|
||||
if (!ld)
|
||||
return 0;
|
||||
} else
|
||||
if (!strcasecmp (host, domain))
|
||||
if (!g_strcasecmp (host, domain))
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -573,11 +566,11 @@ ftpfs_get_proxy_host_and_port (char *proxy, char **host, int *port)
|
||||
#endif
|
||||
dir = vfs_split_url (proxy, host, &user, port, &pass, PORT, URL_DEFAULTANON);
|
||||
|
||||
free (user);
|
||||
g_free (user);
|
||||
if (pass)
|
||||
wipe_password (pass);
|
||||
if (dir)
|
||||
free (dir);
|
||||
g_free (dir);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -617,7 +610,7 @@ ftpfs_open_socket (struct connection *bucket)
|
||||
print_vfs_message ("ftpfs: Invalid host address.");
|
||||
my_errno = EINVAL;
|
||||
if (free_host)
|
||||
free (host);
|
||||
g_free (host);
|
||||
return -1;
|
||||
}
|
||||
server_address.sin_family = hp->h_addrtype;
|
||||
@ -634,14 +627,14 @@ ftpfs_open_socket (struct connection *bucket)
|
||||
if ((my_socket = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||
my_errno = errno;
|
||||
if (free_host)
|
||||
free (host);
|
||||
g_free (host);
|
||||
return -1;
|
||||
}
|
||||
setup_source_route (my_socket, server_address.sin_addr.s_addr);
|
||||
|
||||
print_vfs_message ("ftpfs: making connection to %s", host);
|
||||
if (free_host)
|
||||
free (host);
|
||||
g_free (host);
|
||||
|
||||
enable_interrupt_key (); /* clear the interrupt flag */
|
||||
|
||||
@ -667,8 +660,7 @@ open_command_connection (char *host, char *user, int port, char *netrcpass)
|
||||
struct connection *bucket;
|
||||
int retry_seconds, count_down;
|
||||
|
||||
bucket = xmalloc(sizeof(struct connection),
|
||||
"struct connection");
|
||||
bucket = g_new (struct connection, 1);
|
||||
|
||||
if (bucket == NULL)
|
||||
ERRNOR (ENOMEM, NULL);
|
||||
@ -680,8 +672,8 @@ open_command_connection (char *host, char *user, int port, char *netrcpass)
|
||||
watch_free_pointer = host;
|
||||
}
|
||||
#endif
|
||||
qhost (bucket) = strdup (host);
|
||||
quser (bucket) = strdup (user);
|
||||
qhost (bucket) = g_strdup (host);
|
||||
quser (bucket) = g_strdup (user);
|
||||
qcdir (bucket) = NULL;
|
||||
qport (bucket) = port;
|
||||
qlock (bucket) = 0;
|
||||
@ -704,9 +696,9 @@ open_command_connection (char *host, char *user, int port, char *netrcpass)
|
||||
|
||||
if ((qdcache (bucket) = linklist_init ()) == NULL) {
|
||||
my_errno = ENOMEM;
|
||||
free (qhost (bucket));
|
||||
free (quser (bucket));
|
||||
free (bucket);
|
||||
g_free (qhost (bucket));
|
||||
g_free (quser (bucket));
|
||||
g_free (bucket);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -751,8 +743,8 @@ open_command_connection (char *host, char *user, int port, char *netrcpass)
|
||||
|
||||
qhome (bucket) = ftpfs_get_current_directory (bucket);
|
||||
if (!qhome (bucket))
|
||||
qhome (bucket) = strdup ("/");
|
||||
qupdir (bucket) = strdup ("/"); /* FIXME: I changed behavior to ignore last_current_dir */
|
||||
qhome (bucket) = g_strdup (PATH_SEP_STR);
|
||||
qupdir (bucket) = g_strdup (PATH_SEP_STR); /* FIXME: I changed behavior to ignore last_current_dir */
|
||||
return bucket;
|
||||
}
|
||||
|
||||
@ -851,7 +843,7 @@ ftpfs_get_current_directory (struct connection *bucket)
|
||||
*bufq++ = '/';
|
||||
*bufq = 0;
|
||||
}
|
||||
return strdup (bufp);
|
||||
return g_strdup (bufp);
|
||||
} else ERRNOR (EIO, NULL);
|
||||
}
|
||||
}
|
||||
@ -1064,8 +1056,7 @@ resolve_symlink_without_ls_options(struct connection *bucket, struct dir *dir)
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
fel->l_stat = xmalloc(sizeof(struct stat),
|
||||
"resolve_symlink: struct stat");
|
||||
fel->l_stat = g_new (struct stat, 1);
|
||||
if ( S_ISLNK (fe->s.st_mode))
|
||||
*fel->l_stat = *fe->l_stat;
|
||||
else
|
||||
@ -1131,10 +1122,9 @@ resolve_symlink_with_ls_options(struct connection *bucket, struct dir *dir)
|
||||
}
|
||||
if (vfs_parse_ls_lga (buffer, &s, &filename, NULL)) {
|
||||
int r = strcmp(fe->name, filename);
|
||||
free(filename);
|
||||
g_free(filename);
|
||||
if (r == 0) {
|
||||
fe->l_stat = xmalloc(sizeof(struct stat),
|
||||
"resolve_symlink: struct stat");
|
||||
fe->l_stat = g_new (struct stat, 1);
|
||||
if (fe->l_stat == NULL)
|
||||
goto done;
|
||||
*fe->l_stat = s;
|
||||
@ -1213,7 +1203,7 @@ retrieve_dir(struct connection *bucket, char *remote_path, int resolve_symlinks)
|
||||
p->next->prev = p->prev;
|
||||
p->prev->next = p->next;
|
||||
dir_destructor(dcache);
|
||||
free (p);
|
||||
g_free (p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1234,8 +1224,7 @@ retrieve_dir(struct connection *bucket, char *remote_path, int resolve_symlinks)
|
||||
file_list = linklist_init();
|
||||
if (file_list == NULL)
|
||||
ERRNOR (ENOMEM, NULL);
|
||||
dcache = xmalloc(sizeof(struct dir),
|
||||
"struct dir");
|
||||
dcache = g_new (struct dir, 1);
|
||||
if (dcache == NULL) {
|
||||
my_errno = ENOMEM;
|
||||
linklist_destroy(file_list, NULL);
|
||||
@ -1245,7 +1234,7 @@ retrieve_dir(struct connection *bucket, char *remote_path, int resolve_symlinks)
|
||||
gettimeofday(&dcache->timestamp, NULL);
|
||||
dcache->timestamp.tv_sec += ftpfs_directory_timeout;
|
||||
dcache->file_list = file_list;
|
||||
dcache->remote_path = strdup(remote_path);
|
||||
dcache->remote_path = g_strdup(remote_path);
|
||||
dcache->count = 1;
|
||||
dcache->symlink_status = FTPFS_NO_SYMLINKS;
|
||||
|
||||
@ -1254,9 +1243,9 @@ retrieve_dir(struct connection *bucket, char *remote_path, int resolve_symlinks)
|
||||
else if (has_spaces)
|
||||
sock = open_data_connection (bucket, "LIST -la", ".", TYPE_ASCII, 0);
|
||||
else {
|
||||
char *path = copy_strings (remote_path, PATH_SEP_STR, ".", (char *) 0);
|
||||
char *path = copy_strings (remote_path, PATH_SEP_STR, ".", NULL);
|
||||
sock = open_data_connection (bucket, "LIST -la", path, TYPE_ASCII, 0);
|
||||
free (path);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
if (sock == -1)
|
||||
@ -1294,7 +1283,7 @@ retrieve_dir(struct connection *bucket, char *remote_path, int resolve_symlinks)
|
||||
}
|
||||
if (buffer [0] == 0 && eof)
|
||||
break;
|
||||
fe = xmalloc(sizeof(struct direntry), "struct direntry");
|
||||
fe = g_new (struct direntry, 1);
|
||||
fe->freshly_created = 0;
|
||||
fe->local_filename = NULL;
|
||||
if (fe == NULL) {
|
||||
@ -1311,13 +1300,13 @@ retrieve_dir(struct connection *bucket, char *remote_path, int resolve_symlinks)
|
||||
has_symlinks = 1;
|
||||
|
||||
if (!linklist_insert(file_list, fe)) {
|
||||
free(fe);
|
||||
g_free(fe);
|
||||
my_errno = ENOMEM;
|
||||
goto error_1;
|
||||
}
|
||||
}
|
||||
else
|
||||
free(fe);
|
||||
g_free(fe);
|
||||
if (eof)
|
||||
break;
|
||||
}
|
||||
@ -1357,8 +1346,8 @@ error_2:
|
||||
#endif
|
||||
get_reply(qsock(bucket), NULL, 0);
|
||||
error_3:
|
||||
free(dcache->remote_path);
|
||||
free(dcache);
|
||||
g_free(dcache->remote_path);
|
||||
g_free(dcache);
|
||||
linklist_destroy(file_list, direntry_destructor);
|
||||
print_vfs_message("ftpfs: failed");
|
||||
return NULL;
|
||||
@ -1368,14 +1357,14 @@ fallback:
|
||||
/* It's our first attempt to get a directory listing from this
|
||||
server (UNIX style LIST command) */
|
||||
bucket->strict_rfc959_list_cmd = 1;
|
||||
free(dcache->remote_path);
|
||||
free(dcache);
|
||||
g_free(dcache->remote_path);
|
||||
g_free(dcache);
|
||||
linklist_destroy(file_list, direntry_destructor);
|
||||
return retrieve_dir (bucket, remote_path, resolve_symlinks);
|
||||
}
|
||||
my_errno = EACCES;
|
||||
free(dcache->remote_path);
|
||||
free(dcache);
|
||||
g_free(dcache->remote_path);
|
||||
g_free(dcache);
|
||||
linklist_destroy(file_list, direntry_destructor);
|
||||
print_vfs_message("ftpfs: failed; nowhere to fallback to");
|
||||
return NULL;
|
||||
@ -1541,7 +1530,7 @@ send_ftp_command(char *filename, char *cmd, int flags)
|
||||
if (!(remote_path = get_path(&bucket, filename)))
|
||||
return -1;
|
||||
r = command (bucket, WAIT_REPLY, cmd, remote_path);
|
||||
free(remote_path);
|
||||
g_free(remote_path);
|
||||
vfs_add_noncurrent_stamps (&vfs_ftpfs_ops, (vfsid) bucket, NULL);
|
||||
if (flags & OPT_IGNORE_ERROR)
|
||||
r = COMPLETE;
|
||||
@ -1587,9 +1576,9 @@ ftpfs_init (vfs *me)
|
||||
|
||||
static int ftpfs_chmod (vfs *me, char *path, int mode)
|
||||
{
|
||||
char buf[40];
|
||||
char buf[BUF_SMALL];
|
||||
|
||||
sprintf(buf, "SITE CHMOD %4.4o %%s", mode & 07777);
|
||||
g_snprintf(buf, sizeof(buf), "SITE CHMOD %4.4o %%s", mode & 07777);
|
||||
return send_ftp_command(path, buf, OPT_IGNORE_ERROR | OPT_FLUSH);
|
||||
}
|
||||
|
||||
@ -1634,8 +1623,8 @@ ftpfs_chdir_internal (struct connection *bucket ,char *remote_path)
|
||||
my_errno = EIO;
|
||||
} else {
|
||||
if (qcdir(bucket))
|
||||
free(qcdir(bucket));
|
||||
qcdir(bucket) = strdup (remote_path);
|
||||
g_free(qcdir(bucket));
|
||||
qcdir(bucket) = g_strdup (remote_path);
|
||||
bucket->cwd_defered = 0;
|
||||
}
|
||||
return r;
|
||||
@ -1678,15 +1667,15 @@ static void my_forget (char *file)
|
||||
|
||||
file += 6;
|
||||
if (!(rp = my_get_host_and_username (file, &host, &user, &port, &pass))) {
|
||||
free (host);
|
||||
free (user);
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
if (pass)
|
||||
wipe_password (pass);
|
||||
return;
|
||||
}
|
||||
|
||||
/* we do not care about the path actually */
|
||||
free (rp);
|
||||
g_free (rp);
|
||||
|
||||
for (l = connections_list->next; l != connections_list; l = l->next){
|
||||
struct connection *bucket = l->data;
|
||||
@ -1706,8 +1695,8 @@ static void my_forget (char *file)
|
||||
break;
|
||||
}
|
||||
}
|
||||
free (host);
|
||||
free (user);
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
if (pass)
|
||||
wipe_password (pass);
|
||||
}
|
||||
@ -1770,7 +1759,7 @@ MMAPNULL
|
||||
};
|
||||
|
||||
#ifdef USE_NETRC
|
||||
static char buffer[100];
|
||||
static char buffer[BUF_MEDIUM];
|
||||
static char *netrc, *netrcp;
|
||||
|
||||
static int netrc_next (void)
|
||||
@ -1830,17 +1819,15 @@ int lookup_netrc (char *host, char **login, char **pass)
|
||||
for (rupp = rup_cache; rupp != NULL; rupp = rupp->next)
|
||||
if (!strcmp (host, rupp->host)) {
|
||||
if (rupp->login != NULL)
|
||||
*login = strdup (rupp->login);
|
||||
*login = g_strdup (rupp->login);
|
||||
if (rupp->pass != NULL)
|
||||
*pass = strdup (rupp->pass);
|
||||
*pass = g_strdup (rupp->pass);
|
||||
return 0;
|
||||
}
|
||||
netrcname = xmalloc (strlen (home_dir) + strlen ("/.netrc") + 1, "netrc");
|
||||
strcpy (netrcname, home_dir);
|
||||
strcat (netrcname, "/.netrc");
|
||||
netrcname = concat_dir_and_file (home_dir, ".netrc");
|
||||
netrcp = netrc = load_file (netrcname);
|
||||
if (netrc == NULL) {
|
||||
free (netrcname);
|
||||
g_free (netrcname);
|
||||
return 0;
|
||||
}
|
||||
if (gethostname (hostname, sizeof (hostname)) < 0)
|
||||
@ -1852,10 +1839,10 @@ int lookup_netrc (char *host, char **login, char **pass)
|
||||
if (keyword == 2) {
|
||||
if (netrc_next () != 8)
|
||||
continue;
|
||||
if (strcasecmp (host, buffer) &&
|
||||
if (g_strcasecmp (host, buffer) &&
|
||||
((tmp = strchr (host, '.')) == NULL ||
|
||||
strcasecmp (tmp, domain) ||
|
||||
strncasecmp (host, buffer, tmp - host) ||
|
||||
g_strcasecmp (tmp, domain) ||
|
||||
g_strncasecmp (host, buffer, tmp - host) ||
|
||||
buffer [tmp - host]))
|
||||
continue;
|
||||
} else if (keyword != 1)
|
||||
@ -1865,7 +1852,7 @@ int lookup_netrc (char *host, char **login, char **pass)
|
||||
case 3:
|
||||
if (netrc_next ())
|
||||
if (*login == NULL)
|
||||
*login = strdup (buffer);
|
||||
*login = g_strdup (buffer);
|
||||
else if (strcmp (*login, buffer))
|
||||
keyword = 20;
|
||||
break;
|
||||
@ -1879,12 +1866,12 @@ int lookup_netrc (char *host, char **login, char **pass)
|
||||
"Remove password or correct mode."));
|
||||
be_angry = 0;
|
||||
}
|
||||
free (netrc);
|
||||
free (netrcname);
|
||||
g_free (netrc);
|
||||
g_free (netrcname);
|
||||
return -1;
|
||||
}
|
||||
if (netrc_next () && *pass == NULL)
|
||||
*pass = strdup (buffer);
|
||||
*pass = g_strdup (buffer);
|
||||
break;
|
||||
case 6:
|
||||
if (stat (netrcname, &mystat) >= 0 &&
|
||||
@ -1894,8 +1881,8 @@ int lookup_netrc (char *host, char **login, char **pass)
|
||||
"Remove password or correct mode."));
|
||||
be_angry = 0;
|
||||
}
|
||||
free (netrc);
|
||||
free (netrcname);
|
||||
g_free (netrc);
|
||||
g_free (netrcname);
|
||||
return -1;
|
||||
}
|
||||
netrc_next ();
|
||||
@ -1919,35 +1906,20 @@ int lookup_netrc (char *host, char **login, char **pass)
|
||||
else
|
||||
break;
|
||||
}
|
||||
rupp = (struct rupcache *) xmalloc (sizeof (struct rupcache), "");
|
||||
rupp->host = strdup (host);
|
||||
rupp = g_new (struct rupcache, 1);
|
||||
rupp->host = g_strdup (host);
|
||||
rupp->login = rupp->pass = 0;
|
||||
|
||||
if (*login != NULL)
|
||||
rupp->login = strdup (*login);
|
||||
rupp->login = g_strdup (*login);
|
||||
if (*pass != NULL)
|
||||
rupp->pass = strdup (*pass);
|
||||
rupp->pass = g_strdup (*pass);
|
||||
rupp->next = rup_cache;
|
||||
rup_cache = rupp;
|
||||
|
||||
free (netrc);
|
||||
free (netrcname);
|
||||
g_free (netrc);
|
||||
g_free (netrcname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef HAVE_STRNCASECMP
|
||||
int strncasecmp (char *s, char *d, int l)
|
||||
{
|
||||
int result;
|
||||
|
||||
while (l--){
|
||||
if (result = (0x20 | *s) - (0x20 | *d))
|
||||
break;
|
||||
if (!*s)
|
||||
return 0;
|
||||
s++;
|
||||
d++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* USE_NETRC */
|
||||
|
16
vfs/local.c
16
vfs/local.c
@ -1,15 +1,13 @@
|
||||
#include <config.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <malloc.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "../src/mad.h"
|
||||
#include "../src/fs.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include "../src/util.h"
|
||||
|
||||
#include "utilvfs.h"
|
||||
|
||||
#include "vfs.h"
|
||||
#include "local.h"
|
||||
@ -29,7 +27,7 @@ local_open (vfs *me, char *file, int flags, int mode)
|
||||
if (fd == -1)
|
||||
return 0;
|
||||
|
||||
local_info = (int *) xmalloc (sizeof (int), "Local fs");
|
||||
local_info = g_new (int, 1);
|
||||
*local_info = fd;
|
||||
|
||||
return local_info;
|
||||
@ -64,7 +62,7 @@ local_close (void *data)
|
||||
return -1;
|
||||
|
||||
fd = *(int *) data;
|
||||
free (data);
|
||||
g_free (data);
|
||||
return close (fd);
|
||||
}
|
||||
|
||||
@ -84,7 +82,7 @@ local_opendir (vfs *me, char *dirname)
|
||||
if (!dir)
|
||||
return 0;
|
||||
|
||||
local_info = (DIR **) xmalloc (sizeof (DIR *), "Local fs");
|
||||
local_info = (DIR **) g_new (DIR *, 1);
|
||||
*local_info = dir;
|
||||
|
||||
return local_info;
|
||||
@ -115,7 +113,7 @@ local_closedir (void *data)
|
||||
|
||||
i = closedir (* (DIR **) data);
|
||||
if (data)
|
||||
free (data);
|
||||
g_free (data);
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -264,7 +262,7 @@ local_free (vfsid id)
|
||||
static char *
|
||||
local_getlocalcopy (vfs *me, char *path)
|
||||
{
|
||||
return strdup (path);
|
||||
return g_strdup (path);
|
||||
}
|
||||
|
||||
static void
|
||||
|
103
vfs/mcfs.c
103
vfs/mcfs.c
@ -31,8 +31,6 @@
|
||||
#include <stdarg.h>
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
#include "../src/fs.h"
|
||||
#include "../src/mad.h"
|
||||
#include <netdb.h> /* struct hostent */
|
||||
#include <sys/socket.h> /* AF_INET */
|
||||
#include <netinet/in.h> /* struct in_addr */
|
||||
@ -46,11 +44,11 @@
|
||||
#include <termnet.h>
|
||||
#endif
|
||||
|
||||
#include "../src/mem.h"
|
||||
#include "utilvfs.h"
|
||||
|
||||
#include "vfs.h"
|
||||
#include "mcfs.h"
|
||||
#include "tcputil.h"
|
||||
#include "../src/util.h"
|
||||
#include "../src/dialog.h"
|
||||
|
||||
#define MCFS_MAX_CONNECTIONS 32
|
||||
@ -91,17 +89,17 @@ static void mcfs_fill_names (vfs *me, void (*func)(char *))
|
||||
if (mcfs_connections [i].host == 0)
|
||||
continue;
|
||||
name = copy_strings ("/#mc:", mcfs_connections [i].user,
|
||||
"@", mcfs_connections [i].host, 0);
|
||||
"@", mcfs_connections [i].host, NULL);
|
||||
(*func) (name);
|
||||
free (name);
|
||||
g_free (name);
|
||||
}
|
||||
}
|
||||
|
||||
static void mcfs_free_bucket (int bucket)
|
||||
{
|
||||
free (mcfs_connections [bucket].host);
|
||||
free (mcfs_connections [bucket].user);
|
||||
free (mcfs_connections [bucket].home);
|
||||
g_free (mcfs_connections [bucket].host);
|
||||
g_free (mcfs_connections [bucket].user);
|
||||
g_free (mcfs_connections [bucket].home);
|
||||
|
||||
/* Set all the fields to zero */
|
||||
mcfs_connections [bucket].host =
|
||||
@ -184,7 +182,7 @@ static int mcfs_login_server (int my_socket, char *user, int port,
|
||||
}
|
||||
}
|
||||
if (netrcpass != NULL)
|
||||
pass = strdup (netrcpass);
|
||||
pass = g_strdup (netrcpass);
|
||||
else
|
||||
pass = vfs_get_password (_(" MCFS Password required "));
|
||||
if (!pass){
|
||||
@ -329,8 +327,8 @@ static mcfs_connection *mcfs_open_link (char *host, char *user, int *port, char
|
||||
|
||||
bucket = mcfs_get_free_bucket ();
|
||||
mcfs_open_connections++;
|
||||
bucket->host = strdup (host);
|
||||
bucket->user = strdup (user);
|
||||
bucket->host = g_strdup (host);
|
||||
bucket->user = g_strdup (user);
|
||||
bucket->home = 0;
|
||||
bucket->port = *port;
|
||||
bucket->sock = sock;
|
||||
@ -374,11 +372,11 @@ static char *mcfs_get_path (mcfs_connection **mc, char *path)
|
||||
port = 0;
|
||||
if ((remote_path = mcfs_get_host_and_username(path, &host, &user, &port, &pass)))
|
||||
if (!(*mc = mcfs_open_link (host, user, &port, pass))){
|
||||
free (remote_path);
|
||||
g_free (remote_path);
|
||||
remote_path = NULL;
|
||||
}
|
||||
free (host);
|
||||
free (user);
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
if (pass)
|
||||
wipe_password (pass);
|
||||
|
||||
@ -391,7 +389,7 @@ static char *mcfs_get_path (mcfs_connection **mc, char *path)
|
||||
if (f || !strncmp( remote_path, "/~/", 3 )) {
|
||||
char *s;
|
||||
s = concat_dir_and_file( mcfs_gethome (*mc), remote_path +3-f );
|
||||
free (remote_path);
|
||||
g_free (remote_path);
|
||||
remote_path = s;
|
||||
}
|
||||
}
|
||||
@ -423,7 +421,7 @@ static int mcfs_rpc_two_paths (int command, char *s1, char *s2)
|
||||
return -1;
|
||||
|
||||
if ((r2 = mcfs_get_path (&mc, s2)) == 0){
|
||||
free (r1);
|
||||
g_free (r1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -432,8 +430,8 @@ static int mcfs_rpc_two_paths (int command, char *s1, char *s2)
|
||||
RPC_STRING, r1,
|
||||
RPC_STRING, r2,
|
||||
RPC_END);
|
||||
free (r1);
|
||||
free (r2);
|
||||
g_free (r1);
|
||||
g_free (r2);
|
||||
return mcfs_handle_simple_error (mc->sock, 0);
|
||||
}
|
||||
|
||||
@ -450,7 +448,7 @@ static int mcfs_rpc_path (int command, char *path)
|
||||
RPC_STRING, remote_file,
|
||||
RPC_END);
|
||||
|
||||
free (remote_file);
|
||||
g_free (remote_file);
|
||||
return mcfs_handle_simple_error (mc->sock, 0);
|
||||
}
|
||||
|
||||
@ -467,7 +465,7 @@ static int mcfs_rpc_path_int (int command, char *path, int data)
|
||||
RPC_STRING, remote_file,
|
||||
RPC_INT, data, RPC_END);
|
||||
|
||||
free (remote_file);
|
||||
g_free (remote_file);
|
||||
return mcfs_handle_simple_error (mc->sock, 0);
|
||||
}
|
||||
|
||||
@ -486,7 +484,7 @@ static int mcfs_rpc_path_int_int (int command, char *path, int n1, int n2)
|
||||
RPC_INT, n2,
|
||||
RPC_END);
|
||||
|
||||
free (remote_file);
|
||||
g_free (remote_file);
|
||||
return mcfs_handle_simple_error (mc->sock, 0);
|
||||
}
|
||||
|
||||
@ -495,13 +493,13 @@ static char *mcfs_gethome (mcfs_connection *mc)
|
||||
char *buffer;
|
||||
|
||||
if (mc->home)
|
||||
return strdup (mc->home);
|
||||
return g_strdup (mc->home);
|
||||
else {
|
||||
rpc_send (mc->sock, RPC_INT, MC_GETHOME, RPC_END);
|
||||
if (0 == rpc_get (mc->sock, RPC_STRING, &buffer, RPC_END))
|
||||
return strdup ("/");
|
||||
return g_strdup (PATH_SEP_STR);
|
||||
mc->home = buffer;
|
||||
return strdup (buffer);
|
||||
return g_strdup (buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -518,7 +516,7 @@ static void *mcfs_open (vfs *me, char *file, int flags, int mode)
|
||||
|
||||
rpc_send (mc->sock, RPC_INT, MC_OPEN, RPC_STRING, remote_file,
|
||||
RPC_INT, flags, RPC_INT, mode, RPC_END);
|
||||
free (remote_file);
|
||||
g_free (remote_file);
|
||||
|
||||
if (0 == rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END))
|
||||
return 0;
|
||||
@ -526,7 +524,7 @@ static void *mcfs_open (vfs *me, char *file, int flags, int mode)
|
||||
if (is_error (result, error_num))
|
||||
return 0;
|
||||
|
||||
remote_handle = (mcfs_handle *) xmalloc (2 * sizeof (mcfs_handle), "mcfs_handle");
|
||||
remote_handle = g_new (mcfs_handle, 2);
|
||||
remote_handle->handle = result;
|
||||
remote_handle->conn = mc;
|
||||
|
||||
@ -596,7 +594,7 @@ static int mcfs_close (void *data)
|
||||
|
||||
is_error (result, error);
|
||||
|
||||
free (data);
|
||||
g_free (data);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -631,7 +629,7 @@ static void *mcfs_opendir (vfs *me, char *dirname)
|
||||
return 0;
|
||||
|
||||
rpc_send (mc->sock, RPC_INT, MC_OPENDIR, RPC_STRING, remote_dir, RPC_END);
|
||||
free (remote_dir);
|
||||
g_free (remote_dir);
|
||||
|
||||
if (0 == rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END))
|
||||
return 0;
|
||||
@ -641,7 +639,7 @@ static void *mcfs_opendir (vfs *me, char *dirname)
|
||||
|
||||
handle = result;
|
||||
|
||||
mcfs_info = (opendir_info *) xmalloc (sizeof(opendir_info),"mcfs_opendir");
|
||||
mcfs_info = g_new (opendir_info, 1);
|
||||
mcfs_info->conn = mc;
|
||||
mcfs_info->handle = handle;
|
||||
mcfs_info->entries = 0;
|
||||
@ -671,9 +669,8 @@ static int mcfs_loaddir (opendir_info *mcfs_info)
|
||||
if (entry_len == 0)
|
||||
break;
|
||||
|
||||
new_entry = xmalloc (sizeof (dir_entry), "mcfs_loaddir");
|
||||
new_entry->text = xmalloc (entry_len + 1, "mcfs_loaddir");
|
||||
new_entry->text [entry_len] = 0;
|
||||
new_entry = g_new (dir_entry, 1);
|
||||
new_entry->text = g_new0 (char, entry_len + 1);
|
||||
|
||||
new_entry->next = 0;
|
||||
if (first){
|
||||
@ -710,8 +707,8 @@ static void mcfs_free_dir (dir_entry *de)
|
||||
if (!de)
|
||||
return;
|
||||
mcfs_free_dir (de->next);
|
||||
free (de->text);
|
||||
free (de);
|
||||
g_free (de->text);
|
||||
g_free (de);
|
||||
}
|
||||
|
||||
/* Explanation:
|
||||
@ -770,10 +767,10 @@ static int mcfs_closedir (void *info)
|
||||
for (p = mcfs_info->entries; p;){
|
||||
q = p;
|
||||
p = p->next;
|
||||
free (q->text);
|
||||
free (q);
|
||||
g_free (q->text);
|
||||
g_free (q);
|
||||
}
|
||||
free (info);
|
||||
g_free (info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -804,7 +801,7 @@ static time_t mcfs_get_time (mcfs_connection *mc)
|
||||
RPC_STRING, &buf,
|
||||
RPC_END);
|
||||
sscanf (buf, "%lx", &tm);
|
||||
free (buf);
|
||||
g_free (buf);
|
||||
|
||||
return (time_t) tm;
|
||||
}
|
||||
@ -855,7 +852,7 @@ static int mcfs_stat_cmd (int cmd, char *path, struct stat *buf)
|
||||
return -1;
|
||||
|
||||
rpc_send (mc->sock, RPC_INT, cmd, RPC_STRING, remote_file, RPC_END);
|
||||
free (remote_file);
|
||||
g_free (remote_file);
|
||||
if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END))
|
||||
return the_error (-1, errno);
|
||||
|
||||
@ -931,15 +928,15 @@ static int mcfs_utime (vfs *me, char *path, struct utimbuf *times)
|
||||
|
||||
status = 0;
|
||||
if (mc->version >= 2) {
|
||||
char abuf[2*sizeof(long) + 1];
|
||||
char mbuf[2*sizeof(long) + 1];
|
||||
char abuf[BUF_SMALL];
|
||||
char mbuf[BUF_SMALL];
|
||||
long atime, mtime;
|
||||
|
||||
atime = (long) times->actime;
|
||||
mtime = (long) times->modtime;
|
||||
|
||||
sprintf (abuf, "%lx", atime);
|
||||
sprintf (mbuf, "%lx", mtime);
|
||||
g_snprintf (abuf, sizeof(abuf), "%lx", atime);
|
||||
g_snprintf (mbuf, sizeof(mbuf), "%lx", mtime);
|
||||
|
||||
rpc_send (mc->sock, RPC_INT, MC_UTIME,
|
||||
RPC_STRING, file,
|
||||
@ -949,7 +946,7 @@ static int mcfs_utime (vfs *me, char *path, struct utimbuf *times)
|
||||
status = mcfs_handle_simple_error (mc->sock, 0);
|
||||
|
||||
}
|
||||
free (file);
|
||||
g_free (file);
|
||||
return (status);
|
||||
}
|
||||
|
||||
@ -963,7 +960,7 @@ static int mcfs_readlink (vfs *me, char *path, char *buf, int size)
|
||||
return -1;
|
||||
|
||||
rpc_send (mc->sock, RPC_INT, MC_READLINK, RPC_STRING, remote_file, RPC_END);
|
||||
free (remote_file);
|
||||
g_free (remote_file);
|
||||
if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END))
|
||||
return the_error (-1, EIO);
|
||||
|
||||
@ -974,7 +971,7 @@ static int mcfs_readlink (vfs *me, char *path, char *buf, int size)
|
||||
return the_error (-1, EIO);
|
||||
|
||||
strncpy (buf, stat_str, size);
|
||||
free (stat_str);
|
||||
g_free (stat_str);
|
||||
return strlen (buf);
|
||||
}
|
||||
|
||||
@ -1003,7 +1000,7 @@ static int mcfs_chdir (vfs *me, char *path)
|
||||
return -1;
|
||||
|
||||
rpc_send (mc->sock, RPC_INT, MC_CHDIR, RPC_STRING, remote_dir, RPC_END);
|
||||
free (remote_dir);
|
||||
g_free (remote_dir);
|
||||
if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END))
|
||||
return the_error (-1, EIO);
|
||||
|
||||
@ -1086,8 +1083,8 @@ my_forget (char *path)
|
||||
path += 2;
|
||||
|
||||
if ((p = mcfs_get_host_and_username (path, &host, &user, &port, &pass)) == 0) {
|
||||
free (host);
|
||||
free (user);
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
if (pass)
|
||||
wipe_password (pass);
|
||||
return;
|
||||
@ -1104,9 +1101,9 @@ my_forget (char *path)
|
||||
mcfs_connections [i].sock = mcfs_open_tcp_link (host, user, &port, pass, &vers);
|
||||
}
|
||||
}
|
||||
free (p);
|
||||
free (host);
|
||||
free (user);
|
||||
g_free (p);
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
if (pass)
|
||||
wipe_password (pass);
|
||||
}
|
||||
|
131
vfs/mcserv.c
131
vfs/mcserv.c
@ -93,8 +93,9 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "../src/fs.h"
|
||||
#include "../src/mem.h"
|
||||
#include "utilvfs.h"
|
||||
|
||||
#include "vfs.h"
|
||||
#include "mcfs.h"
|
||||
#include "tcputil.h"
|
||||
|
||||
@ -178,7 +179,7 @@ void do_open (void)
|
||||
|
||||
handle = open (arg, flags, mode);
|
||||
send_status (handle, errno);
|
||||
free (arg);
|
||||
g_free (arg);
|
||||
}
|
||||
|
||||
void do_read (void)
|
||||
@ -187,7 +188,7 @@ void do_read (void)
|
||||
void *data;
|
||||
|
||||
rpc_get (msock, RPC_INT, &handle, RPC_INT, &count, RPC_END);
|
||||
data = malloc (count);
|
||||
data = g_malloc (count);
|
||||
if (!data){
|
||||
send_status (-1, ENOMEM);
|
||||
return;
|
||||
@ -202,7 +203,7 @@ void do_read (void)
|
||||
send_status (n, 0);
|
||||
rpc_send (msock, RPC_BLOCK, n, data, RPC_END);
|
||||
|
||||
free (data);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
void do_write (void)
|
||||
@ -286,9 +287,9 @@ void send_time (int sock, time_t time)
|
||||
RPC_END);
|
||||
} else {
|
||||
long ltime = (long) time;
|
||||
char buf[2*sizeof(long) + 1];
|
||||
char buf[BUF_SMALL];
|
||||
|
||||
sprintf (buf, "%lx", ltime);
|
||||
g_snprintf (buf, sizeof(buf), "%lx", ltime);
|
||||
rpc_send (msock,
|
||||
RPC_STRING, buf,
|
||||
RPC_END);
|
||||
@ -330,7 +331,7 @@ void do_lstat ()
|
||||
send_status (n, errno);
|
||||
if (n >= 0)
|
||||
send_stat_info (&st);
|
||||
free (file);
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
void do_fstat (void)
|
||||
@ -360,7 +361,7 @@ void do_stat ()
|
||||
send_status (n, errno);
|
||||
if (n >= 0)
|
||||
send_stat_info (&st);
|
||||
free (file);
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
@ -379,7 +380,7 @@ void close_handle (int handle)
|
||||
if (mcfs_DIR.dirs [handle])
|
||||
closedir (mcfs_DIR.dirs [handle]);
|
||||
if (mcfs_DIR.names [handle])
|
||||
free (mcfs_DIR.names [handle]);
|
||||
g_free (mcfs_DIR.names [handle]);
|
||||
mcfs_DIR.dirs [handle] = 0;
|
||||
mcfs_DIR.names [handle] = 0;
|
||||
}
|
||||
@ -394,7 +395,7 @@ void do_opendir (void)
|
||||
|
||||
if (mcfs_DIR.used == OPENDIR_HANDLES){
|
||||
send_status (-1, ENFILE); /* Error */
|
||||
free (arg);
|
||||
g_free (arg);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -408,7 +409,7 @@ void do_opendir (void)
|
||||
|
||||
if (handle == -1){
|
||||
send_status (-1, EMFILE);
|
||||
free (arg);
|
||||
g_free (arg);
|
||||
if (!inetd_started)
|
||||
fprintf (stderr, "OOPS! you have found a bug in mc - do_opendir()!\n");
|
||||
return;
|
||||
@ -426,7 +427,7 @@ void do_opendir (void)
|
||||
|
||||
} else {
|
||||
send_status (-1, errno);
|
||||
free (arg);
|
||||
g_free (arg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -435,7 +436,7 @@ void do_readdir (void)
|
||||
{
|
||||
struct dirent *dirent;
|
||||
struct stat st;
|
||||
int handle, n, dnamelen;
|
||||
int handle, n;
|
||||
char *fname = 0;
|
||||
|
||||
rpc_get (msock, RPC_INT, &handle, RPC_END);
|
||||
@ -447,18 +448,17 @@ void do_readdir (void)
|
||||
|
||||
/* We incremented it in opendir */
|
||||
handle --;
|
||||
dnamelen = strlen (mcfs_DIR.names [handle]);
|
||||
|
||||
while ((dirent = readdir (mcfs_DIR.dirs [handle]))){
|
||||
int length = NLENGTH (dirent);
|
||||
|
||||
rpc_send (msock, RPC_INT, length, RPC_END);
|
||||
rpc_send (msock, RPC_BLOCK, length, dirent->d_name, RPC_END);
|
||||
fname = malloc (dnamelen + length + 2);
|
||||
strcat (strcat (strcpy (fname, mcfs_DIR.names [handle]), "/"), dirent->d_name);
|
||||
fname = copy_strings (mcfs_DIR.names [handle],
|
||||
PATH_SEP_STR, dirent->d_name, NULL);
|
||||
n = lstat (fname, &st);
|
||||
send_status (n, errno);
|
||||
free (fname);
|
||||
g_free (fname);
|
||||
if (n >= 0)
|
||||
send_stat_info (&st);
|
||||
}
|
||||
@ -486,7 +486,7 @@ void do_chdir (void)
|
||||
|
||||
status = chdir (file);
|
||||
send_status (status, errno);
|
||||
free (file);
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
void do_rmdir (void)
|
||||
@ -498,7 +498,7 @@ void do_rmdir (void)
|
||||
|
||||
status = rmdir (file);
|
||||
send_status (status, errno);
|
||||
free (file);
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
void do_mkdir (void)
|
||||
@ -510,7 +510,7 @@ void do_mkdir (void)
|
||||
|
||||
status = mkdir (file, mode);
|
||||
send_status (status, errno);
|
||||
free (file);
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
void do_mknod (void)
|
||||
@ -522,7 +522,7 @@ void do_mknod (void)
|
||||
|
||||
status = mknod (file, mode, dev);
|
||||
send_status (status, errno);
|
||||
free (file);
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
void do_readlink (void)
|
||||
@ -538,7 +538,7 @@ void do_readlink (void)
|
||||
buffer [n] = 0;
|
||||
rpc_send (msock, RPC_STRING, buffer, RPC_END);
|
||||
}
|
||||
free (file);
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
void do_unlink (void)
|
||||
@ -549,7 +549,7 @@ void do_unlink (void)
|
||||
rpc_get (msock, RPC_STRING, &file, RPC_END);
|
||||
status = unlink (file);
|
||||
send_status (status, errno);
|
||||
free (file);
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
void do_rename (void)
|
||||
@ -560,7 +560,7 @@ void do_rename (void)
|
||||
rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END);
|
||||
status = rename (f1, f2);
|
||||
send_status (status, errno);
|
||||
free (f1); free (f2);
|
||||
g_free (f1); g_free (f2);
|
||||
}
|
||||
|
||||
void do_symlink (void)
|
||||
@ -571,7 +571,7 @@ void do_symlink (void)
|
||||
rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END);
|
||||
status = symlink (f1, f2);
|
||||
send_status (status, errno);
|
||||
free (f1); free (f2);
|
||||
g_free (f1); g_free (f2);
|
||||
}
|
||||
|
||||
void do_link (void)
|
||||
@ -582,7 +582,7 @@ void do_link (void)
|
||||
rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END);
|
||||
status = link (f1, f2);
|
||||
send_status (link (f1, f2), errno);
|
||||
free (f1); free (f2);
|
||||
g_free (f1); g_free (f2);
|
||||
}
|
||||
|
||||
|
||||
@ -608,7 +608,7 @@ void do_chmod (void)
|
||||
rpc_get (msock, RPC_STRING, &file, RPC_INT, &mode, RPC_END);
|
||||
status = chmod (file, mode);
|
||||
send_status (status, errno);
|
||||
free (file);
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
void do_chown (void)
|
||||
@ -619,7 +619,7 @@ void do_chown (void)
|
||||
rpc_get (msock, RPC_STRING, &file,RPC_INT, &owner, RPC_INT,&group,RPC_END);
|
||||
status = chown (file, owner, group);
|
||||
send_status (status, errno);
|
||||
free (file);
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
void do_utime (void)
|
||||
@ -640,13 +640,13 @@ void do_utime (void)
|
||||
sscanf (ms, "%lx", &mtime);
|
||||
if (verbose) printf ("Got a = %s, m = %s, comp a = %ld, m = %ld\n",
|
||||
as, ms, atime, mtime);
|
||||
free (as);
|
||||
free (ms);
|
||||
g_free (as);
|
||||
g_free (ms);
|
||||
times.actime = (time_t) atime;
|
||||
times.modtime = (time_t) mtime;
|
||||
status = utime (file, ×);
|
||||
send_status (status, errno);
|
||||
free (file);
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
void do_quit ()
|
||||
@ -669,7 +669,7 @@ mc_pam_conversation (int messages, const struct pam_message **msg,
|
||||
struct user_pass *up = appdata_ptr;
|
||||
int status;
|
||||
|
||||
r = (struct pam_response *) malloc (sizeof (struct pam_response) * messages);
|
||||
r = g_new (struct pam_response, messages);
|
||||
if (!r)
|
||||
return PAM_CONV_ERR;
|
||||
*resp = r;
|
||||
@ -678,12 +678,12 @@ mc_pam_conversation (int messages, const struct pam_message **msg,
|
||||
switch ((*msg)->msg_style){
|
||||
|
||||
case PAM_PROMPT_ECHO_ON:
|
||||
r->resp = strdup (up->username);
|
||||
r->resp = g_strdup (up->username);
|
||||
r->resp_retcode = PAM_SUCCESS;
|
||||
break;
|
||||
|
||||
case PAM_PROMPT_ECHO_OFF:
|
||||
r->resp = strdup (up->password);
|
||||
r->resp = g_strdup (up->password);
|
||||
r->resp_retcode = PAM_SUCCESS;
|
||||
break;
|
||||
|
||||
@ -891,9 +891,9 @@ do_auth (char *username, char *password)
|
||||
return 0;
|
||||
|
||||
if (this->pw_dir [strlen (this->pw_dir) - 1] == '/')
|
||||
home_dir = strdup (this->pw_dir);
|
||||
home_dir = g_strdup (this->pw_dir);
|
||||
else {
|
||||
home_dir = malloc (strlen (this->pw_dir) + 2);
|
||||
home_dir = g_malloc (strlen (this->pw_dir) + 2);
|
||||
if (home_dir) {
|
||||
strcpy (home_dir, this->pw_dir);
|
||||
strcat (home_dir, "/");
|
||||
@ -1284,30 +1284,39 @@ char *unix_error_string (int a)
|
||||
return "none";
|
||||
}
|
||||
|
||||
#ifndef HAVE_MAD
|
||||
void *do_xmalloc (int size)
|
||||
{
|
||||
void *m = malloc (size);
|
||||
|
||||
if (!m){
|
||||
fprintf (stderr, "memory exhausted\n");
|
||||
exit (1);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
char *strdup (char *s)
|
||||
{
|
||||
char *t = malloc (strlen (s)+1);
|
||||
strcpy (t, s);
|
||||
return t;
|
||||
}
|
||||
#endif
|
||||
|
||||
void vfs_die( char *m )
|
||||
{
|
||||
fprintf (stderr,m);
|
||||
exit (1);
|
||||
fprintf (stderr, m);
|
||||
exit (1);
|
||||
}
|
||||
#ifdef HAVE_MAD
|
||||
char *copy_strings (const char *first, ...)
|
||||
{
|
||||
va_list ap;
|
||||
long len;
|
||||
char *data, *result;
|
||||
|
||||
if (!first)
|
||||
return 0;
|
||||
|
||||
len = strlen (first) + 1;
|
||||
va_start (ap, first);
|
||||
|
||||
while ((data = va_arg (ap, char *)) != 0)
|
||||
len += strlen (data);
|
||||
|
||||
result = g_malloc (len);
|
||||
|
||||
va_end (ap);
|
||||
|
||||
va_start (ap, first);
|
||||
strcpy (result, first);
|
||||
|
||||
while ((data = va_arg (ap, char *)) != 0)
|
||||
strcat (result, data);
|
||||
|
||||
va_end (ap);
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* HAVE_MAD */
|
||||
|
36
vfs/sfs.c
36
vfs/sfs.c
@ -15,16 +15,12 @@
|
||||
#include <config.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <malloc.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "../src/mad.h"
|
||||
#include "../src/fs.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include "../src/util.h"
|
||||
#include "../src/main.h"
|
||||
|
||||
#include "utilvfs.h"
|
||||
|
||||
#include "vfs.h"
|
||||
#include "local.h"
|
||||
@ -72,7 +68,7 @@ static int vfmake (vfs *me, char *name, char *cache)
|
||||
if (!(sfs_flags[w] & F_NOLOCALCOPY))
|
||||
name = mc_getlocalcopy (name);
|
||||
else
|
||||
name = strdup (name);
|
||||
name = g_strdup (name);
|
||||
s = sfs_command[w];
|
||||
#define COPY_CHAR if (t-pad>10200) return -1; else *t++ = *s;
|
||||
#define COPY_STRING(a) if ((t-pad)+strlen(a)>10200) return -1; else { strcpy (t, a); t+= strlen(a); }
|
||||
@ -93,7 +89,7 @@ static int vfmake (vfs *me, char *name, char *cache)
|
||||
}
|
||||
s++;
|
||||
}
|
||||
free (name);
|
||||
g_free (name);
|
||||
|
||||
if (my_system (EXECUTE_AS_SHELL | EXECUTE_SETUID | EXECUTE_WAIT, "/bin/sh", pad)) {
|
||||
return -1;
|
||||
@ -129,9 +125,9 @@ redirect (vfs *me, char *name)
|
||||
|
||||
close (handle);
|
||||
|
||||
xname = strdup (name);
|
||||
xname = g_strdup (name);
|
||||
if (!vfmake (me, name, cache)){
|
||||
cur = xmalloc (sizeof(struct cachedfile), "SFS cache");
|
||||
cur = g_new (struct cachedfile, 1);
|
||||
cur->name = xname;
|
||||
cur->cache = cache;
|
||||
cur->uid = uid;
|
||||
@ -143,7 +139,7 @@ redirect (vfs *me, char *name)
|
||||
|
||||
return cache;
|
||||
} else {
|
||||
free(xname);
|
||||
g_free(xname);
|
||||
}
|
||||
return "/I_MUST_NOT_EXIST";
|
||||
}
|
||||
@ -159,7 +155,7 @@ sfs_open (vfs *me, char *path, int flags, int mode)
|
||||
if (fd == -1)
|
||||
return 0;
|
||||
|
||||
sfs_info = (int *) xmalloc (sizeof (int), "SF fs");
|
||||
sfs_info = g_new (int, 1);
|
||||
*sfs_info = fd;
|
||||
|
||||
return sfs_info;
|
||||
@ -224,14 +220,14 @@ static vfsid sfs_getid (vfs *me, char *path, struct vfs_stamping **parent)
|
||||
*parent = NULL;
|
||||
|
||||
{
|
||||
char *path2 = strdup (path);
|
||||
char *path2 = g_strdup (path);
|
||||
v = vfs_split (path2, NULL, NULL);
|
||||
id = (*v->getid) (v, path2, &par);
|
||||
free (path2);
|
||||
g_free (path2);
|
||||
}
|
||||
|
||||
if (id != (vfsid)-1) {
|
||||
*parent = xmalloc (sizeof (struct vfs_stamping), "vfs stamping");
|
||||
*parent = g_new (struct vfs_stamping, 1);
|
||||
(*parent)->v = v;
|
||||
(*parent)->id = id;
|
||||
(*parent)->parent = par;
|
||||
@ -277,7 +273,7 @@ static int sfs_nothingisopen (vfsid id)
|
||||
static char *sfs_getlocalcopy (vfs *me, char *path)
|
||||
{
|
||||
path = redirect (me, path);
|
||||
return strdup (path);
|
||||
return g_strdup (path);
|
||||
}
|
||||
|
||||
static void sfs_ungetlocalcopy (vfs *me, char *path, char *local, int has_changed)
|
||||
@ -336,8 +332,8 @@ static int sfs_init (vfs *me)
|
||||
if ((semi = strchr (c, '\n')))
|
||||
*semi = 0;
|
||||
|
||||
sfs_prefix [sfs_no] = strdup (key);
|
||||
sfs_command [sfs_no] = strdup (c);
|
||||
sfs_prefix [sfs_no] = g_strdup (key);
|
||||
sfs_command [sfs_no] = g_strdup (c);
|
||||
sfs_flags [sfs_no] = flags;
|
||||
sfs_no++;
|
||||
}
|
||||
@ -351,8 +347,8 @@ sfs_done (vfs *me)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sfs_no; i++){
|
||||
free (sfs_prefix [i]);
|
||||
free (sfs_command [i]);
|
||||
g_free (sfs_prefix [i]);
|
||||
g_free (sfs_command [i]);
|
||||
sfs_prefix [i] = sfs_command [i] = NULL;
|
||||
}
|
||||
sfs_no = 0;
|
||||
|
@ -79,9 +79,9 @@ direntry_destructor (void *data)
|
||||
|
||||
if (fe->count > 0)
|
||||
return;
|
||||
free(fe->name);
|
||||
g_free(fe->name);
|
||||
if (fe->linkname)
|
||||
free(fe->linkname);
|
||||
g_free(fe->linkname);
|
||||
if (fe->local_filename) {
|
||||
if (fe->local_is_temp) {
|
||||
if (!fe->local_stat.st_mtime)
|
||||
@ -94,14 +94,14 @@ direntry_destructor (void *data)
|
||||
unlink (fe->local_filename); /* Delete only if it hasn't changed */
|
||||
}
|
||||
}
|
||||
free(fe->local_filename);
|
||||
g_free(fe->local_filename);
|
||||
fe->local_filename = NULL;
|
||||
}
|
||||
if (fe->remote_filename)
|
||||
free(fe->remote_filename);
|
||||
g_free(fe->remote_filename);
|
||||
if (fe->l_stat)
|
||||
free(fe->l_stat);
|
||||
free(fe);
|
||||
g_free(fe->l_stat);
|
||||
g_free(fe);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -112,9 +112,9 @@ dir_destructor(void *data)
|
||||
fd->count--;
|
||||
if (fd->count > 0)
|
||||
return;
|
||||
free(fd->remote_path);
|
||||
g_free(fd->remote_path);
|
||||
linklist_destroy(fd->file_list, direntry_destructor);
|
||||
free(fd);
|
||||
g_free(fd);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -147,18 +147,18 @@ free_bucket (void *data)
|
||||
{
|
||||
struct connection *bucket = data;
|
||||
|
||||
free(qhost(bucket));
|
||||
free(quser(bucket));
|
||||
g_free(qhost(bucket));
|
||||
g_free(quser(bucket));
|
||||
if (qcdir(bucket))
|
||||
free(qcdir(bucket));
|
||||
g_free(qcdir(bucket));
|
||||
if (qhome(bucket))
|
||||
free(qhome(bucket));
|
||||
g_free(qhome(bucket));
|
||||
if (qupdir(bucket))
|
||||
free(qupdir(bucket));
|
||||
g_free(qupdir(bucket));
|
||||
if (bucket->password)
|
||||
wipe_password (bucket->password);
|
||||
linklist_destroy(qdcache(bucket), dir_destructor);
|
||||
free(bucket);
|
||||
g_free(bucket);
|
||||
}
|
||||
|
||||
|
||||
@ -189,9 +189,9 @@ static void X_fill_names (vfs *me, void (*func)(char *))
|
||||
|
||||
path_name = copy_strings ( X_myname, quser (bucket),
|
||||
"@", qhost (bucket),
|
||||
qcdir(bucket), 0);
|
||||
qcdir(bucket), NULL);
|
||||
(*func)(path_name);
|
||||
free (path_name);
|
||||
g_free (path_name);
|
||||
}
|
||||
lptr = lptr->next;
|
||||
} while (lptr != connections_list);
|
||||
@ -222,12 +222,12 @@ s_get_path (struct connection **bucket, char *path, char *name)
|
||||
my_errno = ENOENT;
|
||||
else {
|
||||
if ((*bucket = open_link (host, user, port, pass)) == NULL) {
|
||||
free (remote_path);
|
||||
g_free (remote_path);
|
||||
remote_path = NULL;
|
||||
}
|
||||
}
|
||||
free (host);
|
||||
free (user);
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
if (pass)
|
||||
wipe_password (pass);
|
||||
|
||||
@ -245,7 +245,7 @@ s_get_path (struct connection **bucket, char *path, char *name)
|
||||
if (f || !strncmp( remote_path, "/~/", 3 )) {
|
||||
char *s;
|
||||
s = concat_dir_and_file( qhome (*bucket), remote_path +3-f );
|
||||
free (remote_path);
|
||||
g_free (remote_path);
|
||||
remote_path = s;
|
||||
}
|
||||
}
|
||||
@ -310,7 +310,7 @@ _get_file_entry(struct connection *bucket, char *file_name,
|
||||
if (!S_ISREG(fmode)) ERRNOR (EPERM, NULL);
|
||||
if ((flags & O_EXCL) && (flags & O_CREAT)) ERRNOR (EEXIST, NULL);
|
||||
if (ent->remote_filename == NULL)
|
||||
if (!(ent->remote_filename = strdup(file_name))) ERRNOR (ENOMEM, NULL);
|
||||
if (!(ent->remote_filename = g_strdup(file_name))) ERRNOR (ENOMEM, NULL);
|
||||
if (ent->local_filename == NULL ||
|
||||
!ent->local_stat.st_mtime ||
|
||||
stat (ent->local_filename, &sb) < 0 ||
|
||||
@ -318,7 +318,7 @@ _get_file_entry(struct connection *bucket, char *file_name,
|
||||
int handle;
|
||||
|
||||
if (ent->local_filename){
|
||||
free (ent->local_filename);
|
||||
g_free (ent->local_filename);
|
||||
ent->local_filename = NULL;
|
||||
}
|
||||
if (flags & O_TRUNC) {
|
||||
@ -351,15 +351,15 @@ _get_file_entry(struct connection *bucket, char *file_name,
|
||||
if ((op & DO_OPEN) && (flags & O_CREAT)) {
|
||||
int handle;
|
||||
|
||||
ent = xmalloc(sizeof(struct direntry), "struct direntry");
|
||||
ent = g_new (struct direntry, 1);
|
||||
ent->freshly_created = 0;
|
||||
if (ent == NULL) ERRNOR (ENOMEM, NULL);
|
||||
ent->count = 1;
|
||||
ent->linkname = NULL;
|
||||
ent->l_stat = NULL;
|
||||
ent->bucket = bucket;
|
||||
ent->name = strdup(p);
|
||||
ent->remote_filename = strdup(file_name);
|
||||
ent->name = g_strdup(p);
|
||||
ent->remote_filename = g_strdup(file_name);
|
||||
ent->local_filename = tempnam (NULL, X "fs");
|
||||
if (!ent->name && !ent->remote_filename && !ent->local_filename) {
|
||||
direntry_destructor(ent);
|
||||
@ -422,7 +422,7 @@ remove_temp_file (char *file_name)
|
||||
if (strcmp (p, ent->name) == 0) {
|
||||
if (ent->local_filename) {
|
||||
unlink (ent->local_filename);
|
||||
free (ent->local_filename);
|
||||
g_free (ent->local_filename);
|
||||
ent->local_filename = NULL;
|
||||
return 0;
|
||||
}
|
||||
@ -442,7 +442,7 @@ get_file_entry(char *path, int op, int flags)
|
||||
return NULL;
|
||||
fe = _get_file_entry(bucket, remote_path, op,
|
||||
flags);
|
||||
free(remote_path);
|
||||
g_free(remote_path);
|
||||
#if 0
|
||||
if (op & DO_FREE_RESOURCE)
|
||||
vfs_add_noncurrent_stamps (&vfs_X_ops, (vfsid) bucket, NULL);
|
||||
@ -477,18 +477,18 @@ static void *s_open (vfs *me, char *file, int flags, int mode)
|
||||
struct filp *fp;
|
||||
struct direntry *fe;
|
||||
|
||||
fp = xmalloc(sizeof(struct filp), "struct filp");
|
||||
fp = g_new (struct filp, 1);
|
||||
if (fp == NULL) ERRNOR (ENOMEM, NULL);
|
||||
fe = get_file_entry(file, DO_OPEN | DO_RESOLVE_SYMLINK, flags);
|
||||
if (!fe) {
|
||||
free(fp);
|
||||
g_free(fp);
|
||||
return NULL;
|
||||
}
|
||||
fe->linear_state = IS_LINEAR(flags);
|
||||
if (!fe->linear_state) {
|
||||
fp->local_handle = open(fe->local_filename, flags, mode);
|
||||
if (fp->local_handle < 0) {
|
||||
free(fp);
|
||||
g_free(fp);
|
||||
ERRNOR (errno, NULL);
|
||||
}
|
||||
} else fp->local_handle = -1;
|
||||
@ -558,7 +558,7 @@ static int s_close (void *data)
|
||||
close(fp->local_handle);
|
||||
qlock(fp->fe->bucket)--;
|
||||
direntry_destructor(fp->fe);
|
||||
free(fp);
|
||||
g_free(fp);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -592,7 +592,7 @@ static void *s_opendir (vfs *me, char *dirname)
|
||||
|
||||
if (!(remote_path = get_path (&bucket, dirname)))
|
||||
return NULL;
|
||||
dirp = xmalloc(sizeof(struct my_dirent), "struct my_dirent");
|
||||
dirp = g_new (struct my_dirent, 1);
|
||||
if (dirp == NULL) {
|
||||
my_errno = ENOMEM;
|
||||
goto error_return;
|
||||
@ -601,13 +601,13 @@ static void *s_opendir (vfs *me, char *dirname)
|
||||
if (dirp->dcache == NULL)
|
||||
goto error_return;
|
||||
dirp->pos = dirp->dcache->file_list->next;
|
||||
free(remote_path);
|
||||
g_free(remote_path);
|
||||
dirp->dcache->count++;
|
||||
return (void *)dirp;
|
||||
error_return:
|
||||
vfs_add_noncurrent_stamps (&vfs_X_ops, (vfsid) bucket, NULL);
|
||||
free(remote_path);
|
||||
free(dirp);
|
||||
g_free(remote_path);
|
||||
g_free(dirp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -657,7 +657,7 @@ static int s_closedir (void *info)
|
||||
{
|
||||
struct my_dirent *dirp = info;
|
||||
dir_destructor(dirp->dcache);
|
||||
free(dirp);
|
||||
g_free(dirp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -723,7 +723,7 @@ static int s_chdir (vfs *me, char *path)
|
||||
if (!(remote_path = get_path(&bucket, path)))
|
||||
return -1;
|
||||
if (qcdir(bucket))
|
||||
free(qcdir(bucket));
|
||||
g_free(qcdir(bucket));
|
||||
qcdir(bucket) = remote_path;
|
||||
bucket->cwd_defered = 1;
|
||||
|
||||
@ -758,7 +758,7 @@ static vfsid s_getid (vfs *me, char *p, struct vfs_stamping **parent)
|
||||
if (!(remote_path = get_path (&bucket, p)))
|
||||
return (vfsid) -1;
|
||||
else {
|
||||
free(remote_path);
|
||||
g_free(remote_path);
|
||||
return (vfsid) bucket;
|
||||
}
|
||||
}
|
||||
@ -787,7 +787,7 @@ static char *s_getlocalcopy (vfs *me, char *path)
|
||||
s_close ((void *) fp);
|
||||
return NULL;
|
||||
}
|
||||
p = strdup (fp->fe->local_filename);
|
||||
p = g_strdup (fp->fe->local_filename);
|
||||
qlock(fp->fe->bucket)++;
|
||||
fp->fe->count++;
|
||||
s_close ((void *) fp);
|
||||
@ -885,7 +885,7 @@ error_3:
|
||||
close(local_handle);
|
||||
unlink(fe->local_filename);
|
||||
error_4:
|
||||
free(fe->local_filename);
|
||||
g_free(fe->local_filename);
|
||||
fe->local_filename = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
@ -12,12 +12,12 @@
|
||||
static char *get_path (char *inname, struct archive **archive, int is_dir,
|
||||
int do_not_open)
|
||||
{
|
||||
char *buf = strdup( inname );
|
||||
char *buf = g_strdup (inname);
|
||||
char *res = get_path_mangle( buf, archive, is_dir, do_not_open );
|
||||
char *res2 = NULL;
|
||||
if (res)
|
||||
res2 = strdup(res);
|
||||
free(buf);
|
||||
res2 = g_strdup(res);
|
||||
g_free(buf);
|
||||
return res2;
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ static void * s_opendir (vfs *me, char *dirname)
|
||||
return NULL;
|
||||
if (!S_ISDIR (entry->inode->mode)) ERRNOR (ENOTDIR, NULL);
|
||||
|
||||
info = (struct entry **) xmalloc (2*sizeof (struct entry *), "shared opendir");
|
||||
info = g_new (struct entry *, 2);
|
||||
info[0] = entry->inode->first_in_subdir;
|
||||
info[1] = entry->inode->first_in_subdir;
|
||||
|
||||
@ -190,7 +190,7 @@ static void s_seekdir (void *data, int offset)
|
||||
|
||||
static int s_closedir (void *data)
|
||||
{
|
||||
free (data);
|
||||
g_free (data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
23
vfs/tar.c
23
vfs/tar.c
@ -26,8 +26,9 @@
|
||||
#include <sys/timeb.h> /* alex: for struct timeb definition */
|
||||
#endif /* SCO_FLAVOR */
|
||||
#include <time.h>
|
||||
#include "../src/fs.h"
|
||||
#include "../src/util.h"
|
||||
|
||||
#include "utilvfs.h"
|
||||
|
||||
#include "../src/dialog.h" /* For MSG_ERROR */
|
||||
#include "tar.h"
|
||||
#include "names.h"
|
||||
@ -84,7 +85,7 @@ static int tar_open_archive (vfs *me, char *name, vfs_s_super *archive)
|
||||
ERRNOR (ENOENT, -1);
|
||||
}
|
||||
|
||||
archive->name = strdup (name);
|
||||
archive->name = g_strdup (name);
|
||||
mc_stat (name, &(archive->u.tar.tarstat));
|
||||
archive->u.tar.fd = -1;
|
||||
|
||||
@ -98,7 +99,7 @@ static int tar_open_archive (vfs *me, char *name, vfs_s_super *archive)
|
||||
result = mc_open (s, O_RDONLY);
|
||||
if (result == -1)
|
||||
message_2s (1, MSG_ERROR, _("Couldn't open tar archive\n%s"), s);
|
||||
free(s);
|
||||
g_free(s);
|
||||
if (result == -1)
|
||||
ERRNOR (ENOENT, -1);
|
||||
}
|
||||
@ -272,8 +273,8 @@ read_header (vfs *me, vfs_s_super *archive, int tard)
|
||||
: &next_long_link);
|
||||
|
||||
if (*longp)
|
||||
free (*longp);
|
||||
bp = *longp = (char *) xmalloc (hstat.st_size, "Tar: Long name");
|
||||
g_free (*longp);
|
||||
bp = *longp = g_malloc (hstat.st_size);
|
||||
|
||||
for (size = hstat.st_size;
|
||||
size > 0;
|
||||
@ -306,7 +307,7 @@ read_header (vfs *me, vfs_s_super *archive, int tard)
|
||||
|
||||
current_file_name = (next_long_name
|
||||
? next_long_name
|
||||
: strdup (header->header.arch_name));
|
||||
: g_strdup (header->header.arch_name));
|
||||
len = strlen (current_file_name);
|
||||
if (current_file_name[len - 1] == '/') {
|
||||
current_file_name[len - 1] = 0;
|
||||
@ -315,7 +316,7 @@ read_header (vfs *me, vfs_s_super *archive, int tard)
|
||||
|
||||
current_link_name = (next_long_link
|
||||
? next_long_link
|
||||
: strdup (header->header.arch_linkname));
|
||||
: g_strdup (header->header.arch_linkname));
|
||||
len = strlen (current_link_name);
|
||||
if (len && current_link_name [len - 1] == '/')
|
||||
current_link_name[len - 1] = 0;
|
||||
@ -347,7 +348,7 @@ read_header (vfs *me, vfs_s_super *archive, int tard)
|
||||
inode = parent;
|
||||
entry = vfs_s_new_entry(me, p, inode);
|
||||
vfs_s_insert_entry(me, parent, entry);
|
||||
free (current_link_name);
|
||||
g_free (current_link_name);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
@ -361,7 +362,7 @@ read_header (vfs *me, vfs_s_super *archive, int tard)
|
||||
entry = vfs_s_new_entry (me, p, inode);
|
||||
|
||||
vfs_s_insert_entry (me, parent, entry);
|
||||
free (current_file_name);
|
||||
g_free (current_file_name);
|
||||
|
||||
done:
|
||||
if (header->header.isextended) {
|
||||
@ -473,7 +474,7 @@ static int tar_read (void *fh, char *buffer, int count)
|
||||
if (mc_lseek (fd, begin + FH->pos, SEEK_SET) !=
|
||||
begin + FH->pos) ERRNOR (EIO, -1);
|
||||
|
||||
count = VFS_MIN(count, FH->ino->st.st_size - FH->pos);
|
||||
count = MIN(count, FH->ino->st.st_size - FH->pos);
|
||||
|
||||
if ((count = mc_read (fd, buffer, count)) == -1) ERRNOR (errno, -1);
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#ifdef HAVE_PMAP_SET
|
||||
#include <rpc/rpc.h>
|
||||
@ -46,9 +45,9 @@
|
||||
#include <errno.h>
|
||||
#include "tcputil.h"
|
||||
#include "../src/dialog.h" /* for message () */
|
||||
#include "../src/mem.h" /* for bcopy */
|
||||
#include "../src/util.h" /* for unix_error_string */
|
||||
#include "../src/mad.h"
|
||||
|
||||
#include "utilvfs.h"
|
||||
|
||||
#include "mcfs.h" /* for mcserver_port definition */
|
||||
|
||||
#define CHECK_SIG_PIPE(sock) if (got_sigpipe) \
|
||||
@ -165,7 +164,7 @@ static void check_hooks (int sock)
|
||||
} else {
|
||||
prev->link = callback->link;
|
||||
}
|
||||
free (callback);
|
||||
g_free (callback);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -208,12 +207,12 @@ int rpc_get (int sock, ...)
|
||||
}
|
||||
if (len > 128*1024)
|
||||
abort ();
|
||||
text = malloc (len+1);
|
||||
text = g_new0 (char, len+1);
|
||||
if (socket_read_block (sock, text, len) == 0)
|
||||
return 0;
|
||||
str_dest = va_arg (ap, char **);
|
||||
*str_dest = text;
|
||||
text [len] = 0;
|
||||
text [len] = NULL;
|
||||
break;
|
||||
|
||||
case RPC_BLOCK:
|
||||
@ -233,14 +232,15 @@ void rpc_add_get_callback (int sock, void (*cback)(int))
|
||||
{
|
||||
sock_callback_t *new;
|
||||
|
||||
new = malloc (sizeof (sock_callback_t));
|
||||
new = g_new (sock_callback_t, 1);
|
||||
new->cback = cback;
|
||||
new->sock = sock;
|
||||
new->link = sock_callbacks;
|
||||
sock_callbacks = new;
|
||||
}
|
||||
|
||||
#if defined(IS_AIX) || defined(linux) || defined(SCO_FLAVOR) || defined(__QNX__)
|
||||
#if defined(IS_AIX) || defined(linux) || defined(SCO_FLAVOR) || defined(__QNX__) \
|
||||
|| defined(__FreeBSD__)
|
||||
static void sig_pipe (int unused)
|
||||
#else
|
||||
static void sig_pipe (void)
|
||||
|
@ -34,15 +34,8 @@
|
||||
|
||||
#include <config.h>
|
||||
#include <errno.h>
|
||||
#include "../src/fs.h"
|
||||
#include "../src/mad.h"
|
||||
#include "../src/util.h"
|
||||
|
||||
#include "../src/mem.h"
|
||||
#include "vfs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
/* asm/types.h defines its own umode_t :-( */
|
||||
@ -51,6 +44,10 @@
|
||||
#include <ext2fs/ext2fs.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "utilvfs.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
void print_vfs_message(char *, ...);
|
||||
|
||||
struct deleted_info {
|
||||
@ -92,13 +89,13 @@ undelfs_shutdown (void)
|
||||
ext2fs_close (fs);
|
||||
fs = 0;
|
||||
if (ext2_fname)
|
||||
free (ext2_fname);
|
||||
g_free (ext2_fname);
|
||||
ext2_fname = 0;
|
||||
if (delarray)
|
||||
free (delarray);
|
||||
g_free (delarray);
|
||||
delarray = 0;
|
||||
if (block_buf)
|
||||
free (block_buf);
|
||||
g_free (block_buf);
|
||||
block_buf = 0;
|
||||
}
|
||||
|
||||
@ -134,7 +131,7 @@ undelfs_get_path (char *dirname, char **ext2_fname, char **file)
|
||||
|
||||
while (p > dirname){
|
||||
if (*p == '/'){
|
||||
*file = strdup (p+1);
|
||||
*file = g_strdup (p+1);
|
||||
*p = 0;
|
||||
*ext2_fname = copy_strings ("/dev/", dirname, NULL);
|
||||
*p = '/';
|
||||
@ -142,7 +139,7 @@ undelfs_get_path (char *dirname, char **ext2_fname, char **file)
|
||||
}
|
||||
p--;
|
||||
}
|
||||
*file = strdup ("");
|
||||
*file = g_strdup ("");
|
||||
*ext2_fname = copy_strings ("/dev/", dirname, NULL);
|
||||
return;
|
||||
}
|
||||
@ -179,12 +176,12 @@ undelfs_loaddel (void)
|
||||
|
||||
max_delarray = 100;
|
||||
num_delarray = 0;
|
||||
delarray = malloc(max_delarray * sizeof(struct deleted_info));
|
||||
delarray = g_new (struct deleted_info, max_delarray);
|
||||
if (!delarray) {
|
||||
message_1s (1, undelfserr, " not enough memory ");
|
||||
return 0;
|
||||
}
|
||||
block_buf = malloc(fs->blocksize * 3);
|
||||
block_buf = g_new (fs->blocksize, 3);
|
||||
if (!block_buf) {
|
||||
message_1s (1, undelfserr, " while allocating block buffer ");
|
||||
goto free_delarray;
|
||||
@ -255,10 +252,10 @@ undelfs_loaddel (void)
|
||||
error_out:
|
||||
ext2fs_close_inode_scan (scan);
|
||||
free_block_buf:
|
||||
free (block_buf);
|
||||
g_free (block_buf);
|
||||
block_buf = 0;
|
||||
free_delarray:
|
||||
free (delarray);
|
||||
g_free (delarray);
|
||||
delarray = 0;
|
||||
return 0;
|
||||
}
|
||||
@ -267,10 +264,9 @@ void com_err (const char *str, long err_code, const char *s2, ...)
|
||||
{
|
||||
char *cptr;
|
||||
|
||||
cptr = xmalloc (strlen (s2) + strlen (str) + 60, "com_err");
|
||||
sprintf (cptr, " %s (%s: %ld) ", s2, str, err_code);
|
||||
cptr = g_strdup_printf (" %s (%s: %ld) ", s2, str, err_code);
|
||||
message_1s (1, " Ext2lib error ", cptr);
|
||||
free (cptr);
|
||||
g_free (cptr);
|
||||
}
|
||||
|
||||
static void *
|
||||
@ -283,7 +279,7 @@ undelfs_opendir (vfs *me, char *dirname)
|
||||
return 0;
|
||||
|
||||
/* We don't use the file name */
|
||||
free (f);
|
||||
g_free (f);
|
||||
|
||||
if (!ext2_fname || strcmp (ext2_fname, file)){
|
||||
undelfs_shutdown ();
|
||||
@ -291,7 +287,7 @@ undelfs_opendir (vfs *me, char *dirname)
|
||||
} else {
|
||||
/* To avoid expensive re-scannings */
|
||||
readdir_ptr = READDIR_PTR_INIT;
|
||||
free (file);
|
||||
g_free (file);
|
||||
return fs;
|
||||
}
|
||||
|
||||
@ -347,11 +343,11 @@ undelfs_readdir (void *vfs_info)
|
||||
}
|
||||
if (readdir_ptr == num_delarray)
|
||||
return NULL;
|
||||
dirent_dest = &(undelfs_readdir_data.dent.d_name [0]);
|
||||
dirent_dest = (char *) &(undelfs_readdir_data.dent.d_name [0]);
|
||||
if (readdir_ptr < 0)
|
||||
sprintf (dirent_dest, "%s", readdir_ptr == -2 ? "." : "..");
|
||||
g_snprintf(dirent_dest, MC_MAXPATHLEN, "%s", readdir_ptr == -2 ? "." : "..");
|
||||
else
|
||||
sprintf (dirent_dest, "%ld:%d",
|
||||
g_snprintf(dirent_dest, MC_MAXPATHLEN, "%ld:%d",
|
||||
(long)delarray [readdir_ptr].ino,
|
||||
delarray [readdir_ptr].num_blocks);
|
||||
readdir_ptr++;
|
||||
@ -399,8 +395,8 @@ undelfs_open (vfs *me, char *fname, int flags, int mode)
|
||||
|
||||
if (!ext2_fname || strcmp (ext2_fname, file)){
|
||||
message_1s (1, undelfserr, " You have to chdir to extract files first ");
|
||||
free (file);
|
||||
free (f);
|
||||
g_free (file);
|
||||
g_free (f);
|
||||
return 0;
|
||||
}
|
||||
inode = atol (f);
|
||||
@ -411,17 +407,17 @@ undelfs_open (vfs *me, char *fname, int flags, int mode)
|
||||
continue;
|
||||
|
||||
/* Found: setup all the structures needed by read */
|
||||
p = (void *) malloc (sizeof (undelfs_file));
|
||||
p = g_new (undelfs_file, 1);
|
||||
if (!p){
|
||||
free (file);
|
||||
free (f);
|
||||
g_free (file);
|
||||
g_free (f);
|
||||
return 0;
|
||||
}
|
||||
p->buf = malloc(fs->blocksize);
|
||||
p->buf = g_new (fs->blocksize, 1);
|
||||
if (!p->buf){
|
||||
free (p);
|
||||
free (file);
|
||||
free (f);
|
||||
g_free (p);
|
||||
g_free (file);
|
||||
g_free (f);
|
||||
return 0;
|
||||
}
|
||||
p->inode = inode;
|
||||
@ -431,8 +427,8 @@ undelfs_open (vfs *me, char *fname, int flags, int mode)
|
||||
p->pos = 0;
|
||||
p->size = delarray [i].size;
|
||||
}
|
||||
free (file);
|
||||
free (f);
|
||||
g_free (file);
|
||||
g_free (f);
|
||||
undelfs_usage++;
|
||||
return p;
|
||||
}
|
||||
@ -441,8 +437,8 @@ static int
|
||||
undelfs_close (void *vfs_info)
|
||||
{
|
||||
undelfs_file *p = vfs_info;
|
||||
free (p->buf);
|
||||
free (p);
|
||||
g_free (p->buf);
|
||||
g_free (p);
|
||||
undelfs_usage--;
|
||||
return 0;
|
||||
}
|
||||
@ -576,20 +572,20 @@ undelfs_lstat(vfs *me, char *path, struct stat *buf)
|
||||
f = "sda1" f ="401:1"
|
||||
If the first char in f is no digit -> return error */
|
||||
if (!isdigit (*f)) {
|
||||
free (file);
|
||||
free (f);
|
||||
g_free (file);
|
||||
g_free (f);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!ext2_fname || strcmp (ext2_fname, file)){
|
||||
message_1s (1, undelfserr, " You have to chdir to extract files first ");
|
||||
free (file);
|
||||
free (f);
|
||||
g_free (file);
|
||||
g_free (f);
|
||||
return 0;
|
||||
}
|
||||
inode_index = undelfs_getindex (f);
|
||||
free (file);
|
||||
free (f);
|
||||
g_free (file);
|
||||
g_free (f);
|
||||
|
||||
if (inode_index == -1)
|
||||
return -1;
|
||||
@ -627,13 +623,13 @@ undelfs_chdir(vfs *me, char *path)
|
||||
/* our vfs, but that is left as an excercise for the reader */
|
||||
if ((fd = open (file, O_RDONLY)) == -1){
|
||||
message_2s (1, undelfserr, " Could not open file: %s ", file);
|
||||
free (f);
|
||||
free (file);
|
||||
g_free (f);
|
||||
g_free (file);
|
||||
return -1;
|
||||
}
|
||||
close (fd);
|
||||
free (f);
|
||||
free (file);
|
||||
g_free (f);
|
||||
g_free (file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -655,8 +651,8 @@ undelfs_getid(vfs *me, char *path, struct vfs_stamping **parent)
|
||||
|
||||
if (!ext2_fname)
|
||||
return (vfsid) -1;
|
||||
free (ext2_fname);
|
||||
free (file);
|
||||
g_free (ext2_fname);
|
||||
g_free (file);
|
||||
return (vfsid)0;
|
||||
}
|
||||
|
||||
|
@ -61,19 +61,6 @@
|
||||
int source_route = 0;
|
||||
int cd_symlinks = 0;
|
||||
|
||||
/*
|
||||
* Required functions to make mc's vfs layer compile stand-alone
|
||||
*/
|
||||
|
||||
void *do_xmalloc (int size)
|
||||
{
|
||||
void *m = malloc (size);
|
||||
|
||||
if (!m)
|
||||
vfs_die ("Memory exhausted\n");
|
||||
return m;
|
||||
}
|
||||
|
||||
/*
|
||||
* We do not want/need many of midnight's functions, stub routines.
|
||||
*/
|
||||
@ -162,7 +149,7 @@ wipe_password (char *passwd)
|
||||
|
||||
for (;*p; p++)
|
||||
*p = 0;
|
||||
free (passwd);
|
||||
g_free (passwd);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -35,12 +35,13 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <malloc.h>
|
||||
#ifdef USE_TERMNET
|
||||
#include <termnet.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "utilvfs.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
/* Extract the hostname and username from the path */
|
||||
@ -65,7 +66,7 @@ char *vfs_split_url (char *path, char **host, char **user, int *port, char **pas
|
||||
struct passwd *passwd_info;
|
||||
char *dir, *colon, *inner_colon, *at, *rest;
|
||||
char *retval;
|
||||
char *pcopy = strdup (path);
|
||||
char *pcopy = g_strdup (path);
|
||||
char *pend = pcopy + strlen (pcopy);
|
||||
int default_is_anon = flags & URL_DEFAULTANON;
|
||||
|
||||
@ -77,13 +78,13 @@ char *vfs_split_url (char *path, char **host, char **user, int *port, char **pas
|
||||
dir = pcopy;
|
||||
if (!(flags & URL_NOSLASH)) {
|
||||
/* locate path component */
|
||||
for (; *dir != '/' && *dir; dir++)
|
||||
for (; *dir != PATH_SEP && *dir; dir++)
|
||||
;
|
||||
if (*dir){
|
||||
retval = strdup (dir);
|
||||
retval = g_strdup (dir);
|
||||
*dir = 0;
|
||||
} else
|
||||
retval = strdup ("/");
|
||||
retval = g_strdup (PATH_SEP_STR);
|
||||
}
|
||||
|
||||
/* search for any possible user */
|
||||
@ -99,10 +100,10 @@ char *vfs_split_url (char *path, char **host, char **user, int *port, char **pas
|
||||
if (*inner_colon == '@')
|
||||
*pass = NULL;
|
||||
else
|
||||
*pass = strdup (inner_colon);
|
||||
*pass = g_strdup (inner_colon);
|
||||
}
|
||||
if (*pcopy != 0)
|
||||
*user = strdup (pcopy);
|
||||
if (*pcopy != NULL)
|
||||
*user = g_strdup (pcopy);
|
||||
else
|
||||
default_is_anon = 0;
|
||||
|
||||
@ -115,12 +116,12 @@ char *vfs_split_url (char *path, char **host, char **user, int *port, char **pas
|
||||
|
||||
if (!*user){
|
||||
if (default_is_anon)
|
||||
*user = strdup ("anonymous");
|
||||
*user = g_strdup ("anonymous");
|
||||
else {
|
||||
if ((passwd_info = getpwuid (geteuid ())) == NULL)
|
||||
*user = strdup ("anonymous");
|
||||
*user = g_strdup ("anonymous");
|
||||
else {
|
||||
*user = strdup (passwd_info->pw_name);
|
||||
*user = g_strdup (passwd_info->pw_name);
|
||||
}
|
||||
endpwent ();
|
||||
}
|
||||
@ -146,12 +147,24 @@ char *vfs_split_url (char *path, char **host, char **user, int *port, char **pas
|
||||
}
|
||||
}
|
||||
done:
|
||||
*host = strdup (rest);
|
||||
*host = g_strdup (rest);
|
||||
|
||||
free (pcopy);
|
||||
g_free (pcopy);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Returns allocated string with trailing PATH_SEP */
|
||||
char*
|
||||
append_path_sep (char *path)
|
||||
{
|
||||
int i = strlen(path) - 1;
|
||||
|
||||
if(path[i] == PATH_SEP)
|
||||
return g_strndup(path, i);
|
||||
else
|
||||
return copy_strings (path, PATH_SEP_STR, NULL);
|
||||
}
|
||||
|
||||
#ifdef test_get_host_and_username
|
||||
struct tt {
|
||||
char *url;
|
||||
@ -229,9 +242,9 @@ main ()
|
||||
char *current;
|
||||
|
||||
if ((passwd_info = getpwuid (geteuid ())) == NULL)
|
||||
current = strdup ("anonymous");
|
||||
current = g_strdup ("anonymous");
|
||||
else {
|
||||
current= strdup (passwd_info->pw_name);
|
||||
current= g_strdup (passwd_info->pw_name);
|
||||
}
|
||||
endpwent ();
|
||||
|
||||
|
175
vfs/vfs.c
175
vfs/vfs.c
@ -20,16 +20,13 @@
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* Warning: funtions like extfs_lstat() have right to destroy any
|
||||
* strings you pass to them. This is acutally ok as you strdup what
|
||||
* strings you pass to them. This is acutally ok as you g_strdup what
|
||||
* you are passing to them, anyway; still, beware. */
|
||||
|
||||
/* Namespace: exports *many* functions with vfs_ prefix; exports
|
||||
parse_ls_lga and friends which do not have that prefix. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glib.h>
|
||||
#undef MIN
|
||||
#undef MAX
|
||||
|
||||
#include <syslog.h>
|
||||
#include <stdio.h>
|
||||
@ -38,7 +35,6 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <malloc.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#ifdef SCO_FLAVOR
|
||||
@ -46,10 +42,10 @@
|
||||
#endif /* SCO_FLAVOR */
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include "../src/fs.h"
|
||||
#include "../src/mad.h"
|
||||
|
||||
#include "utilvfs.h"
|
||||
|
||||
#include "../src/dir.h"
|
||||
#include "../src/util.h"
|
||||
#include "../src/main.h"
|
||||
#ifndef VFS_STANDALONE
|
||||
#include "../src/panel.h"
|
||||
@ -57,6 +53,7 @@
|
||||
#include "../src/layout.h" /* For get_panel_widget and get_other_index */
|
||||
#include "../src/dialog.h"
|
||||
#endif
|
||||
|
||||
#include "vfs.h"
|
||||
#include "extfs.h" /* FIXME: we should not know anything about our modules */
|
||||
#include "names.h"
|
||||
@ -163,7 +160,7 @@ vfs_strip_suffix_from_filename (char *filename)
|
||||
if (!filename)
|
||||
vfs_die("vfs_strip_suffix_from_path got NULL: impossible");
|
||||
|
||||
p = strdup (filename);
|
||||
p = g_strdup (filename);
|
||||
if (!(semi = strrchr (p, '#')))
|
||||
return p;
|
||||
|
||||
@ -171,11 +168,11 @@ vfs_strip_suffix_from_filename (char *filename)
|
||||
if (vfs->which){
|
||||
if ((*vfs->which) (vfs, semi + 1) == -1)
|
||||
continue;
|
||||
*semi = '\0'; /* Found valid suffix */
|
||||
*semi = NULL; /* Found valid suffix */
|
||||
return p;
|
||||
}
|
||||
if (!strncmp (semi + 1, vfs->prefix, strlen (vfs->prefix))) {
|
||||
*semi = '\0'; /* Found valid suffix */
|
||||
*semi = NULL; /* Found valid suffix */
|
||||
return p;
|
||||
}
|
||||
}
|
||||
@ -198,7 +195,7 @@ path_magic (char *path)
|
||||
|
||||
/*
|
||||
* Splits path '/p1#op/inpath' into inpath,op; returns which vfs it is.
|
||||
* What is left in path is p1. You still want to free(path), you DON'T
|
||||
* What is left in path is p1. You still want to g_free(path), you DON'T
|
||||
* want to free neither *inpath nor *op
|
||||
*/
|
||||
vfs *
|
||||
@ -215,7 +212,7 @@ vfs_split (char *path, char **inpath, char **op)
|
||||
if (!semi || !path_magic(path))
|
||||
return NULL;
|
||||
|
||||
slash = strchr (semi, '/');
|
||||
slash = strchr (semi, PATH_SEP);
|
||||
*semi = 0;
|
||||
|
||||
if (op)
|
||||
@ -236,7 +233,7 @@ vfs_split (char *path, char **inpath, char **op)
|
||||
}
|
||||
|
||||
if (slash)
|
||||
*slash = '/';
|
||||
*slash = PATH_SEP;
|
||||
ret = vfs_split (path, inpath, op);
|
||||
*semi = '#';
|
||||
return ret;
|
||||
@ -257,7 +254,7 @@ vfs_rosplit (char *path)
|
||||
if (!semi || !path_magic (path))
|
||||
return NULL;
|
||||
|
||||
slash = strchr (semi, '/');
|
||||
slash = strchr (semi, PATH_SEP);
|
||||
*semi = 0;
|
||||
if (slash)
|
||||
*slash = 0;
|
||||
@ -265,7 +262,7 @@ vfs_rosplit (char *path)
|
||||
ret = vfs_type_from_op (semi+1);
|
||||
|
||||
if (slash)
|
||||
*slash = '/';
|
||||
*slash = PATH_SEP;
|
||||
if (!ret)
|
||||
ret = vfs_rosplit (path);
|
||||
|
||||
@ -310,13 +307,13 @@ vfs_addstamp (vfs *v, vfsid id, struct vfs_stamping *parent)
|
||||
gettimeofday(&(stamp->time), NULL);
|
||||
return;
|
||||
}
|
||||
stamp = xmalloc (sizeof (struct vfs_stamping), "vfs stamping");
|
||||
stamp = g_new (struct vfs_stamping, 1);
|
||||
stamp->v = v;
|
||||
stamp->id = id;
|
||||
if (parent){
|
||||
struct vfs_stamping *st = stamp;
|
||||
for (; parent;){
|
||||
st->parent = xmalloc (sizeof (struct vfs_stamping), "vfs stamping");
|
||||
st->parent = g_new (struct vfs_stamping, 1);
|
||||
*st->parent = *parent;
|
||||
parent = parent->parent;
|
||||
st = st->parent;
|
||||
@ -359,9 +356,9 @@ vfs_rm_parents (struct vfs_stamping *stamp)
|
||||
|
||||
if (stamp){
|
||||
for (st2 = stamp, st3 = st2->parent; st3 != NULL; st2 = st3, st3 = st3->parent)
|
||||
free (st2);
|
||||
g_free (st2);
|
||||
|
||||
free (st2);
|
||||
g_free (st2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -382,7 +379,7 @@ vfs_rmstamp (vfs *v, vfsid id, int removeparents)
|
||||
} else {
|
||||
st1->next = stamp->next;
|
||||
}
|
||||
free (stamp);
|
||||
g_free (stamp);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -416,7 +413,7 @@ mc_open (char *file, int flags, ...)
|
||||
vfs_die ("VFS must support open.\n");
|
||||
|
||||
info = (*vfs->open) (vfs, file, flags, mode); /* open must be supported */
|
||||
free (file);
|
||||
g_free (file);
|
||||
if (!info){
|
||||
errno = ferrno (vfs);
|
||||
return -1;
|
||||
@ -447,7 +444,7 @@ mc_open (char *file, int flags, ...)
|
||||
}
|
||||
|
||||
#define MC_NAMEOP(name, inarg, callarg) \
|
||||
MC_OP (name, inarg, callarg, path = vfs_canon (path); vfs = vfs_type (path);, free (path); )
|
||||
MC_OP (name, inarg, callarg, path = vfs_canon (path); vfs = vfs_type (path);, g_free (path); )
|
||||
#define MC_HANDLEOP(name, inarg, callarg) \
|
||||
MC_OP (name, inarg, callarg, if (handle == -1) return -1; vfs = vfs_op (handle);, )
|
||||
|
||||
@ -476,7 +473,7 @@ mc_setctl (char *path, int ctlop, char *arg)
|
||||
path = vfs_canon (path);
|
||||
vfs = vfs_type (path);
|
||||
result = vfs->setctl ? (*vfs->setctl)(vfs, path, ctlop, arg) : 0;
|
||||
free (path);
|
||||
g_free (path);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -510,22 +507,17 @@ mc_opendir (char *dirname)
|
||||
void *info;
|
||||
vfs *vfs;
|
||||
char *p = NULL;
|
||||
int i = strlen (dirname);
|
||||
|
||||
if (dirname [i - 1] != '/'){
|
||||
/* We should make possible reading of the root directory in a tar file */
|
||||
p = xmalloc (i + 2, "slash");
|
||||
strcpy (p, dirname);
|
||||
strcpy (p + i, "/");
|
||||
dirname = p;
|
||||
}
|
||||
dirname = p = append_path_sep (dirname);
|
||||
|
||||
dirname = vfs_canon (dirname);
|
||||
vfs = vfs_type (dirname);
|
||||
|
||||
info = vfs->opendir ? (*vfs->opendir)(vfs, dirname) : NULL;
|
||||
free (dirname);
|
||||
g_free (dirname);
|
||||
if (p)
|
||||
free (p);
|
||||
g_free (p);
|
||||
if (!info){
|
||||
errno = vfs->opendir ? ferrno (vfs) : E_NOTSUPP;
|
||||
return NULL;
|
||||
@ -534,7 +526,7 @@ mc_opendir (char *dirname)
|
||||
vfs_file_table [handle].fs_info = info;
|
||||
vfs_file_table [handle].operations = vfs;
|
||||
|
||||
handlep = (int *) xmalloc (sizeof (int), "opendir handle");
|
||||
handlep = g_new (int, 1);
|
||||
*handlep = handle;
|
||||
return (DIR *) handlep;
|
||||
}
|
||||
@ -591,7 +583,7 @@ mc_closedir (DIR *dirp)
|
||||
|
||||
result = vfs->closedir ? (*vfs->closedir)(vfs_info (handle)) : -1;
|
||||
vfs_free_bucket (handle);
|
||||
free (dirp);
|
||||
g_free (dirp);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -600,7 +592,7 @@ MC_NAMEOP (lstat, (char *path, struct stat *buf), (vfs, vfs_name (path), buf))
|
||||
MC_HANDLEOP (fstat, (int handle, struct stat *buf), (vfs_info (handle), buf))
|
||||
|
||||
/*
|
||||
* You must strdup whatever this function returns, static buffers are in use
|
||||
* You must g_strdup whatever this function returns, static buffers are in use
|
||||
*/
|
||||
|
||||
char *
|
||||
@ -622,8 +614,8 @@ mc_return_cwd (void)
|
||||
if (my_stat.st_ino != my_stat2.st_ino ||
|
||||
my_stat.st_dev != my_stat2.st_dev ||
|
||||
!cd_symlinks){
|
||||
free (current_dir);
|
||||
current_dir = strdup (p);
|
||||
g_free (current_dir);
|
||||
current_dir = g_strdup (p);
|
||||
return p;
|
||||
} /* Otherwise we return current_dir below */
|
||||
}
|
||||
@ -657,14 +649,14 @@ int mc_##name (char *name1, char *name2) \
|
||||
name2 = vfs_canon (name2); \
|
||||
if (vfs != vfs_type (name2)){ \
|
||||
errno = EXDEV; \
|
||||
free (name1); \
|
||||
free (name2); \
|
||||
g_free (name1); \
|
||||
g_free (name2); \
|
||||
return -1; \
|
||||
} \
|
||||
\
|
||||
result = vfs->name ? (*vfs->name)(vfs, vfs_name (name1), vfs_name (name2)) : -1; \
|
||||
free (name1); \
|
||||
free (name2); \
|
||||
g_free (name1); \
|
||||
g_free (name2); \
|
||||
if (result == -1) \
|
||||
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \
|
||||
return result; \
|
||||
@ -709,23 +701,23 @@ vfs_canon (char *path)
|
||||
local = tilde_expand (path);
|
||||
if (local){
|
||||
result = vfs_canon (local);
|
||||
free (local);
|
||||
g_free (local);
|
||||
return result;
|
||||
} else
|
||||
return strdup (path);
|
||||
return g_strdup (path);
|
||||
}
|
||||
|
||||
/* Relative to current directory */
|
||||
if (*path != '/'){
|
||||
if (*path != PATH_SEP){
|
||||
char *local, *result;
|
||||
|
||||
if (current_dir [strlen (current_dir) - 1] == '/')
|
||||
if (current_dir [strlen (current_dir) - 1] == PATH_SEP)
|
||||
local = copy_strings (current_dir, path, NULL);
|
||||
else
|
||||
local = copy_strings (current_dir, "/", path, NULL);
|
||||
local = copy_strings (current_dir, PATH_SEP_STR, path, NULL);
|
||||
|
||||
result = vfs_canon (local);
|
||||
free (local);
|
||||
g_free (local);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -737,23 +729,19 @@ vfs_canon (char *path)
|
||||
canonicalize_pathname (path);
|
||||
mad_check("(post-canonicalize)", 0);
|
||||
|
||||
return strdup (path);
|
||||
return g_strdup (path);
|
||||
}
|
||||
|
||||
vfsid
|
||||
vfs_ncs_getid (vfs *nvfs, char *dir, struct vfs_stamping **par)
|
||||
{
|
||||
vfsid nvfsid;
|
||||
int freeit = 0;
|
||||
|
||||
if (dir [strlen (dir) - 1] != '/'){
|
||||
dir = copy_strings (dir, "/", NULL);
|
||||
freeit = 1;
|
||||
dir = append_path_sep (dir);
|
||||
|
||||
}
|
||||
nvfsid = (*nvfs->getid)(nvfs, dir, par);
|
||||
if (freeit)
|
||||
free (dir);
|
||||
|
||||
g_free (dir);
|
||||
return nvfsid;
|
||||
}
|
||||
|
||||
@ -888,43 +876,36 @@ mc_chdir (char *path)
|
||||
char *a, *b;
|
||||
int result;
|
||||
char *p = NULL;
|
||||
int i = strlen (path);
|
||||
vfs *oldvfs;
|
||||
vfsid oldvfsid;
|
||||
struct vfs_stamping *parent;
|
||||
|
||||
if (path [i - 1] != '/'){
|
||||
/* We should make possible reading of the root directory in a tar archive */
|
||||
p = xmalloc (i + 2, "slash");
|
||||
strcpy (p, path);
|
||||
strcpy (p + i, "/");
|
||||
path = p;
|
||||
}
|
||||
path = p = append_path_sep (path);
|
||||
|
||||
a = current_dir; /* Save a copy for case of failure */
|
||||
current_dir = vfs_canon (path);
|
||||
current_vfs = vfs_type (current_dir);
|
||||
b = strdup (current_dir);
|
||||
b = g_strdup (current_dir);
|
||||
result = (*current_vfs->chdir) ? (*current_vfs->chdir)(current_vfs, vfs_name (b)) : -1;
|
||||
free (b);
|
||||
g_free (b);
|
||||
if (result == -1){
|
||||
errno = ferrno (current_vfs);
|
||||
free (current_dir);
|
||||
g_free (current_dir);
|
||||
current_vfs = vfs_type (a);
|
||||
current_dir = a;
|
||||
} else {
|
||||
oldvfs = vfs_type (a);
|
||||
oldvfsid = vfs_ncs_getid (oldvfs, a, &parent);
|
||||
free (a);
|
||||
g_free (a);
|
||||
vfs_add_noncurrent_stamps (oldvfs, oldvfsid, parent);
|
||||
vfs_rm_parents (parent);
|
||||
}
|
||||
if (p)
|
||||
free (p);
|
||||
g_free (p);
|
||||
|
||||
if (*current_dir){
|
||||
p = strchr (current_dir, 0) - 1;
|
||||
if (*p == '/' && p > current_dir)
|
||||
if (*p == PATH_SEP && p > current_dir)
|
||||
*p = 0; /* Sometimes we assume no trailing slash on cwd */
|
||||
}
|
||||
return result;
|
||||
@ -958,7 +939,7 @@ vfs_file_is_local (char *filename)
|
||||
|
||||
filename = vfs_canon (filename);
|
||||
vfs = vfs_type (filename);
|
||||
free (filename);
|
||||
g_free (filename);
|
||||
return vfs == &vfs_local_ops;
|
||||
}
|
||||
|
||||
@ -970,7 +951,7 @@ vfs_file_is_ftp (char *filename)
|
||||
|
||||
filename = vfs_canon (filename);
|
||||
vfs = vfs_type (filename);
|
||||
free (filename);
|
||||
g_free (filename);
|
||||
return vfs == &vfs_ftpfs_ops;
|
||||
#else
|
||||
return 0;
|
||||
@ -984,7 +965,7 @@ char *vfs_get_current_dir (void)
|
||||
|
||||
static void vfs_setup_wd (void)
|
||||
{
|
||||
current_dir = strdup ("/");
|
||||
current_dir = g_strdup (PATH_SEP_STR);
|
||||
if (!(vfs_flags & FL_NO_CWDSETUP))
|
||||
mc_return_cwd();
|
||||
|
||||
@ -1022,7 +1003,7 @@ mc_mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||
errno = ferrno (vfs);
|
||||
return (caddr_t)-1;
|
||||
}
|
||||
mcm = (struct mc_mmapping *) xmalloc (sizeof (struct mc_mmapping), "vfs: mmap handling");
|
||||
mcm =g_new (struct mc_mmapping, 1);
|
||||
mcm->addr = result;
|
||||
mcm->vfs_info = vfs_info (fd);
|
||||
mcm->vfs = vfs;
|
||||
@ -1044,7 +1025,7 @@ mc_munmap (caddr_t addr, size_t len)
|
||||
mcm2->next = mcm->next;
|
||||
if (*mcm->vfs->munmap)
|
||||
(*mcm->vfs->munmap)(mcm->vfs, addr, len, mcm->vfs_info);
|
||||
free (mcm);
|
||||
g_free (mcm);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1068,7 +1049,7 @@ mc_def_getlocalcopy (vfs *vfs, char *filename)
|
||||
fdout = open (tmp, O_CREAT|O_WRONLY|O_TRUNC|O_EXCL, 0600);
|
||||
if (fdout == -1){
|
||||
mc_close (fdin);
|
||||
free (tmp);
|
||||
g_free (tmp);
|
||||
return NULL;
|
||||
}
|
||||
while ((i = mc_read (fdin, buffer, sizeof (buffer))) == sizeof (buffer)){
|
||||
@ -1094,7 +1075,7 @@ mc_getlocalcopy (char *path)
|
||||
vfs = vfs_type (path);
|
||||
result = vfs->getlocalcopy ? (*vfs->getlocalcopy)(vfs, vfs_name (path)) :
|
||||
mc_def_getlocalcopy (vfs, vfs_name (path));
|
||||
free (path);
|
||||
g_free (path);
|
||||
if (!result)
|
||||
errno = ferrno (vfs);
|
||||
return result;
|
||||
@ -1110,14 +1091,14 @@ mc_def_ungetlocalcopy (vfs *vfs, char *filename, char *local, int has_changed)
|
||||
fdin = open (local, O_RDONLY);
|
||||
if (fdin == -1){
|
||||
unlink (local);
|
||||
free (local);
|
||||
g_free (local);
|
||||
return;
|
||||
}
|
||||
fdout = mc_open (filename, O_WRONLY | O_TRUNC);
|
||||
if (fdout == -1){
|
||||
close (fdin);
|
||||
unlink (local);
|
||||
free (local);
|
||||
g_free (local);
|
||||
return;
|
||||
}
|
||||
while ((i = read (fdin, buffer, sizeof (buffer))) == sizeof (buffer)){
|
||||
@ -1129,7 +1110,7 @@ mc_def_ungetlocalcopy (vfs *vfs, char *filename, char *local, int has_changed)
|
||||
mc_close (fdout);
|
||||
}
|
||||
unlink (local);
|
||||
free (local);
|
||||
g_free (local);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1141,7 +1122,7 @@ mc_ungetlocalcopy (char *path, char *local, int has_changed)
|
||||
vfs = vfs_type (path);
|
||||
vfs->ungetlocalcopy ? (*vfs->ungetlocalcopy)(vfs, vfs_name (path), local, has_changed) :
|
||||
mc_def_ungetlocalcopy (vfs, vfs_name (path), local, has_changed);
|
||||
free (path);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1253,7 +1234,7 @@ vfs_shut (void)
|
||||
for (stamp = stamps, stamps = 0; stamp != NULL;){
|
||||
(*stamp->v->free)(stamp->id);
|
||||
st = stamp->next;
|
||||
free (stamp);
|
||||
g_free (stamp);
|
||||
stamp = st;
|
||||
}
|
||||
|
||||
@ -1261,7 +1242,7 @@ vfs_shut (void)
|
||||
vfs_rmstamp (stamps->v, stamps->id, 1);
|
||||
|
||||
if (current_dir)
|
||||
free (current_dir);
|
||||
g_free (current_dir);
|
||||
|
||||
for (vfs=vfs_list; vfs; vfs=vfs->next)
|
||||
if (vfs->done)
|
||||
@ -1591,7 +1572,7 @@ vfs_parse_ls_lga (char *p, struct stat *s, char **filename, char **linkname)
|
||||
if (strncmp (p, "total", 5) == 0)
|
||||
return 0;
|
||||
|
||||
p_copy = strdup(p);
|
||||
p_copy = g_strdup(p);
|
||||
if ((i = vfs_parse_filetype(*(p++))) == -1)
|
||||
goto error;
|
||||
|
||||
@ -1616,8 +1597,8 @@ vfs_parse_ls_lga (char *p, struct stat *s, char **filename, char **linkname)
|
||||
p++;
|
||||
}
|
||||
|
||||
free(p_copy);
|
||||
p_copy = strdup(p);
|
||||
g_free(p_copy);
|
||||
p_copy = g_strdup(p);
|
||||
num_cols = vfs_split_text (p);
|
||||
|
||||
s->st_nlink = atol (columns [0]);
|
||||
@ -1702,14 +1683,11 @@ vfs_parse_ls_lga (char *p, struct stat *s, char **filename, char **linkname)
|
||||
char *s;
|
||||
|
||||
if (filename){
|
||||
p = column_ptr [idx2] - column_ptr [idx];
|
||||
s = xmalloc (p, "filename");
|
||||
strncpy (s, p_copy + column_ptr [idx], p - 1);
|
||||
s[p - 1] = '\0';
|
||||
s = g_strndup (p_copy + column_ptr [idx], column_ptr [idx2] - column_ptr [idx] - 1);
|
||||
*filename = s;
|
||||
}
|
||||
if (linkname){
|
||||
s = strdup (p_copy + column_ptr [idx2+1]);
|
||||
s = g_strdup (p_copy + column_ptr [idx2+1]);
|
||||
p = strlen (s);
|
||||
if (s [p-1] == '\r' || s [p-1] == '\n')
|
||||
s [p-1] = 0;
|
||||
@ -1724,13 +1702,14 @@ vfs_parse_ls_lga (char *p, struct stat *s, char **filename, char **linkname)
|
||||
*/
|
||||
if (filename){
|
||||
/*
|
||||
*filename = strdup (columns [idx++]);
|
||||
*filename = g_strdup (columns [idx++]);
|
||||
*/
|
||||
int p;
|
||||
char *s;
|
||||
|
||||
s = strdup (p_copy + column_ptr [idx++]);
|
||||
s = g_strdup (p_copy + column_ptr [idx++]);
|
||||
p = strlen (s);
|
||||
/* g_strchomp(); */
|
||||
if (s [p-1] == '\r' || s [p-1] == '\n')
|
||||
s [p-1] = 0;
|
||||
if (s [p-2] == '\r' || s [p-2] == '\n')
|
||||
@ -1741,13 +1720,13 @@ vfs_parse_ls_lga (char *p, struct stat *s, char **filename, char **linkname)
|
||||
if (linkname)
|
||||
*linkname = NULL;
|
||||
}
|
||||
free (p_copy);
|
||||
g_free (p_copy);
|
||||
return 1;
|
||||
|
||||
error:
|
||||
message_1s (1, "Could not parse:", p_copy);
|
||||
if (p_copy != p) /* Carefull! */
|
||||
free (p_copy);
|
||||
g_free (p_copy);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1779,13 +1758,13 @@ vfs_get_password (char *msg)
|
||||
|
||||
/*
|
||||
* Returns vfs path corresponding to given url. If passed string is
|
||||
* not recognized as url, strdup(url) is returned.
|
||||
* not recognized as url, g_strdup(url) is returned.
|
||||
*/
|
||||
char *
|
||||
vfs_translate_url (char *url)
|
||||
{
|
||||
if (strncmp (url, "ftp://", 6) == 0)
|
||||
return copy_strings ("/#ftp:", url + 6, 0);
|
||||
return copy_strings ("/#ftp:", url + 6, NULL);
|
||||
else
|
||||
return strdup (url);
|
||||
return g_strdup (url);
|
||||
}
|
||||
|
13
vfs/vfs.h
13
vfs/vfs.h
@ -6,10 +6,6 @@
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#if 0
|
||||
#include "src/mad.h"
|
||||
#endif
|
||||
|
||||
#if !defined(SCO_FLAVOR) || !defined(_SYS_SELECT_H) || defined(IS_AIX)
|
||||
# include <sys/time.h> /* alex: this redefines struct timeval */
|
||||
#endif /* SCO_FLAVOR */
|
||||
@ -242,7 +238,7 @@ struct utimbuf {
|
||||
# define vfs_current_is_tarfs() 0
|
||||
# define vfs_current_is_extfs() 0
|
||||
# define vfs_path(x) x
|
||||
# define vfs_strip_suffix_from_filename(x) strdup(x)
|
||||
# define vfs_strip_suffix_from_filename(x) g_strdup(x)
|
||||
# define mc_close close
|
||||
# define mc_read read
|
||||
# define mc_write write
|
||||
@ -275,7 +271,7 @@ struct utimbuf {
|
||||
|
||||
# define mc_ctl(a,b,c) 0
|
||||
# define mc_setctl(a,b,c) 0
|
||||
# define vfs_translate_url strdup(s)
|
||||
# define vfs_translate_url g_strdup(s)
|
||||
|
||||
# define mc_stat stat
|
||||
# define mc_mknod mknod
|
||||
@ -286,7 +282,7 @@ struct utimbuf {
|
||||
# define vfs_type(x) (vfs *)(NULL)
|
||||
# define vfs_init()
|
||||
# define vfs_shut()
|
||||
# define vfs_canon(p) strdup (canonicalize_pathname(p))
|
||||
# define vfs_canon(p) g_strdup (canonicalize_pathname(p))
|
||||
# define vfs_free_resources()
|
||||
# define vfs_timeout_handler()
|
||||
# define vfs_timeouts() 0
|
||||
@ -394,9 +390,6 @@ extern void mc_vfs_done( void );
|
||||
* cases (ftp transfer). -- pavel@ucw.cz
|
||||
*/
|
||||
|
||||
#define VFS_MIN(a,b) ((a)<(b) ? (a) : (b))
|
||||
#define VFS_MAX(a,b) ((a)<(b) ? (b) : (a))
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
#define MMAPNULL , NULL, NULL
|
||||
#else
|
||||
|
@ -15,10 +15,6 @@
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
|
||||
#include "../src/fs.h"
|
||||
#include "../src/util.h"
|
||||
#include "../src/mem.h"
|
||||
#include "../src/mad.h"
|
||||
#include "vfs.h"
|
||||
|
||||
|
||||
@ -220,7 +216,7 @@ int vfs_s_get_line (vfs *me, int sock, char *buf, int buf_len, char term);
|
||||
int vfs_s_get_line_interruptible (vfs *me, char *buffer, int size, int fd);
|
||||
|
||||
/* If non-null, FREE */
|
||||
#define ifree(ptr) do { if (ptr) free(ptr); } while (0)
|
||||
#define ifree(ptr) do { if (ptr) g_free(ptr); } while (0)
|
||||
|
||||
#define MEDATA ((struct vfs_s_data *) me->data)
|
||||
#define ERRNOR(a, b) do { me->verrno = a; return b; } while (0)
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user