* direntry.c (vfs_s_retrieve_file): Use off_t for total

and stat_size.

* vfs.c (vfs_s_resolve_symlink): Use snprintf
instead of sprintf.
(vfs_print_stats): Use off_t for have and need.  Cast
have to double to eliminate negative percent(s).
Fix print_vfs_message string formats.

* vfs.h (vfs_print_stats): Adjust declaration.

* ftpfs.c (file_store): Use off_t for total.
Fix print_vfs_message string format.
This commit is contained in:
Andrew V. Samoilov 2002-02-08 09:42:38 +00:00
parent 455e64673e
commit 1711c0ab8b
5 changed files with 37 additions and 19 deletions

View File

@ -1,3 +1,19 @@
2002-02-08 Andrew V. Samoilov <kai@cmail.ru>
* direntry.c (vfs_s_retrieve_file): Use off_t for total
and stat_size.
* vfs.c (vfs_s_resolve_symlink): Use snprintf
instead of sprintf.
(vfs_print_stats): Use off_t for have and need. Cast
have to double to eliminate negative percent(s).
Fix print_vfs_message string formats.
* vfs.h (vfs_print_stats): Adjust declaration.
* ftpfs.c (file_store): Use off_t for total.
Fix print_vfs_message string format.
2002-02-07 Andrew V. Samoilov <kai@cmail.ru>
* ftpfs.c (dir_load): Speed up cd_first calculation.

View File

@ -368,7 +368,7 @@ vfs_s_resolve_symlink (vfs *me, vfs_s_entry *entry, char *path, int follow)
return (MEDATA->find_entry) (me, entry->dir->super->root, linkname, follow - 1, 0);
else { /* FIXME: this does not work */
char *fullpath = vfs_s_fullpath(me, entry->dir);
sprintf(buf, "%s/%s", fullpath, linkname);
snprintf(buf, sizeof (buf), "%s/%s", fullpath, linkname);
g_free (fullpath);
return (MEDATA->find_entry) (me, entry->dir->super->root, buf, follow - 1, 0);
}
@ -934,14 +934,14 @@ int
vfs_s_retrieve_file(vfs *me, struct vfs_s_inode *ino)
{
/* If you want reget, you'll have to open file with O_LINEAR */
int total = 0;
off_t total = 0;
char buffer[8192];
int handle, n;
int stat_size = ino->st.st_size;
off_t stat_size = ino->st.st_size;
struct vfs_s_fh fh;
memset(&fh, 0, sizeof(fh));
fh.ino = ino;
handle = mc_mkstemps (&ino->localname, me->name, NULL);

View File

@ -1359,7 +1359,8 @@ fallback:
static int
file_store(vfs *me, vfs_s_super *super, char *name, char *localname)
{
int h, sock, n, total;
int h, sock, n;
off_t total;
#ifdef HAVE_STRUCT_LINGER
struct linger li;
#else
@ -1415,8 +1416,8 @@ file_store(vfs *me, vfs_s_super *super, char *name, char *localname)
goto error_return;
}
total += n;
print_vfs_message(_("ftpfs: storing file %d (%lu)"),
total, (unsigned long) s.st_size);
print_vfs_message(_("ftpfs: storing file %lu (%lu)"),
(unsigned long) total, (unsigned long) s.st_size);
}
disable_interrupt_key();
close(sock);

View File

@ -1397,7 +1397,7 @@ is_dos_date(char *str)
static int
is_week (char *str, struct tm *tim)
{
char *week = "SunMonTueWedThuFriSat";
static const char *week = "SunMonTueWedThuFriSat";
char *pos;
if((pos=strstr(week, str)) != NULL){
@ -1411,7 +1411,7 @@ is_week (char *str, struct tm *tim)
static int
is_month (char *str, struct tm *tim)
{
char *month = "JanFebMarAprMayJunJulAugSepOctNovDec";
static const char *month = "JanFebMarAprMayJunJulAugSepOctNovDec";
char *pos;
if((pos=strstr(month, str)) != NULL){
@ -1840,21 +1840,21 @@ vfs_die (char *m)
}
void
vfs_print_stats (char *fs_name, char *action, char *file_name, int have, int need)
vfs_print_stats (const char *fs_name, const char *action, const char *file_name, off_t have, off_t need)
{
static char *i18n_percent_transf_format = NULL, *i18n_transf_format = NULL;
if (i18n_percent_transf_format == NULL) {
i18n_percent_transf_format = _("%s: %s: %s %3d%% (%ld bytes transfered)");
i18n_transf_format = _("%s: %s: %s %ld bytes transfered");
}
i18n_percent_transf_format = _("%s: %s: %s %3d%% (%lu bytes transfered)");
i18n_transf_format = _("%s: %s: %s %lu bytes transfered");
}
if (need)
print_vfs_message (i18n_percent_transf_format,
fs_name, action, file_name, have*100/need, have);
print_vfs_message (i18n_percent_transf_format, fs_name, action,
file_name, (int)((double)have*100/need), (unsigned long) have);
else
print_vfs_message (i18n_transf_format,
fs_name, action, file_name, have);
print_vfs_message (i18n_transf_format,
fs_name, action, file_name, (unsigned long) have);
}
#ifndef VFS_STANDALONE

View File

@ -338,7 +338,8 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain,
#define URL_DEFAULTANON 1
#define URL_NOSLASH 2
extern void vfs_print_stats (char *fs_name, char *action, char *file_name, int have, int need);
extern void vfs_print_stats (const char *fs_name, const char *action,
const char *file_name, off_t have, off_t need);
/* Don't use values 0..4 for a while -- 10/98, pavel@ucw.cz */
#define MCCTL_REMOVELOCALCOPY 5