diff --git a/vfs/ChangeLog b/vfs/ChangeLog index 5dba9bfe8..54616bd1d 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,5 +1,10 @@ 2002-07-25 Andrew V. Samoilov + * xdirentry.h (vfs_s_fh.u.fish): Add append field. + * fish.c (fish_fh_open): Care about append. + (linear_open): Likewise. + (fish_store): Append data to target file if append is true. + * mcserv.c [HAVE_MAD]: Include "../src/mad.c" at the end of file to fix compilation. (main): Add mad_init() and mad_finalize(). diff --git a/vfs/fish.c b/vfs/fish.c index d56639172..5a30a2e26 100644 --- a/vfs/fish.c +++ b/vfs/fish.c @@ -497,7 +497,8 @@ file_store(vfs *me, vfs_s_fh *fh, char *name, char *localname) * FIXME: Limit size to unsigned long for now. * Files longer than 256 * ULONG_MAX are not supported. */ - if (command (me, super, WAIT_REPLY, + if (!fh->u.fish.append) + n = command (me, super, WAIT_REPLY, "#STOR %lu /%s\n" "> \"/%s\"\n" "echo '### 001'\n" @@ -510,8 +511,23 @@ file_store(vfs *me, vfs_s_fh *fh, char *name, char *localname) "); echo '### 200'\n", (unsigned long) s.st_size, name, name, (unsigned long) (s.st_size >> 8), - ((unsigned long) s.st_size) & (256 - 1), name) - != PRELIM) + ((unsigned long) s.st_size) & (256 - 1), name); + else + n = command (me, super, WAIT_REPLY, + "#STOR %lu /%s\n" + "echo '### 001'\n" + "(\n" + "dd ibs=256 obs=4096 count=%lu\n" + "dd bs=%lu count=1\n" + ") 2>/dev/null | (\n" + "cat >> \"/%s\"\n" + "cat > /dev/null\n" + "); echo '### 200'\n", + (unsigned long) s.st_size, name, + (unsigned long) (s.st_size >> 8), + ((unsigned long) s.st_size) & (256 - 1), name); + + if (n != PRELIM) ERRNOR(E_REMOTE, -1); total = 0; @@ -555,6 +571,7 @@ static int linear_start(vfs *me, vfs_s_fh *fh, int offset) name = vfs_s_fullpath (me, fh->ino); if (!name) return 0; + fh->u.fish.append = 0; offset = command(me, FH_SUPER, WANT_STRING, "#RETR /%s\n" "ls -l \"/%s\" 2>/dev/null | (\n" @@ -786,8 +803,10 @@ static int fish_rmdir (vfs *me, char *path) static int fish_fh_open (vfs *me, vfs_s_fh *fh, int flags, int mode) { + fh->u.fish.append = 0; /* File will be written only, so no need to retrieve it */ if (((flags & O_WRONLY) == O_WRONLY) && !(flags & (O_RDONLY|O_RDWR))){ + fh->u.fish.append = flags & O_APPEND; if (!fh->ino->localname){ int tmp_handle = mc_mkstemps (&fh->ino->localname, me->name, NULL); if (tmp_handle == -1) diff --git a/vfs/xdirentry.h b/vfs/xdirentry.h index 76b75b681..e14da1c5a 100644 --- a/vfs/xdirentry.h +++ b/vfs/xdirentry.h @@ -137,7 +137,7 @@ typedef struct vfs_s_fh { int linear; /* Is that file open with O_LINEAR? */ union { struct { - int got, total; + int got, total, append; } fish; struct { int sock, append;