* *.c: Rename functions that don't have an a prefix indicating
what file they are defined in. This simplifies debugging.
Этот коммит содержится в:
родитель
520f6ddb6c
Коммит
5bc20fd294
@ -1,5 +1,8 @@
|
||||
2003-10-27 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* *.c: Rename functions that don't have an a prefix indicating
|
||||
what file they are defined in. This simplifies debugging.
|
||||
|
||||
* vfs.c (mc_def_getlocalcopy): Use O_LINEAR when retrieving the
|
||||
remote file. This avoids an extra temporary file.
|
||||
|
||||
|
112
vfs/cpio.c
112
vfs/cpio.c
@ -97,11 +97,13 @@ static int cpio_read(void *fh, char *buffer, int count);
|
||||
#define CPIO_SEEK_SET(super, where) mc_lseek((super)->u.arch.fd, CPIO_POS(super) = (where), SEEK_SET)
|
||||
#define CPIO_SEEK_CUR(super, where) mc_lseek((super)->u.arch.fd, CPIO_POS(super) += (where), SEEK_SET)
|
||||
|
||||
static struct defer_inode * defer_find(struct defer_inode *l, struct defer_inode *i)
|
||||
static struct defer_inode *
|
||||
cpio_defer_find (struct defer_inode *l, struct defer_inode *i)
|
||||
{
|
||||
if(!l) return NULL;
|
||||
return l->inumber == i->inumber && l->device == i->device ? l :
|
||||
defer_find(l->next, i);
|
||||
if (!l)
|
||||
return NULL;
|
||||
return l->inumber == i->inumber
|
||||
&& l->device == i->device ? l : cpio_defer_find (l->next, i);
|
||||
}
|
||||
|
||||
static int cpio_skip_padding(struct vfs_s_super *super)
|
||||
@ -386,14 +388,16 @@ static int cpio_read_crc_head(struct vfs_class *me, struct vfs_s_super *super)
|
||||
return cpio_create_entry(me, super, &stat, name);
|
||||
}
|
||||
|
||||
static int cpio_create_entry(struct vfs_class *me, struct vfs_s_super *super, struct stat *stat, char *name)
|
||||
static int
|
||||
cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super,
|
||||
struct stat *stat, char *name)
|
||||
{
|
||||
struct vfs_s_inode *inode = NULL;
|
||||
struct vfs_s_inode *root = super->root;
|
||||
struct vfs_s_entry *entry = NULL;
|
||||
char *tn;
|
||||
|
||||
switch (stat->st_mode & S_IFMT) { /* For case of HP/UX archives */
|
||||
switch (stat->st_mode & S_IFMT) { /* For case of HP/UX archives */
|
||||
case S_IFCHR:
|
||||
case S_IFBLK:
|
||||
#ifdef S_IFSOCK
|
||||
@ -402,8 +406,7 @@ static int cpio_create_entry(struct vfs_class *me, struct vfs_s_super *super, st
|
||||
#ifdef S_IFIFO
|
||||
case S_IFIFO:
|
||||
#endif
|
||||
if((stat->st_size != 0) &&
|
||||
(stat->st_rdev == 0x0001)) {
|
||||
if ((stat->st_size != 0) && (stat->st_rdev == 0x0001)) {
|
||||
stat->st_rdev = (unsigned) stat->st_size;
|
||||
stat->st_size = 0;
|
||||
}
|
||||
@ -412,40 +415,44 @@ static int cpio_create_entry(struct vfs_class *me, struct vfs_s_super *super, st
|
||||
break;
|
||||
}
|
||||
|
||||
if((stat->st_nlink > 1) &&
|
||||
(super->u.arch.type == CPIO_NEWC ||
|
||||
super->u.arch.type == CPIO_CRC)) { /* For case of hardlinked files */
|
||||
if ((stat->st_nlink > 1) && (super->u.arch.type == CPIO_NEWC || super->u.arch.type == CPIO_CRC)) { /* For case of hardlinked files */
|
||||
struct defer_inode i, *l;
|
||||
i.inumber = stat->st_ino;
|
||||
i.device = stat->st_dev;
|
||||
i.inode = NULL;
|
||||
if((l = defer_find(super->u.arch.deferred, &i)) != NULL) {
|
||||
if ((l = cpio_defer_find (super->u.arch.deferred, &i)) != NULL) {
|
||||
inode = l->inode;
|
||||
if(inode->st.st_size && stat->st_size && (inode->st.st_size != stat->st_size)) {
|
||||
message (1, MSG_ERROR, _("Inconsistent hardlinks of\n%s\nin cpio archive\n%s"),
|
||||
name, super->name);
|
||||
if (inode->st.st_size && stat->st_size
|
||||
&& (inode->st.st_size != stat->st_size)) {
|
||||
message (1, MSG_ERROR,
|
||||
_
|
||||
("Inconsistent hardlinks of\n%s\nin cpio archive\n%s"),
|
||||
name, super->name);
|
||||
inode = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while(name[strlen(name)-1] == PATH_SEP) name[strlen(name)-1] = 0;
|
||||
if((tn = strrchr(name, PATH_SEP))) {
|
||||
while (name[strlen (name) - 1] == PATH_SEP)
|
||||
name[strlen (name) - 1] = 0;
|
||||
if ((tn = strrchr (name, PATH_SEP))) {
|
||||
*tn = 0;
|
||||
root = vfs_s_find_inode(me, super, name, LINK_FOLLOW, FL_MKDIR);
|
||||
root = vfs_s_find_inode (me, super, name, LINK_FOLLOW, FL_MKDIR);
|
||||
*tn = PATH_SEP;
|
||||
tn++;
|
||||
} else
|
||||
tn = name;
|
||||
|
||||
entry = vfs_s_find_entry_tree(me, root, tn, LINK_FOLLOW, FL_NONE); /* In case entry is already there */
|
||||
entry = vfs_s_find_entry_tree (me, root, tn, LINK_FOLLOW, FL_NONE); /* In case entry is already there */
|
||||
|
||||
if(entry) { /* This shouldn't happen! (well, it can happen if there is a record for a
|
||||
file and than a record for a directory it is in; cpio would die with
|
||||
'No such file or directory' is such case) */
|
||||
if (entry) { /* This shouldn't happen! (well, it can happen if there is a record for a
|
||||
file and than a record for a directory it is in; cpio would die with
|
||||
'No such file or directory' is such case) */
|
||||
|
||||
if(!S_ISDIR(entry->ino->st.st_mode)) { /* This can be considered archive inconsistency */
|
||||
message (1, MSG_ERROR, _("%s contains duplicate entries! Skipping!"), super->name);
|
||||
if (!S_ISDIR (entry->ino->st.st_mode)) { /* This can be considered archive inconsistency */
|
||||
message (1, MSG_ERROR,
|
||||
_("%s contains duplicate entries! Skipping!"),
|
||||
super->name);
|
||||
} else {
|
||||
entry->ino->st.st_mode = stat->st_mode;
|
||||
entry->ino->st.st_uid = stat->st_uid;
|
||||
@ -455,15 +462,13 @@ static int cpio_create_entry(struct vfs_class *me, struct vfs_s_super *super, st
|
||||
entry->ino->st.st_ctime = stat->st_ctime;
|
||||
}
|
||||
|
||||
} else { /* !entry */
|
||||
} else { /* !entry */
|
||||
|
||||
if(!inode) {
|
||||
inode = vfs_s_new_inode(me, super, stat);
|
||||
if((stat->st_nlink > 0) &&
|
||||
(super->u.arch.type == CPIO_NEWC ||
|
||||
super->u.arch.type == CPIO_CRC)) { /* For case of hardlinked files */
|
||||
if (!inode) {
|
||||
inode = vfs_s_new_inode (me, super, stat);
|
||||
if ((stat->st_nlink > 0) && (super->u.arch.type == CPIO_NEWC || super->u.arch.type == CPIO_CRC)) { /* For case of hardlinked files */
|
||||
struct defer_inode *i;
|
||||
i = g_new(struct defer_inode, 1);
|
||||
i = g_new (struct defer_inode, 1);
|
||||
i->inumber = stat->st_ino;
|
||||
i->device = stat->st_dev;
|
||||
i->inode = inode;
|
||||
@ -471,27 +476,28 @@ static int cpio_create_entry(struct vfs_class *me, struct vfs_s_super *super, st
|
||||
super->u.arch.deferred = i;
|
||||
}
|
||||
}
|
||||
|
||||
if(stat->st_size)
|
||||
inode->data_offset = CPIO_POS(super);
|
||||
|
||||
entry = vfs_s_new_entry(me, tn, inode);
|
||||
vfs_s_insert_entry(me, root, entry);
|
||||
|
||||
if(S_ISLNK(stat->st_mode)) {
|
||||
inode->linkname = g_malloc(stat->st_size + 1);
|
||||
if(mc_read(super->u.arch.fd, inode->linkname, stat->st_size) < stat->st_size) {
|
||||
if (stat->st_size)
|
||||
inode->data_offset = CPIO_POS (super);
|
||||
|
||||
entry = vfs_s_new_entry (me, tn, inode);
|
||||
vfs_s_insert_entry (me, root, entry);
|
||||
|
||||
if (S_ISLNK (stat->st_mode)) {
|
||||
inode->linkname = g_malloc (stat->st_size + 1);
|
||||
if (mc_read (super->u.arch.fd, inode->linkname, stat->st_size)
|
||||
< stat->st_size) {
|
||||
inode->linkname[0] = 0;
|
||||
return STATUS_EOF;
|
||||
}
|
||||
inode->linkname[stat->st_size] = 0; /* Linkname stored without terminating \0 !!! */
|
||||
CPIO_POS(super) += stat->st_size;
|
||||
cpio_skip_padding(super);
|
||||
inode->linkname[stat->st_size] = 0; /* Linkname stored without terminating \0 !!! */
|
||||
CPIO_POS (super) += stat->st_size;
|
||||
cpio_skip_padding (super);
|
||||
} else {
|
||||
CPIO_SEEK_CUR(super, stat->st_size);
|
||||
CPIO_SEEK_CUR (super, stat->st_size);
|
||||
}
|
||||
|
||||
} /* !entry */
|
||||
} /* !entry */
|
||||
|
||||
g_free (name);
|
||||
return STATUS_OK;
|
||||
@ -580,19 +586,19 @@ static int cpio_fh_open(struct vfs_class *me, struct vfs_s_fh *fh, int flags, in
|
||||
void
|
||||
init_cpiofs (void)
|
||||
{
|
||||
static struct vfs_s_subclass cpiofs_subclass;
|
||||
static struct vfs_s_subclass cpio_subclass;
|
||||
|
||||
cpiofs_subclass.archive_check = cpio_super_check;
|
||||
cpiofs_subclass.archive_same = cpio_super_same;
|
||||
cpiofs_subclass.open_archive = cpio_open_archive;
|
||||
cpiofs_subclass.free_archive = cpio_free_archive;
|
||||
cpiofs_subclass.fh_open = cpio_fh_open;
|
||||
cpiofs_subclass.find_entry = vfs_s_find_entry_tree;
|
||||
cpio_subclass.archive_check = cpio_super_check;
|
||||
cpio_subclass.archive_same = cpio_super_same;
|
||||
cpio_subclass.open_archive = cpio_open_archive;
|
||||
cpio_subclass.free_archive = cpio_free_archive;
|
||||
cpio_subclass.fh_open = cpio_fh_open;
|
||||
cpio_subclass.find_entry = vfs_s_find_entry_tree;
|
||||
|
||||
vfs_s_init_class (&vfs_cpiofs_ops);
|
||||
vfs_cpiofs_ops.name = "cpiofs";
|
||||
vfs_cpiofs_ops.prefix = "ucpio";
|
||||
vfs_cpiofs_ops.data = &cpiofs_subclass;
|
||||
vfs_cpiofs_ops.data = &cpio_subclass;
|
||||
vfs_cpiofs_ops.read = cpio_read;
|
||||
vfs_cpiofs_ops.write = NULL;
|
||||
vfs_cpiofs_ops.setctl = NULL;
|
||||
|
195
vfs/extfs.c
195
vfs/extfs.c
@ -76,10 +76,10 @@ struct pseudofile {
|
||||
struct entry *entry;
|
||||
};
|
||||
|
||||
static struct entry *
|
||||
find_entry (struct entry *dir, char *name, int make_dirs, int make_file);
|
||||
static struct entry *extfs_find_entry (struct entry *dir, char *name,
|
||||
int make_dirs, int make_file);
|
||||
static int extfs_which (struct vfs_class *me, char *path);
|
||||
static void remove_entry (struct entry *e);
|
||||
static void extfs_remove_entry (struct entry *e);
|
||||
static void extfs_free (vfsid id);
|
||||
|
||||
static struct vfs_class vfs_extfs_ops;
|
||||
@ -106,7 +106,7 @@ static void extfs_fill_names (struct vfs_class *me, void (*func)(char *))
|
||||
}
|
||||
}
|
||||
|
||||
static void make_dot_doubledot (struct entry *ent)
|
||||
static void extfs_make_dots (struct entry *ent)
|
||||
{
|
||||
struct entry *entry = g_new (struct entry, 1);
|
||||
struct entry *parentry = ent->dir;
|
||||
@ -136,7 +136,7 @@ static void make_dot_doubledot (struct entry *ent)
|
||||
}
|
||||
}
|
||||
|
||||
static struct entry *generate_entry (struct archive *archive,
|
||||
static struct entry *extfs_generate_entry (struct archive *archive,
|
||||
char *name, struct entry *parentry, mode_t mode)
|
||||
{
|
||||
mode_t myumask;
|
||||
@ -173,18 +173,18 @@ static struct entry *generate_entry (struct archive *archive,
|
||||
inode->ctime = inode->mtime;
|
||||
inode->nlink = 1;
|
||||
if (S_ISDIR (mode))
|
||||
make_dot_doubledot (entry);
|
||||
extfs_make_dots (entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
static void free_entries (struct entry *entry)
|
||||
static void extfs_free_entries (struct entry *entry)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void free_archive (struct archive *archive)
|
||||
static void extfs_free_archive (struct archive *archive)
|
||||
{
|
||||
free_entries (archive->root_entry);
|
||||
extfs_free_entries (archive->root_entry);
|
||||
if (archive->local_name != NULL) {
|
||||
struct stat my;
|
||||
|
||||
@ -199,7 +199,7 @@ static void free_archive (struct archive *archive)
|
||||
}
|
||||
|
||||
static FILE *
|
||||
open_archive (int fstype, char *name, struct archive **pparc)
|
||||
extfs_open_archive (int fstype, char *name, struct archive **pparc)
|
||||
{
|
||||
static dev_t __extfs_no = 0;
|
||||
FILE *result;
|
||||
@ -260,7 +260,7 @@ open_archive (int fstype, char *name, struct archive **pparc)
|
||||
if (mode & 0004)
|
||||
mode |= 0001;
|
||||
mode |= S_IFDIR;
|
||||
root_entry = generate_entry (current_archive, "/", NULL, mode);
|
||||
root_entry = extfs_generate_entry (current_archive, "/", NULL, mode);
|
||||
root_entry->inode->uid = mystat.st_uid;
|
||||
root_entry->inode->gid = mystat.st_gid;
|
||||
root_entry->inode->atime = mystat.st_atime;
|
||||
@ -279,14 +279,14 @@ open_archive (int fstype, char *name, struct archive **pparc)
|
||||
* Return 0 on success, -1 on error.
|
||||
*/
|
||||
static int
|
||||
read_archive (int fstype, char *name, struct archive **pparc)
|
||||
extfs_read_archive (int fstype, char *name, struct archive **pparc)
|
||||
{
|
||||
FILE *extfsd;
|
||||
char *buffer;
|
||||
struct archive *current_archive;
|
||||
char *current_file_name, *current_link_name;
|
||||
|
||||
if ((extfsd = open_archive (fstype, name, ¤t_archive)) == NULL) {
|
||||
if ((extfsd = extfs_open_archive (fstype, name, ¤t_archive)) == NULL) {
|
||||
message (1, MSG_ERROR, _("Cannot open %s archive\n%s"),
|
||||
extfs_prefixes[fstype], name);
|
||||
return -1;
|
||||
@ -320,7 +320,7 @@ read_archive (int fstype, char *name, struct archive **pparc)
|
||||
if (S_ISDIR (hstat.st_mode)
|
||||
&& (!strcmp (p, ".") || !strcmp (p, "..")))
|
||||
goto read_extfs_continue;
|
||||
pent = find_entry (current_archive->root_entry, q, 1, 0);
|
||||
pent = extfs_find_entry (current_archive->root_entry, q, 1, 0);
|
||||
if (pent == NULL) {
|
||||
/* FIXME: Should clean everything one day */
|
||||
g_free (buffer);
|
||||
@ -340,7 +340,7 @@ read_archive (int fstype, char *name, struct archive **pparc)
|
||||
}
|
||||
if (!S_ISLNK (hstat.st_mode) && current_link_name != NULL) {
|
||||
pent =
|
||||
find_entry (current_archive->root_entry,
|
||||
extfs_find_entry (current_archive->root_entry,
|
||||
current_link_name, 0, 0);
|
||||
if (pent == NULL) {
|
||||
/* FIXME: Should clean everything one day */
|
||||
@ -383,7 +383,7 @@ read_archive (int fstype, char *name, struct archive **pparc)
|
||||
inode->linkname = NULL;
|
||||
}
|
||||
if (S_ISDIR (hstat.st_mode))
|
||||
make_dot_doubledot (entry);
|
||||
extfs_make_dots (entry);
|
||||
}
|
||||
}
|
||||
read_extfs_continue:
|
||||
@ -407,11 +407,12 @@ read_archive (int fstype, char *name, struct archive **pparc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Returns path inside argument. Returned char* is inside inname, which is
|
||||
* mangled by this operation (so you must not free it's return value).
|
||||
/*
|
||||
* Returns path inside argument. Returned char* is inside inname, which is
|
||||
* mangled by this operation (so you must not free its return value).
|
||||
*/
|
||||
static char *
|
||||
get_path_mangle (char *inname, struct archive **archive, int is_dir,
|
||||
extfs_get_path_mangle (char *inname, struct archive **archive, int is_dir,
|
||||
int do_not_open)
|
||||
{
|
||||
char *local, *archive_name, *op;
|
||||
@ -447,7 +448,7 @@ get_path_mangle (char *inname, struct archive **archive, int is_dir,
|
||||
}
|
||||
}
|
||||
|
||||
result = do_not_open ? -1 : read_archive (fstype, archive_name, &parc);
|
||||
result = do_not_open ? -1 : extfs_read_archive (fstype, archive_name, &parc);
|
||||
if (result == -1)
|
||||
ERRNOR (EIO, NULL);
|
||||
|
||||
@ -469,11 +470,11 @@ get_path_mangle (char *inname, struct archive **archive, int is_dir,
|
||||
}
|
||||
|
||||
static char *
|
||||
get_path (const char *inname, struct archive **archive, int is_dir,
|
||||
extfs_get_path (const char *inname, struct archive **archive, int is_dir,
|
||||
int do_not_open)
|
||||
{
|
||||
char *buf = g_strdup (inname);
|
||||
char *res = get_path_mangle (buf, archive, is_dir, do_not_open);
|
||||
char *res = extfs_get_path_mangle (buf, archive, is_dir, do_not_open);
|
||||
char *res2 = NULL;
|
||||
if (res)
|
||||
res2 = g_strdup (res);
|
||||
@ -482,7 +483,7 @@ get_path (const char *inname, struct archive **archive, int is_dir,
|
||||
}
|
||||
|
||||
/* Returns allocated path (without leading slash) inside the archive */
|
||||
static char *get_path_from_entry (struct entry *entry)
|
||||
static char *extfs_get_path_from_entry (struct entry *entry)
|
||||
{
|
||||
struct list {
|
||||
struct list *next;
|
||||
@ -524,11 +525,11 @@ static int errloop;
|
||||
static int notadir;
|
||||
|
||||
static struct entry *
|
||||
__find_entry (struct entry *dir, char *name,
|
||||
extfs_find_entry_int (struct entry *dir, char *name,
|
||||
struct loop_protect *list, int make_dirs, int make_file);
|
||||
|
||||
static struct entry *
|
||||
__resolve_symlinks (struct entry *entry,
|
||||
extfs_resolve_symlinks_int (struct entry *entry,
|
||||
struct loop_protect *list)
|
||||
{
|
||||
struct entry *pent;
|
||||
@ -544,20 +545,20 @@ __resolve_symlinks (struct entry *entry,
|
||||
looping = g_new (struct loop_protect, 1);
|
||||
looping->entry = entry;
|
||||
looping->next = list;
|
||||
pent = __find_entry (entry->dir, entry->inode->linkname, looping, 0, 0);
|
||||
pent = extfs_find_entry_int (entry->dir, entry->inode->linkname, looping, 0, 0);
|
||||
g_free (looping);
|
||||
if (pent == NULL)
|
||||
my_errno = ENOENT;
|
||||
return pent;
|
||||
}
|
||||
|
||||
static struct entry *my_resolve_symlinks (struct entry *entry)
|
||||
static struct entry *extfs_resolve_symlinks (struct entry *entry)
|
||||
{
|
||||
struct entry *res;
|
||||
|
||||
errloop = 0;
|
||||
notadir = 0;
|
||||
res = __resolve_symlinks (entry, NULL);
|
||||
res = extfs_resolve_symlinks_int (entry, NULL);
|
||||
if (res == NULL) {
|
||||
if (errloop)
|
||||
my_errno = ELOOP;
|
||||
@ -567,7 +568,7 @@ static struct entry *my_resolve_symlinks (struct entry *entry)
|
||||
return res;
|
||||
}
|
||||
|
||||
static char *get_archive_name (struct archive *archive)
|
||||
static char *extfs_get_archive_name (struct archive *archive)
|
||||
{
|
||||
char *archive_name;
|
||||
|
||||
@ -595,10 +596,10 @@ extfs_cmd (const char *extfs_cmd, struct archive *archive,
|
||||
char *cmd;
|
||||
int retval;
|
||||
|
||||
file = get_path_from_entry (entry);
|
||||
file = extfs_get_path_from_entry (entry);
|
||||
quoted_file = name_quote (file, 0);
|
||||
g_free (file);
|
||||
archive_name = name_quote (get_archive_name (archive), 0);
|
||||
archive_name = name_quote (extfs_get_archive_name (archive), 0);
|
||||
quoted_localname = name_quote (localname, 0);
|
||||
|
||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR);
|
||||
@ -624,12 +625,12 @@ extfs_run (char *file)
|
||||
char *p, *q, *archive_name, *mc_extfsdir;
|
||||
char *cmd;
|
||||
|
||||
if ((p = get_path (file, &archive, 0, 0)) == NULL)
|
||||
if ((p = extfs_get_path (file, &archive, 0, 0)) == NULL)
|
||||
return;
|
||||
q = name_quote (p, 0);
|
||||
g_free (p);
|
||||
|
||||
archive_name = name_quote (get_archive_name (archive), 0);
|
||||
archive_name = name_quote (extfs_get_archive_name (archive), 0);
|
||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR);
|
||||
cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype],
|
||||
" run ", archive_name, " ", q, NULL);
|
||||
@ -650,17 +651,17 @@ extfs_open (struct vfs_class *me, char *file, int flags, int mode)
|
||||
int local_handle;
|
||||
int created = 0;
|
||||
|
||||
if ((q = get_path_mangle (file, &archive, 0, 0)) == NULL)
|
||||
if ((q = extfs_get_path_mangle (file, &archive, 0, 0)) == NULL)
|
||||
return NULL;
|
||||
entry = find_entry (archive->root_entry, q, 0, 0);
|
||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (entry == NULL && (flags & O_CREAT)) {
|
||||
/* Create new entry */
|
||||
entry = find_entry (archive->root_entry, q, 0, 1);
|
||||
entry = extfs_find_entry (archive->root_entry, q, 0, 1);
|
||||
created = (entry != NULL);
|
||||
}
|
||||
if (entry == NULL)
|
||||
return NULL;
|
||||
if ((entry = my_resolve_symlinks (entry)) == NULL)
|
||||
if ((entry = extfs_resolve_symlinks (entry)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (S_ISDIR (entry->inode->mode))
|
||||
@ -773,7 +774,7 @@ extfs_close (void *data)
|
||||
#define RECORDSIZE 512
|
||||
|
||||
static struct entry*
|
||||
__find_entry (struct entry *dir, char *name,
|
||||
extfs_find_entry_int (struct entry *dir, char *name,
|
||||
struct loop_protect *list, int make_dirs, int make_file)
|
||||
{
|
||||
struct entry *pent, *pdir;
|
||||
@ -801,7 +802,7 @@ __find_entry (struct entry *dir, char *name,
|
||||
if (!strcmp (p, ".."))
|
||||
pent = pent->dir;
|
||||
else {
|
||||
if ((pent = __resolve_symlinks (pent, list))==NULL){
|
||||
if ((pent = extfs_resolve_symlinks_int (pent, list))==NULL){
|
||||
*q = c;
|
||||
return NULL;
|
||||
}
|
||||
@ -827,10 +828,10 @@ __find_entry (struct entry *dir, char *name,
|
||||
* non-existant directories
|
||||
*/
|
||||
if (pent == NULL && make_dirs) {
|
||||
pent = generate_entry (dir->inode->archive, p, pdir, S_IFDIR | 0777);
|
||||
pent = extfs_generate_entry (dir->inode->archive, p, pdir, S_IFDIR | 0777);
|
||||
}
|
||||
if (pent == NULL && make_file) {
|
||||
pent = generate_entry (dir->inode->archive, p, pdir, S_IFREG | 0666);
|
||||
pent = extfs_generate_entry (dir->inode->archive, p, pdir, S_IFREG | 0666);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -846,13 +847,13 @@ __find_entry (struct entry *dir, char *name,
|
||||
return pent;
|
||||
}
|
||||
|
||||
static struct entry *find_entry (struct entry *dir, char *name, int make_dirs, int make_file)
|
||||
static struct entry *extfs_find_entry (struct entry *dir, char *name, int make_dirs, int make_file)
|
||||
{
|
||||
struct entry *res;
|
||||
|
||||
errloop = 0;
|
||||
notadir = 0;
|
||||
res = __find_entry (dir, name, NULL, make_dirs, make_file);
|
||||
res = extfs_find_entry_int (dir, name, NULL, make_dirs, make_file);
|
||||
if (res == NULL) {
|
||||
if (errloop)
|
||||
my_errno = ELOOP;
|
||||
@ -863,24 +864,24 @@ static struct entry *find_entry (struct entry *dir, char *name, int make_dirs, i
|
||||
}
|
||||
|
||||
|
||||
static int s_errno (struct vfs_class *me)
|
||||
static int extfs_errno (struct vfs_class *me)
|
||||
{
|
||||
return my_errno;
|
||||
}
|
||||
|
||||
static void * s_opendir (struct vfs_class *me, char *dirname)
|
||||
static void * extfs_opendir (struct vfs_class *me, char *dirname)
|
||||
{
|
||||
struct archive *archive;
|
||||
char *q;
|
||||
struct entry *entry;
|
||||
struct entry **info;
|
||||
|
||||
if ((q = get_path_mangle (dirname, &archive, 1, 0)) == NULL)
|
||||
if ((q = extfs_get_path_mangle (dirname, &archive, 1, 0)) == NULL)
|
||||
return NULL;
|
||||
entry = find_entry (archive->root_entry, q, 0, 0);
|
||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (entry == NULL)
|
||||
return NULL;
|
||||
if ((entry = my_resolve_symlinks (entry)) == NULL)
|
||||
if ((entry = extfs_resolve_symlinks (entry)) == NULL)
|
||||
return NULL;
|
||||
if (!S_ISDIR (entry->inode->mode)) ERRNOR (ENOTDIR, NULL);
|
||||
|
||||
@ -891,7 +892,7 @@ static void * s_opendir (struct vfs_class *me, char *dirname)
|
||||
return info;
|
||||
}
|
||||
|
||||
static void * s_readdir(void *data)
|
||||
static void * extfs_readdir(void *data)
|
||||
{
|
||||
static union vfs_dirent dir;
|
||||
struct entry **info = (struct entry **) data;
|
||||
@ -908,13 +909,13 @@ static void * s_readdir(void *data)
|
||||
return (void *) &dir;
|
||||
}
|
||||
|
||||
static int s_closedir (void *data)
|
||||
static int extfs_closedir (void *data)
|
||||
{
|
||||
g_free (data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void stat_move( struct stat *buf, struct inode *inode )
|
||||
static void extfs_stat_move( struct stat *buf, struct inode *inode )
|
||||
{
|
||||
buf->st_dev = inode->dev;
|
||||
buf->st_ino = inode->inode;
|
||||
@ -937,56 +938,56 @@ static void stat_move( struct stat *buf, struct inode *inode )
|
||||
buf->st_ctime = inode->ctime;
|
||||
}
|
||||
|
||||
static int s_internal_stat (char *path, struct stat *buf, int resolve)
|
||||
static int extfs_internal_stat (char *path, struct stat *buf, int resolve)
|
||||
{
|
||||
struct archive *archive;
|
||||
char *q;
|
||||
struct entry *entry;
|
||||
struct inode *inode;
|
||||
|
||||
if ((q = get_path_mangle (path, &archive, 0, 0)) == NULL)
|
||||
if ((q = extfs_get_path_mangle (path, &archive, 0, 0)) == NULL)
|
||||
return -1;
|
||||
entry = find_entry (archive->root_entry, q, 0, 0);
|
||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (entry == NULL)
|
||||
return -1;
|
||||
if (resolve && (entry = my_resolve_symlinks (entry)) == NULL)
|
||||
if (resolve && (entry = extfs_resolve_symlinks (entry)) == NULL)
|
||||
return -1;
|
||||
inode = entry->inode;
|
||||
stat_move( buf, inode );
|
||||
extfs_stat_move( buf, inode );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int s_stat (struct vfs_class *me, char *path, struct stat *buf)
|
||||
static int extfs_stat (struct vfs_class *me, char *path, struct stat *buf)
|
||||
{
|
||||
return s_internal_stat (path, buf, 1);
|
||||
return extfs_internal_stat (path, buf, 1);
|
||||
}
|
||||
|
||||
static int s_lstat (struct vfs_class *me, char *path, struct stat *buf)
|
||||
static int extfs_lstat (struct vfs_class *me, char *path, struct stat *buf)
|
||||
{
|
||||
return s_internal_stat (path, buf, 0);
|
||||
return extfs_internal_stat (path, buf, 0);
|
||||
}
|
||||
|
||||
static int s_fstat (void *data, struct stat *buf)
|
||||
static int extfs_fstat (void *data, struct stat *buf)
|
||||
{
|
||||
struct pseudofile *file = (struct pseudofile *)data;
|
||||
struct inode *inode;
|
||||
|
||||
inode = file->entry->inode;
|
||||
stat_move( buf, inode );
|
||||
extfs_stat_move( buf, inode );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
s_readlink (struct vfs_class *me, char *path, char *buf, int size)
|
||||
extfs_readlink (struct vfs_class *me, char *path, char *buf, int size)
|
||||
{
|
||||
struct archive *archive;
|
||||
char *q;
|
||||
int i;
|
||||
struct entry *entry;
|
||||
|
||||
if ((q = get_path_mangle (path, &archive, 0, 0)) == NULL)
|
||||
if ((q = extfs_get_path_mangle (path, &archive, 0, 0)) == NULL)
|
||||
return -1;
|
||||
entry = find_entry (archive->root_entry, q, 0, 0);
|
||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (entry == NULL)
|
||||
return -1;
|
||||
if (!S_ISLNK (entry->inode->mode))
|
||||
@ -1017,12 +1018,12 @@ static int extfs_unlink (struct vfs_class *me, char *file)
|
||||
char *q;
|
||||
struct entry *entry;
|
||||
|
||||
if ((q = get_path_mangle (file, &archive, 0, 0)) == NULL)
|
||||
if ((q = extfs_get_path_mangle (file, &archive, 0, 0)) == NULL)
|
||||
return -1;
|
||||
entry = find_entry (archive->root_entry, q, 0, 0);
|
||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (entry == NULL)
|
||||
return -1;
|
||||
if ((entry = my_resolve_symlinks (entry)) == NULL)
|
||||
if ((entry = extfs_resolve_symlinks (entry)) == NULL)
|
||||
return -1;
|
||||
if (S_ISDIR (entry->inode->mode)) ERRNOR (EISDIR, -1);
|
||||
|
||||
@ -1030,7 +1031,7 @@ static int extfs_unlink (struct vfs_class *me, char *file)
|
||||
my_errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
remove_entry (entry);
|
||||
extfs_remove_entry (entry);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1041,20 +1042,20 @@ static int extfs_mkdir (struct vfs_class *me, char *path, mode_t mode)
|
||||
char *q;
|
||||
struct entry *entry;
|
||||
|
||||
if ((q = get_path_mangle (path, &archive, 0, 0)) == NULL)
|
||||
if ((q = extfs_get_path_mangle (path, &archive, 0, 0)) == NULL)
|
||||
return -1;
|
||||
entry = find_entry (archive->root_entry, q, 0, 0);
|
||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (entry != NULL) ERRNOR (EEXIST, -1);
|
||||
entry = find_entry (archive->root_entry, q, 1, 0);
|
||||
entry = extfs_find_entry (archive->root_entry, q, 1, 0);
|
||||
if (entry == NULL)
|
||||
return -1;
|
||||
if ((entry = my_resolve_symlinks (entry)) == NULL)
|
||||
if ((entry = extfs_resolve_symlinks (entry)) == NULL)
|
||||
return -1;
|
||||
if (!S_ISDIR (entry->inode->mode)) ERRNOR (ENOTDIR, -1);
|
||||
|
||||
if (extfs_cmd (" mkdir ", archive, entry, "")){
|
||||
my_errno = EIO;
|
||||
remove_entry (entry);
|
||||
extfs_remove_entry (entry);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1067,12 +1068,12 @@ static int extfs_rmdir (struct vfs_class *me, char *path)
|
||||
char *q;
|
||||
struct entry *entry;
|
||||
|
||||
if ((q = get_path_mangle (path, &archive, 0, 0)) == NULL)
|
||||
if ((q = extfs_get_path_mangle (path, &archive, 0, 0)) == NULL)
|
||||
return -1;
|
||||
entry = find_entry (archive->root_entry, q, 0, 0);
|
||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (entry == NULL)
|
||||
return -1;
|
||||
if ((entry = my_resolve_symlinks (entry)) == NULL)
|
||||
if ((entry = extfs_resolve_symlinks (entry)) == NULL)
|
||||
return -1;
|
||||
if (!S_ISDIR (entry->inode->mode)) ERRNOR (ENOTDIR, -1);
|
||||
|
||||
@ -1080,7 +1081,7 @@ static int extfs_rmdir (struct vfs_class *me, char *path)
|
||||
my_errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
remove_entry (entry);
|
||||
extfs_remove_entry (entry);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1092,12 +1093,12 @@ static int extfs_chdir (struct vfs_class *me, char *path)
|
||||
struct entry *entry;
|
||||
|
||||
my_errno = ENOTDIR;
|
||||
if ((q = get_path_mangle (path, &archive, 1, 0)) == NULL)
|
||||
if ((q = extfs_get_path_mangle (path, &archive, 1, 0)) == NULL)
|
||||
return -1;
|
||||
entry = find_entry (archive->root_entry, q, 0, 0);
|
||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||
if (!entry)
|
||||
return -1;
|
||||
entry = my_resolve_symlinks (entry);
|
||||
entry = extfs_resolve_symlinks (entry);
|
||||
if ((!entry) || (!S_ISDIR (entry->inode->mode)))
|
||||
return -1;
|
||||
entry->inode->archive->current_dir = entry;
|
||||
@ -1121,7 +1122,7 @@ static vfsid extfs_getid (struct vfs_class *me, const char *path, struct vfs_sta
|
||||
char *p;
|
||||
|
||||
*parent = NULL;
|
||||
if (!(p = get_path (path, &archive, 1, 1)))
|
||||
if (!(p = extfs_get_path (path, &archive, 1, 1)))
|
||||
return (vfsid) -1;
|
||||
g_free(p);
|
||||
if (archive->name){
|
||||
@ -1145,7 +1146,7 @@ static int extfs_nothingisopen (vfsid id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void remove_entry (struct entry *e)
|
||||
static void extfs_remove_entry (struct entry *e)
|
||||
{
|
||||
int i = --(e->inode->nlink);
|
||||
struct entry *pe, *ent, *prev;
|
||||
@ -1153,7 +1154,7 @@ static void remove_entry (struct entry *e)
|
||||
if (S_ISDIR (e->inode->mode) && e->inode->first_in_subdir != NULL) {
|
||||
struct entry *f = e->inode->first_in_subdir;
|
||||
e->inode->first_in_subdir = NULL;
|
||||
remove_entry (f);
|
||||
extfs_remove_entry (f);
|
||||
}
|
||||
pe = e->dir;
|
||||
if (e == pe->inode->first_in_subdir)
|
||||
@ -1185,14 +1186,14 @@ static void remove_entry (struct entry *e)
|
||||
g_free (e);
|
||||
}
|
||||
|
||||
static void free_entry (struct entry *e)
|
||||
static void extfs_free_entry (struct entry *e)
|
||||
{
|
||||
int i = --(e->inode->nlink);
|
||||
if (S_ISDIR (e->inode->mode) && e->inode->first_in_subdir != NULL) {
|
||||
struct entry *f = e->inode->first_in_subdir;
|
||||
|
||||
e->inode->first_in_subdir = NULL;
|
||||
free_entry (f);
|
||||
extfs_free_entry (f);
|
||||
}
|
||||
if (i <= 0) {
|
||||
if (e->inode->local_filename != NULL) {
|
||||
@ -1204,7 +1205,7 @@ static void free_entry (struct entry *e)
|
||||
g_free (e->inode);
|
||||
}
|
||||
if (e->next_in_dir != NULL)
|
||||
free_entry (e->next_in_dir);
|
||||
extfs_free_entry (e->next_in_dir);
|
||||
g_free (e->name);
|
||||
g_free (e);
|
||||
}
|
||||
@ -1214,7 +1215,7 @@ static void extfs_free (vfsid id)
|
||||
struct archive *parc;
|
||||
struct archive *archive = (struct archive *)id;
|
||||
|
||||
free_entry (archive->root_entry);
|
||||
extfs_free_entry (archive->root_entry);
|
||||
if (archive == first_archive) {
|
||||
first_archive = archive->next;
|
||||
} else {
|
||||
@ -1224,7 +1225,7 @@ static void extfs_free (vfsid id)
|
||||
if (parc != NULL)
|
||||
parc->next = archive->next;
|
||||
}
|
||||
free_archive (archive);
|
||||
extfs_free_archive (archive);
|
||||
}
|
||||
|
||||
static char *extfs_getlocalcopy (struct vfs_class *me, char *path)
|
||||
@ -1366,17 +1367,17 @@ init_extfs (void)
|
||||
vfs_extfs_ops.close = extfs_close;
|
||||
vfs_extfs_ops.read = extfs_read;
|
||||
vfs_extfs_ops.write = extfs_write;
|
||||
vfs_extfs_ops.opendir = s_opendir;
|
||||
vfs_extfs_ops.readdir = s_readdir;
|
||||
vfs_extfs_ops.closedir = s_closedir;
|
||||
vfs_extfs_ops.stat = s_stat;
|
||||
vfs_extfs_ops.lstat = s_lstat;
|
||||
vfs_extfs_ops.fstat = s_fstat;
|
||||
vfs_extfs_ops.opendir = extfs_opendir;
|
||||
vfs_extfs_ops.readdir = extfs_readdir;
|
||||
vfs_extfs_ops.closedir = extfs_closedir;
|
||||
vfs_extfs_ops.stat = extfs_stat;
|
||||
vfs_extfs_ops.lstat = extfs_lstat;
|
||||
vfs_extfs_ops.fstat = extfs_fstat;
|
||||
vfs_extfs_ops.chmod = extfs_chmod;
|
||||
vfs_extfs_ops.readlink = s_readlink;
|
||||
vfs_extfs_ops.readlink = extfs_readlink;
|
||||
vfs_extfs_ops.unlink = extfs_unlink;
|
||||
vfs_extfs_ops.chdir = extfs_chdir;
|
||||
vfs_extfs_ops.ferrno = s_errno;
|
||||
vfs_extfs_ops.ferrno = extfs_errno;
|
||||
vfs_extfs_ops.lseek = extfs_lseek;
|
||||
vfs_extfs_ops.getid = extfs_getid;
|
||||
vfs_extfs_ops.nothingisopen = extfs_nothingisopen;
|
||||
|
205
vfs/fish.c
205
vfs/fish.c
@ -75,10 +75,11 @@ static char reply_str [80];
|
||||
static struct vfs_class vfs_fish_ops;
|
||||
|
||||
static int
|
||||
command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, const char *fmt, ...)
|
||||
fish_command (struct vfs_class *me, struct vfs_s_super *super,
|
||||
int wait_reply, const char *fmt, ...)
|
||||
__attribute__ ((format (printf, 4, 5)));
|
||||
|
||||
static int decode_reply (char *s, int was_garbage)
|
||||
static int fish_decode_reply (char *s, int was_garbage)
|
||||
{
|
||||
int code;
|
||||
if (!sscanf(s, "%d", &code)) {
|
||||
@ -90,7 +91,7 @@ static int decode_reply (char *s, int was_garbage)
|
||||
}
|
||||
|
||||
/* Returns a reply code, check /usr/include/arpa/ftp.h for possible values */
|
||||
static int get_reply (struct vfs_class *me, int sock, char *string_buf, int string_len)
|
||||
static int fish_get_reply (struct vfs_class *me, int sock, char *string_buf, int string_len)
|
||||
{
|
||||
char answer[1024];
|
||||
int was_garbage = 0;
|
||||
@ -107,14 +108,15 @@ static int get_reply (struct vfs_class *me, int sock, char *string_buf, int stri
|
||||
strncpy(string_buf, answer, string_len - 1);
|
||||
*(string_buf + string_len - 1) = 0;
|
||||
}
|
||||
} else return decode_reply(answer+4, was_garbage);
|
||||
} else return fish_decode_reply(answer+4, was_garbage);
|
||||
}
|
||||
}
|
||||
|
||||
#define SUP super->u.fish
|
||||
|
||||
static int
|
||||
command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, const char *fmt, ...)
|
||||
fish_command (struct vfs_class *me, struct vfs_s_super *super,
|
||||
int wait_reply, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *str;
|
||||
@ -126,33 +128,36 @@ command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, const
|
||||
str = g_strdup_vprintf (fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
if (logfile){
|
||||
fwrite (str, strlen (str), 1, logfile);
|
||||
if (logfile) {
|
||||
fwrite (str, strlen (str), 1, logfile);
|
||||
fflush (logfile);
|
||||
}
|
||||
|
||||
enable_interrupt_key();
|
||||
enable_interrupt_key ();
|
||||
|
||||
status = write(SUP.sockw, str, strlen(str));
|
||||
status = write (SUP.sockw, str, strlen (str));
|
||||
g_free (str);
|
||||
|
||||
disable_interrupt_key();
|
||||
disable_interrupt_key ();
|
||||
if (status < 0)
|
||||
return TRANSIENT;
|
||||
|
||||
|
||||
if (wait_reply)
|
||||
return get_reply (me, SUP.sockr, (wait_reply & WANT_STRING) ? reply_str : NULL, sizeof (reply_str)-1);
|
||||
return fish_get_reply (me, SUP.sockr,
|
||||
(wait_reply & WANT_STRING) ? reply_str :
|
||||
NULL, sizeof (reply_str) - 1);
|
||||
return COMPLETE;
|
||||
}
|
||||
|
||||
static void
|
||||
free_archive (struct vfs_class *me, struct vfs_s_super *super)
|
||||
fish_free_archive (struct vfs_class *me, struct vfs_s_super *super)
|
||||
{
|
||||
if ((SUP.sockw != -1) || (SUP.sockr != -1)){
|
||||
print_vfs_message (_("fish: Disconnecting from %s"), super->name?super->name:"???");
|
||||
command(me, super, NONE, "#BYE\nexit\n");
|
||||
close(SUP.sockw);
|
||||
close(SUP.sockr);
|
||||
if ((SUP.sockw != -1) || (SUP.sockr != -1)) {
|
||||
print_vfs_message (_("fish: Disconnecting from %s"),
|
||||
super->name ? super->name : "???");
|
||||
fish_command (me, super, NONE, "#BYE\nexit\n");
|
||||
close (SUP.sockw);
|
||||
close (SUP.sockr);
|
||||
SUP.sockw = SUP.sockr = -1;
|
||||
}
|
||||
g_free (SUP.host);
|
||||
@ -162,7 +167,7 @@ free_archive (struct vfs_class *me, struct vfs_s_super *super)
|
||||
}
|
||||
|
||||
static void
|
||||
pipeopen(struct vfs_s_super *super, char *path, char *argv[])
|
||||
fish_pipeopen(struct vfs_s_super *super, char *path, char *argv[])
|
||||
{
|
||||
int fileset1[2], fileset2[2];
|
||||
int res;
|
||||
@ -194,12 +199,13 @@ pipeopen(struct vfs_s_super *super, char *path, char *argv[])
|
||||
/* The returned directory should always contain a trailing slash */
|
||||
static char *fish_getcwd(struct vfs_class *me, struct vfs_s_super *super)
|
||||
{
|
||||
if (command(me, super, WANT_STRING, "#PWD\npwd; echo '### 200'\n") == COMPLETE)
|
||||
if (fish_command (me, super, WANT_STRING, "#PWD\npwd; echo '### 200'\n") == COMPLETE)
|
||||
return g_strconcat (reply_str, "/", NULL);
|
||||
ERRNOR (EIO, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
{
|
||||
char *argv[100];
|
||||
char *xsh = (SUP.flags == FISH_FLAG_RSH ? "rsh" : "ssh");
|
||||
@ -213,84 +219,94 @@ open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
argv[i++] = SUP.user;
|
||||
argv[i++] = SUP.host;
|
||||
if (SUP.flags == FISH_FLAG_COMPRESSED)
|
||||
argv[i++] = "-C";
|
||||
argv[i++] = "-C";
|
||||
argv[i++] = "echo FISH:; /bin/sh";
|
||||
argv[i++] = NULL;
|
||||
|
||||
#if 0
|
||||
/* Debugging hack */
|
||||
if (!MEDATA->logfile)
|
||||
MEDATA->logfile = fopen( "/home/pavel/talk.fish", "w+" ); /* FIXME */
|
||||
MEDATA->logfile = fopen ("/home/pavel/talk.fish", "w+"); /* FIXME */
|
||||
#endif
|
||||
|
||||
pipeopen(super, xsh, argv );
|
||||
fish_pipeopen (super, xsh, argv);
|
||||
|
||||
{
|
||||
char answer[2048];
|
||||
print_vfs_message( _("fish: Waiting for initial line...") );
|
||||
if (!vfs_s_get_line(me, SUP.sockr, answer, sizeof(answer), ':'))
|
||||
char answer[2048];
|
||||
print_vfs_message (_("fish: Waiting for initial line..."));
|
||||
if (!vfs_s_get_line (me, SUP.sockr, answer, sizeof (answer), ':'))
|
||||
ERRNOR (E_PROTO, -1);
|
||||
print_vfs_message( answer );
|
||||
if (strstr(answer, "assword")) {
|
||||
print_vfs_message (answer);
|
||||
if (strstr (answer, "assword")) {
|
||||
|
||||
/* Currently, this does not work. ssh reads passwords from
|
||||
/dev/tty, not from stdin :-(. */
|
||||
/* Currently, this does not work. ssh reads passwords from
|
||||
/dev/tty, not from stdin :-(. */
|
||||
|
||||
#ifndef HAVE_HACKED_SSH
|
||||
message (1, MSG_ERROR, _("Sorry, we cannot do password authenticated connections for now."));
|
||||
message (1, MSG_ERROR,
|
||||
_
|
||||
("Sorry, we cannot do password authenticated connections for now."));
|
||||
ERRNOR (EPERM, -1);
|
||||
#endif
|
||||
if (!SUP.password){
|
||||
if (!SUP.password) {
|
||||
char *p, *op;
|
||||
p = g_strconcat (_(" fish: Password required for "), SUP.user,
|
||||
" ", NULL);
|
||||
p = g_strconcat (_(" fish: Password required for "),
|
||||
SUP.user, " ", NULL);
|
||||
op = vfs_get_password (p);
|
||||
g_free (p);
|
||||
if (op == NULL)
|
||||
ERRNOR (EPERM, -1);
|
||||
SUP.password = g_strdup (op);
|
||||
wipe_password(op);
|
||||
wipe_password (op);
|
||||
}
|
||||
print_vfs_message( _("fish: Sending password...") );
|
||||
write(SUP.sockw, SUP.password, strlen(SUP.password));
|
||||
write(SUP.sockw, "\n", 1);
|
||||
print_vfs_message (_("fish: Sending password..."));
|
||||
write (SUP.sockw, SUP.password, strlen (SUP.password));
|
||||
write (SUP.sockw, "\n", 1);
|
||||
}
|
||||
}
|
||||
|
||||
print_vfs_message( _("fish: Sending initial line...") );
|
||||
print_vfs_message (_("fish: Sending initial line..."));
|
||||
/*
|
||||
* Run `start_fish_server'. If it doesn't exist - no problem,
|
||||
* we'll talk directly to the shell.
|
||||
*/
|
||||
if (command (me, super, WAIT_REPLY,
|
||||
"#FISH\necho; start_fish_server 2>&1;"
|
||||
" echo '### 200'\n") != COMPLETE)
|
||||
ERRNOR (E_PROTO, -1);
|
||||
if (fish_command
|
||||
(me, super, WAIT_REPLY,
|
||||
"#FISH\necho; start_fish_server 2>&1;" " echo '### 200'\n") !=
|
||||
COMPLETE)
|
||||
ERRNOR (E_PROTO, -1);
|
||||
|
||||
print_vfs_message( _("fish: Handshaking version...") );
|
||||
if (command (me, super, WAIT_REPLY, "#VER 0.0.0\necho '### 000'\n") != COMPLETE)
|
||||
ERRNOR (E_PROTO, -1);
|
||||
print_vfs_message (_("fish: Handshaking version..."));
|
||||
if (fish_command
|
||||
(me, super, WAIT_REPLY,
|
||||
"#VER 0.0.0\necho '### 000'\n") != COMPLETE)
|
||||
ERRNOR (E_PROTO, -1);
|
||||
|
||||
/* Set up remote locale to C, otherwise dates cannot be recognized */
|
||||
if (command (me, super, WAIT_REPLY, "LANG=C; LC_ALL=C; LC_TIME=C\n"
|
||||
"export LANG; export LC_ALL; export LC_TIME\n"
|
||||
"echo '### 200'\n") != COMPLETE)
|
||||
ERRNOR (E_PROTO, -1);
|
||||
if (fish_command
|
||||
(me, super, WAIT_REPLY,
|
||||
"LANG=C; LC_ALL=C; LC_TIME=C\n"
|
||||
"export LANG; export LC_ALL; export LC_TIME\n" "echo '### 200'\n")
|
||||
!= COMPLETE)
|
||||
ERRNOR (E_PROTO, -1);
|
||||
|
||||
print_vfs_message( _("fish: Setting up current directory...") );
|
||||
print_vfs_message (_("fish: Setting up current directory..."));
|
||||
SUP.cwdir = fish_getcwd (me, super);
|
||||
print_vfs_message( _("fish: Connected, home %s."), SUP.cwdir );
|
||||
print_vfs_message (_("fish: Connected, home %s."), SUP.cwdir);
|
||||
#if 0
|
||||
super->name = g_strconcat ( "/#sh:", SUP.user, "@", SUP.host, "/", NULL );
|
||||
super->name =
|
||||
g_strconcat ("/#sh:", SUP.user, "@", SUP.host, "/", NULL);
|
||||
#endif
|
||||
super->name = g_strdup(PATH_SEP_STR);
|
||||
super->name = g_strdup (PATH_SEP_STR);
|
||||
|
||||
super->root = vfs_s_new_inode (me, super, vfs_s_default_stat(me, S_IFDIR | 0755));
|
||||
super->root =
|
||||
vfs_s_new_inode (me, super,
|
||||
vfs_s_default_stat (me, S_IFDIR | 0755));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
open_archive (struct vfs_class *me, struct vfs_s_super *super, char *archive_name, char *op)
|
||||
fish_open_archive (struct vfs_class *me, struct vfs_s_super *super, char *archive_name, char *op)
|
||||
{
|
||||
char *host, *user, *password, *p;
|
||||
int flags;
|
||||
@ -308,11 +324,11 @@ open_archive (struct vfs_class *me, struct vfs_s_super *super, char *archive_nam
|
||||
SUP.cwdir = NULL;
|
||||
if (password)
|
||||
SUP.password = password;
|
||||
return open_archive_int (me, super);
|
||||
return fish_open_archive_int (me, super);
|
||||
}
|
||||
|
||||
static int
|
||||
archive_same(struct vfs_class *me, struct vfs_s_super *super, char *archive_name, char *op, void *cookie)
|
||||
fish_archive_same(struct vfs_class *me, struct vfs_s_super *super, char *archive_name, char *op, void *cookie)
|
||||
{
|
||||
char *host, *user;
|
||||
int flags;
|
||||
@ -332,7 +348,7 @@ archive_same(struct vfs_class *me, struct vfs_s_super *super, char *archive_name
|
||||
}
|
||||
|
||||
static int
|
||||
dir_uptodate(struct vfs_class *me, struct vfs_s_inode *ino)
|
||||
fish_dir_uptodate(struct vfs_class *me, struct vfs_s_inode *ino)
|
||||
{
|
||||
struct timeval tim;
|
||||
|
||||
@ -347,7 +363,7 @@ dir_uptodate(struct vfs_class *me, struct vfs_s_inode *ino)
|
||||
}
|
||||
|
||||
static int
|
||||
dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
fish_dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
{
|
||||
struct vfs_s_super *super = dir->super;
|
||||
char buffer[8192];
|
||||
@ -363,7 +379,7 @@ dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
dir->timestamp.tv_sec += 10; /* was 360: 10 is good for
|
||||
stressing direntry layer a bit */
|
||||
quoted_path = name_quote (remote_path, 0);
|
||||
command(me, super, NONE,
|
||||
fish_command (me, super, NONE,
|
||||
"#LIST /%s\n"
|
||||
"ls -lLa /%s 2>/dev/null | grep '^[^cbt]' | (\n"
|
||||
"while read p x u g s m d y n; do\n"
|
||||
@ -378,8 +394,7 @@ dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
"echo '### 200'\n",
|
||||
remote_path, quoted_path, quoted_path);
|
||||
g_free (quoted_path);
|
||||
#define SIMPLE_ENTRY vfs_s_generate_entry(me, NULL, dir, 0)
|
||||
ent = SIMPLE_ENTRY;
|
||||
ent = vfs_s_generate_entry(me, NULL, dir, 0);
|
||||
while (1) {
|
||||
int res = vfs_s_get_line_interruptible (me, buffer, sizeof (buffer), SUP.sockr);
|
||||
if ((!res) || (res == EINTR)) {
|
||||
@ -397,7 +412,7 @@ dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
if ((!buffer[0])) {
|
||||
if (ent->name) {
|
||||
vfs_s_insert_entry(me, dir, ent);
|
||||
ent = SIMPLE_ENTRY;
|
||||
ent = vfs_s_generate_entry(me, NULL, dir, 0);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -457,7 +472,7 @@ dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
|
||||
vfs_s_free_entry (me, ent);
|
||||
me->verrno = E_REMOTE;
|
||||
if (decode_reply(buffer+4, 0) == COMPLETE) {
|
||||
if (fish_decode_reply(buffer+4, 0) == COMPLETE) {
|
||||
g_free (SUP.cwdir);
|
||||
SUP.cwdir = g_strdup (remote_path);
|
||||
print_vfs_message (_("%s: done."), me->name);
|
||||
@ -470,7 +485,7 @@ error:
|
||||
}
|
||||
|
||||
static int
|
||||
file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *localname)
|
||||
fish_file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *localname)
|
||||
{
|
||||
struct vfs_s_super *super = FH_SUPER;
|
||||
int n, total;
|
||||
@ -495,7 +510,7 @@ file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *localnam
|
||||
|
||||
/* FIXME: File size is limited to ULONG_MAX */
|
||||
if (!fh->u.fish.append)
|
||||
n = command (me, super, WAIT_REPLY,
|
||||
n = fish_command (me, super, WAIT_REPLY,
|
||||
"#STOR %lu /%s\n"
|
||||
"> /%s\n"
|
||||
"echo '### 001'\n"
|
||||
@ -508,7 +523,7 @@ file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *localnam
|
||||
(unsigned long) s.st_size, name, quoted_name,
|
||||
(unsigned long) s.st_size, quoted_name);
|
||||
else
|
||||
n = command (me, super, WAIT_REPLY,
|
||||
n = fish_command (me, super, WAIT_REPLY,
|
||||
"#STOR %lu /%s\n"
|
||||
"echo '### 001'\n"
|
||||
"(\n"
|
||||
@ -548,16 +563,16 @@ file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *localnam
|
||||
(unsigned long) s.st_size);
|
||||
}
|
||||
close(h);
|
||||
if ((get_reply (me, SUP.sockr, NULL, 0) != COMPLETE) || was_error)
|
||||
if ((fish_get_reply (me, SUP.sockr, NULL, 0) != COMPLETE) || was_error)
|
||||
ERRNOR (E_REMOTE, -1);
|
||||
return 0;
|
||||
error_return:
|
||||
close(h);
|
||||
get_reply(me, SUP.sockr, NULL, 0);
|
||||
fish_get_reply(me, SUP.sockr, NULL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int linear_start(struct vfs_class *me, struct vfs_s_fh *fh, int offset)
|
||||
static int fish_linear_start(struct vfs_class *me, struct vfs_s_fh *fh, int offset)
|
||||
{
|
||||
char *name;
|
||||
char *quoted_name;
|
||||
@ -570,7 +585,7 @@ static int linear_start(struct vfs_class *me, struct vfs_s_fh *fh, int offset)
|
||||
g_free (name);
|
||||
name = quoted_name;
|
||||
fh->u.fish.append = 0;
|
||||
offset = command(me, FH_SUPER, WANT_STRING,
|
||||
offset = fish_command (me, FH_SUPER, WANT_STRING,
|
||||
"#RETR /%s\n"
|
||||
"ls -l /%s 2>/dev/null | (\n"
|
||||
"read var1 var2 var3 var4 var5 var6\n"
|
||||
@ -590,7 +605,7 @@ static int linear_start(struct vfs_class *me, struct vfs_s_fh *fh, int offset)
|
||||
}
|
||||
|
||||
static void
|
||||
linear_abort (struct vfs_class *me, struct vfs_s_fh *fh)
|
||||
fish_linear_abort (struct vfs_class *me, struct vfs_s_fh *fh)
|
||||
{
|
||||
struct vfs_s_super *super = FH_SUPER;
|
||||
char buffer[8192];
|
||||
@ -604,14 +619,14 @@ linear_abort (struct vfs_class *me, struct vfs_s_fh *fh)
|
||||
return;
|
||||
} while (n);
|
||||
|
||||
if (get_reply (me, SUP.sockr, NULL, 0) != COMPLETE)
|
||||
if (fish_get_reply (me, SUP.sockr, NULL, 0) != COMPLETE)
|
||||
print_vfs_message( _("Error reported after abort.") );
|
||||
else
|
||||
print_vfs_message( _("Aborted transfer would be successful.") );
|
||||
}
|
||||
|
||||
static int
|
||||
linear_read (struct vfs_class *me, struct vfs_s_fh *fh, void *buf, int len)
|
||||
fish_linear_read (struct vfs_class *me, struct vfs_s_fh *fh, void *buf, int len)
|
||||
{
|
||||
struct vfs_s_super *super = FH_SUPER;
|
||||
int n = 0;
|
||||
@ -625,17 +640,17 @@ linear_read (struct vfs_class *me, struct vfs_s_fh *fh, void *buf, int len)
|
||||
enable_interrupt_key();
|
||||
|
||||
if (n>0) fh->u.fish.got += n;
|
||||
if (n<0) linear_abort(me, fh);
|
||||
if ((!n) && ((get_reply (me, SUP.sockr, NULL, 0) != COMPLETE)))
|
||||
if (n<0) fish_linear_abort(me, fh);
|
||||
if ((!n) && ((fish_get_reply (me, SUP.sockr, NULL, 0) != COMPLETE)))
|
||||
ERRNOR (E_REMOTE, -1);
|
||||
ERRNOR (errno, n);
|
||||
}
|
||||
|
||||
static void
|
||||
linear_close (struct vfs_class *me, struct vfs_s_fh *fh)
|
||||
fish_linear_close (struct vfs_class *me, struct vfs_s_fh *fh)
|
||||
{
|
||||
if (fh->u.fish.total != fh->u.fish.got)
|
||||
linear_abort(me, fh);
|
||||
fish_linear_abort(me, fh);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -663,11 +678,11 @@ fish_ctl (void *fh, int ctlop, void *arg)
|
||||
}
|
||||
|
||||
static int
|
||||
send_fish_command(struct vfs_class *me, struct vfs_s_super *super, char *cmd, int flags)
|
||||
fish_send_command(struct vfs_class *me, struct vfs_s_super *super, char *cmd, int flags)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = command (me, super, WAIT_REPLY, cmd);
|
||||
r = fish_command (me, super, WAIT_REPLY, cmd);
|
||||
vfs_add_noncurrent_stamps (&vfs_fish_ops, (vfsid) super, NULL);
|
||||
if (r != COMPLETE) ERRNOR (E_REMOTE, -1);
|
||||
if (flags & OPT_FLUSH)
|
||||
@ -685,7 +700,7 @@ send_fish_command(struct vfs_class *me, struct vfs_s_super *super, char *cmd, in
|
||||
|
||||
#define POSTFIX(flags) \
|
||||
g_free (rpath); \
|
||||
return send_fish_command(me, super, buf, flags);
|
||||
return fish_send_command(me, super, buf, flags);
|
||||
|
||||
static int
|
||||
fish_chmod (struct vfs_class *me, char *path, int mode)
|
||||
@ -714,7 +729,7 @@ static int fish_##name (struct vfs_class *me, char *path1, char *path2) \
|
||||
g_snprintf(buf, sizeof(buf), string "\n", rpath1, rpath2, rpath1, rpath2); \
|
||||
g_free (rpath1); \
|
||||
g_free (rpath2); \
|
||||
return send_fish_command(me, super2, buf, OPT_FLUSH); \
|
||||
return fish_send_command(me, super2, buf, OPT_FLUSH); \
|
||||
}
|
||||
|
||||
#define XTEST if (bucket1 != bucket2) { ERRNOR (EXDEV, -1); }
|
||||
@ -760,7 +775,7 @@ fish_chown (struct vfs_class *me, char *path, int owner, int group)
|
||||
"echo '### 000'\n",
|
||||
sowner, rpath,
|
||||
sowner, rpath);
|
||||
send_fish_command(me, super, buf, OPT_FLUSH);
|
||||
fish_send_command(me, super, buf, OPT_FLUSH);
|
||||
/* FIXME: what should we report if chgrp succeeds but chown fails? */
|
||||
g_snprintf(buf, sizeof(buf),
|
||||
"#CHGRP /%s /%s\n"
|
||||
@ -768,7 +783,7 @@ fish_chown (struct vfs_class *me, char *path, int owner, int group)
|
||||
"echo '### 000'\n",
|
||||
sgroup, rpath,
|
||||
sgroup, rpath);
|
||||
/* send_fish_command(me, super, buf, OPT_FLUSH); */
|
||||
/* fish_send_command(me, super, buf, OPT_FLUSH); */
|
||||
POSTFIX(OPT_FLUSH)
|
||||
}
|
||||
|
||||
@ -863,17 +878,17 @@ init_fish (void)
|
||||
{
|
||||
static struct vfs_s_subclass fish_subclass;
|
||||
|
||||
fish_subclass.archive_same = archive_same;
|
||||
fish_subclass.open_archive = open_archive;
|
||||
fish_subclass.free_archive = free_archive;
|
||||
fish_subclass.archive_same = fish_archive_same;
|
||||
fish_subclass.open_archive = fish_open_archive;
|
||||
fish_subclass.free_archive = fish_free_archive;
|
||||
fish_subclass.fh_open = fish_fh_open;
|
||||
fish_subclass.find_entry = vfs_s_find_entry_linear;
|
||||
fish_subclass.dir_load = dir_load;
|
||||
fish_subclass.dir_uptodate = dir_uptodate;
|
||||
fish_subclass.file_store = file_store;
|
||||
fish_subclass.linear_start = linear_start;
|
||||
fish_subclass.linear_read = linear_read;
|
||||
fish_subclass.linear_close = linear_close;
|
||||
fish_subclass.dir_load = fish_dir_load;
|
||||
fish_subclass.dir_uptodate = fish_dir_uptodate;
|
||||
fish_subclass.file_store = fish_file_store;
|
||||
fish_subclass.linear_start = fish_linear_start;
|
||||
fish_subclass.linear_read = fish_linear_read;
|
||||
fish_subclass.linear_close = fish_linear_close;
|
||||
|
||||
vfs_s_init_class (&vfs_fish_ops);
|
||||
vfs_fish_ops.name = "fish";
|
||||
|
307
vfs/ftpfs.c
307
vfs/ftpfs.c
@ -92,7 +92,7 @@ What to do with this?
|
||||
#define RFC_STRICT 2
|
||||
|
||||
|
||||
static int my_errno;
|
||||
static int ftpfs_errno;
|
||||
static int code;
|
||||
|
||||
/* Delay to retry a connection */
|
||||
@ -128,7 +128,7 @@ int ftpfs_always_use_proxy;
|
||||
static struct linklist *connections_list;
|
||||
#endif
|
||||
|
||||
/* command wait_flag: */
|
||||
/* ftpfs_command wait_flag: */
|
||||
#define NONE 0x00
|
||||
#define WAIT_REPLY 0x01
|
||||
#define WANT_STRING 0x02
|
||||
@ -136,7 +136,7 @@ static char reply_str [80];
|
||||
|
||||
static struct vfs_class vfs_ftpfs_ops;
|
||||
|
||||
/* char *translate_path (struct ftpfs_connection *bucket, char *remote_path)
|
||||
/* char *ftpfs_translate_path (struct ftpfs_connection *bucket, char *remote_path)
|
||||
Translate a Unix path, i.e. MC's internal path representation (e.g.
|
||||
/somedir/somefile) to a path valid for the remote server. Every path
|
||||
transfered to the remote server has to be mangled by this function
|
||||
@ -151,14 +151,14 @@ static struct vfs_class vfs_ftpfs_ops;
|
||||
|
||||
static char *ftpfs_get_current_directory (struct vfs_class *me, struct vfs_s_super *super);
|
||||
static int ftpfs_chdir_internal (struct vfs_class *me, struct vfs_s_super *super, char *remote_path);
|
||||
static int command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, const char *fmt, ...)
|
||||
static int ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, const char *fmt, ...)
|
||||
__attribute__ ((format (printf, 4, 5)));
|
||||
static int ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super);
|
||||
static int login_server (struct vfs_class *me, struct vfs_s_super *super, const char *netrcpass);
|
||||
static int lookup_netrc (const char *host, char **login, char **pass);
|
||||
static int ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, const char *netrcpass);
|
||||
static int ftpfs_netrc_lookup (const char *host, char **login, char **pass);
|
||||
|
||||
static char *
|
||||
translate_path (struct vfs_class *me, struct vfs_s_super *super, const char *remote_path)
|
||||
ftpfs_translate_path (struct vfs_class *me, struct vfs_s_super *super, const char *remote_path)
|
||||
{
|
||||
if (!SUP.remote_is_amiga)
|
||||
return g_strdup (remote_path);
|
||||
@ -166,7 +166,7 @@ translate_path (struct vfs_class *me, struct vfs_s_super *super, const char *rem
|
||||
char *ret, *p;
|
||||
|
||||
if (MEDATA->logfile) {
|
||||
fprintf (MEDATA->logfile, "MC -- translate_path: %s\n", remote_path);
|
||||
fprintf (MEDATA->logfile, "MC -- ftpfs_translate_path: %s\n", remote_path);
|
||||
fflush (MEDATA->logfile);
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ translate_path (struct vfs_class *me, struct vfs_s_super *super, const char *rem
|
||||
#define FTP_COMMAND_PORT 21
|
||||
|
||||
static void
|
||||
ftp_split_url(char *path, char **host, char **user, int *port, char **pass)
|
||||
ftpfs_split_url(char *path, char **host, char **user, int *port, char **pass)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -220,7 +220,7 @@ ftp_split_url(char *path, char **host, char **user, int *port, char **pass)
|
||||
if (!*user) {
|
||||
/* Look up user and password in netrc */
|
||||
if (use_netrc)
|
||||
lookup_netrc (*host, user, pass);
|
||||
ftpfs_netrc_lookup (*host, user, pass);
|
||||
if (!*user)
|
||||
*user = g_strdup ("anonymous");
|
||||
}
|
||||
@ -229,7 +229,7 @@ ftp_split_url(char *path, char **host, char **user, int *port, char **pass)
|
||||
if (use_netrc && *user && pass && !*pass) {
|
||||
char *new_user;
|
||||
|
||||
lookup_netrc (*host, &new_user, pass);
|
||||
ftpfs_netrc_lookup (*host, &new_user, pass);
|
||||
|
||||
/* If user is different, remove password */
|
||||
if (new_user && strcmp (*user, new_user)) {
|
||||
@ -246,7 +246,7 @@ ftp_split_url(char *path, char **host, char **user, int *port, char **pass)
|
||||
|
||||
/* Returns a reply code, check /usr/include/arpa/ftp.h for possible values */
|
||||
static int
|
||||
get_reply (struct vfs_class *me, int sock, char *string_buf, int string_len)
|
||||
ftpfs_get_reply (struct vfs_class *me, int sock, char *string_buf, int string_len)
|
||||
{
|
||||
char answer[BUF_1K];
|
||||
int i;
|
||||
@ -290,7 +290,7 @@ get_reply (struct vfs_class *me, int sock, char *string_buf, int string_len)
|
||||
}
|
||||
|
||||
static int
|
||||
reconnect (struct vfs_class *me, struct vfs_s_super *super)
|
||||
ftpfs_reconnect (struct vfs_class *me, struct vfs_s_super *super)
|
||||
{
|
||||
int sock = ftpfs_open_socket (me, super);
|
||||
if (sock != -1){
|
||||
@ -298,7 +298,7 @@ reconnect (struct vfs_class *me, struct vfs_s_super *super)
|
||||
close (SUP.sock);
|
||||
SUP.sock = sock;
|
||||
SUP.cwdir = NULL;
|
||||
if (login_server (me, super, SUP.password)){
|
||||
if (ftpfs_login_server (me, super, SUP.password)){
|
||||
if (!cwdir)
|
||||
return 1;
|
||||
sock = ftpfs_chdir_internal (me, super, cwdir);
|
||||
@ -311,7 +311,7 @@ reconnect (struct vfs_class *me, struct vfs_s_super *super)
|
||||
}
|
||||
|
||||
static int
|
||||
command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, const char *fmt, ...)
|
||||
ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *cmdstr;
|
||||
@ -343,10 +343,10 @@ command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, const
|
||||
code = 421;
|
||||
|
||||
if (errno == EPIPE) { /* Remote server has closed connection */
|
||||
static int level = 0; /* login_server() use command() */
|
||||
static int level = 0; /* ftpfs_login_server() use ftpfs_command() */
|
||||
if (level == 0) {
|
||||
level = 1;
|
||||
status = reconnect (me, super);
|
||||
status = ftpfs_reconnect (me, super);
|
||||
level = 0;
|
||||
if (status && (write (SUP.sock, cmdstr, cmdlen) > 0)) {
|
||||
goto ok;
|
||||
@ -364,18 +364,18 @@ command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, const
|
||||
disable_interrupt_key ();
|
||||
|
||||
if (wait_reply)
|
||||
return get_reply (me, SUP.sock,
|
||||
return ftpfs_get_reply (me, SUP.sock,
|
||||
(wait_reply & WANT_STRING) ? reply_str : NULL,
|
||||
sizeof (reply_str) - 1);
|
||||
return COMPLETE;
|
||||
}
|
||||
|
||||
static void
|
||||
free_archive (struct vfs_class *me, struct vfs_s_super *super)
|
||||
ftpfs_free_archive (struct vfs_class *me, struct vfs_s_super *super)
|
||||
{
|
||||
if (SUP.sock != -1){
|
||||
print_vfs_message (_("ftpfs: Disconnecting from %s"), SUP.host);
|
||||
command(me, super, NONE, "QUIT");
|
||||
ftpfs_command(me, super, NONE, "QUIT");
|
||||
close(SUP.sock);
|
||||
}
|
||||
g_free (SUP.host);
|
||||
@ -384,20 +384,20 @@ free_archive (struct vfs_class *me, struct vfs_s_super *super)
|
||||
g_free (SUP.password);
|
||||
}
|
||||
|
||||
/* some defines only used by changetype */
|
||||
/* some defines only used by ftpfs_changetype */
|
||||
/* These two are valid values for the second parameter */
|
||||
#define TYPE_ASCII 0
|
||||
#define TYPE_BINARY 1
|
||||
|
||||
/* This one is only used to initialize bucket->isbinary, don't use it as
|
||||
second parameter to changetype. */
|
||||
second parameter to ftpfs_changetype. */
|
||||
#define TYPE_UNKNOWN -1
|
||||
|
||||
static int
|
||||
changetype (struct vfs_class *me, struct vfs_s_super *super, int binary)
|
||||
ftpfs_changetype (struct vfs_class *me, struct vfs_s_super *super, int binary)
|
||||
{
|
||||
if (binary != SUP.isbinary) {
|
||||
if (command (me, super, WAIT_REPLY, "TYPE %c", binary ? 'I' : 'A') != COMPLETE)
|
||||
if (ftpfs_command (me, super, WAIT_REPLY, "TYPE %c", binary ? 'I' : 'A') != COMPLETE)
|
||||
ERRNOR (EIO, -1);
|
||||
SUP.isbinary = binary;
|
||||
}
|
||||
@ -406,7 +406,7 @@ changetype (struct vfs_class *me, struct vfs_s_super *super, int binary)
|
||||
|
||||
/* This routine logs the user in */
|
||||
static int
|
||||
login_server (struct vfs_class *me, struct vfs_s_super *super, const char *netrcpass)
|
||||
ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, const char *netrcpass)
|
||||
{
|
||||
char *pass;
|
||||
char *op;
|
||||
@ -455,7 +455,7 @@ login_server (struct vfs_class *me, struct vfs_s_super *super, const char *netrc
|
||||
} else
|
||||
name = g_strdup (SUP.user);
|
||||
|
||||
if (get_reply (me, SUP.sock, reply_string, sizeof (reply_string) - 1)
|
||||
if (ftpfs_get_reply (me, SUP.sock, reply_string, sizeof (reply_string) - 1)
|
||||
== COMPLETE) {
|
||||
g_strup (reply_string);
|
||||
SUP.remote_is_amiga = strstr (reply_string, "AMIGA") != 0;
|
||||
@ -467,10 +467,10 @@ login_server (struct vfs_class *me, struct vfs_s_super *super, const char *netrc
|
||||
|
||||
print_vfs_message (_("ftpfs: sending login name"));
|
||||
|
||||
switch (command (me, super, WAIT_REPLY, "USER %s", name)) {
|
||||
switch (ftpfs_command (me, super, WAIT_REPLY, "USER %s", name)) {
|
||||
case CONTINUE:
|
||||
print_vfs_message (_("ftpfs: sending user password"));
|
||||
code = command (me, super, WAIT_REPLY, "PASS %s", pass);
|
||||
code = ftpfs_command (me, super, WAIT_REPLY, "PASS %s", pass);
|
||||
if (code == CONTINUE) {
|
||||
char *p;
|
||||
|
||||
@ -482,7 +482,7 @@ login_server (struct vfs_class *me, struct vfs_s_super *super, const char *netrc
|
||||
if (op == NULL)
|
||||
ERRNOR (EPERM, 0);
|
||||
print_vfs_message (_("ftpfs: sending user account"));
|
||||
code = command (me, super, WAIT_REPLY, "ACCT %s", op);
|
||||
code = ftpfs_command (me, super, WAIT_REPLY, "ACCT %s", op);
|
||||
g_free (op);
|
||||
}
|
||||
if (code != COMPLETE)
|
||||
@ -518,7 +518,7 @@ static struct no_proxy_entry {
|
||||
} *no_proxy;
|
||||
|
||||
static void
|
||||
load_no_proxy_list (void)
|
||||
ftpfs_load_no_proxy_list (void)
|
||||
{
|
||||
/* FixMe: shouldn't be hardcoded!!! */
|
||||
char s[BUF_LARGE]; /* provide for BUF_LARGE characters */
|
||||
@ -579,7 +579,7 @@ ftpfs_check_proxy (const char *host)
|
||||
if (!strchr (host, '.'))
|
||||
return 0;
|
||||
|
||||
load_no_proxy_list ();
|
||||
ftpfs_load_no_proxy_list ();
|
||||
for (npe = no_proxy; npe; npe=npe->next) {
|
||||
char *domain = npe->domain;
|
||||
|
||||
@ -629,7 +629,7 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super)
|
||||
|
||||
if (!host || !*host){
|
||||
print_vfs_message (_("ftpfs: Invalid host name."));
|
||||
my_errno = EINVAL;
|
||||
ftpfs_errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -647,7 +647,7 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super)
|
||||
hp = gethostbyname (host);
|
||||
if (hp == NULL){
|
||||
print_vfs_message (_("ftpfs: Invalid host address."));
|
||||
my_errno = EINVAL;
|
||||
ftpfs_errno = EINVAL;
|
||||
if (free_host)
|
||||
g_free (host);
|
||||
return -1;
|
||||
@ -662,7 +662,7 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super)
|
||||
|
||||
/* Connect */
|
||||
if ((my_socket = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||
my_errno = errno;
|
||||
ftpfs_errno = errno;
|
||||
if (free_host)
|
||||
g_free (host);
|
||||
return -1;
|
||||
@ -676,7 +676,7 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super)
|
||||
|
||||
if (connect (my_socket, (struct sockaddr *) &server_address,
|
||||
sizeof (server_address)) < 0){
|
||||
my_errno = errno;
|
||||
ftpfs_errno = errno;
|
||||
if (errno == EINTR && got_interrupt ())
|
||||
print_vfs_message (_("ftpfs: connection interrupted by user"));
|
||||
else
|
||||
@ -691,7 +691,7 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super)
|
||||
}
|
||||
|
||||
static int
|
||||
open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
ftpfs_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
{
|
||||
int retry_seconds, count_down;
|
||||
|
||||
@ -707,7 +707,7 @@ open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
if (SUP.sock == -1)
|
||||
return -1;
|
||||
|
||||
if (login_server (me, super, NULL)) {
|
||||
if (ftpfs_login_server (me, super, NULL)) {
|
||||
/* Logged in, no need to retry the connection */
|
||||
break;
|
||||
} else {
|
||||
@ -724,7 +724,7 @@ open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
print_vfs_message (_("Waiting to retry... %d (Control-C to cancel)"), count_down);
|
||||
sleep (1);
|
||||
if (got_interrupt ()){
|
||||
/* my_errno = E; */
|
||||
/* ftpfs_errno = E; */
|
||||
disable_interrupt_key ();
|
||||
return 0;
|
||||
}
|
||||
@ -741,12 +741,12 @@ open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
}
|
||||
|
||||
static int
|
||||
open_archive (struct vfs_class *me, struct vfs_s_super *super, char *archive_name, char *op)
|
||||
ftpfs_open_archive (struct vfs_class *me, struct vfs_s_super *super, char *archive_name, char *op)
|
||||
{
|
||||
char *host, *user, *password;
|
||||
int port;
|
||||
|
||||
ftp_split_url (strchr (op, ':') + 1, &host, &user, &port, &password);
|
||||
ftpfs_split_url (strchr (op, ':') + 1, &host, &user, &port, &password);
|
||||
|
||||
SUP.host = host;
|
||||
SUP.user = user;
|
||||
@ -763,20 +763,20 @@ open_archive (struct vfs_class *me, struct vfs_s_super *super, char *archive_nam
|
||||
super->name = g_strdup("/");
|
||||
super->root = vfs_s_new_inode (me, super, vfs_s_default_stat(me, S_IFDIR | 0755));
|
||||
|
||||
return open_archive_int (me, super);
|
||||
return ftpfs_open_archive_int (me, super);
|
||||
}
|
||||
|
||||
static int
|
||||
archive_same(struct vfs_class *me, struct vfs_s_super *super, char *archive_name, char *op, void *cookie)
|
||||
{
|
||||
ftpfs_archive_same (struct vfs_class *me, struct vfs_s_super *super,
|
||||
char *archive_name, char *op, void *cookie)
|
||||
{
|
||||
char *host, *user;
|
||||
int port;
|
||||
|
||||
ftp_split_url (strchr(op, ':') + 1, &host, &user, &port, 0);
|
||||
ftpfs_split_url (strchr (op, ':') + 1, &host, &user, &port, 0);
|
||||
|
||||
port = ((strcmp (host, SUP.host) == 0) &&
|
||||
(strcmp (user, SUP.user) == 0) &&
|
||||
(port == SUP.port));
|
||||
port = ((strcmp (host, SUP.host) == 0)
|
||||
&& (strcmp (user, SUP.user) == 0) && (port == SUP.port));
|
||||
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
@ -785,7 +785,7 @@ archive_same(struct vfs_class *me, struct vfs_s_super *super, char *archive_name
|
||||
}
|
||||
|
||||
static int
|
||||
dir_uptodate(struct vfs_class *me, struct vfs_s_inode *ino)
|
||||
ftpfs_dir_uptodate(struct vfs_class *me, struct vfs_s_inode *ino)
|
||||
{
|
||||
struct timeval tim;
|
||||
|
||||
@ -805,8 +805,8 @@ ftpfs_get_current_directory (struct vfs_class *me, struct vfs_s_super *super)
|
||||
{
|
||||
char buf[BUF_8K], *bufp, *bufq;
|
||||
|
||||
if (command (me, super, NONE, "PWD") == COMPLETE &&
|
||||
get_reply(me, SUP.sock, buf, sizeof(buf)) == COMPLETE) {
|
||||
if (ftpfs_command (me, super, NONE, "PWD") == COMPLETE &&
|
||||
ftpfs_get_reply(me, SUP.sock, buf, sizeof(buf)) == COMPLETE) {
|
||||
bufp = NULL;
|
||||
for (bufq = buf; *bufq; bufq++)
|
||||
if (*bufq == '"') {
|
||||
@ -828,26 +828,26 @@ ftpfs_get_current_directory (struct vfs_class *me, struct vfs_s_super *super)
|
||||
return g_strconcat( "/", bufp, 0);
|
||||
}
|
||||
} else {
|
||||
my_errno = EIO;
|
||||
ftpfs_errno = EIO;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
my_errno = EIO;
|
||||
ftpfs_errno = EIO;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Setup Passive ftp connection, we use it for source routed connections */
|
||||
static int
|
||||
setup_passive (struct vfs_class *me, struct vfs_s_super *super, int my_socket, struct sockaddr_in *sa)
|
||||
ftpfs_setup_passive (struct vfs_class *me, struct vfs_s_super *super, int my_socket, struct sockaddr_in *sa)
|
||||
{
|
||||
int xa, xb, xc, xd, xe, xf;
|
||||
char n [6];
|
||||
char *c;
|
||||
|
||||
if (command (me, super, WAIT_REPLY | WANT_STRING, "PASV") != COMPLETE)
|
||||
if (ftpfs_command (me, super, WAIT_REPLY | WANT_STRING, "PASV") != COMPLETE)
|
||||
return 0;
|
||||
|
||||
/* Parse remote parameters */
|
||||
@ -874,7 +874,7 @@ setup_passive (struct vfs_class *me, struct vfs_s_super *super, int my_socket, s
|
||||
}
|
||||
|
||||
static int
|
||||
initconn (struct vfs_class *me, struct vfs_s_super *super)
|
||||
ftpfs_initconn (struct vfs_class *me, struct vfs_s_super *super)
|
||||
{
|
||||
struct sockaddr_in data_addr;
|
||||
int data;
|
||||
@ -894,13 +894,13 @@ again:
|
||||
ERRNOR (EIO, -1);
|
||||
|
||||
if (SUP.use_passive_connection) {
|
||||
if (setup_passive (me, super, data, &data_addr))
|
||||
if (ftpfs_setup_passive (me, super, data, &data_addr))
|
||||
return data;
|
||||
|
||||
SUP.use_passive_connection = 0;
|
||||
print_vfs_message (_("ftpfs: could not setup passive mode"));
|
||||
|
||||
/* data or data_addr may be damaged by setup_passive */
|
||||
/* data or data_addr may be damaged by ftpfs_setup_passive */
|
||||
close (data);
|
||||
goto again;
|
||||
}
|
||||
@ -914,39 +914,39 @@ again:
|
||||
unsigned char *a = (unsigned char *)&data_addr.sin_addr;
|
||||
unsigned char *p = (unsigned char *)&data_addr.sin_port;
|
||||
|
||||
if (command (me, super, WAIT_REPLY, "PORT %d,%d,%d,%d,%d,%d", a[0], a[1],
|
||||
if (ftpfs_command (me, super, WAIT_REPLY, "PORT %d,%d,%d,%d,%d,%d", a[0], a[1],
|
||||
a[2], a[3], p[0], p[1]) == COMPLETE)
|
||||
return data;
|
||||
}
|
||||
close (data);
|
||||
my_errno = EIO;
|
||||
ftpfs_errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
open_data_connection (struct vfs_class *me, struct vfs_s_super *super, const char *cmd,
|
||||
ftpfs_open_data_connection (struct vfs_class *me, struct vfs_s_super *super, const char *cmd,
|
||||
const char *remote, int isbinary, int reget)
|
||||
{
|
||||
struct sockaddr_in from;
|
||||
int s, j, data, fromlen = sizeof(from);
|
||||
|
||||
if ((s = initconn (me, super)) == -1)
|
||||
if ((s = ftpfs_initconn (me, super)) == -1)
|
||||
return -1;
|
||||
if (changetype (me, super, isbinary) == -1)
|
||||
if (ftpfs_changetype (me, super, isbinary) == -1)
|
||||
return -1;
|
||||
if (reget > 0){
|
||||
j = command (me, super, WAIT_REPLY, "REST %d", reget);
|
||||
j = ftpfs_command (me, super, WAIT_REPLY, "REST %d", reget);
|
||||
if (j != CONTINUE)
|
||||
return -1;
|
||||
}
|
||||
if (remote) {
|
||||
char *remote_path = translate_path (me, super, remote);
|
||||
j = command (me, super, WAIT_REPLY, "%s /%s", cmd,
|
||||
char *remote_path = ftpfs_translate_path (me, super, remote);
|
||||
j = ftpfs_command (me, super, WAIT_REPLY, "%s /%s", cmd,
|
||||
/* WarFtpD can't STORE //filename */
|
||||
(*remote_path == '/') ? remote_path + 1 : remote_path);
|
||||
g_free (remote_path);
|
||||
} else
|
||||
j = command (me, super, WAIT_REPLY, "%s", cmd);
|
||||
j = ftpfs_command (me, super, WAIT_REPLY, "%s", cmd);
|
||||
if (j != PRELIM)
|
||||
ERRNOR (EPERM, -1);
|
||||
enable_interrupt_key();
|
||||
@ -955,7 +955,7 @@ open_data_connection (struct vfs_class *me, struct vfs_s_super *super, const cha
|
||||
else {
|
||||
data = accept (s, (struct sockaddr *)&from, &fromlen);
|
||||
if (data < 0) {
|
||||
my_errno = errno;
|
||||
ftpfs_errno = errno;
|
||||
close (s);
|
||||
return -1;
|
||||
}
|
||||
@ -967,7 +967,7 @@ open_data_connection (struct vfs_class *me, struct vfs_s_super *super, const cha
|
||||
|
||||
#define ABORT_TIMEOUT 5
|
||||
static void
|
||||
linear_abort (struct vfs_class *me, struct vfs_s_fh *fh)
|
||||
ftpfs_linear_abort (struct vfs_class *me, struct vfs_s_fh *fh)
|
||||
{
|
||||
struct vfs_s_super *super = FH_SUPER;
|
||||
static unsigned char const ipbuf[3] = { IAC, IP, IAC };
|
||||
@ -986,7 +986,7 @@ linear_abort (struct vfs_class *me, struct vfs_s_fh *fh)
|
||||
return;
|
||||
}
|
||||
|
||||
if (command (me, super, NONE, "%cABOR", DM) != COMPLETE) {
|
||||
if (ftpfs_command (me, super, NONE, "%cABOR", DM) != COMPLETE) {
|
||||
print_vfs_message (_("ftpfs: abort failed"));
|
||||
if (dsock != -1)
|
||||
close (dsock);
|
||||
@ -1002,17 +1002,17 @@ linear_abort (struct vfs_class *me, struct vfs_s_fh *fh)
|
||||
while (read (dsock, buf, sizeof (buf)) > 0) {
|
||||
gettimeofday (&tim, NULL);
|
||||
if (tim.tv_sec > start_tim.tv_sec + ABORT_TIMEOUT) {
|
||||
/* server keeps sending, drop the connection and reconnect */
|
||||
/* server keeps sending, drop the connection and ftpfs_reconnect */
|
||||
close (dsock);
|
||||
reconnect (me, super);
|
||||
ftpfs_reconnect (me, super);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
close (dsock);
|
||||
}
|
||||
if ((get_reply (me, SUP.sock, NULL, 0) == TRANSIENT) && (code == 426))
|
||||
get_reply (me, SUP.sock, NULL, 0);
|
||||
if ((ftpfs_get_reply (me, SUP.sock, NULL, 0) == TRANSIENT) && (code == 426))
|
||||
ftpfs_get_reply (me, SUP.sock, NULL, 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -1094,10 +1094,10 @@ resolve_symlink_with_ls_options(struct vfs_class *me, struct vfs_s_super *super,
|
||||
print_vfs_message(_("ftpfs: CWD failed."));
|
||||
return;
|
||||
}
|
||||
sock = open_data_connection (bucket, "LIST -lLa", ".", TYPE_ASCII, 0);
|
||||
sock = ftpfs_open_data_connection (bucket, "LIST -lLa", ".", TYPE_ASCII, 0);
|
||||
}
|
||||
else
|
||||
sock = open_data_connection (bucket, "LIST -lLa",
|
||||
sock = ftpfs_open_data_connection (bucket, "LIST -lLa",
|
||||
dir->remote_path, TYPE_ASCII, 0);
|
||||
|
||||
if (sock == -1) {
|
||||
@ -1153,7 +1153,7 @@ done:
|
||||
while (fgets(buffer, sizeof(buffer), fp) != NULL);
|
||||
disable_interrupt_key();
|
||||
fclose(fp);
|
||||
get_reply(me, SUP.sock, NULL, 0);
|
||||
ftpfs_get_reply(me, SUP.sock, NULL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1169,7 +1169,7 @@ resolve_symlink(struct vfs_class *me, struct vfs_s_super *super, struct vfs_s_in
|
||||
#endif
|
||||
|
||||
static int
|
||||
dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
ftpfs_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
{
|
||||
struct vfs_s_entry *ent;
|
||||
struct vfs_s_super *super = dir->super;
|
||||
@ -1190,11 +1190,11 @@ dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
if (cd_first) {
|
||||
char *p;
|
||||
|
||||
p = translate_path (me, super, remote_path);
|
||||
p = ftpfs_translate_path (me, super, remote_path);
|
||||
|
||||
if (ftpfs_chdir_internal (me, super, p) != COMPLETE) {
|
||||
g_free (p);
|
||||
my_errno = ENOENT;
|
||||
ftpfs_errno = ENOENT;
|
||||
print_vfs_message (_("ftpfs: CWD failed."));
|
||||
return -1;
|
||||
}
|
||||
@ -1205,17 +1205,17 @@ dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
dir->timestamp.tv_sec += ftpfs_directory_timeout;
|
||||
|
||||
if (SUP.strict == RFC_STRICT)
|
||||
sock = open_data_connection (me, super, "LIST", 0, TYPE_ASCII, 0);
|
||||
sock = ftpfs_open_data_connection (me, super, "LIST", 0, TYPE_ASCII, 0);
|
||||
else if (cd_first)
|
||||
/* Dirty hack to avoid autoprepending / to . */
|
||||
/* Wu-ftpd produces strange output for '/' if 'LIST -la .' used */
|
||||
sock =
|
||||
open_data_connection (me, super, "LIST -la", 0, TYPE_ASCII, 0);
|
||||
ftpfs_open_data_connection (me, super, "LIST -la", 0, TYPE_ASCII, 0);
|
||||
else {
|
||||
/* Trailing "/." is necessary if remote_path is a symlink */
|
||||
char *path = concat_dir_and_file (remote_path, ".");
|
||||
sock =
|
||||
open_data_connection (me, super, "LIST -la", path, TYPE_ASCII,
|
||||
ftpfs_open_data_connection (me, super, "LIST -la", path, TYPE_ASCII,
|
||||
0);
|
||||
g_free (path);
|
||||
}
|
||||
@ -1238,7 +1238,7 @@ dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
me->verrno = ECONNRESET;
|
||||
close (sock);
|
||||
disable_interrupt_key ();
|
||||
get_reply (me, SUP.sock, NULL, 0);
|
||||
ftpfs_get_reply (me, SUP.sock, NULL, 0);
|
||||
print_vfs_message (_("%s: failure"), me->name);
|
||||
return -1;
|
||||
}
|
||||
@ -1263,7 +1263,7 @@ dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
|
||||
close (sock);
|
||||
me->verrno = E_REMOTE;
|
||||
if ((get_reply (me, SUP.sock, NULL, 0) != COMPLETE) || !num_entries)
|
||||
if ((ftpfs_get_reply (me, SUP.sock, NULL, 0) != COMPLETE) || !num_entries)
|
||||
goto fallback;
|
||||
|
||||
if (SUP.strict == RFC_AUTODETECT)
|
||||
@ -1278,7 +1278,7 @@ dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
server (UNIX style LIST command) */
|
||||
SUP.strict = RFC_STRICT;
|
||||
/* I hate goto, but recursive call needs another 8K on stack */
|
||||
/* return dir_load (me, dir, remote_path); */
|
||||
/* return ftpfs_dir_load (me, dir, remote_path); */
|
||||
cd_first = 1;
|
||||
goto again;
|
||||
}
|
||||
@ -1287,7 +1287,7 @@ dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
}
|
||||
|
||||
static int
|
||||
file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *localname)
|
||||
ftpfs_file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *localname)
|
||||
{
|
||||
int h, sock, n;
|
||||
off_t total;
|
||||
@ -1304,7 +1304,7 @@ file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *localnam
|
||||
if (h == -1)
|
||||
ERRNOR (EIO, -1);
|
||||
fstat(h, &s);
|
||||
sock = open_data_connection(me, super, fh->u.ftp.append ? "APPE" : "STOR", name, TYPE_BINARY, 0);
|
||||
sock = ftpfs_open_data_connection(me, super, fh->u.ftp.append ? "APPE" : "STOR", name, TYPE_BINARY, 0);
|
||||
if (sock < 0) {
|
||||
close(h);
|
||||
return -1;
|
||||
@ -1323,13 +1323,13 @@ file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *localnam
|
||||
while ((n = read(h, buffer, sizeof(buffer))) < 0) {
|
||||
if (errno == EINTR) {
|
||||
if (got_interrupt()) {
|
||||
my_errno = EINTR;
|
||||
ftpfs_errno = EINTR;
|
||||
goto error_return;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
my_errno = errno;
|
||||
ftpfs_errno = errno;
|
||||
goto error_return;
|
||||
}
|
||||
if (n == 0)
|
||||
@ -1337,13 +1337,13 @@ file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *localnam
|
||||
while (write(sock, buffer, n) < 0) {
|
||||
if (errno == EINTR) {
|
||||
if (got_interrupt()) {
|
||||
my_errno = EINTR;
|
||||
ftpfs_errno = EINTR;
|
||||
goto error_return;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
my_errno = errno;
|
||||
ftpfs_errno = errno;
|
||||
goto error_return;
|
||||
}
|
||||
total += n;
|
||||
@ -1353,25 +1353,25 @@ file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *localnam
|
||||
disable_interrupt_key();
|
||||
close(sock);
|
||||
close(h);
|
||||
if (get_reply (me, SUP.sock, NULL, 0) != COMPLETE)
|
||||
if (ftpfs_get_reply (me, SUP.sock, NULL, 0) != COMPLETE)
|
||||
ERRNOR (EIO, -1);
|
||||
return 0;
|
||||
error_return:
|
||||
disable_interrupt_key();
|
||||
close(sock);
|
||||
close(h);
|
||||
get_reply(me, SUP.sock, NULL, 0);
|
||||
ftpfs_get_reply(me, SUP.sock, NULL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
linear_start(struct vfs_class *me, struct vfs_s_fh *fh, int offset)
|
||||
ftpfs_linear_start(struct vfs_class *me, struct vfs_s_fh *fh, int offset)
|
||||
{
|
||||
char *name = vfs_s_fullpath (me, fh->ino);
|
||||
|
||||
if (!name)
|
||||
return 0;
|
||||
FH_SOCK = open_data_connection(me, FH_SUPER, "RETR", name, TYPE_BINARY, offset);
|
||||
FH_SOCK = ftpfs_open_data_connection(me, FH_SUPER, "RETR", name, TYPE_BINARY, offset);
|
||||
g_free (name);
|
||||
if (FH_SOCK == -1)
|
||||
ERRNOR (EACCES, 0);
|
||||
@ -1382,7 +1382,7 @@ linear_start(struct vfs_class *me, struct vfs_s_fh *fh, int offset)
|
||||
}
|
||||
|
||||
static int
|
||||
linear_read (struct vfs_class *me, struct vfs_s_fh *fh, void *buf, int len)
|
||||
ftpfs_linear_read (struct vfs_class *me, struct vfs_s_fh *fh, void *buf, int len)
|
||||
{
|
||||
int n;
|
||||
struct vfs_s_super *super = FH_SUPER;
|
||||
@ -1394,13 +1394,13 @@ linear_read (struct vfs_class *me, struct vfs_s_fh *fh, void *buf, int len)
|
||||
}
|
||||
|
||||
if (n<0)
|
||||
linear_abort(me, fh);
|
||||
ftpfs_linear_abort(me, fh);
|
||||
|
||||
if (!n) {
|
||||
SUP.ctl_connection_busy = 0;
|
||||
close (FH_SOCK);
|
||||
FH_SOCK = -1;
|
||||
if ((get_reply (me, SUP.sock, NULL, 0) != COMPLETE))
|
||||
if ((ftpfs_get_reply (me, SUP.sock, NULL, 0) != COMPLETE))
|
||||
ERRNOR (E_REMOTE, -1);
|
||||
return 0;
|
||||
}
|
||||
@ -1408,10 +1408,10 @@ linear_read (struct vfs_class *me, struct vfs_s_fh *fh, void *buf, int len)
|
||||
}
|
||||
|
||||
static void
|
||||
linear_close (struct vfs_class *me, struct vfs_s_fh *fh)
|
||||
ftpfs_linear_close (struct vfs_class *me, struct vfs_s_fh *fh)
|
||||
{
|
||||
if (FH_SOCK != -1)
|
||||
linear_abort(me, fh);
|
||||
ftpfs_linear_abort(me, fh);
|
||||
}
|
||||
|
||||
static int ftpfs_ctl (void *fh, int ctlop, void *arg)
|
||||
@ -1438,7 +1438,7 @@ static int ftpfs_ctl (void *fh, int ctlop, void *arg)
|
||||
|
||||
/* Warning: filename passed to this command is damaged */
|
||||
static int
|
||||
send_ftp_command(struct vfs_class *me, char *filename, char *cmd, int flags)
|
||||
ftpfs_send_command(struct vfs_class *me, char *filename, char *cmd, int flags)
|
||||
{
|
||||
char *rpath, *p;
|
||||
struct vfs_s_super *super;
|
||||
@ -1447,8 +1447,8 @@ send_ftp_command(struct vfs_class *me, char *filename, char *cmd, int flags)
|
||||
|
||||
if (!(rpath = vfs_s_get_path_mangle(me, filename, &super, 0)))
|
||||
return -1;
|
||||
p = translate_path (me, super, rpath);
|
||||
r = command (me, super, WAIT_REPLY, cmd, p);
|
||||
p = ftpfs_translate_path (me, super, rpath);
|
||||
r = ftpfs_command (me, super, WAIT_REPLY, cmd, p);
|
||||
g_free (p);
|
||||
vfs_add_noncurrent_stamps (&vfs_ftpfs_ops, (vfsid) super, NULL);
|
||||
if (flags & OPT_IGNORE_ERROR)
|
||||
@ -1484,13 +1484,13 @@ static int ftpfs_chmod (struct vfs_class *me, char *path, int mode)
|
||||
char buf[BUF_SMALL];
|
||||
|
||||
g_snprintf(buf, sizeof(buf), "SITE CHMOD %4.4o /%%s", mode & 07777);
|
||||
return send_ftp_command(me, path, buf, OPT_FLUSH);
|
||||
return ftpfs_send_command(me, path, buf, OPT_FLUSH);
|
||||
}
|
||||
|
||||
static int ftpfs_chown (struct vfs_class *me, char *path, int owner, int group)
|
||||
{
|
||||
#if 0
|
||||
my_errno = EPERM;
|
||||
ftpfs_errno = EPERM;
|
||||
return -1;
|
||||
#else
|
||||
/* Everyone knows it is not possible to chown remotely, so why bother them.
|
||||
@ -1501,12 +1501,12 @@ static int ftpfs_chown (struct vfs_class *me, char *path, int owner, int group)
|
||||
|
||||
static int ftpfs_unlink (struct vfs_class *me, char *path)
|
||||
{
|
||||
return send_ftp_command(me, path, "DELE /%s", OPT_FLUSH);
|
||||
return ftpfs_send_command(me, path, "DELE /%s", OPT_FLUSH);
|
||||
}
|
||||
|
||||
/* Return 1 if path is the same directory as the one we are in now */
|
||||
static int
|
||||
is_same_dir (struct vfs_class *me, struct vfs_s_super *super, const char *path)
|
||||
ftpfs_is_same_dir (struct vfs_class *me, struct vfs_s_super *super, const char *path)
|
||||
{
|
||||
if (!SUP.cwdir)
|
||||
return 0;
|
||||
@ -1521,15 +1521,15 @@ ftpfs_chdir_internal (struct vfs_class *me, struct vfs_s_super *super, char *rem
|
||||
int r;
|
||||
char *p;
|
||||
|
||||
if (!SUP.cwd_deferred && is_same_dir (me, super, remote_path))
|
||||
if (!SUP.cwd_deferred && ftpfs_is_same_dir (me, super, remote_path))
|
||||
return COMPLETE;
|
||||
|
||||
p = translate_path (me, super, remote_path);
|
||||
r = command (me, super, WAIT_REPLY, "CWD /%s", p);
|
||||
p = ftpfs_translate_path (me, super, remote_path);
|
||||
r = ftpfs_command (me, super, WAIT_REPLY, "CWD /%s", p);
|
||||
g_free (p);
|
||||
|
||||
if (r != COMPLETE) {
|
||||
my_errno = EIO;
|
||||
ftpfs_errno = EIO;
|
||||
} else {
|
||||
g_free(SUP.cwdir);
|
||||
SUP.cwdir = g_strdup (remote_path);
|
||||
@ -1540,39 +1540,42 @@ ftpfs_chdir_internal (struct vfs_class *me, struct vfs_s_super *super, char *rem
|
||||
|
||||
static int ftpfs_rename (struct vfs_class *me, char *path1, char *path2)
|
||||
{
|
||||
send_ftp_command(me, path1, "RNFR /%s", OPT_FLUSH);
|
||||
return send_ftp_command(me, path2, "RNTO /%s", OPT_FLUSH);
|
||||
ftpfs_send_command(me, path1, "RNFR /%s", OPT_FLUSH);
|
||||
return ftpfs_send_command(me, path2, "RNTO /%s", OPT_FLUSH);
|
||||
}
|
||||
|
||||
static int ftpfs_mkdir (struct vfs_class *me, char *path, mode_t mode)
|
||||
{
|
||||
return send_ftp_command(me, path, "MKD /%s", OPT_FLUSH);
|
||||
return ftpfs_send_command(me, path, "MKD /%s", OPT_FLUSH);
|
||||
}
|
||||
|
||||
static int ftpfs_rmdir (struct vfs_class *me, char *path)
|
||||
{
|
||||
return send_ftp_command(me, path, "RMD /%s", OPT_FLUSH);
|
||||
return ftpfs_send_command(me, path, "RMD /%s", OPT_FLUSH);
|
||||
}
|
||||
|
||||
static int ftpfs_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags, int mode)
|
||||
static int
|
||||
ftpfs_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags,
|
||||
int mode)
|
||||
{
|
||||
fh->u.ftp.append = 0;
|
||||
/* File will be written only, so no need to retrieve it from ftp server */
|
||||
if (((flags & O_WRONLY) == O_WRONLY) && !(flags & (O_RDONLY|O_RDWR))){
|
||||
if (((flags & O_WRONLY) == O_WRONLY) && !(flags & (O_RDONLY | O_RDWR))) {
|
||||
#ifdef HAVE_STRUCT_LINGER
|
||||
struct linger li;
|
||||
#else
|
||||
int li = 1;
|
||||
#endif
|
||||
char * name;
|
||||
char *name;
|
||||
|
||||
/* linear_start() called, so data will be written
|
||||
/* ftpfs_linear_start() called, so data will be written
|
||||
* to local temporary file and stored to ftp server
|
||||
* by vfs_s_close later
|
||||
*/
|
||||
if (FH_SUPER->u.ftp.ctl_connection_busy) {
|
||||
if (!fh->ino->localname){
|
||||
int handle = mc_mkstemps (&fh->ino->localname, me->name, NULL);
|
||||
if (!fh->ino->localname) {
|
||||
int handle =
|
||||
mc_mkstemps (&fh->ino->localname, me->name, NULL);
|
||||
if (handle == -1)
|
||||
return -1;
|
||||
close (handle);
|
||||
@ -1583,8 +1586,10 @@ static int ftpfs_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags,
|
||||
name = vfs_s_fullpath (me, fh->ino);
|
||||
if (!name)
|
||||
return -1;
|
||||
fh->handle = open_data_connection(me, fh->ino->super,
|
||||
(flags & O_APPEND) ? "APPE" : "STOR", name, TYPE_BINARY, 0);
|
||||
fh->handle =
|
||||
ftpfs_open_data_connection (me, fh->ino->super,
|
||||
(flags & O_APPEND) ? "APPE" :
|
||||
"STOR", name, TYPE_BINARY, 0);
|
||||
g_free (name);
|
||||
|
||||
if (fh->handle < 0)
|
||||
@ -1593,9 +1598,9 @@ static int ftpfs_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags,
|
||||
li.l_onoff = 1;
|
||||
li.l_linger = 120;
|
||||
#endif
|
||||
setsockopt(fh->handle, SOL_SOCKET, SO_LINGER, &li, sizeof(li));
|
||||
setsockopt (fh->handle, SOL_SOCKET, SO_LINGER, &li, sizeof (li));
|
||||
|
||||
if (fh->ino->localname){
|
||||
if (fh->ino->localname) {
|
||||
unlink (fh->ino->localname);
|
||||
g_free (fh->ino->localname);
|
||||
fh->ino->localname = NULL;
|
||||
@ -1604,10 +1609,10 @@ static int ftpfs_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags,
|
||||
}
|
||||
|
||||
if (!fh->ino->localname)
|
||||
if (vfs_s_retrieve_file (me, fh->ino)==-1)
|
||||
if (vfs_s_retrieve_file (me, fh->ino) == -1)
|
||||
return -1;
|
||||
if (!fh->ino->localname)
|
||||
vfs_die( "retrieve_file failed to fill in localname" );
|
||||
vfs_die ("retrieve_file failed to fill in localname");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1617,10 +1622,10 @@ static int ftpfs_fh_close (struct vfs_class *me, struct vfs_s_fh *fh)
|
||||
close (fh->handle);
|
||||
fh->handle = -1;
|
||||
/* File is stored to destination already, so
|
||||
* we prevent MEDATA->file_store() call from vfs_s_close ()
|
||||
* we prevent MEDATA->ftpfs_file_store() call from vfs_s_close ()
|
||||
*/
|
||||
fh->changed = 0;
|
||||
if (get_reply (me, fh->ino->SUP.sock, NULL, 0) != COMPLETE)
|
||||
if (ftpfs_get_reply (me, fh->ino->SUP.sock, NULL, 0) != COMPLETE)
|
||||
ERRNOR (EIO, -1);
|
||||
vfs_s_invalidate (me, FH_SUPER);
|
||||
}
|
||||
@ -1672,7 +1677,7 @@ typedef enum {
|
||||
NETRC_UNKNOWN
|
||||
} keyword_t;
|
||||
|
||||
static keyword_t netrc_next (void)
|
||||
static keyword_t ftpfs_netrc_next (void)
|
||||
{
|
||||
char *p;
|
||||
keyword_t i;
|
||||
@ -1719,7 +1724,7 @@ static keyword_t netrc_next (void)
|
||||
return NETRC_UNKNOWN;
|
||||
}
|
||||
|
||||
static int netrc_has_incorrect_mode (char *netrcname, char *netrc)
|
||||
static int ftpfs_netrc_bad_mode (char *netrcname, char *netrc)
|
||||
{
|
||||
static int be_angry = 1;
|
||||
struct stat mystat;
|
||||
@ -1740,11 +1745,11 @@ static int netrc_has_incorrect_mode (char *netrcname, char *netrc)
|
||||
* domain is used for additional matching
|
||||
* No search is done after "default" in compliance with "man netrc"
|
||||
* Return 0 if found, -1 otherwise */
|
||||
static int find_machine (const char *host, const char *domain)
|
||||
static int ftpfs_find_machine (const char *host, const char *domain)
|
||||
{
|
||||
keyword_t keyword;
|
||||
|
||||
while ((keyword = netrc_next ()) != NETRC_NONE) {
|
||||
while ((keyword = ftpfs_netrc_next ()) != NETRC_NONE) {
|
||||
if (keyword == NETRC_DEFAULT)
|
||||
return 0;
|
||||
|
||||
@ -1764,7 +1769,7 @@ static int find_machine (const char *host, const char *domain)
|
||||
continue;
|
||||
|
||||
/* Take machine name */
|
||||
if (netrc_next () == NETRC_NONE)
|
||||
if (ftpfs_netrc_next () == NETRC_NONE)
|
||||
break;
|
||||
|
||||
if (g_strcasecmp (host, buffer)) {
|
||||
@ -1792,7 +1797,7 @@ static int find_machine (const char *host, const char *domain)
|
||||
/* Extract login and password from .netrc for the host.
|
||||
* pass may be NULL.
|
||||
* Returns 0 for success, -1 for error */
|
||||
static int lookup_netrc (const char *host, char **login, char **pass)
|
||||
static int ftpfs_netrc_lookup (const char *host, char **login, char **pass)
|
||||
{
|
||||
char *netrcname;
|
||||
char *tmp_pass = NULL;
|
||||
@ -1838,16 +1843,16 @@ static int lookup_netrc (const char *host, char **login, char **pass)
|
||||
domain = "";
|
||||
|
||||
/* Scan for "default" and matching "machine" keywords */
|
||||
find_machine (host, domain);
|
||||
ftpfs_find_machine (host, domain);
|
||||
|
||||
/* Scan for keywords following "default" and "machine" */
|
||||
while (1) {
|
||||
int need_break = 0;
|
||||
keyword = netrc_next ();
|
||||
keyword = ftpfs_netrc_next ();
|
||||
|
||||
switch (keyword) {
|
||||
case NETRC_LOGIN:
|
||||
if (netrc_next () == NETRC_NONE) {
|
||||
if (ftpfs_netrc_next () == NETRC_NONE) {
|
||||
need_break = 1;
|
||||
break;
|
||||
}
|
||||
@ -1864,14 +1869,14 @@ static int lookup_netrc (const char *host, char **login, char **pass)
|
||||
|
||||
case NETRC_PASSWORD:
|
||||
case NETRC_PASSWD:
|
||||
if (netrc_next () == NETRC_NONE) {
|
||||
if (ftpfs_netrc_next () == NETRC_NONE) {
|
||||
need_break = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Ignore unsafe passwords */
|
||||
if (strcmp (*login, "anonymous") && strcmp (*login, "ftp")
|
||||
&& netrc_has_incorrect_mode (netrcname, netrc)) {
|
||||
&& ftpfs_netrc_bad_mode (netrcname, netrc)) {
|
||||
need_break = 1;
|
||||
break;
|
||||
}
|
||||
@ -1883,13 +1888,13 @@ static int lookup_netrc (const char *host, char **login, char **pass)
|
||||
|
||||
case NETRC_ACCOUNT:
|
||||
/* "account" is followed by a token which we ignore */
|
||||
if (netrc_next () == NETRC_NONE) {
|
||||
if (ftpfs_netrc_next () == NETRC_NONE) {
|
||||
need_break = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Ignore account, but warn user anyways */
|
||||
netrc_has_incorrect_mode (netrcname, netrc);
|
||||
ftpfs_netrc_bad_mode (netrcname, netrc);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1928,18 +1933,18 @@ init_ftpfs (void)
|
||||
{
|
||||
static struct vfs_s_subclass ftpfs_subclass;
|
||||
|
||||
ftpfs_subclass.archive_same = archive_same;
|
||||
ftpfs_subclass.open_archive = open_archive;
|
||||
ftpfs_subclass.free_archive = free_archive;
|
||||
ftpfs_subclass.archive_same = ftpfs_archive_same;
|
||||
ftpfs_subclass.open_archive = ftpfs_open_archive;
|
||||
ftpfs_subclass.free_archive = ftpfs_free_archive;
|
||||
ftpfs_subclass.fh_open = ftpfs_fh_open;
|
||||
ftpfs_subclass.fh_close = ftpfs_fh_close;
|
||||
ftpfs_subclass.find_entry = vfs_s_find_entry_linear;
|
||||
ftpfs_subclass.dir_load = dir_load;
|
||||
ftpfs_subclass.dir_uptodate = dir_uptodate;
|
||||
ftpfs_subclass.file_store = file_store;
|
||||
ftpfs_subclass.linear_start = linear_start;
|
||||
ftpfs_subclass.linear_read = linear_read;
|
||||
ftpfs_subclass.linear_close = linear_close;
|
||||
ftpfs_subclass.dir_load = ftpfs_dir_load;
|
||||
ftpfs_subclass.dir_uptodate = ftpfs_dir_uptodate;
|
||||
ftpfs_subclass.file_store = ftpfs_file_store;
|
||||
ftpfs_subclass.linear_start = ftpfs_linear_start;
|
||||
ftpfs_subclass.linear_read = ftpfs_linear_read;
|
||||
ftpfs_subclass.linear_close = ftpfs_linear_close;
|
||||
|
||||
vfs_s_init_class (&vfs_ftpfs_ops);
|
||||
vfs_ftpfs_ops.name = "ftpfs";
|
||||
|
70
vfs/mcfs.c
70
vfs/mcfs.c
@ -174,7 +174,7 @@ mcfs_login_server (int my_socket, char *user, int port,
|
||||
}
|
||||
|
||||
static int
|
||||
get_remote_port (struct sockaddr_in *sin, int *version)
|
||||
mcfs_get_remote_port (struct sockaddr_in *sin, int *version)
|
||||
{
|
||||
#ifdef HAVE_PMAP_GETMAPS
|
||||
int port;
|
||||
@ -205,7 +205,7 @@ get_remote_port (struct sockaddr_in *sin, int *version)
|
||||
/* This used to be in utilvfs.c, but as it deals with portmapper, it
|
||||
is probably useful for mcfs */
|
||||
static int
|
||||
open_tcp_link (char *host, int *port, int *version, char *caller)
|
||||
mcfs_create_tcp_link (char *host, int *port, int *version, char *caller)
|
||||
{
|
||||
struct sockaddr_in server_address;
|
||||
unsigned long inaddr;
|
||||
@ -234,7 +234,7 @@ open_tcp_link (char *host, int *port, int *version, char *caller)
|
||||
|
||||
/* Try to contact a remote portmapper to obtain the listening port */
|
||||
if (*port == 0) {
|
||||
*port = get_remote_port (&server_address, version);
|
||||
*port = mcfs_get_remote_port (&server_address, version);
|
||||
if (*port < 1)
|
||||
return 0;
|
||||
} else
|
||||
@ -264,7 +264,7 @@ mcfs_open_tcp_link (char *host, char *user,
|
||||
int my_socket;
|
||||
int old_port = *port;
|
||||
|
||||
my_socket = open_tcp_link (host, port, version, " MCfs ");
|
||||
my_socket = mcfs_create_tcp_link (host, port, version, " MCfs ");
|
||||
if (my_socket <= 0)
|
||||
return 0;
|
||||
|
||||
@ -341,7 +341,7 @@ mcfs_open_link (char *host, char *user, int *port, char *netrcpass)
|
||||
}
|
||||
|
||||
static int
|
||||
is_error (int result, int errno_num)
|
||||
mcfs_is_error (int result, int errno_num)
|
||||
{
|
||||
if (!(result == -1))
|
||||
return my_errno = 0;
|
||||
@ -351,7 +351,7 @@ is_error (int result, int errno_num)
|
||||
}
|
||||
|
||||
static int
|
||||
the_error (int result, int errno_num)
|
||||
mcfs_set_error (int result, int errno_num)
|
||||
{
|
||||
if (result == -1)
|
||||
my_errno = errno_num;
|
||||
@ -372,7 +372,7 @@ mcfs_get_path (mcfs_connection **mc, char *path)
|
||||
return NULL;
|
||||
path += 5;
|
||||
|
||||
/* Port = 0 means that open_tcp_link will try to contact the
|
||||
/* Port = 0 means that mcfs_create_tcp_link will try to contact the
|
||||
* remote portmapper to get the port number
|
||||
*/
|
||||
port = 0;
|
||||
@ -411,9 +411,9 @@ mcfs_handle_simple_error (int sock, int return_status)
|
||||
int status, error;
|
||||
|
||||
if (0 == rpc_get (sock, RPC_INT, &status, RPC_INT, &error, RPC_END))
|
||||
return the_error (-1, EIO);
|
||||
return mcfs_set_error (-1, EIO);
|
||||
|
||||
if (is_error (status, error))
|
||||
if (mcfs_is_error (status, error))
|
||||
return -1;
|
||||
if (return_status)
|
||||
return status;
|
||||
@ -528,7 +528,7 @@ mcfs_open (struct vfs_class *me, char *file, int flags, int mode)
|
||||
rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END))
|
||||
return 0;
|
||||
|
||||
if (is_error (result, error_num))
|
||||
if (mcfs_is_error (result, error_num))
|
||||
return 0;
|
||||
|
||||
remote_handle = g_new (mcfs_handle, 2);
|
||||
@ -554,13 +554,13 @@ mcfs_read (void *data, char *buffer, int count)
|
||||
|
||||
if (0 ==
|
||||
rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error, RPC_END))
|
||||
return the_error (-1, EIO);
|
||||
return mcfs_set_error (-1, EIO);
|
||||
|
||||
if (is_error (result, error))
|
||||
if (mcfs_is_error (result, error))
|
||||
return 0;
|
||||
|
||||
if (0 == rpc_get (mc->sock, RPC_BLOCK, result, buffer, RPC_END))
|
||||
return the_error (-1, EIO);
|
||||
return mcfs_set_error (-1, EIO);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -600,9 +600,9 @@ mcfs_close (void *data)
|
||||
|
||||
if (0 ==
|
||||
rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error, RPC_END))
|
||||
return the_error (-1, EIO);
|
||||
return mcfs_set_error (-1, EIO);
|
||||
|
||||
is_error (result, error);
|
||||
mcfs_is_error (result, error);
|
||||
|
||||
g_free (data);
|
||||
return result;
|
||||
@ -648,7 +648,7 @@ mcfs_opendir (struct vfs_class *me, char *dirname)
|
||||
rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END))
|
||||
return 0;
|
||||
|
||||
if (is_error (result, error_num))
|
||||
if (mcfs_is_error (result, error_num))
|
||||
return 0;
|
||||
|
||||
handle = result;
|
||||
@ -662,7 +662,7 @@ mcfs_opendir (struct vfs_class *me, char *dirname)
|
||||
return mcfs_info;
|
||||
}
|
||||
|
||||
static int get_stat_info (mcfs_connection * mc, struct stat *buf);
|
||||
static int mcfs_get_stat_info (mcfs_connection * mc, struct stat *buf);
|
||||
|
||||
static int
|
||||
mcfs_loaddir (opendir_info *mcfs_info)
|
||||
@ -706,11 +706,11 @@ mcfs_loaddir (opendir_info *mcfs_info)
|
||||
if (!rpc_get (link, RPC_INT, &status, RPC_INT, &error, RPC_END))
|
||||
return 0;
|
||||
|
||||
if (is_error (status, error))
|
||||
if (mcfs_is_error (status, error))
|
||||
new_entry->merrno = error;
|
||||
else {
|
||||
new_entry->merrno = 0;
|
||||
if (!get_stat_info (mc, &(new_entry->my_stat)))
|
||||
if (!mcfs_get_stat_info (mc, &(new_entry->my_stat)))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -815,7 +815,7 @@ mcfs_get_time (mcfs_connection *mc)
|
||||
}
|
||||
|
||||
static int
|
||||
get_stat_info (mcfs_connection *mc, struct stat *buf)
|
||||
mcfs_get_stat_info (mcfs_connection *mc, struct stat *buf)
|
||||
{
|
||||
long mylong;
|
||||
int sock = mc->sock;
|
||||
@ -863,15 +863,15 @@ mcfs_stat_cmd (int cmd, char *path, struct stat *buf)
|
||||
rpc_send (mc->sock, RPC_INT, cmd, RPC_STRING, remote_file, RPC_END);
|
||||
g_free (remote_file);
|
||||
if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END))
|
||||
return the_error (-1, errno);
|
||||
return mcfs_set_error (-1, errno);
|
||||
|
||||
if (is_error (status, error))
|
||||
if (mcfs_is_error (status, error))
|
||||
return -1;
|
||||
|
||||
if (get_stat_info (mc, buf))
|
||||
if (mcfs_get_stat_info (mc, buf))
|
||||
return 0;
|
||||
else
|
||||
return the_error (-1, EIO);
|
||||
return mcfs_set_error (-1, EIO);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -907,15 +907,15 @@ mcfs_fstat (void *data, struct stat *buf)
|
||||
|
||||
rpc_send (sock, RPC_INT, MC_FSTAT, RPC_INT, handle, RPC_END);
|
||||
if (!rpc_get (sock, RPC_INT, &result, RPC_INT, &error, RPC_END))
|
||||
return the_error (-1, EIO);
|
||||
return mcfs_set_error (-1, EIO);
|
||||
|
||||
if (is_error (result, error))
|
||||
if (mcfs_is_error (result, error))
|
||||
return -1;
|
||||
|
||||
if (get_stat_info (info->conn, buf))
|
||||
if (mcfs_get_stat_info (info->conn, buf))
|
||||
return 0;
|
||||
else
|
||||
return the_error (-1, EIO);
|
||||
return mcfs_set_error (-1, EIO);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -976,13 +976,13 @@ mcfs_readlink (struct vfs_class *me, char *path, char *buf, int size)
|
||||
RPC_END);
|
||||
g_free (remote_file);
|
||||
if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END))
|
||||
return the_error (-1, EIO);
|
||||
return mcfs_set_error (-1, EIO);
|
||||
|
||||
if (is_error (status, errno))
|
||||
if (mcfs_is_error (status, errno))
|
||||
return -1;
|
||||
|
||||
if (!rpc_get (mc->sock, RPC_STRING, &stat_str, RPC_END))
|
||||
return the_error (-1, EIO);
|
||||
return mcfs_set_error (-1, EIO);
|
||||
|
||||
status = strlen (stat_str);
|
||||
if (status < size)
|
||||
@ -1024,9 +1024,9 @@ mcfs_chdir (struct vfs_class *me, char *path)
|
||||
RPC_END);
|
||||
g_free (remote_dir);
|
||||
if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END))
|
||||
return the_error (-1, EIO);
|
||||
return mcfs_set_error (-1, EIO);
|
||||
|
||||
if (is_error (status, error))
|
||||
if (mcfs_is_error (status, error))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
@ -1098,7 +1098,7 @@ mcfs_free (vfsid id)
|
||||
* now
|
||||
*/
|
||||
static void
|
||||
my_forget (char *path)
|
||||
mcfs_forget (char *path)
|
||||
{
|
||||
char *host, *user, *pass, *p;
|
||||
int port, i, vers;
|
||||
@ -1144,7 +1144,7 @@ mcfs_setctl (struct vfs_class *me, char *path, int ctlop, void *arg)
|
||||
{
|
||||
switch (ctlop) {
|
||||
case VFS_SETCTL_FORGET:
|
||||
my_forget (path);
|
||||
mcfs_forget (path);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
28
vfs/sfs.c
28
vfs/sfs.c
@ -43,12 +43,12 @@ static int sfs_flags[ MAXFS ];
|
||||
#define F_NOLOCALCOPY 4
|
||||
#define F_FULLMATCH 8
|
||||
|
||||
static int uptodate (char *name, char *cache)
|
||||
static int sfs_uptodate (char *name, char *cache)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int vfmake (struct vfs_class *me, char *name, char *cache)
|
||||
static int sfs_vfmake (struct vfs_class *me, char *name, char *cache)
|
||||
{
|
||||
char *inpath, *op;
|
||||
int w;
|
||||
@ -105,17 +105,15 @@ static int vfmake (struct vfs_class *me, char *name, char *cache)
|
||||
}
|
||||
|
||||
static char *
|
||||
redirect (struct vfs_class *me, char *name)
|
||||
sfs_redirect (struct vfs_class *me, char *name)
|
||||
{
|
||||
struct cachedfile *cur = head;
|
||||
char *cache;
|
||||
int handle;
|
||||
|
||||
while (cur) {
|
||||
/* FIXME: when not uptodate, we might want to kill cache
|
||||
* file immediately, not to wait until timeout. */
|
||||
if ((!strcmp (name, cur->name))
|
||||
&& (uptodate (cur->name, cur->cache))) {
|
||||
&& (sfs_uptodate (cur->name, cur->cache))) {
|
||||
vfs_stamp (&vfs_sfs_ops, cur);
|
||||
return cur->cache;
|
||||
}
|
||||
@ -130,7 +128,7 @@ redirect (struct vfs_class *me, char *name)
|
||||
|
||||
close (handle);
|
||||
|
||||
if (!vfmake (me, name, cache)) {
|
||||
if (!sfs_vfmake (me, name, cache)) {
|
||||
cur = g_new (struct cachedfile, 1);
|
||||
cur->name = g_strdup (name);
|
||||
cur->cache = cache;
|
||||
@ -153,7 +151,7 @@ sfs_open (struct vfs_class *me, char *path, int flags, int mode)
|
||||
int *sfs_info;
|
||||
int fd;
|
||||
|
||||
path = redirect (me, path);
|
||||
path = sfs_redirect (me, path);
|
||||
fd = open (path, NO_LINEAR(flags), mode);
|
||||
if (fd == -1)
|
||||
return 0;
|
||||
@ -166,13 +164,13 @@ sfs_open (struct vfs_class *me, char *path, int flags, int mode)
|
||||
|
||||
static int sfs_stat (struct vfs_class *me, char *path, struct stat *buf)
|
||||
{
|
||||
path = redirect (me, path);
|
||||
path = sfs_redirect (me, path);
|
||||
return stat (path, buf);
|
||||
}
|
||||
|
||||
static int sfs_lstat (struct vfs_class *me, char *path, struct stat *buf)
|
||||
{
|
||||
path = redirect (me, path);
|
||||
path = sfs_redirect (me, path);
|
||||
#ifndef HAVE_STATLSTAT
|
||||
return lstat (path, buf);
|
||||
#else
|
||||
@ -182,25 +180,25 @@ static int sfs_lstat (struct vfs_class *me, char *path, struct stat *buf)
|
||||
|
||||
static int sfs_chmod (struct vfs_class *me, char *path, int mode)
|
||||
{
|
||||
path = redirect (me, path);
|
||||
path = sfs_redirect (me, path);
|
||||
return chmod (path, mode);
|
||||
}
|
||||
|
||||
static int sfs_chown (struct vfs_class *me, char *path, int owner, int group)
|
||||
{
|
||||
path = redirect (me, path);
|
||||
path = sfs_redirect (me, path);
|
||||
return chown (path, owner, group);
|
||||
}
|
||||
|
||||
static int sfs_utime (struct vfs_class *me, char *path, struct utimbuf *times)
|
||||
{
|
||||
path = redirect (me, path);
|
||||
path = sfs_redirect (me, path);
|
||||
return utime (path, times);
|
||||
}
|
||||
|
||||
static int sfs_readlink (struct vfs_class *me, char *path, char *buf, int size)
|
||||
{
|
||||
path = redirect (me, path);
|
||||
path = sfs_redirect (me, path);
|
||||
return readlink (path, buf, size);
|
||||
}
|
||||
|
||||
@ -286,7 +284,7 @@ static int sfs_nothingisopen (vfsid id)
|
||||
|
||||
static char *sfs_getlocalcopy (struct vfs_class *me, char *path)
|
||||
{
|
||||
path = redirect (me, path);
|
||||
path = sfs_redirect (me, path);
|
||||
return g_strdup (path);
|
||||
}
|
||||
|
||||
|
293
vfs/smbfs.c
293
vfs/smbfs.c
@ -98,7 +98,7 @@ typedef struct {
|
||||
static GSList *auth_list;
|
||||
|
||||
static void
|
||||
authinfo_free (struct smb_authinfo const *a)
|
||||
smbfs_auth_free (struct smb_authinfo const *a)
|
||||
{
|
||||
g_free (a->host);
|
||||
g_free (a->share);
|
||||
@ -108,17 +108,17 @@ authinfo_free (struct smb_authinfo const *a)
|
||||
}
|
||||
|
||||
static void
|
||||
authinfo_free_all ()
|
||||
smbfs_auth_free_all ()
|
||||
{
|
||||
if (auth_list) {
|
||||
g_slist_foreach (auth_list, (GFunc)authinfo_free, 0);
|
||||
g_slist_foreach (auth_list, (GFunc)smbfs_auth_free, 0);
|
||||
g_slist_free (auth_list);
|
||||
auth_list = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
authinfo_compare_host_and_share (gconstpointer _a, gconstpointer _b)
|
||||
smbfs_auth_cmp_host_and_share (gconstpointer _a, gconstpointer _b)
|
||||
{
|
||||
struct smb_authinfo const *a = (struct smb_authinfo const *)_a;
|
||||
struct smb_authinfo const *b = (struct smb_authinfo const *)_b;
|
||||
@ -133,7 +133,7 @@ authinfo_compare_host_and_share (gconstpointer _a, gconstpointer _b)
|
||||
}
|
||||
|
||||
static gint
|
||||
authinfo_compare_host (gconstpointer _a, gconstpointer _b)
|
||||
smbfs_auth_cmp_host (gconstpointer _a, gconstpointer _b)
|
||||
{
|
||||
struct smb_authinfo const *a = (struct smb_authinfo const *)_a;
|
||||
struct smb_authinfo const *b = (struct smb_authinfo const *)_b;
|
||||
@ -148,7 +148,7 @@ authinfo_compare_host (gconstpointer _a, gconstpointer _b)
|
||||
}
|
||||
|
||||
static void
|
||||
authinfo_add (const char *host, const char *share, const char *domain,
|
||||
smbfs_auth_add (const char *host, const char *share, const char *domain,
|
||||
const char *user, const char *password)
|
||||
{
|
||||
struct smb_authinfo *auth = g_new (struct smb_authinfo, 1);
|
||||
@ -166,7 +166,7 @@ authinfo_add (const char *host, const char *share, const char *domain,
|
||||
}
|
||||
|
||||
static void
|
||||
authinfo_remove (const char *host, const char *share)
|
||||
smbfs_auth_remove (const char *host, const char *share)
|
||||
{
|
||||
struct smb_authinfo data;
|
||||
struct smb_authinfo *auth;
|
||||
@ -176,21 +176,21 @@ authinfo_remove (const char *host, const char *share)
|
||||
data.share = g_strdup (share);
|
||||
list = g_slist_find_custom (auth_list,
|
||||
&data,
|
||||
authinfo_compare_host_and_share);
|
||||
smbfs_auth_cmp_host_and_share);
|
||||
g_free (data.host);
|
||||
g_free (data.share);
|
||||
if (!list)
|
||||
return;
|
||||
auth = list->data;
|
||||
auth_list = g_slist_remove (auth_list, auth);
|
||||
authinfo_free (auth);
|
||||
smbfs_auth_free (auth);
|
||||
}
|
||||
|
||||
/* Set authentication information in bucket. Return 1 if successful, else 0 */
|
||||
/* Information in auth_list overrides user if pass is NULL. */
|
||||
/* bucket->host and bucket->service must be valid. */
|
||||
static int
|
||||
bucket_set_authinfo (smbfs_connection *bucket,
|
||||
smbfs_bucket_set_authinfo (smbfs_connection *bucket,
|
||||
const char *domain, const char *user, const char *pass,
|
||||
int fallback_to_host)
|
||||
{
|
||||
@ -205,17 +205,17 @@ bucket_set_authinfo (smbfs_connection *bucket,
|
||||
bucket->domain = g_strdup (domain);
|
||||
bucket->user = g_strdup (user);
|
||||
bucket->password = g_strdup (pass);
|
||||
authinfo_remove (bucket->host, bucket->service);
|
||||
authinfo_add (bucket->host, bucket->service,
|
||||
smbfs_auth_remove (bucket->host, bucket->service);
|
||||
smbfs_auth_add (bucket->host, bucket->service,
|
||||
domain, user, pass);
|
||||
return 1;
|
||||
}
|
||||
|
||||
data.host = bucket->host;
|
||||
data.share = bucket->service;
|
||||
list = g_slist_find_custom (auth_list, &data, authinfo_compare_host_and_share);
|
||||
list = g_slist_find_custom (auth_list, &data, smbfs_auth_cmp_host_and_share);
|
||||
if (!list && fallback_to_host)
|
||||
list = g_slist_find_custom (auth_list, &data, authinfo_compare_host);
|
||||
list = g_slist_find_custom (auth_list, &data, smbfs_auth_cmp_host);
|
||||
if (list) {
|
||||
auth = list->data;
|
||||
bucket->domain = g_strdup (auth->domain);
|
||||
@ -242,7 +242,7 @@ bucket_set_authinfo (smbfs_connection *bucket,
|
||||
bucket->domain = g_strdup (auth->domain);
|
||||
bucket->user = g_strdup (auth->user);
|
||||
bucket->password = g_strdup (auth->password);
|
||||
authinfo_remove (bucket->host, bucket->service);
|
||||
smbfs_auth_remove (bucket->host, bucket->service);
|
||||
auth_list = g_slist_prepend (auth_list, auth);
|
||||
return 1;
|
||||
}
|
||||
@ -425,7 +425,7 @@ static opendir_info
|
||||
static gboolean first_direntry;
|
||||
|
||||
static dir_entry *
|
||||
new_dir_entry (const char *name)
|
||||
smbfs_new_dir_entry (const char *name)
|
||||
{
|
||||
static int inode_counter;
|
||||
dir_entry *new_entry;
|
||||
@ -446,11 +446,11 @@ new_dir_entry (const char *name)
|
||||
|
||||
/* browse for shares on server */
|
||||
static void
|
||||
browsing_helper (const char *name, uint32 type, const char *comment, void *state)
|
||||
smbfs_browsing_helper (const char *name, uint32 type, const char *comment, void *state)
|
||||
{
|
||||
char *typestr = "";
|
||||
|
||||
dir_entry *new_entry = new_dir_entry (name);
|
||||
dir_entry *new_entry = smbfs_new_dir_entry (name);
|
||||
|
||||
switch (type) {
|
||||
case STYPE_DISKTREE:
|
||||
@ -474,7 +474,7 @@ browsing_helper (const char *name, uint32 type, const char *comment, void *state
|
||||
}
|
||||
|
||||
static void
|
||||
loaddir_helper (file_info * finfo, const char *mask, void *entry)
|
||||
smbfs_loaddir_helper (file_info * finfo, const char *mask, void *entry)
|
||||
{
|
||||
dir_entry *new_entry = (dir_entry *) entry;
|
||||
time_t t = finfo->mtime; /* the time is assumed to be passed as GMT */
|
||||
@ -483,7 +483,7 @@ loaddir_helper (file_info * finfo, const char *mask, void *entry)
|
||||
return; /* don't bother with hidden files, "~$" screws up mc */
|
||||
#endif
|
||||
if (!entry)
|
||||
new_entry = new_dir_entry (finfo->name);
|
||||
new_entry = smbfs_new_dir_entry (finfo->name);
|
||||
|
||||
new_entry->my_stat.st_size = finfo->size;
|
||||
new_entry->my_stat.st_mtime = finfo->mtime;
|
||||
@ -517,7 +517,7 @@ loaddir_helper (file_info * finfo, const char *mask, void *entry)
|
||||
|
||||
/* takes "/foo/bar/file" and gives malloced "\\foo\\bar\\file" */
|
||||
static int
|
||||
convert_path(char **remote_file, gboolean trailing_asterik)
|
||||
smbfs_convert_path(char **remote_file, gboolean trailing_asterik)
|
||||
{
|
||||
char *p, *my_remote;
|
||||
|
||||
@ -545,20 +545,21 @@ convert_path(char **remote_file, gboolean trailing_asterik)
|
||||
}
|
||||
|
||||
static void
|
||||
server_browsing_helper (const char *name, uint32 m, const char *comment, void *state)
|
||||
smbfs_srv_browsing_helper (const char *name, uint32 m, const char *comment,
|
||||
void *state)
|
||||
{
|
||||
dir_entry *new_entry = new_dir_entry (name);
|
||||
dir_entry *new_entry = smbfs_new_dir_entry (name);
|
||||
|
||||
/* show this as dir */
|
||||
new_entry->my_stat.st_mode =
|
||||
(S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH) &
|
||||
myumask;
|
||||
(S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP |
|
||||
S_IXOTH) & myumask;
|
||||
|
||||
DEBUG (3, ("\t%-16.16s %s\n", name, comment));
|
||||
}
|
||||
|
||||
static BOOL
|
||||
reconnect(smbfs_connection *conn, int *retries)
|
||||
smbfs_reconnect(smbfs_connection *conn, int *retries)
|
||||
{
|
||||
char *host;
|
||||
DEBUG(3, ("RECONNECT\n"));
|
||||
@ -572,7 +573,7 @@ reconnect(smbfs_connection *conn, int *retries)
|
||||
|
||||
if (!(conn->cli = smbfs_do_connect(host, conn->service))) {
|
||||
message (1, MSG_ERROR,
|
||||
_(" reconnect to %s failed\n "), conn->host);
|
||||
_(" smbfs_reconnect to %s failed\n "), conn->host);
|
||||
g_free(host);
|
||||
return False;
|
||||
}
|
||||
@ -583,7 +584,7 @@ reconnect(smbfs_connection *conn, int *retries)
|
||||
}
|
||||
|
||||
static BOOL
|
||||
smb_send(struct cli_state *cli)
|
||||
smbfs_send(struct cli_state *cli)
|
||||
{
|
||||
size_t len;
|
||||
size_t nwritten=0;
|
||||
@ -606,7 +607,7 @@ See if server has cut us off by checking for EPIPE when writing.
|
||||
Taken from cli_chkpath()
|
||||
****************************************************************************/
|
||||
static BOOL
|
||||
chkpath(struct cli_state *cli, char *path, BOOL send_only)
|
||||
smbfs_chkpath(struct cli_state *cli, char *path, BOOL send_only)
|
||||
{
|
||||
fstring path2;
|
||||
char *p;
|
||||
@ -635,23 +636,23 @@ chkpath(struct cli_state *cli, char *path, BOOL send_only)
|
||||
*p++ = 4;
|
||||
fstrcpy(p,path2);
|
||||
|
||||
if (!smb_send(cli)) {
|
||||
DEBUG(3, ("chkpath: couldnt send\n"));
|
||||
if (!smbfs_send(cli)) {
|
||||
DEBUG(3, ("smbfs_chkpath: couldnt send\n"));
|
||||
return False;
|
||||
}
|
||||
if (send_only) {
|
||||
client_receive_smb(cli->fd, cli->inbuf, cli->timeout);
|
||||
DEBUG(3, ("chkpath: send only OK\n"));
|
||||
DEBUG(3, ("smbfs_chkpath: send only OK\n"));
|
||||
return True; /* just testing for EPIPE */
|
||||
}
|
||||
if (!client_receive_smb(cli->fd, cli->inbuf, cli->timeout)) {
|
||||
DEBUG(3, ("chkpath: receive error\n"));
|
||||
DEBUG(3, ("smbfs_chkpath: receive error\n"));
|
||||
return False;
|
||||
}
|
||||
if ((my_errno = cli_error(cli, NULL, NULL, NULL))) {
|
||||
if (my_errno == 20 || my_errno == 13)
|
||||
return True; /* ignore if 'not a directory' error */
|
||||
DEBUG(3, ("chkpath: cli_error: %s\n", g_strerror(my_errno)));
|
||||
DEBUG(3, ("smbfs_chkpath: cli_error: %s\n", g_strerror(my_errno)));
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -660,7 +661,7 @@ chkpath(struct cli_state *cli, char *path, BOOL send_only)
|
||||
|
||||
#if 1
|
||||
static int
|
||||
fs (const char *text)
|
||||
smbfs_fs (const char *text)
|
||||
{
|
||||
const char *p = text;
|
||||
int count = 0;
|
||||
@ -678,75 +679,83 @@ fs (const char *text)
|
||||
static int
|
||||
smbfs_loaddir (opendir_info *smbfs_info)
|
||||
{
|
||||
uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
|
||||
int servlen = strlen(smbfs_info->conn->service);
|
||||
char *my_dirname = smbfs_info->dirname;
|
||||
uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
|
||||
int servlen = strlen (smbfs_info->conn->service);
|
||||
char *my_dirname = smbfs_info->dirname;
|
||||
|
||||
DEBUG(3, ("smbfs_loaddir: dirname:%s\n", my_dirname));
|
||||
first_direntry = TRUE;
|
||||
DEBUG (3, ("smbfs_loaddir: dirname:%s\n", my_dirname));
|
||||
first_direntry = TRUE;
|
||||
|
||||
if (current_info) {
|
||||
DEBUG(3, ("smbfs_loaddir: new:'%s', cached:'%s'\n", my_dirname, current_info->dirname));
|
||||
/* if new desired dir is longer than cached in current_info */
|
||||
if (fs(my_dirname) > fs(current_info->dirname)) {
|
||||
DEBUG(3, ("saving to previous_info\n"));
|
||||
previous_info = current_info;
|
||||
}
|
||||
if (current_info) {
|
||||
DEBUG (3,
|
||||
("smbfs_loaddir: new:'%s', cached:'%s'\n", my_dirname,
|
||||
current_info->dirname));
|
||||
/* if new desired dir is longer than cached in current_info */
|
||||
if (smbfs_fs (my_dirname) > smbfs_fs (current_info->dirname)) {
|
||||
DEBUG (3, ("saving to previous_info\n"));
|
||||
previous_info = current_info;
|
||||
}
|
||||
}
|
||||
|
||||
current_info = smbfs_info;
|
||||
current_info = smbfs_info;
|
||||
|
||||
if (strcmp(my_dirname, "/") == 0) {
|
||||
if (!strcmp(smbfs_info->path, URL_HEADER)) {
|
||||
DEBUG(6, ("smbfs_loaddir: browsing %s\n", IPC));
|
||||
/* browse for servers */
|
||||
if (!cli_NetServerEnum(smbfs_info->conn->cli, smbfs_info->conn->domain,
|
||||
SV_TYPE_ALL, server_browsing_helper, NULL))
|
||||
return 0;
|
||||
else
|
||||
current_server_info = smbfs_info;
|
||||
smbfs_info->server_list = TRUE;
|
||||
} else {
|
||||
/* browse for shares */
|
||||
if (cli_RNetShareEnum(smbfs_info->conn->cli, browsing_helper, NULL) < 1)
|
||||
return 0;
|
||||
else
|
||||
current_share_info = smbfs_info;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* do regular directory listing */
|
||||
if(strncmp(smbfs_info->conn->service, my_dirname+1, servlen) == 0) {
|
||||
/* strip share name from dir */
|
||||
char *p = my_dirname = g_strdup(my_dirname + servlen);
|
||||
*p = '/';
|
||||
convert_path(&my_dirname, TRUE);
|
||||
g_free (p);
|
||||
} else
|
||||
convert_path(&my_dirname, TRUE);
|
||||
|
||||
DEBUG(6, ("smbfs_loaddir: service: %s\n", smbfs_info->conn->service));
|
||||
DEBUG(6, ("smbfs_loaddir: cli->share: %s\n", smbfs_info->conn->cli->share));
|
||||
DEBUG(6, ("smbfs_loaddir: calling cli_list with mask %s\n", my_dirname));
|
||||
/* do file listing: cli_list returns number of files */
|
||||
if (cli_list(
|
||||
smbfs_info->conn->cli, my_dirname, attribute, loaddir_helper, NULL) < 0) {
|
||||
/* cli_list returns -1 if directory empty or cannot read socket */
|
||||
my_errno = cli_error(smbfs_info->conn->cli, NULL, &err, NULL);
|
||||
g_free (my_dirname);
|
||||
if (strcmp (my_dirname, "/") == 0) {
|
||||
if (!strcmp (smbfs_info->path, URL_HEADER)) {
|
||||
DEBUG (6, ("smbfs_loaddir: browsing %s\n", IPC));
|
||||
/* browse for servers */
|
||||
if (!cli_NetServerEnum
|
||||
(smbfs_info->conn->cli, smbfs_info->conn->domain,
|
||||
SV_TYPE_ALL, smbfs_srv_browsing_helper, NULL))
|
||||
return 0;
|
||||
else
|
||||
current_server_info = smbfs_info;
|
||||
smbfs_info->server_list = TRUE;
|
||||
} else {
|
||||
/* browse for shares */
|
||||
if (cli_RNetShareEnum
|
||||
(smbfs_info->conn->cli, smbfs_browsing_helper, NULL) < 1)
|
||||
return 0;
|
||||
else
|
||||
current_share_info = smbfs_info;
|
||||
}
|
||||
if (*(my_dirname) == 0)
|
||||
smbfs_info->dirname = smbfs_info->conn->service;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* do regular directory listing */
|
||||
if (strncmp (smbfs_info->conn->service, my_dirname + 1, servlen) == 0) {
|
||||
/* strip share name from dir */
|
||||
char *p = my_dirname = g_strdup (my_dirname + servlen);
|
||||
*p = '/';
|
||||
smbfs_convert_path (&my_dirname, TRUE);
|
||||
g_free (p);
|
||||
} else
|
||||
smbfs_convert_path (&my_dirname, TRUE);
|
||||
|
||||
DEBUG (6, ("smbfs_loaddir: service: %s\n", smbfs_info->conn->service));
|
||||
DEBUG (6,
|
||||
("smbfs_loaddir: cli->share: %s\n",
|
||||
smbfs_info->conn->cli->share));
|
||||
DEBUG (6,
|
||||
("smbfs_loaddir: calling cli_list with mask %s\n", my_dirname));
|
||||
/* do file listing: cli_list returns number of files */
|
||||
if (cli_list
|
||||
(smbfs_info->conn->cli, my_dirname, attribute,
|
||||
smbfs_loaddir_helper, NULL) < 0) {
|
||||
/* cli_list returns -1 if directory empty or cannot read socket */
|
||||
my_errno = cli_error (smbfs_info->conn->cli, NULL, &err, NULL);
|
||||
g_free (my_dirname);
|
||||
return 0;
|
||||
}
|
||||
if (*(my_dirname) == 0)
|
||||
smbfs_info->dirname = smbfs_info->conn->service;
|
||||
g_free (my_dirname);
|
||||
/* do_dskattr(); */
|
||||
|
||||
done:
|
||||
done:
|
||||
/* current_info->parent = smbfs_info->dirname; */
|
||||
|
||||
smbfs_info->current = smbfs_info->entries;
|
||||
return 1; /* 1 = ok */
|
||||
smbfs_info->current = smbfs_info->entries;
|
||||
return 1; /* 1 = ok */
|
||||
}
|
||||
|
||||
#ifdef SMBFS_FREE_DIR
|
||||
@ -926,7 +935,7 @@ smbfs_do_connect (const char *server, char *share)
|
||||
current_bucket->password, strlen(current_bucket->password),
|
||||
current_bucket->domain)) {
|
||||
DEBUG(1,("session setup failed: %s\n", cli_errstr(c)));
|
||||
authinfo_remove (server, share);
|
||||
smbfs_auth_remove (server, share);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -955,7 +964,7 @@ smbfs_do_connect (const char *server, char *share)
|
||||
}
|
||||
|
||||
static int
|
||||
get_master_browser(char **host)
|
||||
smbfs_get_master_browser(char **host)
|
||||
{
|
||||
int count;
|
||||
struct in_addr *ip_list, bcast_addr;
|
||||
@ -981,7 +990,7 @@ get_master_browser(char **host)
|
||||
}
|
||||
|
||||
static void
|
||||
free_bucket (smbfs_connection *bucket)
|
||||
smbfs_free_bucket (smbfs_connection *bucket)
|
||||
{
|
||||
g_free (bucket->host);
|
||||
g_free (bucket->service);
|
||||
@ -1010,7 +1019,7 @@ smbfs_get_free_bucket ()
|
||||
}
|
||||
}
|
||||
cli_shutdown(smbfs_connections[oldest].cli);
|
||||
free_bucket (&smbfs_connections[oldest]);
|
||||
smbfs_free_bucket (&smbfs_connections[oldest]);
|
||||
return &smbfs_connections[oldest];
|
||||
}
|
||||
|
||||
@ -1062,8 +1071,8 @@ smbfs_open_link (char *host, char *path, const char *user, int *port,
|
||||
int retries = 0;
|
||||
BOOL inshare = (*host != 0 && *path != 0 && strchr (path, '/'));
|
||||
/* check if this connection has died */
|
||||
while (!chkpath (smbfs_connections[i].cli, "\\", !inshare)) {
|
||||
if (!reconnect (&smbfs_connections[i], &retries))
|
||||
while (!smbfs_chkpath (smbfs_connections[i].cli, "\\", !inshare)) {
|
||||
if (!smbfs_reconnect (&smbfs_connections[i], &retries))
|
||||
return 0;
|
||||
}
|
||||
DEBUG (6, ("smbfs_open_link: returning smbfs_connection[%d]\n", i));
|
||||
@ -1092,14 +1101,14 @@ smbfs_open_link (char *host, char *path, const char *user, int *port,
|
||||
bucket->service = g_strdup (service);
|
||||
|
||||
if (!(*host)) { /* if blank host name, browse for servers */
|
||||
if (!get_master_browser (&host)) /* set host to ip of master browser */
|
||||
if (!smbfs_get_master_browser (&host)) /* set host to ip of master browser */
|
||||
return 0; /* could not find master browser? */
|
||||
g_free (host);
|
||||
bucket->host = g_strdup (""); /* blank host means master browser */
|
||||
} else
|
||||
bucket->host = g_strdup (host);
|
||||
|
||||
if (!bucket_set_authinfo (bucket, 0, /* domain currently not used */
|
||||
if (!smbfs_bucket_set_authinfo (bucket, 0, /* domain currently not used */
|
||||
user, this_pass, 1))
|
||||
return 0;
|
||||
|
||||
@ -1111,8 +1120,8 @@ smbfs_open_link (char *host, char *path, const char *user, int *port,
|
||||
message (1, MSG_ERROR, _(" Authentication failed "));
|
||||
|
||||
/* authentication failed, try again */
|
||||
authinfo_remove (bucket->host, bucket->service);
|
||||
if (!bucket_set_authinfo (bucket, bucket->domain, bucket->user, 0, 0))
|
||||
smbfs_auth_remove (bucket->host, bucket->service);
|
||||
if (!smbfs_bucket_set_authinfo (bucket, bucket->domain, bucket->user, 0, 0))
|
||||
return 0;
|
||||
|
||||
}
|
||||
@ -1202,7 +1211,7 @@ smbfs_opendir (struct vfs_class *me, char *dirname)
|
||||
}
|
||||
|
||||
static int
|
||||
fake_server_stat (const char *server_url, const char *path, struct stat *buf)
|
||||
smbfs_fake_server_stat (const char *server_url, const char *path, struct stat *buf)
|
||||
{
|
||||
dir_entry *dentry;
|
||||
char *p;
|
||||
@ -1220,7 +1229,7 @@ fake_server_stat (const char *server_url, const char *path, struct stat *buf)
|
||||
DEBUG (4, ("fake stat for SERVER \"%s\"\n", path));
|
||||
while (dentry) {
|
||||
if (strcmp (dentry->text, path) == 0) {
|
||||
DEBUG (4, ("fake_server_stat: %s:%4o\n",
|
||||
DEBUG (4, ("smbfs_fake_server_stat: %s:%4o\n",
|
||||
dentry->text, (int)dentry->my_stat.st_mode));
|
||||
memcpy (buf, &dentry->my_stat, sizeof (struct stat));
|
||||
return 0;
|
||||
@ -1233,7 +1242,7 @@ fake_server_stat (const char *server_url, const char *path, struct stat *buf)
|
||||
}
|
||||
|
||||
static int
|
||||
fake_share_stat (const char *server_url, const char *path, struct stat *buf)
|
||||
smbfs_fake_share_stat (const char *server_url, const char *path, struct stat *buf)
|
||||
{
|
||||
dir_entry *dentry;
|
||||
if (strlen (path) < strlen (server_url))
|
||||
@ -1267,10 +1276,10 @@ fake_share_stat (const char *server_url, const char *path, struct stat *buf)
|
||||
return -1;
|
||||
}
|
||||
dentry = current_share_info->entries;
|
||||
DEBUG (3, ("fake_share_stat: %s on %s\n", path, server_url));
|
||||
DEBUG (3, ("smbfs_fake_share_stat: %s on %s\n", path, server_url));
|
||||
while (dentry) {
|
||||
if (strcmp (dentry->text, path) == 0) {
|
||||
DEBUG (6, ("fake_share_stat: %s:%4o\n",
|
||||
DEBUG (6, ("smbfs_fake_share_stat: %s:%4o\n",
|
||||
dentry->text, (int) dentry->my_stat.st_mode));
|
||||
memcpy (buf, &dentry->my_stat, sizeof (struct stat));
|
||||
return 0;
|
||||
@ -1281,19 +1290,19 @@ fake_share_stat (const char *server_url, const char *path, struct stat *buf)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* stat a single file, get_remote_stat callback */
|
||||
/* stat a single file, smbfs_get_remote_stat callback */
|
||||
static dir_entry *single_entry;
|
||||
|
||||
/* stat a single file */
|
||||
static int
|
||||
get_remote_stat (smbfs_connection * sc, char *path, struct stat *buf)
|
||||
smbfs_get_remote_stat (smbfs_connection * sc, char *path, struct stat *buf)
|
||||
{
|
||||
uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
|
||||
char *mypath = path;
|
||||
|
||||
DEBUG (3, ("get_remote_stat(): mypath:%s\n", mypath));
|
||||
DEBUG (3, ("smbfs_get_remote_stat(): mypath:%s\n", mypath));
|
||||
|
||||
convert_path (&mypath, FALSE);
|
||||
smbfs_convert_path (&mypath, FALSE);
|
||||
|
||||
#if 0 /* single_entry is never free()d now. And only my_stat is used */
|
||||
single_entry = g_new (dir_entry, 1);
|
||||
@ -1306,7 +1315,7 @@ get_remote_stat (smbfs_connection * sc, char *path, struct stat *buf)
|
||||
single_entry = g_new0 (dir_entry, 1);
|
||||
|
||||
if (cli_list
|
||||
(sc->cli, mypath, attribute, loaddir_helper, single_entry) < 1) {
|
||||
(sc->cli, mypath, attribute, smbfs_loaddir_helper, single_entry) < 1) {
|
||||
my_errno = ENOENT;
|
||||
g_free (mypath);
|
||||
return -1; /* cli_list returns number of files */
|
||||
@ -1322,7 +1331,7 @@ get_remote_stat (smbfs_connection * sc, char *path, struct stat *buf)
|
||||
}
|
||||
|
||||
static int
|
||||
search_dir_entry (dir_entry *dentry, const char *text, struct stat *buf)
|
||||
smbfs_search_dir_entry (dir_entry *dentry, const char *text, struct stat *buf)
|
||||
{
|
||||
while (dentry) {
|
||||
if (strcmp(text, dentry->text) == 0) {
|
||||
@ -1337,7 +1346,7 @@ search_dir_entry (dir_entry *dentry, const char *text, struct stat *buf)
|
||||
}
|
||||
|
||||
static int
|
||||
get_stat_info (smbfs_connection * sc, char *path, struct stat *buf)
|
||||
smbfs_get_stat_info (smbfs_connection * sc, char *path, struct stat *buf)
|
||||
{
|
||||
char *p;
|
||||
#if 0
|
||||
@ -1348,7 +1357,7 @@ get_stat_info (smbfs_connection * sc, char *path, struct stat *buf)
|
||||
mypath++; /* cut off leading '/' */
|
||||
if ((p = strrchr (mypath, '/')))
|
||||
mypath = p + 1; /* advance until last file/dir name */
|
||||
DEBUG (3, ("get_stat_info: mypath:%s, current_info->dirname:%s\n",
|
||||
DEBUG (3, ("smbfs_get_stat_info: mypath:%s, current_info->dirname:%s\n",
|
||||
mypath, current_info->dirname));
|
||||
#if 0
|
||||
if (!dentry) {
|
||||
@ -1359,7 +1368,7 @@ get_stat_info (smbfs_connection * sc, char *path, struct stat *buf)
|
||||
#endif
|
||||
if (!single_entry) /* when found, this will be written too */
|
||||
single_entry = g_new (dir_entry, 1);
|
||||
if (search_dir_entry (current_info->entries, mypath, buf) == 0) {
|
||||
if (smbfs_search_dir_entry (current_info->entries, mypath, buf) == 0) {
|
||||
return 0;
|
||||
}
|
||||
/* now try to identify mypath as PARENT dir */
|
||||
@ -1384,7 +1393,7 @@ get_stat_info (smbfs_connection * sc, char *path, struct stat *buf)
|
||||
/* now try to identify as CURRENT dir? */
|
||||
{
|
||||
char *dnp = current_info->dirname;
|
||||
DEBUG (6, ("get_stat_info: is %s current dir? this dir is: %s\n",
|
||||
DEBUG (6, ("smbfs_get_stat_info: is %s current dir? this dir is: %s\n",
|
||||
mypath, current_info->dirname));
|
||||
if (*dnp == '/')
|
||||
dnp++;
|
||||
@ -1403,27 +1412,27 @@ get_stat_info (smbfs_connection * sc, char *path, struct stat *buf)
|
||||
current_info->dirname));
|
||||
/* try to find this in the PREVIOUS listing */
|
||||
if (previous_info) {
|
||||
if (search_dir_entry (previous_info->entries, mypath, buf) == 0)
|
||||
if (smbfs_search_dir_entry (previous_info->entries, mypath, buf) == 0)
|
||||
return 0;
|
||||
DEBUG (3, ("'%s' not found in previous_info '%s'\n", path,
|
||||
previous_info->dirname));
|
||||
}
|
||||
/* try to find this in the SHARE listing */
|
||||
if (current_share_info) {
|
||||
if (search_dir_entry (current_share_info->entries, mypath, buf) == 0)
|
||||
if (smbfs_search_dir_entry (current_share_info->entries, mypath, buf) == 0)
|
||||
return 0;
|
||||
DEBUG (3, ("'%s' not found in share_info '%s'\n", path,
|
||||
current_share_info->dirname));
|
||||
}
|
||||
/* try to find this in the SERVER listing */
|
||||
if (current_server_info) {
|
||||
if (search_dir_entry (current_server_info->entries, mypath, buf) == 0)
|
||||
if (smbfs_search_dir_entry (current_server_info->entries, mypath, buf) == 0)
|
||||
return 0;
|
||||
DEBUG (3, ("'%s' not found in server_info '%s'\n", path,
|
||||
current_server_info->dirname));
|
||||
}
|
||||
/* nothing found. get stat file info from server */
|
||||
return get_remote_stat (sc, path, buf);
|
||||
return smbfs_get_remote_stat (sc, path, buf);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1441,7 +1450,7 @@ smbfs_chdir (struct vfs_class *me, char *path)
|
||||
}
|
||||
|
||||
static int
|
||||
loaddir(struct vfs_class *me, const char *path)
|
||||
smbfs_loaddir_by_name (struct vfs_class *me, const char *path)
|
||||
{
|
||||
void *info;
|
||||
char *mypath, *p;
|
||||
@ -1451,7 +1460,7 @@ loaddir(struct vfs_class *me, const char *path)
|
||||
|
||||
if (p > mypath)
|
||||
*p = 0;
|
||||
DEBUG(6, ("loaddir(%s)\n", mypath));
|
||||
DEBUG(6, ("smbfs_loaddir_by_name(%s)\n", mypath));
|
||||
smbfs_chdir(me, mypath);
|
||||
info = smbfs_opendir (me, mypath);
|
||||
g_free(mypath);
|
||||
@ -1474,7 +1483,7 @@ smbfs_stat (struct vfs_class * me, char *path, struct stat *buf)
|
||||
|
||||
if (!current_info) {
|
||||
DEBUG (1, ("current_info = NULL: "));
|
||||
if (loaddir (me, path) < 0)
|
||||
if (smbfs_loaddir_by_name (me, path) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1509,14 +1518,14 @@ smbfs_stat (struct vfs_class * me, char *path, struct stat *buf)
|
||||
|
||||
if (!pp) {
|
||||
if (!current_info->server_list) {
|
||||
if (loaddir (me, path) < 0)
|
||||
if (smbfs_loaddir_by_name (me, path) < 0)
|
||||
return -1;
|
||||
}
|
||||
return fake_server_stat (server_url, path, buf);
|
||||
return smbfs_fake_server_stat (server_url, path, buf);
|
||||
}
|
||||
|
||||
if (!strchr (++pp, '/')) {
|
||||
return fake_share_stat (server_url, path, buf);
|
||||
return smbfs_fake_share_stat (server_url, path, buf);
|
||||
}
|
||||
|
||||
/* stating inside share at this point */
|
||||
@ -1552,7 +1561,7 @@ smbfs_stat (struct vfs_class * me, char *path, struct stat *buf)
|
||||
pp++;
|
||||
if (strncmp (p, pp, strlen (p)) != 0) {
|
||||
DEBUG (6, ("desired '%s' is not loaded, we have '%s'\n", p, pp));
|
||||
if (loaddir (me, path) < 0) {
|
||||
if (smbfs_loaddir_by_name (me, path) < 0) {
|
||||
g_free (service);
|
||||
return -1;
|
||||
}
|
||||
@ -1560,7 +1569,7 @@ smbfs_stat (struct vfs_class * me, char *path, struct stat *buf)
|
||||
}
|
||||
g_free (service);
|
||||
/* stat dirs & files under shares now */
|
||||
return get_stat_info (sc, path, buf);
|
||||
return smbfs_get_stat_info (sc, path, buf);
|
||||
}
|
||||
|
||||
#define smbfs_lstat smbfs_stat /* no symlinks on smb filesystem? */
|
||||
@ -1616,7 +1625,7 @@ smbfs_mkdir (struct vfs_class * me, char *path, mode_t mode)
|
||||
if ((remote_file = smbfs_get_path (&sc, path)) == 0)
|
||||
return -1;
|
||||
g_free (remote_file);
|
||||
convert_path (&path, FALSE);
|
||||
smbfs_convert_path (&path, FALSE);
|
||||
|
||||
if (!cli_mkdir (sc->cli, path)) {
|
||||
my_errno = cli_error (sc->cli, NULL, &err, NULL);
|
||||
@ -1639,7 +1648,7 @@ smbfs_rmdir (struct vfs_class *me, char *path)
|
||||
if ((remote_file = smbfs_get_path (&sc, path)) == 0)
|
||||
return -1;
|
||||
g_free (remote_file);
|
||||
convert_path(&path, FALSE);
|
||||
smbfs_convert_path(&path, FALSE);
|
||||
|
||||
if (!cli_rmdir(sc->cli, path)) {
|
||||
my_errno = cli_error(sc->cli, NULL, &err, NULL);
|
||||
@ -1685,14 +1694,14 @@ smbfs_free (vfsid id)
|
||||
{
|
||||
DEBUG (3, ("smbfs_free(%p)\n", id));
|
||||
/* FIXME: Should not be empty */
|
||||
authinfo_free_all ();
|
||||
smbfs_auth_free_all ();
|
||||
}
|
||||
|
||||
/* Gives up on a socket and reopens the connection, the child own the socket
|
||||
* now
|
||||
*/
|
||||
static void
|
||||
my_forget (char *path)
|
||||
smbfs_forget (char *path)
|
||||
{
|
||||
char *host, *user, *p;
|
||||
int port, i;
|
||||
@ -1700,7 +1709,7 @@ my_forget (char *path)
|
||||
if (strncmp (path, URL_HEADER, HEADER_LEN))
|
||||
return;
|
||||
|
||||
DEBUG(3, ("my_forget(path:%s)\n", path));
|
||||
DEBUG(3, ("smbfs_forget(path:%s)\n", path));
|
||||
|
||||
path += 6;
|
||||
if (path[0] == '/' && path[1] == '/')
|
||||
@ -1732,7 +1741,7 @@ smbfs_setctl (struct vfs_class *me, char *path, int ctlop, void *arg)
|
||||
DEBUG (3, ("smbfs_setctl(path:%s, ctlop:%d)\n", path, ctlop));
|
||||
switch (ctlop) {
|
||||
case VFS_SETCTL_FORGET:
|
||||
my_forget (path);
|
||||
smbfs_forget (path);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
@ -1740,7 +1749,7 @@ smbfs_setctl (struct vfs_class *me, char *path, int ctlop, void *arg)
|
||||
|
||||
|
||||
static smbfs_handle *
|
||||
open_readwrite (smbfs_handle *remote_handle, char *rname, int flags, int mode)
|
||||
smbfs_open_readwrite (smbfs_handle *remote_handle, char *rname, int flags, int mode)
|
||||
{
|
||||
size_t size;
|
||||
|
||||
@ -1795,14 +1804,14 @@ smbfs_open (struct vfs_class *me, char *file, int flags, int mode)
|
||||
return 0;
|
||||
|
||||
p = remote_file;
|
||||
convert_path (&remote_file, FALSE);
|
||||
smbfs_convert_path (&remote_file, FALSE);
|
||||
g_free (p);
|
||||
|
||||
remote_handle = g_new (smbfs_handle, 2);
|
||||
remote_handle->cli = sc->cli;
|
||||
remote_handle->nread = 0;
|
||||
|
||||
ret = open_readwrite (remote_handle, remote_file, flags, mode);
|
||||
ret = smbfs_open_readwrite (remote_handle, remote_file, flags, mode);
|
||||
|
||||
g_free (remote_file);
|
||||
if (!ret)
|
||||
@ -1821,7 +1830,7 @@ smbfs_unlink (struct vfs_class *me, char *path)
|
||||
return -1;
|
||||
|
||||
p = remote_file;
|
||||
convert_path(&remote_file, FALSE);
|
||||
smbfs_convert_path(&remote_file, FALSE);
|
||||
g_free (p);
|
||||
|
||||
if (!cli_unlink(sc->cli, remote_file)) {
|
||||
@ -1851,10 +1860,10 @@ smbfs_rename (struct vfs_class *me, char *a, char *b)
|
||||
}
|
||||
|
||||
p = ra;
|
||||
convert_path(&ra, FALSE);
|
||||
smbfs_convert_path(&ra, FALSE);
|
||||
g_free (p);
|
||||
p = rb;
|
||||
convert_path(&rb, FALSE);
|
||||
smbfs_convert_path(&rb, FALSE);
|
||||
g_free (p);
|
||||
|
||||
retval = cli_rename(sc->cli, ra, rb);
|
||||
@ -1877,7 +1886,7 @@ smbfs_fstat (void *data, struct stat *buf)
|
||||
|
||||
DEBUG(3, ("smbfs_fstat(fnum:%d)\n", remote_handle->fnum));
|
||||
|
||||
/* use left over from previous get_remote_stat, if available */
|
||||
/* use left over from previous smbfs_get_remote_stat, if available */
|
||||
if (single_entry)
|
||||
memcpy(buf, &single_entry->my_stat, sizeof(struct stat));
|
||||
else { /* single_entry not set up: bug */
|
||||
|
91
vfs/tar.c
91
vfs/tar.c
@ -165,7 +165,7 @@ union record {
|
||||
*
|
||||
* Result is -1 if the field is invalid (all blank, or nonoctal).
|
||||
*/
|
||||
static long from_oct (int digs, char *where)
|
||||
static long tar_from_oct (int digs, char *where)
|
||||
{
|
||||
register long value;
|
||||
|
||||
@ -198,7 +198,7 @@ static void tar_free_archive (struct vfs_class *me, struct vfs_s_super *archive)
|
||||
static int current_tar_position = 0;
|
||||
|
||||
/* Returns fd of the open tar file */
|
||||
static int tar_open_archive (struct vfs_class *me, char *name, struct vfs_s_super *archive)
|
||||
static int tar_tar_open_archive (struct vfs_class *me, char *name, struct vfs_s_super *archive)
|
||||
{
|
||||
int result, type;
|
||||
mode_t mode;
|
||||
@ -250,7 +250,7 @@ static int tar_open_archive (struct vfs_class *me, char *name, struct vfs_s_supe
|
||||
static union record rec_buf;
|
||||
|
||||
static union record *
|
||||
get_next_record (struct vfs_s_super *archive, int tard)
|
||||
tar_get_next_record (struct vfs_s_super *archive, int tard)
|
||||
{
|
||||
int n;
|
||||
|
||||
@ -261,15 +261,16 @@ get_next_record (struct vfs_s_super *archive, int tard)
|
||||
return &rec_buf;
|
||||
}
|
||||
|
||||
static void skip_n_records (struct vfs_s_super *archive, int tard, int n)
|
||||
static void tar_skip_n_records (struct vfs_s_super *archive, int tard, int n)
|
||||
{
|
||||
mc_lseek (tard, n * RECORDSIZE, SEEK_CUR);
|
||||
current_tar_position += n * RECORDSIZE;
|
||||
}
|
||||
|
||||
static void fill_stat_from_header (struct vfs_class *me, struct stat *st, union record *header)
|
||||
static void
|
||||
tar_fill_stat (struct vfs_class *me, struct stat *st, union record *header)
|
||||
{
|
||||
st->st_mode = from_oct (8, header->header.mode);
|
||||
st->st_mode = tar_from_oct (8, header->header.mode);
|
||||
|
||||
/* Adjust st->st_mode because there are tar-files with
|
||||
* linkflag==LF_SYMLINK and S_ISLNK(mod)==0. I don't
|
||||
@ -286,29 +287,38 @@ static void fill_stat_from_header (struct vfs_class *me, struct stat *st, union
|
||||
st->st_mode |= S_IFBLK;
|
||||
} else if (header->header.linkflag == LF_FIFO) {
|
||||
st->st_mode |= S_IFIFO;
|
||||
} else
|
||||
} else
|
||||
st->st_mode |= S_IFREG;
|
||||
|
||||
st->st_rdev = 0;
|
||||
if (!strcmp (header->header.magic, TMAGIC)) {
|
||||
st->st_uid = *header->header.uname ? finduid (header->header.uname) :
|
||||
from_oct (8, header->header.uid);
|
||||
st->st_gid = *header->header.gname ? findgid (header->header.gname) :
|
||||
from_oct (8, header->header.gid);
|
||||
st->st_uid =
|
||||
*header->header.uname ? vfs_finduid (header->header.
|
||||
uname) : tar_from_oct (8,
|
||||
header->
|
||||
header.
|
||||
uid);
|
||||
st->st_gid =
|
||||
*header->header.gname ? vfs_findgid (header->header.
|
||||
gname) : tar_from_oct (8,
|
||||
header->
|
||||
header.
|
||||
gid);
|
||||
switch (header->header.linkflag) {
|
||||
case LF_BLK:
|
||||
case LF_CHR:
|
||||
st->st_rdev = (from_oct (8, header->header.devmajor) << 8) |
|
||||
from_oct (8, header->header.devminor);
|
||||
st->st_rdev =
|
||||
(tar_from_oct (8, header->header.devmajor) << 8) |
|
||||
tar_from_oct (8, header->header.devminor);
|
||||
}
|
||||
} else { /* Old Unix tar */
|
||||
st->st_uid = from_oct (8, header->header.uid);
|
||||
st->st_gid = from_oct (8, header->header.gid);
|
||||
} else { /* Old Unix tar */
|
||||
st->st_uid = tar_from_oct (8, header->header.uid);
|
||||
st->st_gid = tar_from_oct (8, header->header.gid);
|
||||
}
|
||||
st->st_size = hstat.st_size;
|
||||
st->st_mtime = from_oct (1 + 12, header->header.mtime);
|
||||
st->st_atime = from_oct (1 + 12, header->header.atime);
|
||||
st->st_ctime = from_oct (1 + 12, header->header.ctime);
|
||||
st->st_mtime = tar_from_oct (1 + 12, header->header.mtime);
|
||||
st->st_atime = tar_from_oct (1 + 12, header->header.atime);
|
||||
st->st_ctime = tar_from_oct (1 + 12, header->header.ctime);
|
||||
}
|
||||
|
||||
|
||||
@ -324,7 +334,7 @@ typedef enum {
|
||||
*
|
||||
*/
|
||||
static ReadStatus
|
||||
read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard)
|
||||
tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard)
|
||||
{
|
||||
register int i;
|
||||
register long sum, signed_sum, recsum;
|
||||
@ -334,11 +344,11 @@ read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard)
|
||||
|
||||
recurse:
|
||||
|
||||
header = get_next_record (archive, tard);
|
||||
header = tar_get_next_record (archive, tard);
|
||||
if (NULL == header)
|
||||
return STATUS_EOF;
|
||||
|
||||
recsum = from_oct (8, header->header.chksum);
|
||||
recsum = tar_from_oct (8, header->header.chksum);
|
||||
|
||||
sum = 0; signed_sum = 0;
|
||||
p = header->charptr;
|
||||
@ -383,7 +393,7 @@ read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard)
|
||||
if (header->header.linkflag == LF_LINK || header->header.linkflag == LF_DIR)
|
||||
hstat.st_size = 0; /* Links 0 size on tape */
|
||||
else
|
||||
hstat.st_size = from_oct (1 + 12, header->header.size);
|
||||
hstat.st_size = tar_from_oct (1 + 12, header->header.size);
|
||||
|
||||
header->header.arch_name[NAMSIZ - 1] = '\0';
|
||||
if (header->header.linkflag == LF_LONGNAME
|
||||
@ -403,7 +413,7 @@ read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard)
|
||||
for (size = hstat.st_size;
|
||||
size > 0;
|
||||
size -= written) {
|
||||
data = get_next_record (archive, tard)->charptr;
|
||||
data = tar_get_next_record (archive, tard)->charptr;
|
||||
if (data == NULL) {
|
||||
message (1, MSG_ERROR, _("Unexpected EOF on archive file"));
|
||||
return STATUS_BADCHECKSUM;
|
||||
@ -473,7 +483,7 @@ read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard)
|
||||
}
|
||||
}
|
||||
|
||||
fill_stat_from_header (me, &st, header);
|
||||
tar_fill_stat (me, &st, header);
|
||||
inode = vfs_s_new_inode (me, archive, &st);
|
||||
|
||||
inode->data_offset = data_position;
|
||||
@ -491,7 +501,7 @@ read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard)
|
||||
next_long_link = next_long_name = NULL;
|
||||
|
||||
if (header->header.isextended) {
|
||||
while (get_next_record (archive, tard)->ext_hdr.isextended);
|
||||
while (tar_get_next_record (archive, tard)->ext_hdr.isextended);
|
||||
inode->data_offset = current_tar_position;
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
@ -502,25 +512,31 @@ read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard)
|
||||
* Main loop for reading an archive.
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
static int open_archive (struct vfs_class *me, struct vfs_s_super *archive, char *name, char *op)
|
||||
static int
|
||||
tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive,
|
||||
char *name, char *op)
|
||||
{
|
||||
ReadStatus status = STATUS_EOFMARK; /* Initial status at start of archive */
|
||||
/* Initial status at start of archive */
|
||||
ReadStatus status = STATUS_EOFMARK;
|
||||
ReadStatus prev_status;
|
||||
int tard;
|
||||
|
||||
current_tar_position = 0;
|
||||
if ((tard = tar_open_archive (me, name, archive)) == -1) /* Open for reading */
|
||||
/* Open for reading */
|
||||
if ((tard = tar_tar_open_archive (me, name, archive)) == -1)
|
||||
return -1;
|
||||
|
||||
for (;;) {
|
||||
prev_status = status;
|
||||
status = read_header (me, archive, tard);
|
||||
status = tar_read_header (me, archive, tard);
|
||||
|
||||
|
||||
switch (status) {
|
||||
|
||||
case STATUS_SUCCESS:
|
||||
skip_n_records (archive, tard, (hstat.st_size + RECORDSIZE - 1) / RECORDSIZE);
|
||||
tar_skip_n_records (archive, tard,
|
||||
(hstat.st_size + RECORDSIZE -
|
||||
1) / RECORDSIZE);
|
||||
continue;
|
||||
|
||||
/*
|
||||
@ -529,12 +545,15 @@ static int open_archive (struct vfs_class *me, struct vfs_s_super *archive, char
|
||||
* If the previous header was good, tell them
|
||||
* that we are skipping bad ones.
|
||||
*/
|
||||
case STATUS_BADCHECKSUM:
|
||||
switch (prev_status){
|
||||
case STATUS_BADCHECKSUM:
|
||||
switch (prev_status) {
|
||||
|
||||
/* Error on first record */
|
||||
case STATUS_EOFMARK:
|
||||
message (1, MSG_ERROR, _("Hmm,...\n%s\ndoesn't look like a tar archive."), name);
|
||||
message (1, MSG_ERROR,
|
||||
_
|
||||
("Hmm,...\n%s\ndoesn't look like a tar archive."),
|
||||
name);
|
||||
/* FALL THRU */
|
||||
|
||||
/* Error after header rec */
|
||||
@ -549,7 +568,7 @@ static int open_archive (struct vfs_class *me, struct vfs_s_super *archive, char
|
||||
}
|
||||
|
||||
/* Record of zeroes */
|
||||
case STATUS_EOFMARK:
|
||||
case STATUS_EOFMARK:
|
||||
status = prev_status; /* If error after 0's */
|
||||
/* FALL THRU */
|
||||
|
||||
@ -620,7 +639,7 @@ init_tarfs (void)
|
||||
|
||||
tarfs_subclass.archive_check = tar_super_check;
|
||||
tarfs_subclass.archive_same = tar_super_same;
|
||||
tarfs_subclass.open_archive = open_archive;
|
||||
tarfs_subclass.open_archive = tar_open_archive;
|
||||
tarfs_subclass.free_archive = tar_free_archive;
|
||||
tarfs_subclass.fh_open = tar_fh_open;
|
||||
tarfs_subclass.find_entry = vfs_s_find_entry_tree;
|
||||
|
@ -146,7 +146,7 @@ undelfs_get_path (const char *dirname, char **ext2_fname, char **file)
|
||||
}
|
||||
|
||||
static int
|
||||
lsdel_proc(ext2_filsys fs, blk_t *block_nr, int blockcnt, void *private)
|
||||
undelfs_lsdel_proc(ext2_filsys fs, blk_t *block_nr, int blockcnt, void *private)
|
||||
{
|
||||
struct lsdel_struct *lsd = (struct lsdel_struct *) private;
|
||||
|
||||
@ -173,8 +173,8 @@ undelfs_loaddel (void)
|
||||
int retval, count;
|
||||
ext2_ino_t ino;
|
||||
struct ext2_inode inode;
|
||||
ext2_inode_scan scan;
|
||||
|
||||
ext2_inode_scan scan;
|
||||
|
||||
max_delarray = 100;
|
||||
num_delarray = 0;
|
||||
delarray = g_new (struct deleted_info, max_delarray);
|
||||
@ -187,23 +187,26 @@ undelfs_loaddel (void)
|
||||
message (1, undelfserr, _(" while allocating block buffer "));
|
||||
goto free_delarray;
|
||||
}
|
||||
if ((retval = ext2fs_open_inode_scan(fs, 0, &scan))){
|
||||
if ((retval = ext2fs_open_inode_scan (fs, 0, &scan))) {
|
||||
message (1, undelfserr, _(" open_inode_scan: %d "), retval);
|
||||
goto free_block_buf;
|
||||
}
|
||||
if ((retval = ext2fs_get_next_inode(scan, &ino, &inode))){
|
||||
message (1, undelfserr, _(" while starting inode scan %d "), retval);
|
||||
if ((retval = ext2fs_get_next_inode (scan, &ino, &inode))) {
|
||||
message (1, undelfserr, _(" while starting inode scan %d "),
|
||||
retval);
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
while (ino) {
|
||||
if ((count++ % 1024) == 0)
|
||||
print_vfs_message (_("undelfs: loading deleted files information %d inodes"), count);
|
||||
if ((count++ % 1024) == 0)
|
||||
print_vfs_message (_
|
||||
("undelfs: loading deleted files information %d inodes"),
|
||||
count);
|
||||
if (inode.i_dtime == 0)
|
||||
goto next;
|
||||
|
||||
if (S_ISDIR(inode.i_mode))
|
||||
if (S_ISDIR (inode.i_mode))
|
||||
goto next;
|
||||
|
||||
lsd.inode = ino;
|
||||
@ -211,22 +214,27 @@ undelfs_loaddel (void)
|
||||
lsd.free_blocks = 0;
|
||||
lsd.bad_blocks = 0;
|
||||
|
||||
retval = ext2fs_block_iterate(fs, ino, 0, block_buf,
|
||||
lsdel_proc, &lsd);
|
||||
retval =
|
||||
ext2fs_block_iterate (fs, ino, 0, block_buf,
|
||||
undelfs_lsdel_proc, &lsd);
|
||||
if (retval) {
|
||||
message (1, undelfserr, _(" while calling ext2_block_iterate %d "), retval);
|
||||
message (1, undelfserr,
|
||||
_(" while calling ext2_block_iterate %d "), retval);
|
||||
goto next;
|
||||
}
|
||||
if (lsd.free_blocks && !lsd.bad_blocks) {
|
||||
if (num_delarray >= max_delarray) {
|
||||
max_delarray += 50;
|
||||
delarray = g_renew (struct deleted_info, delarray, max_delarray);
|
||||
delarray =
|
||||
g_renew (struct deleted_info, delarray, max_delarray);
|
||||
if (!delarray) {
|
||||
message (1, undelfserr, _(" no more memory while reallocating array "));
|
||||
message (1, undelfserr,
|
||||
_
|
||||
(" no more memory while reallocating array "));
|
||||
goto error_out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
delarray[num_delarray].ino = ino;
|
||||
delarray[num_delarray].mode = inode.i_mode;
|
||||
delarray[num_delarray].uid = inode.i_uid;
|
||||
@ -238,23 +246,24 @@ undelfs_loaddel (void)
|
||||
num_delarray++;
|
||||
}
|
||||
|
||||
next:
|
||||
retval = ext2fs_get_next_inode(scan, &ino, &inode);
|
||||
next:
|
||||
retval = ext2fs_get_next_inode (scan, &ino, &inode);
|
||||
if (retval) {
|
||||
message (1, undelfserr, _(" while doing inode scan %d "), retval);
|
||||
message (1, undelfserr, _(" while doing inode scan %d "),
|
||||
retval);
|
||||
goto error_out;
|
||||
}
|
||||
}
|
||||
readdir_ptr = READDIR_PTR_INIT;
|
||||
ext2fs_close_inode_scan (scan);
|
||||
return 1;
|
||||
|
||||
error_out:
|
||||
|
||||
error_out:
|
||||
ext2fs_close_inode_scan (scan);
|
||||
free_block_buf:
|
||||
free_block_buf:
|
||||
g_free (block_buf);
|
||||
block_buf = NULL;
|
||||
free_delarray:
|
||||
free_delarray:
|
||||
g_free (delarray);
|
||||
delarray = NULL;
|
||||
return 0;
|
||||
@ -433,7 +442,7 @@ undelfs_close (void *vfs_info)
|
||||
}
|
||||
|
||||
static int
|
||||
dump_read(ext2_filsys fs, blk_t *blocknr, int blockcnt, void *private)
|
||||
undelfs_dump_read(ext2_filsys fs, blk_t *blocknr, int blockcnt, void *private)
|
||||
{
|
||||
int copy_count;
|
||||
undelfs_file *p = (undelfs_file *) private;
|
||||
@ -504,7 +513,7 @@ undelfs_read (void *vfs_info, char *buffer, int count)
|
||||
p->count = p->size - p->pos;
|
||||
}
|
||||
retval = ext2fs_block_iterate(fs, p->inode, 0, NULL,
|
||||
dump_read, p);
|
||||
undelfs_dump_read, p);
|
||||
if (retval){
|
||||
message (1, undelfserr, _(" while iterating over blocks "));
|
||||
return -1;
|
||||
@ -529,7 +538,7 @@ undelfs_getindex (char *path)
|
||||
}
|
||||
|
||||
static int
|
||||
do_stat (int inode_index, struct stat *buf)
|
||||
undelfs_stat_int (int inode_index, struct stat *buf)
|
||||
{
|
||||
buf->st_dev = 0;
|
||||
buf->st_ino = delarray [inode_index].ino;
|
||||
@ -579,7 +588,7 @@ undelfs_lstat(struct vfs_class *me, char *path, struct stat *buf)
|
||||
if (inode_index == -1)
|
||||
return -1;
|
||||
|
||||
return do_stat (inode_index, buf);
|
||||
return undelfs_stat_int (inode_index, buf);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -594,7 +603,7 @@ undelfs_fstat (void *vfs_info, struct stat *buf)
|
||||
{
|
||||
undelfs_file *p = vfs_info;
|
||||
|
||||
return do_stat (p->f_index, buf);
|
||||
return undelfs_stat_int (p->f_index, buf);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -165,7 +165,7 @@ vfs_split_url (const char *path, char **host, char **user, int *port,
|
||||
#define mygid ( my_gid < 0? (my_gid = getgid()): my_gid )
|
||||
|
||||
int
|
||||
finduid (char *uname)
|
||||
vfs_finduid (char *uname)
|
||||
{
|
||||
static int saveuid = -993;
|
||||
static char saveuname[TUNMLEN];
|
||||
@ -187,7 +187,7 @@ finduid (char *uname)
|
||||
}
|
||||
|
||||
int
|
||||
findgid (char *gname)
|
||||
vfs_findgid (char *gname)
|
||||
{
|
||||
static int savegid = -993;
|
||||
static char savegname[TGNMLEN];
|
||||
|
@ -14,7 +14,7 @@
|
||||
char *vfs_split_url (const char *path, char **host, char **user, int *port,
|
||||
char **pass, int default_port, int flags);
|
||||
|
||||
int finduid (char *name);
|
||||
int findgid (char *name);
|
||||
int vfs_finduid (char *name);
|
||||
int vfs_findgid (char *name);
|
||||
|
||||
#endif /* !__UTILVFS_H */
|
||||
|
@ -1681,7 +1681,7 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, char **linknam
|
||||
goto error;
|
||||
|
||||
if (!is_num (1))
|
||||
s->st_uid = finduid (columns [1]);
|
||||
s->st_uid = vfs_finduid (columns [1]);
|
||||
else
|
||||
s->st_uid = (uid_t) atol (columns [1]);
|
||||
|
||||
@ -1702,7 +1702,7 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, char **linknam
|
||||
if (is_num (2))
|
||||
s->st_gid = (gid_t) atol (columns [2]);
|
||||
else
|
||||
s->st_gid = findgid (columns [2]);
|
||||
s->st_gid = vfs_findgid (columns [2]);
|
||||
idx2 = 3;
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user