1
1

Some fixes in src/ part (want_stale_data is now done right) and more

daring code in vfs/ (errors are now reported instead of silently
ignored)
Этот коммит содержится в:
Pavel Machek 1998-12-09 20:22:53 +00:00
родитель 44a1b32eeb
Коммит 3e1a72d64d
8 изменённых файлов: 100 добавлений и 78 удалений

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

@ -1,3 +1,13 @@
Mon Nov 30 21:10:30 1998 Pavel Machek <pavel@bug.ucw.cz>
* file.c (copy_file_file): minor code beatifulling: replace goto's
with while loops (it is both shorter and nicer :-)
(panel_operate): hopefully done WANT_STALE_DATA right. We really
should kill ftpfs_hint_reread hack soon.
* cmd.c (dirsizes_cmd): report error if you are on non-local
filesystem. (As oposed to silently failing.)
1998-12-07 Miguel de Icaza <miguel@nuclecu.unam.mx>
* screen.c (panel_reload): Set panel->selected to zero here, this

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

@ -1361,8 +1361,10 @@ void dirsizes_cmd (void)
# define DUSUM_FACTOR 512
#endif
if (!vfs_current_is_local ())
if (!vfs_current_is_local ()) {
message (1, MSG_ERROR, _("You can not scan disk usage on non-local filesystem. Sorry.") );
return;
}
for (i = 0; i < panel->count; i++)
if (S_ISDIR (panel->dir.list [i].buf.st_mode))
j += strlen (panel->dir.list [i].fname) + 1;

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

