1998-09-13 14:40:43 +04:00
|
|
|
/* Virtual File System: FISH implementation for transfering files over
|
|
|
|
shell connections.
|
|
|
|
|
|
|
|
Copyright (C) 1998 The Free Software Foundation
|
|
|
|
|
|
|
|
Written by: 1998 Pavel Machek
|
|
|
|
|
|
|
|
Derived from ftpfs.c.
|
|
|
|
|
1998-09-27 23:27:58 +04:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2 of
|
|
|
|
the License, or (at your option) any later version.
|
1998-09-13 14:40:43 +04:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
1998-09-27 23:27:58 +04:00
|
|
|
GNU Library General Public License for more details.
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-09-27 23:27:58 +04:00
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this program; if not, write to the Free Software
|
1998-09-13 14:40:43 +04:00
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read README.fish for protocol specification.
|
|
|
|
*
|
|
|
|
* Syntax of path is: /#sh:user@host[:Cr]/path
|
|
|
|
* where C means you want compressed connection,
|
|
|
|
* and r means you want to use rsh
|
1998-10-13 02:07:53 +04:00
|
|
|
*
|
|
|
|
* Namespace: fish_vfs_ops exported.
|
1998-09-13 14:40:43 +04:00
|
|
|
*/
|
1998-11-21 22:36:01 +03:00
|
|
|
|
|
|
|
/* Define this if your ssh can take -I option */
|
|
|
|
|
1998-12-07 13:15:17 +03:00
|
|
|
#undef HAVE_HACKED_SSH
|
1998-11-21 22:36:01 +03:00
|
|
|
|
|
|
|
#include "xdirentry.h"
|
1998-09-13 14:40:43 +04:00
|
|
|
#include "../src/tty.h" /* enable/disable interrupt key */
|
|
|
|
#include "../src/main.h"
|
|
|
|
#include "../src/mem.h"
|
|
|
|
#include "vfs.h"
|
|
|
|
#include "tcputil.h"
|
|
|
|
#include "container.h"
|
|
|
|
#include "fish.h"
|
1998-11-21 22:36:01 +03:00
|
|
|
#include <glib.h>
|
1998-10-23 12:26:25 +04:00
|
|
|
|
1998-09-13 14:40:43 +04:00
|
|
|
/*
|
|
|
|
* Reply codes.
|
|
|
|
*/
|
|
|
|
#define PRELIM 1 /* positive preliminary */
|
|
|
|
#define COMPLETE 2 /* positive completion */
|
|
|
|
#define CONTINUE 3 /* positive intermediate */
|
|
|
|
#define TRANSIENT 4 /* transient negative completion */
|
|
|
|
#define ERROR 5 /* permanent negative completion */
|
|
|
|
|
|
|
|
/* If true, the directory cache is forced to reload */
|
|
|
|
static int force_expiration = 0;
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
/* FIXME: prev two variables should be killed */
|
1998-09-13 14:40:43 +04:00
|
|
|
|
|
|
|
/* command wait_flag: */
|
|
|
|
#define NONE 0x00
|
|
|
|
#define WAIT_REPLY 0x01
|
|
|
|
#define WANT_STRING 0x02
|
|
|
|
static char reply_str [80];
|
|
|
|
|
|
|
|
static int decode_reply (char *s, int was_garbage)
|
|
|
|
{
|
1998-11-21 22:36:01 +03:00
|
|
|
int code;
|
1998-09-13 14:40:43 +04:00
|
|
|
if (!sscanf(s, "%d", &code)) {
|
|
|
|
code = 500;
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
if (code<100) return was_garbage ? ERROR : (!code ? COMPLETE : PRELIM);
|
|
|
|
return code / 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns a reply code, check /usr/include/arpa/ftp.h for possible values */
|
1998-11-21 22:36:01 +03:00
|
|
|
static int get_reply (vfs *me, int sock, char *string_buf, int string_len)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
|
|
|
char answer[1024];
|
|
|
|
int was_garbage = 0;
|
|
|
|
|
|
|
|
for (;;) {
|
1998-11-21 22:36:01 +03:00
|
|
|
if (!vfs_s_get_line(me, sock, answer, sizeof(answer), '\n')) {
|
1998-09-13 14:40:43 +04:00
|
|
|
if (string_buf)
|
|
|
|
*string_buf = 0;
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
if (strncmp(answer, "### ", 4)) {
|
|
|
|
was_garbage = 1;
|
|
|
|
if (string_buf) {
|
|
|
|
strncpy(string_buf, answer, string_len - 1);
|
|
|
|
*(string_buf + string_len - 1) = 0;
|
|
|
|
}
|
|
|
|
} else return decode_reply(answer+4, was_garbage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
#define SUP super->u.fish
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
static int command (vfs *me, vfs_s_super *super, int wait_reply, char *fmt, ...)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
|
|
|
va_list ap;
|
1998-10-30 20:45:43 +03:00
|
|
|
char *str;
|
1999-01-11 03:48:23 +03:00
|
|
|
int status;
|
1998-11-21 22:36:01 +03:00
|
|
|
FILE *logfile = MEDATA->logfile;
|
1998-10-30 20:45:43 +03:00
|
|
|
|
1998-09-13 14:40:43 +04:00
|
|
|
va_start (ap, fmt);
|
1998-11-21 22:36:01 +03:00
|
|
|
|
1998-10-30 20:45:43 +03:00
|
|
|
str = g_strdup_vprintf (fmt, ap);
|
1998-09-13 14:40:43 +04:00
|
|
|
va_end (ap);
|
1998-11-21 22:36:01 +03:00
|
|
|
|
1998-09-13 14:40:43 +04:00
|
|
|
if (logfile){
|
1998-10-30 20:45:43 +03:00
|
|
|
fwrite (str, strlen (str), 1, logfile);
|
1998-09-13 14:40:43 +04:00
|
|
|
fflush (logfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
enable_interrupt_key();
|
1998-11-21 22:36:01 +03:00
|
|
|
|
|
|
|
status = write(SUP.sockw, str, strlen(str));
|
1998-10-30 20:45:43 +03:00
|
|
|
g_free (str);
|
1998-11-21 22:36:01 +03:00
|
|
|
|
1998-09-13 14:40:43 +04:00
|
|
|
disable_interrupt_key();
|
1998-11-21 22:36:01 +03:00
|
|
|
if (status < 0)
|
|
|
|
return TRANSIENT;
|
1998-09-13 14:40:43 +04:00
|
|
|
|
|
|
|
if (wait_reply)
|
1998-11-21 22:36:01 +03:00
|
|
|
return get_reply (me, SUP.sockr, (wait_reply & WANT_STRING) ? reply_str : NULL, sizeof (reply_str)-1);
|
1998-09-13 14:40:43 +04:00
|
|
|
return COMPLETE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-11-21 22:36:01 +03:00
|
|
|
free_archive (vfs *me, vfs_s_super *super)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
1998-11-21 22:36:01 +03:00
|
|
|
if ((SUP.sockw != -1) || (SUP.sockr != -1)){
|
1998-12-09 23:22:53 +03:00
|
|
|
print_vfs_message ("fish: Disconnecting from %s", super->name?super->name:"???");
|
1998-11-21 22:36:01 +03:00
|
|
|
command(me, super, NONE, "#BYE\nlogout\n");
|
|
|
|
close(SUP.sockw);
|
|
|
|
close(SUP.sockr);
|
|
|
|
SUP.sockw = SUP.sockr = -1;
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
1998-11-21 22:36:01 +03:00
|
|
|
ifree (SUP.host);
|
|
|
|
ifree (SUP.home);
|
|
|
|
ifree (SUP.user);
|
|
|
|
ifree (SUP.cwdir);
|
|
|
|
ifree (SUP.password);
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-11-21 22:36:01 +03:00
|
|
|
pipeopen(vfs_s_super *super, char *path, char *argv[])
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
|
|
|
int fileset1[2], fileset2[2];
|
|
|
|
int res;
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
if ((pipe(fileset1)<0) || (pipe(fileset2)<0))
|
|
|
|
vfs_die("Could not pipe(): %m.");
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-09-27 23:27:58 +04:00
|
|
|
if ((res = fork())) {
|
1998-09-13 14:40:43 +04:00
|
|
|
if (res<0) vfs_die("Could not fork(): %m.");
|
|
|
|
/* We are the parent */
|
|
|
|
close(fileset1[0]);
|
1998-11-21 22:36:01 +03:00
|
|
|
SUP.sockw = fileset1[1];
|
1998-09-13 14:40:43 +04:00
|
|
|
close(fileset2[1]);
|
1998-11-21 22:36:01 +03:00
|
|
|
SUP.sockr = fileset2[0];
|
1998-09-13 14:40:43 +04:00
|
|
|
} else {
|
|
|
|
close(0);
|
|
|
|
dup(fileset1[0]);
|
|
|
|
close(fileset1[0]); close(fileset1[1]);
|
|
|
|
close(1); close(2);
|
|
|
|
dup(fileset2[1]);
|
|
|
|
dup(fileset2[1]);
|
|
|
|
close(fileset2[0]); close(fileset2[1]);
|
|
|
|
execvp(path, argv);
|
|
|
|
vfs_die("Exec failed.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
/* The returned directory should always contain a trailing slash */
|
|
|
|
static char *fish_getcwd(vfs *me, vfs_s_super *super)
|
|
|
|
{
|
|
|
|
if (command(me, super, WANT_STRING, "#PWD\npwd; echo '### 200'\n") == COMPLETE)
|
|
|
|
return copy_strings(reply_str, "/", NULL);
|
|
|
|
ERRNOR (EIO, NULL);
|
|
|
|
}
|
|
|
|
static int
|
|
|
|
open_archive_int (vfs *me, vfs_s_super *super)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
|
|
|
char *argv[100];
|
1998-11-21 22:36:01 +03:00
|
|
|
char *xsh = (SUP.flags == FISH_FLAG_RSH ? "rsh" : "ssh");
|
1998-09-13 14:40:43 +04:00
|
|
|
int i = 0;
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
argv[i++] = xsh;
|
|
|
|
#ifdef HAVE_HACKED_SSH
|
|
|
|
argv[i++] = "-I";
|
|
|
|
#endif
|
1998-09-13 14:40:43 +04:00
|
|
|
argv[i++] = "-l";
|
1998-11-21 22:36:01 +03:00
|
|
|
argv[i++] = SUP.user;
|
|
|
|
argv[i++] = SUP.host;
|
|
|
|
if (SUP.flags == FISH_FLAG_COMPRESSED)
|
1998-09-13 14:40:43 +04:00
|
|
|
argv[i++] = "-C";
|
|
|
|
argv[i++] = "echo FISH:; /bin/sh";
|
|
|
|
argv[i++] = NULL;
|
|
|
|
|
1998-12-07 13:15:17 +03:00
|
|
|
#if 0
|
1998-11-21 22:36:01 +03:00
|
|
|
/* Debugging hack */
|
|
|
|
if (!MEDATA->logfile)
|
|
|
|
MEDATA->logfile = fopen( "/home/pavel/talk.fish", "w+" ); /* FIXME */
|
1998-12-07 13:15:17 +03:00
|
|
|
#endif
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
pipeopen(super, xsh, argv );
|
1998-09-13 14:40:43 +04:00
|
|
|
|
|
|
|
{
|
|
|
|
char answer[2048];
|
1998-11-21 22:36:01 +03:00
|
|
|
print_vfs_message( "fish: Waiting for initial line..." );
|
|
|
|
if (!vfs_s_get_line(me, SUP.sockr, answer, sizeof(answer), ':'))
|
|
|
|
ERRNOR (E_PROTO, -1);
|
1998-09-13 14:40:43 +04:00
|
|
|
print_vfs_message( answer );
|
|
|
|
if (strstr(answer, "assword")) {
|
|
|
|
|
|
|
|
/* Currently, this does not work. ssh reads passwords from
|
|
|
|
/dev/tty, not from stdin :-(. */
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
#ifndef HAVE_HACKED_SSH
|
|
|
|
message_1s (1, _(" Error "), _("Sorry, we can not do password authenticated connections for now."));
|
|
|
|
ERRNOR (EPERM, -1);
|
|
|
|
#endif
|
|
|
|
if (!SUP.password){
|
|
|
|
char *p, *op;
|
|
|
|
p = copy_strings (" fish: Password required for ", SUP.user,
|
1998-09-13 14:40:43 +04:00
|
|
|
" ", NULL);
|
|
|
|
op = vfs_get_password (p);
|
|
|
|
free (p);
|
|
|
|
if (op == NULL)
|
1998-11-21 22:36:01 +03:00
|
|
|
ERRNOR (EPERM, -1);
|
|
|
|
SUP.password = strdup (op);
|
1998-09-13 14:40:43 +04:00
|
|
|
wipe_password(op);
|
|
|
|
}
|
1998-11-21 22:36:01 +03:00
|
|
|
print_vfs_message( "fish: Sending password..." );
|
|
|
|
write(SUP.sockw, SUP.password, strlen(SUP.password));
|
|
|
|
write(SUP.sockw, "\n", 1);
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print_vfs_message( "FISH: Sending initial line..." );
|
1998-11-21 22:36:01 +03:00
|
|
|
if (command (me, super, WAIT_REPLY, "#FISH\necho; start_fish_server; echo '### 200'\n") != COMPLETE)
|
|
|
|
ERRNOR (E_PROTO, -1);
|
1998-09-13 14:40:43 +04:00
|
|
|
|
|
|
|
print_vfs_message( "FISH: Handshaking version..." );
|
1998-11-21 22:36:01 +03:00
|
|
|
if (command (me, super, WAIT_REPLY, "#VER 0.0.0\necho '### 000'\n") != COMPLETE)
|
|
|
|
ERRNOR (E_PROTO, -1);
|
1998-09-13 14:40:43 +04:00
|
|
|
|
|
|
|
print_vfs_message( "FISH: Setting up current directory..." );
|
1998-11-21 22:36:01 +03:00
|
|
|
SUP.home = fish_getcwd (me, super);
|
|
|
|
print_vfs_message( "FISH: Connected, home %s.", SUP.home );
|
|
|
|
#if 0
|
|
|
|
super->name = copy_strings( "/#sh:", SUP.user, "@", SUP.host, "/", NULL );
|
|
|
|
#endif
|
|
|
|
super->name = strdup( "/" );
|
|
|
|
|
|
|
|
super->root = vfs_s_new_inode (me, super, vfs_s_default_stat(me, S_IFDIR | 0755));
|
|
|
|
return 0;
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
int
|
|
|
|
open_archive (vfs *me, vfs_s_super *super, char *archive_name, char *op)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
1998-11-21 22:36:01 +03:00
|
|
|
char *host, *user, *password;
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
vfs_split_url (strchr(op, ':')+1, &host, &user, &flags, &password, 0, URL_NOSLASH);
|
|
|
|
SUP.host = strdup (host);
|
|
|
|
SUP.user = strdup (user);
|
|
|
|
SUP.flags = flags;
|
|
|
|
if (!strncmp( op, "rsh:", 4 ))
|
|
|
|
SUP.flags |= FISH_FLAG_RSH;
|
|
|
|
SUP.home = NULL;
|
|
|
|
if (password)
|
|
|
|
SUP.password = strdup (password);
|
|
|
|
return open_archive_int (me, super);
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
static int
|
|
|
|
archive_same(vfs *me, vfs_s_super *super, char *archive_name, char *op, void *cookie)
|
|
|
|
{
|
|
|
|
char *host, *user, *dummy2;
|
|
|
|
int flags;
|
|
|
|
vfs_split_url (strchr(op, ':')+1, &host, &user, &flags, &dummy2, 0, URL_NOSLASH);
|
|
|
|
return ((strcmp (host, SUP.host) == 0) &&
|
|
|
|
(strcmp (user, SUP.user) == 0) &&
|
|
|
|
(flags == SUP.flags));
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
int
|
|
|
|
fish_which (vfs *me, char *path)
|
1998-09-27 23:27:58 +04:00
|
|
|
{
|
1998-11-21 22:36:01 +03:00
|
|
|
if (!strncmp (path, "/#sh:", 5))
|
|
|
|
return 1;
|
|
|
|
if (!strncmp (path, "/#ssh:", 6))
|
|
|
|
return 1;
|
|
|
|
if (!strncmp (path, "/#rsh:", 6))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
1998-09-27 23:27:58 +04:00
|
|
|
}
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
int
|
|
|
|
dir_uptodate(vfs *me, vfs_s_inode *ino)
|
1998-09-18 15:02:04 +04:00
|
|
|
{
|
1998-11-21 22:36:01 +03:00
|
|
|
struct timeval tim;
|
|
|
|
|
|
|
|
return 1; /* Timeouting of directories does not work too well :-(. */
|
|
|
|
gettimeofday(&tim, NULL);
|
|
|
|
if (force_expiration) {
|
|
|
|
force_expiration = 0;
|
|
|
|
return 0;
|
1998-09-18 15:02:04 +04:00
|
|
|
}
|
1998-11-21 22:36:01 +03:00
|
|
|
if (tim.tv_sec < ino->u.fish.timestamp.tv_sec)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
1998-09-18 15:02:04 +04:00
|
|
|
}
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
static int
|
|
|
|
dir_load(vfs *me, vfs_s_inode *dir, char *remote_path)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
1998-11-21 22:36:01 +03:00
|
|
|
vfs_s_super *super = dir->super;
|
1998-09-13 14:40:43 +04:00
|
|
|
char buffer[8192];
|
1998-11-21 22:36:01 +03:00
|
|
|
vfs_s_entry *ent = NULL;
|
|
|
|
FILE *logfile;
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
logfile = MEDATA->logfile;
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
print_vfs_message("fish: Reading directory %s...", remote_path);
|
|
|
|
|
|
|
|
gettimeofday(&dir->u.fish.timestamp, NULL);
|
|
|
|
dir->u.fish.timestamp.tv_sec += 10; /* was 360: 10 is good for
|
|
|
|
stressing direntry layer a bit */
|
|
|
|
|
|
|
|
command(me, super, NONE,
|
|
|
|
"#LIST /%s\nls -lLa /%s | grep '^[^cbt]' | ( while read p x u g s m d y n; do echo \"P$p $u.$g\n"
|
1998-09-13 14:40:43 +04:00
|
|
|
"S$s\nd$m $d $y\n:$n\n\"; done )\n"
|
1998-11-21 22:36:01 +03:00
|
|
|
"ls -lLa /%s | grep '^[cb]' | ( while read p x u g a i m d y n; do echo \"P$p $u.$g\n"
|
1998-09-13 14:40:43 +04:00
|
|
|
"E$a$i\nd$m $d $y\n:$n\n\"; done ); echo '### 200'\n",
|
|
|
|
remote_path, remote_path, remote_path);
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
#define SIMPLE_ENTRY vfs_s_generate_entry(me, NULL, dir, 0)
|
|
|
|
ent = SIMPLE_ENTRY;
|
|
|
|
while (1) {
|
|
|
|
int res = vfs_s_get_line_interruptible (me, buffer, sizeof (buffer), SUP.sockr);
|
|
|
|
if ((!res) || (res == EINTR)) {
|
|
|
|
vfs_s_free_entry(me, ent);
|
|
|
|
me->verrno = ECONNRESET;
|
|
|
|
goto error;
|
|
|
|
}
|
1998-09-13 14:40:43 +04:00
|
|
|
if (logfile){
|
|
|
|
fputs (buffer, logfile);
|
|
|
|
fputs ("\n", logfile);
|
|
|
|
fflush (logfile);
|
|
|
|
}
|
|
|
|
if (!strncmp(buffer, "### ", 4))
|
|
|
|
break;
|
1998-11-21 22:36:01 +03:00
|
|
|
if ((!buffer[0])) {
|
|
|
|
if (ent->name) {
|
|
|
|
vfs_s_insert_entry(me, dir, ent);
|
|
|
|
ent = SIMPLE_ENTRY;
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
#define ST ent->ino->st
|
1998-09-13 14:40:43 +04:00
|
|
|
|
|
|
|
switch(buffer[0]) {
|
1998-11-21 22:36:01 +03:00
|
|
|
case ':': {
|
|
|
|
char *c;
|
|
|
|
if (!strcmp(buffer+1, ".") || !strcmp(buffer+1, ".."))
|
|
|
|
break; /* We'll do . and .. ourself */
|
|
|
|
ent->name = strdup(buffer+1);
|
|
|
|
if ((c=strchr(ent->name, ' ')))
|
|
|
|
*c = 0; /* this is ugly, but we can not handle " " in name */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'S': ST.st_size = atoi(buffer+1); break;
|
1998-09-13 14:40:43 +04:00
|
|
|
case 'P': {
|
|
|
|
int i;
|
1998-10-13 02:07:53 +04:00
|
|
|
if ((i = vfs_parse_filetype(buffer[1])) ==-1)
|
1998-09-13 14:40:43 +04:00
|
|
|
break;
|
1998-11-21 22:36:01 +03:00
|
|
|
ST.st_mode = i;
|
1998-10-13 02:07:53 +04:00
|
|
|
if ((i = vfs_parse_filemode(buffer+2)) ==-1)
|
1998-09-13 14:40:43 +04:00
|
|
|
break;
|
1998-11-21 22:36:01 +03:00
|
|
|
ST.st_mode |= i;
|
|
|
|
if (S_ISLNK(ST.st_mode))
|
|
|
|
ST.st_mode = 0;
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'd': {
|
1998-10-13 02:07:53 +04:00
|
|
|
vfs_split_text(buffer+1);
|
1998-11-21 22:36:01 +03:00
|
|
|
if (!vfs_parse_filedate(0, &ST.st_ctime))
|
1998-09-13 14:40:43 +04:00
|
|
|
break;
|
1998-11-21 22:36:01 +03:00
|
|
|
ST.st_atime = ST.st_mtime = ST.st_ctime;
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'D': {
|
|
|
|
struct tm tim;
|
|
|
|
if (sscanf(buffer+1, "%d %d %d %d %d %d", &tim.tm_year, &tim.tm_mon,
|
|
|
|
&tim.tm_mday, &tim.tm_hour, &tim.tm_min, &tim.tm_sec) != 6)
|
|
|
|
break;
|
1998-11-21 22:36:01 +03:00
|
|
|
ST.st_atime = ST.st_mtime = ST.st_ctime = mktime(&tim);
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'E': {
|
|
|
|
int maj, min;
|
|
|
|
if (sscanf(buffer+1, "%d,%d", &maj, &min) != 2)
|
|
|
|
break;
|
|
|
|
#ifdef HAVE_ST_RDEV
|
1998-11-21 22:36:01 +03:00
|
|
|
ST.st_rdev = (maj << 8) | min;
|
1998-09-13 14:40:43 +04:00
|
|
|
#endif
|
|
|
|
}
|
1998-11-21 22:36:01 +03:00
|
|
|
case 'L': ent->ino->linkname = strdup(buffer+1);
|
1998-09-13 14:40:43 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-11-21 22:36:01 +03:00
|
|
|
|
|
|
|
vfs_s_free_entry (me, ent);
|
|
|
|
me->verrno = E_REMOTE;
|
|
|
|
if (decode_reply(buffer+4, 0) != COMPLETE)
|
|
|
|
goto error;
|
1998-09-13 14:40:43 +04:00
|
|
|
|
|
|
|
print_vfs_message("fish: got listing");
|
1998-11-21 22:36:01 +03:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
1998-09-13 14:40:43 +04:00
|
|
|
print_vfs_message("fish: failed");
|
1998-11-21 22:36:01 +03:00
|
|
|
return 1;
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-11-21 22:36:01 +03:00
|
|
|
file_store(vfs *me, vfs_s_super *super, char *name, char *localname)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
1998-11-21 22:36:01 +03:00
|
|
|
int n, total;
|
1998-09-13 14:40:43 +04:00
|
|
|
char buffer[8192];
|
|
|
|
struct stat s;
|
|
|
|
int was_error = 0;
|
1998-11-21 22:36:01 +03:00
|
|
|
int h;
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
h = open(localname, O_RDONLY);
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
if (fstat(h, &s)<0)
|
|
|
|
ERRNOR (EIO, -1);
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-10-23 12:26:25 +04:00
|
|
|
/* Use this as stor: ( dd block ; dd smallblock ) | ( cat > file; cat > /dev/null ) */
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
print_vfs_message("FISH: store %s: sending command...", name );
|
|
|
|
if (command (me, super, WAIT_REPLY,
|
|
|
|
"#STOR %d /%s\n> /%s; echo '### 001'; ( dd bs=4096 count=%d; dd bs=%d count=1 ) 2>/dev/null | ( cat > /%s; cat > /dev/null ); echo '### 200'\n",
|
|
|
|
s.st_size, name, name,
|
|
|
|
s.st_size / 4096, s.st_size % 4096, name)
|
1998-09-13 14:40:43 +04:00
|
|
|
!= PRELIM)
|
1998-11-21 22:36:01 +03:00
|
|
|
ERRNOR(E_REMOTE, -1);
|
1998-09-13 14:40:43 +04:00
|
|
|
|
|
|
|
total = 0;
|
|
|
|
|
|
|
|
while (1) {
|
1998-11-21 22:36:01 +03:00
|
|
|
while ((n = read(h, buffer, sizeof(buffer))) < 0) {
|
1998-09-13 14:40:43 +04:00
|
|
|
if ((errno == EINTR) && got_interrupt)
|
|
|
|
continue;
|
|
|
|
print_vfs_message("FISH: Local read failed, sending zeros" );
|
1998-11-21 22:36:01 +03:00
|
|
|
close(h);
|
|
|
|
h = open( "/dev/zero", O_RDONLY );
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
if (n == 0)
|
|
|
|
break;
|
1998-11-21 22:36:01 +03:00
|
|
|
while (write(SUP.sockw, buffer, n) < 0) {
|
|
|
|
me->verrno = errno;
|
1998-09-13 14:40:43 +04:00
|
|
|
goto error_return;
|
|
|
|
}
|
1998-11-21 22:36:01 +03:00
|
|
|
disable_interrupt_key();
|
1998-09-13 14:40:43 +04:00
|
|
|
total += n;
|
|
|
|
print_vfs_message("fish: storing %s %d (%d)",
|
|
|
|
was_error ? "zeros" : "file", total, s.st_size);
|
|
|
|
}
|
1998-11-21 22:36:01 +03:00
|
|
|
if ((get_reply (me, SUP.sockr, NULL, 0) != COMPLETE) || was_error)
|
|
|
|
ERRNOR (E_REMOTE, 0);
|
|
|
|
close(h);
|
1998-09-13 14:40:43 +04:00
|
|
|
return 0;
|
1998-11-21 22:36:01 +03:00
|
|
|
error_return:
|
|
|
|
close(h);
|
|
|
|
get_reply(me, SUP.sockr, NULL, 0);
|
|
|
|
return -1;
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
static int linear_start(vfs *me, vfs_s_fh *fh, int offset)
|
1998-09-21 13:52:07 +04:00
|
|
|
{
|
1998-11-21 22:36:01 +03:00
|
|
|
char *name;
|
1998-10-13 02:07:53 +04:00
|
|
|
if (offset)
|
1998-11-21 22:36:01 +03:00
|
|
|
ERRNOR (E_NOTSUPP, 0);
|
|
|
|
/* fe->local_stat.st_mtime = 0; FIXME: what is this good for? */
|
|
|
|
name = vfs_s_fullpath (me, fh->ino);
|
|
|
|
if (!name)
|
|
|
|
return 0;
|
|
|
|
if (command(me, FH_SUPER, WANT_STRING,
|
|
|
|
"#RETR /%s\nls -l /%s | ( read var1 var2 var3 var4 var5 var6; echo $var5 ); echo '### 100'; cat /%s; echo '### 200'\n",
|
|
|
|
name, name, name )
|
|
|
|
!= PRELIM) ERRNOR (E_REMOTE, 0);
|
|
|
|
fh->linear = LS_LINEAR_OPEN;
|
|
|
|
fh->u.fish.got = 0;
|
|
|
|
if (sscanf( reply_str, "%d", &fh->u.fish.total )!=1)
|
|
|
|
ERRNOR (E_REMOTE, 0);
|
1998-09-21 13:52:07 +04:00
|
|
|
return 1;
|
|
|
|
}
|
1998-09-13 14:40:43 +04:00
|
|
|
|
|
|
|
static void
|
1998-11-21 22:36:01 +03:00
|
|
|
linear_abort (vfs *me, vfs_s_fh *fh)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
1998-11-21 22:36:01 +03:00
|
|
|
vfs_s_super *super = FH_SUPER;
|
1998-09-21 13:52:07 +04:00
|
|
|
char buffer[8192];
|
1998-09-13 14:40:43 +04:00
|
|
|
int n;
|
|
|
|
|
|
|
|
print_vfs_message( "Aborting transfer..." );
|
|
|
|
do {
|
1998-11-21 22:36:01 +03:00
|
|
|
n = VFS_MIN(8192, fh->u.fish.total - fh->u.fish.got);
|
1998-09-13 14:40:43 +04:00
|
|
|
if (n)
|
1998-11-21 22:36:01 +03:00
|
|
|
if ((n = read(SUP.sockr, buffer, n)) < 0)
|
1998-09-13 14:40:43 +04:00
|
|
|
return;
|
|
|
|
} while (n);
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
if (get_reply (me, SUP.sockr, NULL, 0) != COMPLETE)
|
1998-09-13 14:40:43 +04:00
|
|
|
print_vfs_message( "Error reported after abort." );
|
|
|
|
else
|
|
|
|
print_vfs_message( "Aborted transfer would be successfull." );
|
|
|
|
}
|
|
|
|
|
1998-09-21 13:52:07 +04:00
|
|
|
static int
|
1998-11-21 22:36:01 +03:00
|
|
|
linear_read (vfs *me, vfs_s_fh *fh, void *buf, int len)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
1998-11-21 22:36:01 +03:00
|
|
|
vfs_s_super *super = FH_SUPER;
|
1998-09-21 13:52:07 +04:00
|
|
|
int n = 0;
|
1998-11-21 22:36:01 +03:00
|
|
|
len = VFS_MIN( fh->u.fish.total - fh->u.fish.got, len );
|
|
|
|
disable_interrupt_key();
|
|
|
|
while (len && ((n = read (SUP.sockr, buf, len))<0)) {
|
1998-09-21 13:52:07 +04:00
|
|
|
if ((errno == EINTR) && !got_interrupt())
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
1998-11-21 22:36:01 +03:00
|
|
|
enable_interrupt_key();
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
if (n>0) fh->u.fish.got += n;
|
|
|
|
if (n<0) linear_abort(me, fh);
|
|
|
|
if ((!n) && ((get_reply (me, SUP.sockr, NULL, 0) != COMPLETE)))
|
|
|
|
ERRNOR (E_REMOTE, -1);
|
1998-09-21 13:52:07 +04:00
|
|
|
ERRNOR (errno, n);
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
|
1998-09-27 23:27:58 +04:00
|
|
|
static void
|
1998-11-21 22:36:01 +03:00
|
|
|
linear_close (vfs *me, vfs_s_fh *fh)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
1998-11-21 22:36:01 +03:00
|
|
|
if (fh->u.fish.total != fh->u.fish.got)
|
|
|
|
linear_abort(me, fh);
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
|
1998-10-13 02:07:53 +04:00
|
|
|
static int
|
1998-11-21 22:36:01 +03:00
|
|
|
fish_ctl (void *fh, int ctlop, int arg)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
1998-11-21 22:36:01 +03:00
|
|
|
return 0;
|
1998-09-13 14:40:43 +04:00
|
|
|
switch (ctlop) {
|
1998-09-21 13:52:07 +04:00
|
|
|
case MCCTL_IS_NOTREADY:
|
|
|
|
{
|
1998-10-13 02:07:53 +04:00
|
|
|
int v;
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
if (!FH->linear)
|
1998-10-13 02:07:53 +04:00
|
|
|
vfs_die ("You may not do this");
|
1998-11-21 22:36:01 +03:00
|
|
|
if (FH->linear == LS_LINEAR_CLOSED)
|
1998-10-13 02:07:53 +04:00
|
|
|
return 0;
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
v = vfs_s_select_on_two (FH_SUPER->u.fish.sockr, 0);
|
1998-09-21 13:52:07 +04:00
|
|
|
if (((v < 0) && (errno == EINTR)) || v == 0)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
1998-09-21 13:52:07 +04:00
|
|
|
default:
|
|
|
|
return 0;
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-11-21 22:36:01 +03:00
|
|
|
send_fish_command(vfs *me, vfs_s_super *super, char *cmd, int flags)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
r = command (me, super, WAIT_REPLY, cmd);
|
|
|
|
vfs_add_noncurrent_stamps (&vfs_fish_ops, (vfsid) super, NULL);
|
|
|
|
if (r != COMPLETE) ERRNOR (E_REMOTE, -1);
|
|
|
|
if (flags & OPT_FLUSH)
|
|
|
|
vfs_s_invalidate(me, super);
|
1998-09-13 14:40:43 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PREFIX \
|
|
|
|
char buf[999]; \
|
1998-11-21 22:36:01 +03:00
|
|
|
char *rpath; \
|
|
|
|
vfs_s_super *super; \
|
|
|
|
if (!(rpath = vfs_s_get_path_mangle(me, path, &super, 0))) \
|
1998-09-13 14:40:43 +04:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
#define POSTFIX(flags) \
|
1998-11-21 22:36:01 +03:00
|
|
|
return send_fish_command(me, super, buf, flags);
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-10-13 02:07:53 +04:00
|
|
|
static int
|
|
|
|
fish_chmod (vfs *me, char *path, int mode)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
|
|
|
PREFIX
|
1998-11-21 22:36:01 +03:00
|
|
|
sprintf(buf, "#CHMOD %4.4o /%s\nchmod %4.4o /%s; echo '### 000'\n",
|
|
|
|
mode & 07777, rpath,
|
|
|
|
mode & 07777, rpath);
|
1998-09-13 14:40:43 +04:00
|
|
|
POSTFIX(OPT_FLUSH);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FISH_OP(name, chk, string) \
|
1998-10-13 02:07:53 +04:00
|
|
|
static int fish_##name (vfs *me, char *path1, char *path2) \
|
1998-09-13 14:40:43 +04:00
|
|
|
{ \
|
1998-11-21 22:36:01 +03:00
|
|
|
char buf[1024]; \
|
|
|
|
char *rpath1 = NULL, *rpath2 = NULL; \
|
|
|
|
vfs_s_super *super1, *super2; \
|
|
|
|
if (!(rpath1 = vfs_s_get_path_mangle(me, path1, &super1, 0))) \
|
1998-09-13 14:40:43 +04:00
|
|
|
return -1; \
|
1998-11-21 22:36:01 +03:00
|
|
|
if (!(rpath2 = vfs_s_get_path_mangle(me, path2, &super2, 0))) \
|
1998-09-13 14:40:43 +04:00
|
|
|
return -1; \
|
1998-12-02 16:17:24 +03:00
|
|
|
g_snprintf(buf, 1023, string "\n", rpath1, rpath2, rpath1, rpath2 ); \
|
1998-11-21 22:36:01 +03:00
|
|
|
return send_fish_command(me, super2, buf, OPT_FLUSH); \
|
1998-09-13 14:40:43 +04:00
|
|
|
}
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
#define XTEST if (bucket1 != bucket2) { ERRNOR (EXDEV, -1); }
|
|
|
|
FISH_OP(rename, XTEST, "#RENAME /%s /%s\nmv /%s /%s; echo '### 000'" );
|
|
|
|
FISH_OP(link, XTEST, "#LINK /%s /%s\nln /%s /%s; echo '### 000'" );
|
|
|
|
|
|
|
|
static int fish_symlink (vfs *me, char *setto, char *path)
|
|
|
|
{
|
|
|
|
PREFIX
|
|
|
|
sprintf(buf, "#SYMLINK %s /%s\nln -s %s /%s; echo '### 000'\n", setto, rpath, setto, rpath);
|
|
|
|
POSTFIX(OPT_FLUSH);
|
|
|
|
}
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-10-13 02:07:53 +04:00
|
|
|
static int
|
|
|
|
fish_chown (vfs *me, char *path, int owner, int group)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
|
|
|
char *sowner, *sgroup;
|
|
|
|
PREFIX
|
|
|
|
sowner = getpwuid( owner )->pw_name;
|
|
|
|
sgroup = getgrgid( group )->gr_name;
|
1998-11-21 22:36:01 +03:00
|
|
|
sprintf(buf, "#CHOWN /%s /%s\nchown /%s /%s; echo '### 000'\n",
|
|
|
|
sowner, rpath,
|
|
|
|
sowner, rpath);
|
|
|
|
send_fish_command(me, super, buf, OPT_FLUSH);
|
1998-09-13 14:40:43 +04:00
|
|
|
/* FIXME: what should we report if chgrp succeeds but chown fails? */
|
1998-11-21 22:36:01 +03:00
|
|
|
sprintf(buf, "#CHGRP /%s /%s\nchgrp /%s /%s; echo '### 000'\n",
|
|
|
|
sgroup, rpath,
|
|
|
|
sgroup, rpath);
|
1998-09-13 14:40:43 +04:00
|
|
|
POSTFIX(OPT_FLUSH)
|
|
|
|
}
|
|
|
|
|
1998-09-27 23:27:58 +04:00
|
|
|
static int fish_unlink (vfs *me, char *path)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
|
|
|
PREFIX
|
1998-11-21 22:36:01 +03:00
|
|
|
sprintf(buf, "#DELE /%s\nrm -f /%s; echo '### 000'\n", rpath, rpath);
|
1998-09-13 14:40:43 +04:00
|
|
|
POSTFIX(OPT_FLUSH);
|
|
|
|
}
|
|
|
|
|
1998-09-27 23:27:58 +04:00
|
|
|
static int fish_mkdir (vfs *me, char *path, mode_t mode)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
|
|
|
PREFIX
|
1998-11-21 22:36:01 +03:00
|
|
|
sprintf(buf, "#MKD /%s\nmkdir /%s; echo '### 000'\n", rpath, rpath);
|
1998-09-13 14:40:43 +04:00
|
|
|
POSTFIX(OPT_FLUSH);
|
|
|
|
}
|
|
|
|
|
1998-09-27 23:27:58 +04:00
|
|
|
static int fish_rmdir (vfs *me, char *path)
|
1998-09-13 14:40:43 +04:00
|
|
|
{
|
|
|
|
PREFIX
|
1998-11-21 22:36:01 +03:00
|
|
|
sprintf(buf, "#RMD /%s\nrmdir /%s; echo '### 000'\n", rpath, rpath);
|
1998-09-13 14:40:43 +04:00
|
|
|
POSTFIX(OPT_FLUSH);
|
|
|
|
}
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
static int 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;
|
|
|
|
char buffer[8192];
|
|
|
|
int handle, n;
|
|
|
|
int stat_size = ino->st.st_size;
|
|
|
|
struct vfs_s_fh fh;
|
|
|
|
|
|
|
|
memset(&fh, 0, sizeof(fh));
|
|
|
|
|
|
|
|
fh.ino = ino;
|
|
|
|
if (!(ino->localname = tempnam (NULL, me->name))) ERRNOR (ENOMEM, 0);
|
|
|
|
|
|
|
|
handle = open(ino->localname, O_RDWR | O_CREAT | O_TRUNC | O_EXCL, 0600);
|
|
|
|
if (handle == -1) {
|
|
|
|
me->verrno = errno;
|
|
|
|
goto error_4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!MEDATA->linear_start (me, &fh, 0))
|
|
|
|
goto error_3;
|
|
|
|
|
|
|
|
/* Clear the interrupt status */
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
n = linear_read(me, &fh, buffer, sizeof(buffer));
|
|
|
|
if (n < 0)
|
|
|
|
goto error_1;
|
|
|
|
if (!n)
|
|
|
|
break;
|
|
|
|
|
|
|
|
total += n;
|
|
|
|
vfs_print_stats (me->name, "Getting file", ino->ent->name, total, stat_size);
|
|
|
|
|
|
|
|
if (write(handle, buffer, n) < 0) {
|
|
|
|
me->verrno = errno;
|
|
|
|
goto error_1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
linear_close(me, &fh);
|
|
|
|
close(handle);
|
|
|
|
|
|
|
|
if (stat (ino->localname, &ino->u.fish.local_stat) < 0)
|
|
|
|
ino->u.fish.local_stat.st_mtime = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
error_1:
|
|
|
|
linear_close(me, &fh);
|
|
|
|
error_3:
|
|
|
|
disable_interrupt_key();
|
|
|
|
close(handle);
|
|
|
|
unlink(ino->localname);
|
|
|
|
error_4:
|
|
|
|
free(ino->localname);
|
|
|
|
ino->localname = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fish_fh_open (vfs *me, vfs_s_fh *fh, int flags, int mode)
|
|
|
|
{
|
|
|
|
if (IS_LINEAR(mode)) {
|
|
|
|
message_1s(1, "Linear mode requested", "?!" );
|
|
|
|
fh->linear = LS_LINEAR_CLOSED;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!fh->ino->localname)
|
|
|
|
if (retrieve_file (me, fh->ino)==-1)
|
|
|
|
return -1;
|
|
|
|
if (!fh->ino->localname)
|
|
|
|
vfs_die( "retrieve_file failed to fill in localname" );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct vfs_s_data fish_data = {
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
|
|
|
|
NULL, /* init_inode */
|
|
|
|
NULL, /* free_inode */
|
|
|
|
NULL, /* init_entry */
|
|
|
|
|
|
|
|
NULL, /* archive_check */
|
|
|
|
archive_same,
|
|
|
|
open_archive,
|
|
|
|
free_archive,
|
|
|
|
|
|
|
|
fish_fh_open, /* fh_open */
|
|
|
|
NULL, /* fh_close */
|
|
|
|
|
|
|
|
vfs_s_find_entry_linear,
|
|
|
|
dir_load,
|
|
|
|
dir_uptodate,
|
|
|
|
file_store,
|
|
|
|
|
|
|
|
linear_start,
|
|
|
|
linear_read,
|
|
|
|
linear_close
|
|
|
|
};
|
|
|
|
|
1998-10-13 02:07:53 +04:00
|
|
|
vfs vfs_fish_ops = {
|
1998-09-27 23:27:58 +04:00
|
|
|
NULL, /* This is place of next pointer */
|
|
|
|
"FIles tranferred over SHell",
|
|
|
|
F_EXEC, /* flags */
|
|
|
|
"sh:", /* prefix */
|
1998-11-21 22:36:01 +03:00
|
|
|
&fish_data, /* data */
|
1998-09-27 23:27:58 +04:00
|
|
|
0, /* errno */
|
1998-11-21 22:36:01 +03:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
vfs_s_fill_names,
|
1998-09-27 23:27:58 +04:00
|
|
|
NULL,
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
vfs_s_open,
|
|
|
|
vfs_s_close,
|
|
|
|
vfs_s_read,
|
|
|
|
vfs_s_write,
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
vfs_s_opendir,
|
|
|
|
vfs_s_readdir,
|
|
|
|
vfs_s_closedir,
|
|
|
|
vfs_s_telldir,
|
|
|
|
vfs_s_seekdir,
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
vfs_s_stat,
|
|
|
|
vfs_s_lstat,
|
|
|
|
vfs_s_fstat,
|
1998-09-13 14:40:43 +04:00
|
|
|
|
|
|
|
fish_chmod,
|
1998-11-21 22:36:01 +03:00
|
|
|
fish_chown,
|
1998-09-13 14:40:43 +04:00
|
|
|
NULL, /* utime */
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
vfs_s_readlink,
|
1998-09-13 14:40:43 +04:00
|
|
|
fish_symlink, /* symlink */
|
|
|
|
fish_link, /* link */
|
|
|
|
fish_unlink,
|
|
|
|
|
|
|
|
fish_rename, /* rename */
|
1998-11-21 22:36:01 +03:00
|
|
|
vfs_s_chdir,
|
|
|
|
vfs_s_ferrno,
|
|
|
|
vfs_s_lseek,
|
1998-09-13 14:40:43 +04:00
|
|
|
NULL, /* mknod */
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
vfs_s_getid,
|
|
|
|
vfs_s_nothingisopen,
|
|
|
|
vfs_s_free,
|
1998-09-13 14:40:43 +04:00
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
NULL, /* vfs_s_getlocalcopy, */
|
|
|
|
NULL, /* vfs_s_ungetlocalcopy, */
|
1998-09-13 14:40:43 +04:00
|
|
|
|
|
|
|
fish_mkdir,
|
|
|
|
fish_rmdir,
|
|
|
|
fish_ctl,
|
1998-11-21 22:36:01 +03:00
|
|
|
vfs_s_setctl
|
1998-10-13 02:07:53 +04:00
|
|
|
|
|
|
|
MMAPNULL
|
1998-09-13 14:40:43 +04:00
|
|
|
};
|