Fixed problems with stating / of ftp archive; minor bugfix.

This commit is contained in:
Pavel Machek 2000-05-03 19:10:52 +00:00
parent 6f3d6c89c0
commit 8542ae3328
3 changed files with 16 additions and 12 deletions

View File

@ -1,3 +1,10 @@
2000-05-01 Pavel Machek <pavel@bug.ucw.cz>
* direntry.c (vfs_s_inode_from_path): fix for stating / directory
done properly
* vfs.c: == 0 is right test of eof.
2000-04-28 Pavel Machek <pavel@artax.karlin.mff.cuni.cz> 2000-04-28 Pavel Machek <pavel@artax.karlin.mff.cuni.cz>
* direntry.c (vfs_s_internal_stat): added ugly special case for / * direntry.c (vfs_s_internal_stat): added ugly special case for /

View File

@ -565,12 +565,17 @@ vfs_s_inode *
vfs_s_inode_from_path (vfs *me, char *name, int flags) vfs_s_inode_from_path (vfs *me, char *name, int flags)
{ {
struct vfs_s_super *super; struct vfs_s_super *super;
struct vfs_s_inode *ino;
char *q; char *q;
if (!(q = vfs_s_get_path_mangle (me, name, &super, 0))) if (!(q = vfs_s_get_path_mangle (me, name, &super, 0)))
return NULL; return NULL;
return vfs_s_find_inode (me, super->root, q, flags & FL_FOLLOW ? LINK_FOLLOW : LINK_NO_FOLLOW, flags & ~FL_FOLLOW); ino = vfs_s_find_inode (me, super->root, q, flags & FL_FOLLOW ? LINK_FOLLOW : LINK_NO_FOLLOW, flags & ~FL_FOLLOW);
if ((!ino) && (!*q))
/* We are asking about / directory of ftp server: assume it exists */
ino = vfs_s_find_inode (me, super->root, q, flags & FL_FOLLOW ? LINK_FOLLOW : LINK_NO_FOLLOW, FL_DIR | (flags & ~FL_FOLLOW));
return ino;
} }
struct dirhandle { struct dirhandle {
@ -683,18 +688,11 @@ vfs_s_chdir (vfs *me, char *path)
static int static int
vfs_s_internal_stat (vfs *me, char *path, struct stat *buf, int flag) vfs_s_internal_stat (vfs *me, char *path, struct stat *buf, int flag)
{ {
char *path2;
struct vfs_s_inode *ino; struct vfs_s_inode *ino;
path2 = g_strdup(path); if (!(ino = vfs_s_inode_from_path (me, path, flag)))
if (!(ino = vfs_s_inode_from_path (me, path2, flag))) {
if ((!path) || (*path) || !(ino = vfs_s_inode_from_path (me, path, flag|FL_DIR))) { /* Seems we have problem: vfs_s_inode_from_path on directories always succeeds. This is *hack* to make / directory of ftp archive statable */
g_free(path2);
return -1; return -1;
}
}
*buf = ino->st; *buf = ino->st;
g_free(path2);
return 0; return 0;
} }

View File

@ -1074,9 +1074,8 @@ mc_def_getlocalcopy (vfs *vfs, char *filename)
fdout = open (tmp, O_CREAT|O_WRONLY|O_TRUNC|O_EXCL, 0600); fdout = open (tmp, O_CREAT|O_WRONLY|O_TRUNC|O_EXCL, 0600);
if (fdout == -1) if (fdout == -1)
goto fail; goto fail;
while ((i = mc_read (fdin, buffer, sizeof (buffer))) == sizeof (buffer)){ while ((i = mc_read (fdin, buffer, sizeof (buffer))) > 0)
write (fdout, buffer, i); write (fdout, buffer, i);
}
if (i == -1) if (i == -1)
goto fail; goto fail;
if (write (fdout, buffer, i)==-1) if (write (fdout, buffer, i)==-1)