diff --git a/vfs/ChangeLog b/vfs/ChangeLog index fef547e73..b7ada3452 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,8 @@ +2005-01-19 Andrew V. Samoilov + + * ftpfs.c (ftpfs_file_store): Make sure we write() all read() data. + Check fstat() return value. + 2005-01-07 Roland Illig * extfs/urar.in: Fixed some quoting issues. @@ -103,11 +108,12 @@ 2004-10-29 Pavel S. Shirshov * extfs/iso9660.in (mcisofs_list): Fix regular expression for stripping - of file name. Use autotools macro for awk instead full path. + of file name. Use autotools macro for awk instead of full path. 2004-10-28 Leonard den Ottolander - * extfs/iso9660.in (mcisofs_list): Fix stripping of file name in awk code. + * extfs/iso9660.in (mcisofs_list): Fix stripping of file name + in awk code. 2004-10-28 Andrew V. Samoilov @@ -120,7 +126,7 @@ 2004-10-27 Leonard den Ottolander - * tar.c tar_read_header(): q should not point to a static string. + * tar.c (tar_read_header): q should not point to a static string. Canonicalize q. * extfs/iso9660.in: Fix quoting issues. @@ -200,7 +206,7 @@ 2004-10-05 Miroslav Rudisin - * utilvfs.c(vfs_split_url): Add support for '@' in username. + * utilvfs.c (vfs_split_url): Add support for '@' in username. 2004-09-27 Andrew V. Samoilov @@ -217,12 +223,13 @@ * ftpfs.c (ftpfs_find_machine): Added const qualifier. * mcserv.c (do_auth): Likewise. - * utilvfs.c (is_month): Likewise. (is_time): Likewise. + * utilvfs.c (is_month): Likewise. + (is_time): Likewise. (is_week): Likewise. * vfs.c (_vfs_get_class): Added const qualifier. (vfs_prefix_to_class): Added a string length parameter to - reduce the use of g_strdup. (vfs_split): Changes due to the - new string length parameter. + reduce the use of g_strdup(). + (vfs_split): Changes due to the new string length parameter. 2004-09-25 Pavel S. Shirshov diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index 524df4cb8..25ca5f36c 100644 --- a/vfs/ftpfs.c +++ b/vfs/ftpfs.c @@ -1292,10 +1292,11 @@ ftpfs_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path } static int -ftpfs_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; + int h, sock, n_read, n_written; + off_t n_stored; #ifdef HAVE_STRUCT_LINGER_L_LINGER struct linger li; #else @@ -1303,69 +1304,71 @@ ftpfs_file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *lo #endif char buffer[8192]; struct stat s; + char *w_buf; struct vfs_s_super *super = FH_SUPER; - h = open(localname, O_RDONLY); + h = open (localname, O_RDONLY); if (h == -1) - ERRNOR (EIO, -1); - fstat(h, &s); - sock = ftpfs_open_data_connection(me, super, fh->u.ftp.append ? "APPE" : "STOR", name, TYPE_BINARY, 0); - if (sock < 0) { - close(h); + ERRNOR (EIO, -1); + sock = + ftpfs_open_data_connection (me, super, + fh->u.ftp.append ? "APPE" : "STOR", name, + TYPE_BINARY, 0); + if (sock < 0 || fstat (h, &s) == -1) { + close (h); return -1; } #ifdef HAVE_STRUCT_LINGER_L_LINGER li.l_onoff = 1; li.l_linger = 120; - setsockopt(sock, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(li)); + setsockopt (sock, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof (li)); #else - setsockopt(sock, SOL_SOCKET, SO_LINGER, &flag_one, sizeof (flag_one)); + setsockopt (sock, SOL_SOCKET, SO_LINGER, &flag_one, sizeof (flag_one)); #endif - total = 0; - - enable_interrupt_key(); + n_stored = 0; + + enable_interrupt_key (); while (1) { - while ((n = read(h, buffer, sizeof(buffer))) < 0) { + while ((n_read = read (h, buffer, sizeof (buffer))) == -1) { if (errno == EINTR) { - if (got_interrupt()) { + if (got_interrupt ()) { ftpfs_errno = EINTR; goto error_return; - } - else + } else continue; } ftpfs_errno = errno; goto error_return; } - if (n == 0) + if (n_read == 0) break; - while (write(sock, buffer, n) < 0) { - if (errno == EINTR) { - if (got_interrupt()) { - ftpfs_errno = EINTR; - goto error_return; - } - else + n_stored += n_read; + w_buf = buffer; + while ((n_written = write (sock, w_buf, n_read)) != n_read) { + if (n_written == -1) { + if (errno == EINTR && !got_interrupt ()) { continue; + } + ftpfs_errno = errno; + goto error_return; } - ftpfs_errno = errno; - goto error_return; + w_buf += n_written; + n_read -= n_written; } - total += n; - print_vfs_message(_("ftpfs: storing file %lu (%lu)"), - (unsigned long) total, (unsigned long) s.st_size); + print_vfs_message (_("ftpfs: storing file %lu (%lu)"), + (unsigned long) n_stored, (unsigned long) s.st_size); } - disable_interrupt_key(); - close(sock); - close(h); + disable_interrupt_key (); + close (sock); + close (h); if (ftpfs_get_reply (me, SUP.sock, NULL, 0) != COMPLETE) - ERRNOR (EIO, -1); + ERRNOR (EIO, -1); return 0; -error_return: - disable_interrupt_key(); - close(sock); - close(h); - ftpfs_get_reply(me, SUP.sock, NULL, 0); + error_return: + disable_interrupt_key (); + close (sock); + close (h); + ftpfs_get_reply (me, SUP.sock, NULL, 0); return -1; }