@ -388,7 +388,7 @@ check_hardlinks (char *src_name, char *dst_name, struct stat *pstat)
struct stat link_stat;
char *p;
#if 1 /* What will happen if we kill this line? mc_link() will fail on this and it is right behaivour... */
#if 1 /* What will happen if we kill this line? mc_link() will fail on this and it is right behaviour... */
if (vfs_file_is_ftp (src_name))
return 0;
#endif
@ -577,12 +577,11 @@ copy_file_file (char *src_path, char *dst_path, int ask_overwrite,
dst_exists = 1;
}
retry_src_xstat:
if ((*file_mask_xstat)(src_path, &sb)){
while ((*file_mask_xstat)(src_path, &sb)){
return_status = file_error (_(" Cannot stat source file \"%s\" \n %s "),
src_path);
if (return_status == FILE_RETRY)
goto retry_src_xstat;
continue;
return return_status;
}
@ -627,33 +626,30 @@ copy_file_file (char *src_path, char *dst_path, int ask_overwrite,
if (S_ISCHR (sb.st_mode) || S_ISBLK (sb.st_mode) || S_ISFIFO (sb.st_mode)
|| S_ISSOCK (sb.st_mode)){
retry_mknod:
if (mc_mknod (dst_path, sb.st_mode & file_mask_umask_kill, sb.st_rdev) < 0){
while (mc_mknod (dst_path, sb.st_mode & file_mask_umask_kill, sb.st_rdev) < 0){
return_status = file_error
(_(" Cannot create special file \"%s\" \n %s "), dst_path);
if (return_status == FILE_RETRY)
goto retry_mknod;
continue;
return return_status;
}
/* Success */
#ifndef OS2_NT
retry_mknod_uidgid:
if (file_mask_preserve_uidgid && mc_chown (dst_path, sb.st_uid, sb.st_gid)){
while (file_mask_preserve_uidgid && mc_chown (dst_path, sb.st_uid, sb.st_gid)){
temp_status = file_error
(_(" Cannot chown target file \"%s\" \n %s "), dst_path);
if (temp_status == FILE_RETRY)
goto retry_mknod_uidgid;
continue;
return temp_status;
}
#endif
#ifndef __os2__
retry_mknod_chmod:
if (file_mask_preserve &&
while (file_mask_preserve &&
(mc_chmod (dst_path, sb.st_mode & file_mask_umask_kill) < 0)){
temp_status = file_error (_(" Cannot chmod target file \"%s\" \n %s "), dst_path);
if (temp_status == FILE_RETRY)
goto retry_mknod_chmod;
continue;
return temp_status;
}
#endif
@ -663,12 +659,11 @@ copy_file_file (char *src_path, char *dst_path, int ask_overwrite,
gettimeofday (&tv_transfer_start, (struct timezone *) NULL);
retry_src_open:
if ((src_desc = mc_open (src_path, O_RDONLY | O_LINEAR)) < 0){
while ((src_desc = mc_open (src_path, O_RDONLY | O_LINEAR)) < 0){
return_status = file_error
(_(" Cannot open source file \"%s\" \n %s "), src_path);
if (return_status == FILE_RETRY)
goto retry_src_open;
continue;
file_progress_do_append = 0;
return return_status;
}
@ -681,12 +676,11 @@ copy_file_file (char *src_path, char *dst_path, int ask_overwrite,
}
}
retry_src_fstat:
if (mc_fstat (src_desc, &sb)){
while (mc_fstat (src_desc, &sb)){
return_status = file_error
(_(" Cannot fstat source file \"%s\" \n %s "), src_path);
if (return_status == FILE_RETRY)
goto retry_src_fstat;
continue;
file_progress_do_append = 0;
goto ret;
}
@ -700,17 +694,15 @@ copy_file_file (char *src_path, char *dst_path, int ask_overwrite,
file_size = sb.st_size;
/* Create the new regular file with small permissions initially,
do not create a security hole. */
do not create a security hole. FIXME: You have security hole
here, btw. Imagine copying to /tmp and symlink attack :-( */
retry_dst_open:
if ((file_progress_do_append &&
(dest_desc = mc_open (dst_path, O_WRONLY | O_APPEND)) < 0) ||
(!file_progress_do_append &&
(dest_desc = mc_open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0)){
while ((dest_desc = mc_open (dst_path, O_WRONLY |
(file_progress_do_append ? O_APPEND : (O_CREAT | O_TRUNC)), 0600)) < 0){
return_status = file_error
(_(" Cannot create target file \"%s\" \n %s "), dst_path);
if (return_status == FILE_RETRY)
goto retry_dst_open;
continue;
file_progress_do_append = 0;
goto ret;
}
@ -720,17 +712,14 @@ copy_file_file (char *src_path, char *dst_path, int ask_overwrite,
appending = file_progress_do_append;
file_progress_do_append = 0;
retry_dst_fstat:
/* Find out the optimal buffer size. */
if (mc_fstat (dest_desc, &sb)){
while (mc_fstat (dest_desc, &sb)){
return_status = file_error
(_(" Cannot fstat target file \"%s\" \n %s "), dst_path);
if (return_status == FILE_RETRY)
goto retry_dst_fstat;
continue;
goto ret;
}
buf_size = 8*1024;
buf = (char *) xmalloc (buf_size, "copy_file_file");
file_progress_eta_secs = 0.0;
@ -842,23 +831,23 @@ ret:
if (buf)
free (buf);
retry_src_close:
if ((resources & 1) && mc_close (src_desc) < 0){
while ((resources & 1) && mc_close (src_desc) < 0){
temp_status = file_error
(_(" Cannot close source file \"%s\" \n %s "), src_path);
if (temp_status == FILE_RETRY)
goto retry_src_close;
continue;
if (temp_status == FILE_ABORT)
return_status = temp_status;
break;
}
retry_dst_close:
if ((resources & 2) && mc_close (dest_desc) < 0){
while ((resources & 2) && mc_close (dest_desc) < 0){
temp_status = file_error
(_(" Cannot close target file \"%s\" \n %s "), dst_path);
if (temp_status == FILE_RETRY)
goto retry_dst_close;
continue;
return_status = temp_status;
break;
}
if (resources & 4){
@ -871,13 +860,13 @@ ret:
/* no short file and destination file exists */
#ifndef OS2_NT
if (!appending && file_mask_preserve_uidgid){
retry_dst_chown:
if (mc_chown (dst_path, src_uid, src_gid)){
while (mc_chown (dst_path, src_uid, src_gid)){
temp_status = file_error
(_(" Cannot chown target file \"%s\" \n %s "), dst_path);
if (temp_status == FILE_RETRY)
goto retry_dst_chown;
continue;
return_status = temp_status;
break;
}
}
#endif
@ -1189,9 +1178,7 @@ move_file_file (char *s, char *d, long *progress_count, double *progress_bytes)
}
/* Ok to overwrite */
}
#if 0
retry_rename:
#endif
if (!file_progress_do_append){
if (S_ISLNK (src_stats.st_mode) && file_mask_stable_symlinks){
if ((return_status = make_symlink (s, d)) == FILE_CONT)
@ -1693,6 +1680,7 @@ panel_operate (void *source_panel, FileOperation operation, char *thedefault)
char *source = NULL;
char *dest = NULL;
char *temp = NULL;
char *save_cwd = NULL, *save_dest = NULL;
int only_one = (get_current_type () == view_tree) || (panel->marked <= 1);
struct stat src_stat, dst_stat;
int i, value;
@ -1774,14 +1762,18 @@ panel_operate (void *source_panel, FileOperation operation, char *thedefault)
/* Initialize things */
/* We now have ETA in all cases */
create_op_win (operation, 1);
/* We do not want to trash cache every time file is
created/touched. However, this will make our cache contain
invalid data. */
if (dest) {
if (mc_setctl (dest, MCCTL_WANT_STALE_DATA, NULL))
save_dest = strdup(dest);
}
if (panel->cwd) {
if (mc_setctl (panel->cwd, MCCTL_WANT_STALE_DATA, NULL))
save_cwd = strdup(panel->cwd);
}
/*
* We do not want to trash cache every time file is
* created/touched. However, this will make our cache contain
* invalid data.
*/
if (dest)
mc_setctl (dest, MCCTL_WANT_STALE_DATA, NULL);
ftpfs_hint_reread (0);
/* Now, let's do the job */
@ -1972,10 +1964,14 @@ panel_operate (void *source_panel, FileOperation operation, char *thedefault)
clean_up:
/* Clean up */
destroy_op_win ();
if (dest)
mc_setctl (dest, MCCTL_NO_STALE_DATA, NULL);
if (save_cwd) {
mc_setctl (save_cwd, MCCTL_NO_STALE_DATA, NULL);
free(save_cwd);
}
if (save_dest) {
mc_setctl (save_dest, MCCTL_NO_STALE_DATA, NULL);
free(save_dest);
}
ftpfs_hint_reread (1);
free_linklist (&linklist);

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

@ -1,3 +1,16 @@
Mon Nov 30 23:49:11 1998 Pavel Machek <pavel@bug.ucw.cz>
* direntry.c: Hopefully got want_stale_data right...
Wed Nov 25 23:54:23 1998 Pavel Machek <pavel@bug.ucw.cz>
* vfs.h: use ENETUNREACH if EREMOTEIO error code is not defined,
this is neccessary for Solaris and probably others
Mon Nov 23 17:39:33 1998 Pavel Machek <pavel@bug.ucw.cz>
* vfs.c (vfs_type_from_op): removing unneccessary code
Wed Dec 9 12:24:52 1998 Pavel Machek <pavel@atrey.karlin.mff.cuni.cz>
* extfs/rpm: commit fix for files with spaces in name by Marc

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

@ -3,8 +3,8 @@
*
* Written at 1998 by Pavel Machek <pavel@ucw.cz>, distribute under LGPL.
*
* Based on tar.c from midnight and archives.[ch] from avfs by Miklos
* Szeredi (mszeredi@inf.bme.hu)
* Very loosely based on tar.c from midnight and archives.[ch] from
* avfs by Miklos Szeredi (mszeredi@inf.bme.hu)
*
* Unfortunately, I was unable to keep all filesystems
* uniform. tar-like filesystems use tree structure where each
@ -269,7 +269,7 @@ vfs_s_entry *vfs_s_find_entry_linear(vfs *me, vfs_s_inode *root, char *path, int
break;
if (ent && (! (MEDATA->dir_uptodate) (me, ent->ino))) {
#if 0
#if 1
message_1s( 1, "Dir cache expired for", path);
#endif
vfs_s_free_entry (me, ent);
@ -368,10 +368,13 @@ void vfs_s_free_super (vfs *me, vfs_s_super *super)
super->root = NULL;
}
#if 0
#if 1
/* We currently leak small ammount of memory, sometimes. Fix it if you can. */
if (super->fd_usage)
message_1s1d (1, " Direntry warning ", "Super fd_usage is %d, memory leak", super->fd_usage);
if (super->want_stale)
message_1s( 1, " Direntry warning ", "Super has want_stale set" );
#endif
if (super->prevp) {
@ -663,6 +666,8 @@ void *vfs_s_open (vfs *me, char *file, int flags, int mode)
return NULL;
split_dir_name(me, q, &dirname, &name, &save);
/* FIXME: if vfs_s_find_inode returns NULL, this will do rather bad
things. */
dir = vfs_s_find_inode(me, super->root, dirname, LINK_FOLLOW, FL_DIR);
if (save)
*save = DIR_SEP_CHAR;
@ -673,7 +678,7 @@ void *vfs_s_open (vfs *me, char *file, int flags, int mode)
was_changed = 1;
}
if (ino && S_ISDIR (ino->st.st_mode)) ERRNOR (EISDIR, NULL);
if (S_ISDIR (ino->st.st_mode)) ERRNOR (EISDIR, NULL);
fh = (struct vfs_s_fh *) xmalloc (sizeof (struct vfs_s_fh), "Direntry: filehandle");
fh->pos = 0;
@ -877,8 +882,7 @@ vfs_s_setctl (vfs *me, char *path, int ctlop, char *arg)
return 0;
switch (ctlop) {
case MCCTL_WANT_STALE_DATA:
#warning Should se this to 1
ino->super->want_stale = 0;
ino->super->want_stale = 1;
return 1;
case MCCTL_NO_STALE_DATA:
ino->super->want_stale = 0;

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

@ -135,7 +135,7 @@ static void
free_archive (vfs *me, vfs_s_super *super)
{
if ((SUP.sockw != -1) || (SUP.sockr != -1)){
print_vfs_message ("fish: Disconnecting from %s", super->name);
print_vfs_message ("fish: Disconnecting from %s", super->name?super->name:"???");
command(me, super, NONE, "#BYE\nlogout\n");
close(SUP.sockw);
close(SUP.sockr);

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

@ -31,6 +31,7 @@
#undef MIN
#undef MAX
#include <syslog.h>
#include <stdio.h>
#include <stdlib.h> /* For atol() */
#include <stdarg.h>
@ -116,7 +117,6 @@ vfs_register (vfs *vfs)
int res;
if (!vfs) vfs_die("You can not register NULL.");
res = (vfs->init) ? (*vfs->init)(vfs) : 1;
if (!res) return 0;
@ -134,20 +134,15 @@ vfs_type_from_op (char *path)
if (!path) vfs_die( "vfs_type_from_op got NULL: impossible" );
for (vfs = vfs_list; vfs; vfs = vfs->next){
/* FIXME: this code could be much more elegant */
if (vfs == &vfs_local_ops) /* local catches all */
return NULL;
for (vfs = vfs_list; vfs != &vfs_local_ops; vfs = vfs->next){
if (vfs->which) {
if ((*vfs->which) (vfs, path) != -1)
return vfs;
else
if ((*vfs->which) (vfs, path) == -1)
continue;
return vfs;
}
if (!strncmp (path, vfs->prefix, strlen (vfs->prefix)))
return vfs;
}
vfs_die ("No local in vfs list?");
return NULL; /* shut up stupid gcc */
}
@ -436,6 +431,8 @@ mc_setctl (char *path, int ctlop, char *arg)
vfs *vfs;
int result;
if (!path)
vfs_die( "You don't want to pass NULL to mc_setctl." );
path = vfs_canon (path);
vfs = vfs_type (path);
result = vfs->setctl ? (*vfs->setctl)(vfs, path, ctlop, arg) : 0;

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

@ -406,25 +406,25 @@ extern void mc_vfs_done( void );
#ifdef ENOSYS
#define E_NOTSUPP ENOSYS /* for use in vfs when module does not provide function */
#else
/* Yes, this does happen */
#define E_NOTSUPP EFAULT /* Does this happen? */
#endif
#ifdef ENOMSG
#define E_UNKNOWN ENOMSG /* if we do not know what error happened */
#else
#define E_UNKNOWN (ELAST+2) /* if we do not know what error happened */
#define E_UNKNOWN EIO /* if we do not know what error happened */
#endif
#ifdef EREMOTEIO
#define E_REMOTE EREMOTEIO /* if other side of ftp/fish reports error */
#else
#define E_REMOTE ENETUNREACH
#define E_REMOTE ENETUNREACH /* :-( there's no EREMOTEIO on some systems */
#endif
#ifdef EPROTO
#define E_PROTO EPROTO /* if other side fails to follow protocol */
#else
#define E_PROTO (ELAST+4) /* if other side fails to follow protocol */
#define E_PROTO EIO
#endif
#endif /* __VFS_H */