2 Virtual File System: FISH implementation for transfering files over
5 Copyright (C) 1998-2018
6 Free Software Foundation, Inc.
11 Andrew Borodin <aborodin@vmail.ru>, 2010
12 Slava Zanko <slavazanko@gmail.com>, 2010, 2013
13 Ilia Maslakov <il.smind@gmail.com>, 2010
17 This file is part of the Midnight Commander.
19 The Midnight Commander is free software: you can redistribute it
20 and/or modify it under the terms of the GNU General Public License as
21 published by the Free Software Foundation, either version 3 of the License,
22 or (at your option) any later version.
24 The Midnight Commander is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 GNU General Public License for more details.
29 You should have received a copy of the GNU General Public License
30 along with this program. If not, see <http://www.gnu.org/licenses/>.
35 * \brief Source: Virtual File System: FISH implementation for transfering files over
37 * \author Pavel Machek
41 * Derived from ftpfs.c
42 * Read README.fish for protocol specification.
44 * Syntax of path is: \verbatim sh://user@host[:Cr]/path \endverbatim
45 * where C means you want compressed connection,
46 * and r means you want to use rsh
48 * Namespace: fish_vfs_ops exported.
51 /* Define this if your ssh can take -I option */
57 #include <sys/time.h> /* gettimeofday() */
60 #include <inttypes.h> /* uintmax_t */
62 #include "lib/global.h"
63 #include "lib/tty/tty.h" /* enable/disable interrupt key */
64 #include "lib/strescape.h"
65 #include "lib/unixcompat.h"
66 #include "lib/fileloc.h"
67 #include "lib/util.h" /* my_exit() */
68 #include "lib/mcconfig.h"
70 #include "src/execute.h" /* pre_exec, post_exec */
72 #include "lib/vfs/vfs.h"
73 #include "lib/vfs/utilvfs.h"
74 #include "lib/vfs/netutil.h"
75 #include "lib/vfs/xdirentry.h"
76 #include "lib/vfs/gc.h" /* vfs_stamp_create */
81 /*** global variables ****************************************************************************/
83 int fish_directory_timeout
= 900;
85 /*** file scope macro definitions ****************************************************************/
87 #define DO_RESOLVE_SYMLINK 1
89 #define DO_FREE_RESOURCE 4
91 #define FISH_FLAG_COMPRESSED 1
92 #define FISH_FLAG_RSH 2
95 #define OPT_IGNORE_ERROR 2
100 #define PRELIM 1 /* positive preliminary */
101 #define COMPLETE 2 /* positive completion */
102 #define CONTINUE 3 /* positive intermediate */
103 #define TRANSIENT 4 /* transient negative completion */
104 #define ERROR 5 /* permanent negative completion */
106 /* command wait_flag: */
108 #define WAIT_REPLY 0x01
109 #define WANT_STRING 0x02
111 /* environment flags */
112 #define FISH_HAVE_HEAD 1
113 #define FISH_HAVE_SED 2
114 #define FISH_HAVE_AWK 4
115 #define FISH_HAVE_PERL 8
116 #define FISH_HAVE_LSQ 16
117 #define FISH_HAVE_DATE_MDYT 32
118 #define FISH_HAVE_TAIL 64
120 #define SUP ((fish_super_data_t *) super)
122 /*** file scope type declarations ****************************************************************/
126 struct vfs_s_super base
; /* base class */
156 /*** file scope variables ************************************************************************/
158 static char reply_str
[80];
160 static struct vfs_s_subclass fish_subclass
;
161 static struct vfs_class
*vfs_fish_ops
= (struct vfs_class
*) &fish_subclass
;
163 /* --------------------------------------------------------------------------------------------- */
164 /*** file scope functions ************************************************************************/
165 /* --------------------------------------------------------------------------------------------- */
168 fish_set_blksize (struct stat
*s
)
170 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
171 /* redefine block size */
172 s
->st_blksize
= 64 * 1024; /* FIXME */
176 /* --------------------------------------------------------------------------------------------- */
179 fish_default_stat (struct vfs_class
*me
)
183 s
= vfs_s_default_stat (me
, S_IFDIR
| 0755);
184 fish_set_blksize (s
);
190 /* --------------------------------------------------------------------------------------------- */
193 fish_load_script_from_file (const char *hostname
, const char *script_name
, const char *def_content
)
195 char *scr_filename
= NULL
;
199 /* 1st: scan user directory */
200 scr_filename
= g_build_path (PATH_SEP_STR
, mc_config_get_data_path (), FISH_PREFIX
, hostname
,
201 script_name
, (char *) NULL
);
202 /* silent about user dir */
203 g_file_get_contents (scr_filename
, &scr_content
, &scr_len
, NULL
);
204 g_free (scr_filename
);
205 /* 2nd: scan system dir */
206 if (scr_content
== NULL
)
209 g_build_path (PATH_SEP_STR
, LIBEXECDIR
, FISH_PREFIX
, script_name
, (char *) NULL
);
210 g_file_get_contents (scr_filename
, &scr_content
, &scr_len
, NULL
);
211 g_free (scr_filename
);
214 if (scr_content
!= NULL
)
217 return g_strdup (def_content
);
220 /* --------------------------------------------------------------------------------------------- */
223 fish_decode_reply (char *s
, gboolean was_garbage
)
227 /* cppcheck-suppress invalidscanf */
228 if (sscanf (s
, "%d", &code
) == 0)
234 return was_garbage
? ERROR
: (code
== 0 ? COMPLETE
: PRELIM
);
238 /* --------------------------------------------------------------------------------------------- */
239 /* Returns a reply code, check /usr/include/arpa/ftp.h for possible values */
242 fish_get_reply (struct vfs_class
*me
, int sock
, char *string_buf
, int string_len
)
245 gboolean was_garbage
= FALSE
;
249 if (!vfs_s_get_line (me
, sock
, answer
, sizeof (answer
), '\n'))
251 if (string_buf
!= NULL
)
256 if (strncmp (answer
, "### ", 4) == 0)
257 return fish_decode_reply (answer
+ 4, was_garbage
? 1 : 0);
260 if (string_buf
!= NULL
)
261 g_strlcpy (string_buf
, answer
, string_len
);
265 /* --------------------------------------------------------------------------------------------- */
268 fish_command (struct vfs_class
*me
, struct vfs_s_super
*super
, int wait_reply
, const char *cmd
,
272 FILE *logfile
= MEDATA
->logfile
;
274 if (cmd_len
== (size_t) (-1))
275 cmd_len
= strlen (cmd
);
281 ret
= fwrite (cmd
, cmd_len
, 1, logfile
);
282 ret
= fflush (logfile
);
286 tty_enable_interrupt_key ();
287 status
= write (SUP
->sockw
, cmd
, cmd_len
);
288 tty_disable_interrupt_key ();
294 return fish_get_reply (me
, SUP
->sockr
,
295 (wait_reply
& WANT_STRING
) != 0 ? reply_str
:
296 NULL
, sizeof (reply_str
) - 1);
300 /* --------------------------------------------------------------------------------------------- */
304 fish_command_va (struct vfs_class
*me
, struct vfs_s_super
*super
, int wait_reply
, const char *scr
,
305 const char *vars
, va_list ap
)
310 command
= g_string_new (SUP
->scr_env
);
311 g_string_append_vprintf (command
, vars
, ap
);
312 g_string_append (command
, scr
);
313 r
= fish_command (me
, super
, wait_reply
, command
->str
, command
->len
);
314 g_string_free (command
, TRUE
);
319 /* --------------------------------------------------------------------------------------------- */
323 fish_command_v (struct vfs_class
*me
, struct vfs_s_super
*super
, int wait_reply
, const char *scr
,
324 const char *vars
, ...)
330 r
= fish_command_va (me
, super
, wait_reply
, scr
, vars
, ap
);
336 /* --------------------------------------------------------------------------------------------- */
340 fish_send_command (struct vfs_class
*me
, struct vfs_s_super
*super
, int flags
, const char *scr
,
341 const char *vars
, ...)
347 r
= fish_command_va (me
, super
, WAIT_REPLY
, scr
, vars
, ap
);
349 vfs_stamp_create (vfs_fish_ops
, super
);
352 ERRNOR (E_REMOTE
, -1);
353 if ((flags
& OPT_FLUSH
) != 0)
354 vfs_s_invalidate (me
, super
);
359 /* --------------------------------------------------------------------------------------------- */
361 static struct vfs_s_super
*
362 fish_new_archive (struct vfs_class
*me
)
364 fish_super_data_t
*arch
;
366 arch
= g_new0 (fish_super_data_t
, 1);
369 return VFS_SUPER (arch
);
372 /* --------------------------------------------------------------------------------------------- */
375 fish_free_archive (struct vfs_class
*me
, struct vfs_s_super
*super
)
377 if ((SUP
->sockw
!= -1) || (SUP
->sockr
!= -1))
379 vfs_print_message (_("fish: Disconnecting from %s"), super
->name
? super
->name
: "???");
380 fish_command (me
, super
, NONE
, "#BYE\nexit\n", -1);
383 SUP
->sockw
= SUP
->sockr
= -1;
385 g_free (SUP
->scr_ls
);
386 g_free (SUP
->scr_exists
);
387 g_free (SUP
->scr_mkdir
);
388 g_free (SUP
->scr_unlink
);
389 g_free (SUP
->scr_chown
);
390 g_free (SUP
->scr_chmod
);
391 g_free (SUP
->scr_utime
);
392 g_free (SUP
->scr_rmdir
);
393 g_free (SUP
->scr_ln
);
394 g_free (SUP
->scr_mv
);
395 g_free (SUP
->scr_hardlink
);
396 g_free (SUP
->scr_get
);
397 g_free (SUP
->scr_send
);
398 g_free (SUP
->scr_append
);
399 g_free (SUP
->scr_info
);
400 g_free (SUP
->scr_env
);
403 /* --------------------------------------------------------------------------------------------- */
406 fish_pipeopen (struct vfs_s_super
*super
, const char *path
, const char *argv
[])
408 int fileset1
[2], fileset2
[2];
411 if ((pipe (fileset1
) < 0) || (pipe (fileset2
) < 0))
412 vfs_die ("Cannot pipe(): %m.");
419 vfs_die ("Cannot fork(): %m.");
420 /* We are the parent */
422 SUP
->sockw
= fileset1
[1];
424 SUP
->sockr
= fileset2
[0];
428 res
= dup2 (fileset1
[0], STDIN_FILENO
);
431 res
= dup2 (fileset2
[1], STDOUT_FILENO
);
432 close (STDERR_FILENO
);
433 /* stderr to /dev/null */
434 res
= open ("/dev/null", O_WRONLY
);
437 execvp (path
, (char **) argv
);
442 /* --------------------------------------------------------------------------------------------- */
445 fish_set_env (int flags
)
449 tmp
= g_string_sized_new (250);
450 g_string_assign (tmp
, "");
452 if ((flags
& FISH_HAVE_HEAD
) != 0)
453 g_string_append (tmp
, "FISH_HAVE_HEAD=1 export FISH_HAVE_HEAD; ");
455 if ((flags
& FISH_HAVE_SED
) != 0)
456 g_string_append (tmp
, "FISH_HAVE_SED=1 export FISH_HAVE_SED; ");
458 if ((flags
& FISH_HAVE_AWK
) != 0)
459 g_string_append (tmp
, "FISH_HAVE_AWK=1 export FISH_HAVE_AWK; ");
461 if ((flags
& FISH_HAVE_PERL
) != 0)
462 g_string_append (tmp
, "FISH_HAVE_PERL=1 export FISH_HAVE_PERL; ");
464 if ((flags
& FISH_HAVE_LSQ
) != 0)
465 g_string_append (tmp
, "FISH_HAVE_LSQ=1 export FISH_HAVE_LSQ; ");
467 if ((flags
& FISH_HAVE_DATE_MDYT
) != 0)
468 g_string_append (tmp
, "FISH_HAVE_DATE_MDYT=1 export FISH_HAVE_DATE_MDYT; ");
470 if ((flags
& FISH_HAVE_TAIL
) != 0)
471 g_string_append (tmp
, "FISH_HAVE_TAIL=1 export FISH_HAVE_TAIL; ");
473 return g_string_free (tmp
, FALSE
);
476 /* --------------------------------------------------------------------------------------------- */
479 fish_info (struct vfs_class
*me
, struct vfs_s_super
*super
)
481 if (fish_command (me
, super
, NONE
, SUP
->scr_info
, -1) == COMPLETE
)
488 res
= vfs_s_get_line_interruptible (me
, buffer
, sizeof (buffer
), SUP
->sockr
);
489 if ((res
== 0) || (res
== EINTR
))
490 ERRNOR (ECONNRESET
, FALSE
);
491 if (strncmp (buffer
, "### ", 4) == 0)
493 SUP
->host_flags
= atol (buffer
);
497 ERRNOR (E_PROTO
, FALSE
);
500 /* --------------------------------------------------------------------------------------------- */
503 fish_open_archive_pipeopen (struct vfs_s_super
*super
)
506 const char *argv
[10]; /* All of 10 is used now */
507 const char *xsh
= (super
->path_element
->port
== FISH_FLAG_RSH
? "rsh" : "ssh");
511 if (super
->path_element
->port
== FISH_FLAG_COMPRESSED
)
514 if (super
->path_element
->port
> FISH_FLAG_RSH
)
517 g_snprintf (gbuf
, sizeof (gbuf
), "%d", super
->path_element
->port
);
522 * Add the user name to the ssh command line only if it was explicitly
523 * set in vfs URL. rsh/ssh will get current user by default
524 * plus we can set convenient overrides in ~/.ssh/config (explicit -l
525 * option breaks it for some)
528 if (super
->path_element
->user
!= NULL
)
531 argv
[i
++] = super
->path_element
->user
;
535 /* The rest of the code assumes it to be a valid username */
536 super
->path_element
->user
= vfs_get_local_username ();
539 argv
[i
++] = super
->path_element
->host
;
540 argv
[i
++] = "echo FISH:; /bin/sh";
543 fish_pipeopen (super
, xsh
, argv
);
546 /* --------------------------------------------------------------------------------------------- */
549 fish_open_archive_talk (struct vfs_class
*me
, struct vfs_s_super
*super
)
553 printf ("\n%s\n", _("fish: Waiting for initial line..."));
555 if (vfs_s_get_line (me
, SUP
->sockr
, answer
, sizeof (answer
), ':') == 0)
558 if (strstr (answer
, "assword") != NULL
)
560 /* Currently, this does not work. ssh reads passwords from
561 /dev/tty, not from stdin :-(. */
563 printf ("\n%s\n", _("Sorry, we cannot do password authenticated connections for now."));
567 if (super
->path_element
->password
== NULL
)
571 p
= g_strdup_printf (_("fish: Password is required for %s"), super
->path_element
->user
);
572 op
= vfs_get_password (p
);
576 super
->path_element
->password
= op
;
579 printf ("\n%s\n", _("fish: Sending password..."));
584 str_len
= strlen (super
->path_element
->password
);
585 if ((write (SUP
.sockw
, super
->path_element
->password
, str_len
) != (ssize_t
) str_len
)
586 || (write (SUP
->sockw
, "\n", 1) != 1))
594 /* --------------------------------------------------------------------------------------------- */
597 fish_open_archive_int (struct vfs_class
*me
, struct vfs_s_super
*super
)
605 fish_open_archive_pipeopen (super
);
607 /* Start talk with ssh-server (password prompt, etc ) */
608 ftalk
= fish_open_archive_talk (me
, super
);
614 ERRNOR (E_PROTO
, -1);
616 vfs_print_message ("%s", _("fish: Sending initial line..."));
618 * Run 'start_fish_server'. If it doesn't exist - no problem,
619 * we'll talk directly to the shell.
623 (me
, super
, WAIT_REPLY
, "#FISH\necho; start_fish_server 2>&1; echo '### 200'\n",
625 ERRNOR (E_PROTO
, -1);
627 vfs_print_message ("%s", _("fish: Handshaking version..."));
628 if (fish_command (me
, super
, WAIT_REPLY
, "#VER 0.0.3\necho '### 000'\n", -1) != COMPLETE
)
629 ERRNOR (E_PROTO
, -1);
631 /* Set up remote locale to C, otherwise dates cannot be recognized */
633 (me
, super
, WAIT_REPLY
,
634 "LANG=C LC_ALL=C LC_TIME=C; export LANG LC_ALL LC_TIME;\n" "echo '### 200'\n",
636 ERRNOR (E_PROTO
, -1);
638 vfs_print_message ("%s", _("fish: Getting host info..."));
639 if (fish_info (me
, super
))
640 SUP
->scr_env
= fish_set_env (SUP
->host_flags
);
644 g_strconcat ("sh://", super
->path_element
->user
, "@", super
->path_element
->host
,
645 PATH_SEP_STR
, (char *) NULL
);
647 super
->name
= g_strdup (PATH_SEP_STR
);
650 super
->root
= vfs_s_new_inode (me
, super
, fish_default_stat (me
));
655 /* --------------------------------------------------------------------------------------------- */
658 fish_open_archive (struct vfs_s_super
*super
,
659 const vfs_path_t
* vpath
, const vfs_path_element_t
* vpath_element
)
663 super
->path_element
= vfs_path_element_clone (vpath_element
);
665 if (strncmp (vpath_element
->vfs_prefix
, "rsh", 3) == 0)
666 super
->path_element
->port
= FISH_FLAG_RSH
;
669 fish_load_script_from_file (super
->path_element
->host
, FISH_LS_FILE
, FISH_LS_DEF_CONTENT
);
671 fish_load_script_from_file (super
->path_element
->host
, FISH_EXISTS_FILE
,
672 FISH_EXISTS_DEF_CONTENT
);
674 fish_load_script_from_file (super
->path_element
->host
, FISH_MKDIR_FILE
,
675 FISH_MKDIR_DEF_CONTENT
);
677 fish_load_script_from_file (super
->path_element
->host
, FISH_UNLINK_FILE
,
678 FISH_UNLINK_DEF_CONTENT
);
680 fish_load_script_from_file (super
->path_element
->host
, FISH_CHOWN_FILE
,
681 FISH_CHOWN_DEF_CONTENT
);
683 fish_load_script_from_file (super
->path_element
->host
, FISH_CHMOD_FILE
,
684 FISH_CHMOD_DEF_CONTENT
);
686 fish_load_script_from_file (super
->path_element
->host
, FISH_UTIME_FILE
,
687 FISH_UTIME_DEF_CONTENT
);
689 fish_load_script_from_file (super
->path_element
->host
, FISH_RMDIR_FILE
,
690 FISH_RMDIR_DEF_CONTENT
);
692 fish_load_script_from_file (super
->path_element
->host
, FISH_LN_FILE
, FISH_LN_DEF_CONTENT
);
694 fish_load_script_from_file (super
->path_element
->host
, FISH_MV_FILE
, FISH_MV_DEF_CONTENT
);
696 fish_load_script_from_file (super
->path_element
->host
, FISH_HARDLINK_FILE
,
697 FISH_HARDLINK_DEF_CONTENT
);
699 fish_load_script_from_file (super
->path_element
->host
, FISH_GET_FILE
, FISH_GET_DEF_CONTENT
);
701 fish_load_script_from_file (super
->path_element
->host
, FISH_SEND_FILE
,
702 FISH_SEND_DEF_CONTENT
);
704 fish_load_script_from_file (super
->path_element
->host
, FISH_APPEND_FILE
,
705 FISH_APPEND_DEF_CONTENT
);
707 fish_load_script_from_file (super
->path_element
->host
, FISH_INFO_FILE
,
708 FISH_INFO_DEF_CONTENT
);
710 return fish_open_archive_int (vpath_element
->class, super
);
713 /* --------------------------------------------------------------------------------------------- */
716 fish_archive_same (const vfs_path_element_t
* vpath_element
, struct vfs_s_super
*super
,
717 const vfs_path_t
* vpath
, void *cookie
)
719 vfs_path_element_t
*path_element
;
725 path_element
= vfs_path_element_clone (vpath_element
);
727 if (path_element
->user
== NULL
)
728 path_element
->user
= vfs_get_local_username ();
730 result
= ((strcmp (path_element
->host
, super
->path_element
->host
) == 0)
731 && (strcmp (path_element
->user
, super
->path_element
->user
) == 0)
732 && (path_element
->port
== super
->path_element
->port
)) ? 1 : 0;
734 vfs_path_element_free (path_element
);
739 /* --------------------------------------------------------------------------------------------- */
742 fish_dir_load (struct vfs_class
*me
, struct vfs_s_inode
*dir
, char *remote_path
)
744 struct vfs_s_super
*super
= dir
->super
;
745 char buffer
[BUF_8K
] = "\0";
746 struct vfs_s_entry
*ent
= NULL
;
752 * Simple FISH debug interface :]
755 if (MEDATA
->logfile
== NULL
)
756 MEDATA
->logfile
= fopen ("/tmp/mc-FISH.sh", "w");
758 logfile
= MEDATA
->logfile
;
760 vfs_print_message (_("fish: Reading directory %s..."), remote_path
);
762 gettimeofday (&dir
->timestamp
, NULL
);
763 dir
->timestamp
.tv_sec
+= fish_directory_timeout
;
765 quoted_path
= strutils_shell_escape (remote_path
);
766 (void) fish_command_v (me
, super
, NONE
, SUP
->scr_ls
, "FISH_FILENAME=%s;\n", quoted_path
);
767 g_free (quoted_path
);
769 ent
= vfs_s_generate_entry (me
, NULL
, dir
, 0);
775 res
= vfs_s_get_line_interruptible (me
, buffer
, sizeof (buffer
), SUP
->sockr
);
777 if ((res
== 0) || (res
== EINTR
))
779 vfs_s_free_entry (me
, ent
);
780 me
->verrno
= ECONNRESET
;
785 fputs (buffer
, logfile
);
786 fputs ("\n", logfile
);
789 if (strncmp (buffer
, "### ", 4) == 0)
791 if (buffer
[0] == '\0')
793 if (ent
->name
!= NULL
)
795 vfs_s_insert_entry (me
, dir
, ent
);
796 ent
= vfs_s_generate_entry (me
, NULL
, dir
, 0);
801 #define ST ent->ino->st
808 char *data_start
= buffer
+ 1;
809 char *filename
= data_start
;
810 char *filename_bound
;
812 filename_bound
= filename
+ strlen (filename
);
814 if (strcmp (data_start
, "\".\"") == 0 || strcmp (data_start
, "\"..\"") == 0)
815 break; /* We'll do "." and ".." ourselves */
817 if (S_ISLNK (ST
.st_mode
))
820 char *linkname_bound
;
821 /* we expect: "escaped-name" -> "escaped-name"
822 // -> cannot occur in filenames,
823 // because it will be escaped to -\> */
826 linkname_bound
= filename_bound
;
828 if (*filename
== '"')
831 linkname
= strstr (filename
, "\" -> \"");
832 if (linkname
== NULL
)
834 /* broken client, or smth goes wrong */
835 linkname
= filename_bound
;
836 if (filename_bound
> filename
&& *(filename_bound
- 1) == '"')
837 --filename_bound
; /* skip trailing " */
841 filename_bound
= linkname
;
842 linkname
+= 6; /* strlen ("\" -> \"") */
843 if (*(linkname_bound
- 1) == '"')
844 --linkname_bound
; /* skip trailing " */
847 ent
->name
= g_strndup (filename
, filename_bound
- filename
);
849 ent
->name
= strutils_shell_unescape (ent
->name
);
852 ent
->ino
->linkname
= g_strndup (linkname
, linkname_bound
- linkname
);
853 temp
= ent
->ino
->linkname
;
854 ent
->ino
->linkname
= strutils_shell_unescape (ent
->ino
->linkname
);
859 /* we expect: "escaped-name" */
860 if (filename_bound
- filename
> 2)
863 there is at least 2 "
866 if (*filename
== '"')
868 if (*(filename_bound
- 1) == '"')
871 ent
->name
= g_strndup (filename
, filename_bound
- filename
);
873 ent
->name
= strutils_shell_unescape (ent
->name
);
879 ST
.st_size
= (off_t
) g_ascii_strtoll (buffer
+ 1, NULL
, 10);
885 vfs_parse_filemode (buffer
+ 1, &skipped
, &ST
.st_mode
);
892 we expect: Roctal-filemode octal-filetype uid.gid
896 vfs_parse_raw_filemode (buffer
+ 1, &skipped
, &ST
.st_mode
);
901 vfs_split_text (buffer
+ 1);
902 if (vfs_parse_filedate (0, &ST
.st_ctime
) == 0)
904 ST
.st_atime
= ST
.st_mtime
= ST
.st_ctime
;
905 #ifdef HAVE_STRUCT_STAT_ST_MTIM
906 ST
.st_atim
.tv_nsec
= ST
.st_mtim
.tv_nsec
= ST
.st_ctim
.tv_nsec
= 0;
914 /* cppcheck-suppress invalidscanf */
915 if (sscanf (buffer
+ 1, "%d %d %d %d %d %d", &tim
.tm_year
, &tim
.tm_mon
,
916 &tim
.tm_mday
, &tim
.tm_hour
, &tim
.tm_min
, &tim
.tm_sec
) != 6)
918 ST
.st_atime
= ST
.st_mtime
= ST
.st_ctime
= mktime (&tim
);
919 #ifdef HAVE_STRUCT_STAT_ST_MTIM
920 ST
.st_atim
.tv_nsec
= ST
.st_mtim
.tv_nsec
= ST
.st_ctim
.tv_nsec
= 0;
928 /* cppcheck-suppress invalidscanf */
929 if (sscanf (buffer
+ 1, "%d,%d", &maj
, &min
) != 2)
931 #ifdef HAVE_STRUCT_STAT_ST_RDEV
932 ST
.st_rdev
= makedev (maj
, min
);
940 vfs_s_free_entry (me
, ent
);
941 reply_code
= fish_decode_reply (buffer
+ 4, 0);
942 if (reply_code
== COMPLETE
)
944 vfs_print_message (_("%s: done."), me
->name
);
948 me
->verrno
= reply_code
== ERROR
? EACCES
: E_REMOTE
;
951 vfs_print_message (_("%s: failure"), me
->name
);
955 /* --------------------------------------------------------------------------------------------- */
958 fish_file_store (struct vfs_class
*me
, vfs_file_handler_t
* fh
, char *name
, char *localname
)
960 fish_fh_data_t
*fish
= (fish_fh_data_t
*) fh
->data
;
961 struct vfs_s_super
*super
= FH_SUPER
;
969 h
= open (localname
, O_RDONLY
);
972 if (fstat (h
, &s
) < 0)
978 /* First, try this as stor:
980 * ( head -c number ) | ( cat > file; cat >/dev/null )
982 * If 'head' is not present on the remote system, 'dd' will be used.
983 * Unfortunately, we cannot trust most non-GNU 'head' implementations
984 * even if '-c' options is supported. Therefore, we separate GNU head
985 * (and other modern heads?) using '-q' and '-' . This causes another
986 * implementations to fail (because of "incorrect options").
991 * while [ $rest -gt 0 ]
993 * cnt=`expr \( $rest + 255 \) / 256`
994 * n=`dd bs=256 count=$cnt | tee -a <target_file> | wc -c`
995 * rest=`expr $rest - $n`
998 * 'dd' was not designed for full filling of input buffers,
999 * and does not report exact number of bytes (not blocks).
1000 * Therefore a more complex shell script is needed.
1002 * On some systems non-GNU head writes "Usage:" error report to stdout
1003 * instead of stderr. It makes impossible the use of "head || dd"
1004 * algorithm for file appending case, therefore just "dd" is used for it.
1007 quoted_name
= strutils_shell_escape (name
);
1008 vfs_print_message (_("fish: store %s: sending command..."), quoted_name
);
1010 /* FIXME: File size is limited to ULONG_MAX */
1011 code
= fish_command_v (me
, super
, WAIT_REPLY
, fish
->append
? SUP
->scr_append
: SUP
->scr_send
,
1012 "FISH_FILENAME=%s FISH_FILESIZE=%" PRIuMAX
";\n", quoted_name
,
1013 (uintmax_t) s
.st_size
);
1014 g_free (quoted_name
);
1019 ERRNOR (E_REMOTE
, -1);
1026 while ((n
= read (h
, buffer
, sizeof (buffer
))) < 0)
1028 if ((errno
== EINTR
) && tty_got_interrupt ())
1030 vfs_print_message ("%s", _("fish: Local read failed, sending zeros"));
1032 h
= open ("/dev/zero", O_RDONLY
);
1038 t
= write (SUP
->sockw
, buffer
, n
);
1047 tty_disable_interrupt_key ();
1049 vfs_print_message ("%s: %" PRIuMAX
"/%" PRIuMAX
, _("fish: storing file"),
1050 (uintmax_t) total
, (uintmax_t) s
.st_size
);
1054 if (fish_get_reply (me
, SUP
->sockr
, NULL
, 0) != COMPLETE
)
1055 ERRNOR (E_REMOTE
, -1);
1060 fish_get_reply (me
, SUP
->sockr
, NULL
, 0);
1064 /* --------------------------------------------------------------------------------------------- */
1067 fish_linear_start (struct vfs_class
*me
, vfs_file_handler_t
* fh
, off_t offset
)
1069 fish_fh_data_t
*fish
;
1070 struct vfs_s_super
*super
= FH_SUPER
;
1074 if (fh
->data
== NULL
)
1075 fh
->data
= g_new0 (fish_fh_data_t
, 1);
1077 fish
= (fish_fh_data_t
*) fh
->data
;
1079 name
= vfs_s_fullpath (me
, fh
->ino
);
1082 quoted_name
= strutils_shell_escape (name
);
1084 fish
->append
= FALSE
;
1087 * Check whether the remote file is readable by using 'dd' to copy
1088 * a single byte from the remote file to /dev/null. If 'dd' completes
1089 * with exit status of 0 use 'cat' to send the file contents to the
1090 * standard output (i.e. over the network).
1094 fish_command_v (me
, super
, WANT_STRING
, SUP
->scr_get
,
1095 "FISH_FILENAME=%s FISH_START_OFFSET=%" PRIuMAX
";\n", quoted_name
,
1096 (uintmax_t) offset
);
1097 g_free (quoted_name
);
1099 if (offset
!= PRELIM
)
1100 ERRNOR (E_REMOTE
, 0);
1101 fh
->linear
= LS_LINEAR_OPEN
;
1104 #if SIZEOF_OFF_T == SIZEOF_LONG
1105 fish
->total
= (off_t
) strtol (reply_str
, NULL
, 10);
1107 fish
->total
= (off_t
) g_ascii_strtoll (reply_str
, NULL
, 10);
1110 ERRNOR (E_REMOTE
, 0);
1114 /* --------------------------------------------------------------------------------------------- */
1117 fish_linear_abort (struct vfs_class
*me
, vfs_file_handler_t
* fh
)
1119 fish_fh_data_t
*fish
= (fish_fh_data_t
*) fh
->data
;
1120 struct vfs_s_super
*super
= FH_SUPER
;
1121 char buffer
[BUF_8K
];
1124 vfs_print_message ("%s", _("Aborting transfer..."));
1128 n
= MIN ((off_t
) sizeof (buffer
), (fish
->total
- fish
->got
));
1131 n
= read (SUP
->sockr
, buffer
, n
);
1139 if (fish_get_reply (me
, SUP
->sockr
, NULL
, 0) != COMPLETE
)
1140 vfs_print_message ("%s", _("Error reported after abort."));
1142 vfs_print_message ("%s", _("Aborted transfer would be successful."));
1145 /* --------------------------------------------------------------------------------------------- */
1148 fish_linear_read (struct vfs_class
*me
, vfs_file_handler_t
* fh
, void *buf
, size_t len
)
1150 fish_fh_data_t
*fish
= (fish_fh_data_t
*) fh
->data
;
1151 struct vfs_s_super
*super
= FH_SUPER
;
1154 len
= MIN ((size_t) (fish
->total
- fish
->got
), len
);
1155 tty_disable_interrupt_key ();
1156 while (len
!= 0 && ((n
= read (SUP
->sockr
, buf
, len
)) < 0))
1158 if ((errno
== EINTR
) && !tty_got_interrupt ())
1162 tty_enable_interrupt_key ();
1167 fish_linear_abort (me
, fh
);
1168 else if (fish_get_reply (me
, SUP
->sockr
, NULL
, 0) != COMPLETE
)
1169 ERRNOR (E_REMOTE
, -1);
1173 /* --------------------------------------------------------------------------------------------- */
1176 fish_linear_close (struct vfs_class
*me
, vfs_file_handler_t
* fh
)
1178 fish_fh_data_t
*fish
= (fish_fh_data_t
*) fh
->data
;
1180 if (fish
->total
!= fish
->got
)
1181 fish_linear_abort (me
, fh
);
1184 /* --------------------------------------------------------------------------------------------- */
1187 fish_ctl (void *fh
, int ctlop
, void *arg
)
1198 case VFS_CTL_IS_NOTREADY
:
1202 if (FH
->linear
== LS_NOT_LINEAR
)
1203 vfs_die ("You may not do this");
1204 if (FH
->linear
== LS_LINEAR_CLOSED
|| FH
->linear
== LS_LINEAR_PREOPEN
)
1207 v
= vfs_s_select_on_two (FH_SUPER
->u
.fish
.sockr
, 0);
1209 return (((v
< 0) && (errno
== EINTR
)) || v
== 0) ? 1 : 0;
1217 /* --------------------------------------------------------------------------------------------- */
1220 fish_rename (const vfs_path_t
* vpath1
, const vfs_path_t
* vpath2
)
1222 const char *crpath1
, *crpath2
;
1223 char *rpath1
, *rpath2
;
1224 struct vfs_s_super
*super
, *super2
;
1225 const vfs_path_element_t
*path_element
;
1228 path_element
= vfs_path_get_by_index (vpath1
, -1);
1230 crpath1
= vfs_s_get_path (vpath1
, &super
, 0);
1231 if (crpath1
== NULL
)
1234 crpath2
= vfs_s_get_path (vpath2
, &super2
, 0);
1235 if (crpath2
== NULL
)
1238 rpath1
= strutils_shell_escape (crpath1
);
1239 rpath2
= strutils_shell_escape (crpath2
);
1242 fish_send_command (path_element
->class, super2
, OPT_FLUSH
, SUP
->scr_mv
,
1243 "FISH_FILEFROM=%s FISH_FILETO=%s;\n", rpath1
, rpath2
);
1251 /* --------------------------------------------------------------------------------------------- */
1254 fish_link (const vfs_path_t
* vpath1
, const vfs_path_t
* vpath2
)
1256 const char *crpath1
, *crpath2
;
1257 char *rpath1
, *rpath2
;
1258 struct vfs_s_super
*super
, *super2
;
1259 const vfs_path_element_t
*path_element
;
1262 path_element
= vfs_path_get_by_index (vpath1
, -1);
1264 crpath1
= vfs_s_get_path (vpath1
, &super
, 0);
1265 if (crpath1
== NULL
)
1268 crpath2
= vfs_s_get_path (vpath2
, &super2
, 0);
1269 if (crpath2
== NULL
)
1272 rpath1
= strutils_shell_escape (crpath1
);
1273 rpath2
= strutils_shell_escape (crpath2
);
1276 fish_send_command (path_element
->class, super2
, OPT_FLUSH
, SUP
->scr_hardlink
,
1277 "FISH_FILEFROM=%s FISH_FILETO=%s;\n", rpath1
, rpath2
);
1285 /* --------------------------------------------------------------------------------------------- */
1288 fish_symlink (const vfs_path_t
* vpath1
, const vfs_path_t
* vpath2
)
1293 struct vfs_s_super
*super
;
1294 const vfs_path_element_t
*path_element
;
1297 path_element
= vfs_path_get_by_index (vpath2
, -1);
1299 crpath
= vfs_s_get_path (vpath2
, &super
, 0);
1303 rpath
= strutils_shell_escape (crpath
);
1304 qsetto
= strutils_shell_escape (vfs_path_get_by_index (vpath1
, -1)->path
);
1307 fish_send_command (path_element
->class, super
, OPT_FLUSH
, SUP
->scr_ln
,
1308 "FISH_FILEFROM=%s FISH_FILETO=%s;\n", qsetto
, rpath
);
1316 /* --------------------------------------------------------------------------------------------- */
1319 fish_stat (const vfs_path_t
* vpath
, struct stat
*buf
)
1323 ret
= vfs_s_stat (vpath
, buf
);
1324 fish_set_blksize (buf
);
1328 /* --------------------------------------------------------------------------------------------- */
1331 fish_lstat (const vfs_path_t
* vpath
, struct stat
*buf
)
1335 ret
= vfs_s_lstat (vpath
, buf
);
1336 fish_set_blksize (buf
);
1340 /* --------------------------------------------------------------------------------------------- */
1343 fish_fstat (void *vfs_info
, struct stat
*buf
)
1347 ret
= vfs_s_fstat (vfs_info
, buf
);
1348 fish_set_blksize (buf
);
1352 /* --------------------------------------------------------------------------------------------- */
1355 fish_chmod (const vfs_path_t
* vpath
, mode_t mode
)
1359 struct vfs_s_super
*super
;
1360 const vfs_path_element_t
*path_element
;
1363 path_element
= vfs_path_get_by_index (vpath
, -1);
1365 crpath
= vfs_s_get_path (vpath
, &super
, 0);
1369 rpath
= strutils_shell_escape (crpath
);
1372 fish_send_command (path_element
->class, super
, OPT_FLUSH
, SUP
->scr_chmod
,
1373 "FISH_FILENAME=%s FISH_FILEMODE=%4.4o;\n", rpath
,
1374 (unsigned int) (mode
& 07777));
1381 /* --------------------------------------------------------------------------------------------- */
1384 fish_chown (const vfs_path_t
* vpath
, uid_t owner
, gid_t group
)
1386 char *sowner
, *sgroup
;
1391 struct vfs_s_super
*super
;
1392 const vfs_path_element_t
*path_element
;
1395 pw
= getpwuid (owner
);
1399 gr
= getgrgid (group
);
1403 sowner
= pw
->pw_name
;
1404 sgroup
= gr
->gr_name
;
1406 path_element
= vfs_path_get_by_index (vpath
, -1);
1408 crpath
= vfs_s_get_path (vpath
, &super
, 0);
1412 rpath
= strutils_shell_escape (crpath
);
1414 /* FIXME: what should we report if chgrp succeeds but chown fails? */
1416 fish_send_command (path_element
->class, super
, OPT_FLUSH
, SUP
->scr_chown
,
1417 "FISH_FILENAME=%s FISH_FILEOWNER=%s FISH_FILEGROUP=%s;\n", rpath
, sowner
,
1425 /* --------------------------------------------------------------------------------------------- */
1428 fish_get_atime (mc_timesbuf_t
* times
, time_t * sec
, long *nsec
)
1430 #ifdef HAVE_UTIMENSAT
1431 *sec
= (*times
)[0].tv_sec
;
1432 *nsec
= (*times
)[0].tv_nsec
;
1434 *sec
= times
->actime
;
1439 /* --------------------------------------------------------------------------------------------- */
1442 fish_get_mtime (mc_timesbuf_t
* times
, time_t * sec
, long *nsec
)
1444 #ifdef HAVE_UTIMENSAT
1445 *sec
= (*times
)[1].tv_sec
;
1446 *nsec
= (*times
)[1].tv_nsec
;
1448 *sec
= times
->modtime
;
1453 /* --------------------------------------------------------------------------------------------- */
1456 fish_utime (const vfs_path_t
* vpath
, mc_timesbuf_t
* times
)
1458 char utcatime
[16], utcmtime
[16];
1459 char utcatime_w_nsec
[30], utcmtime_w_nsec
[30];
1460 time_t atime
, mtime
;
1461 long atime_nsec
, mtime_nsec
;
1465 struct vfs_s_super
*super
;
1466 const vfs_path_element_t
*path_element
;
1469 path_element
= vfs_path_get_by_index (vpath
, -1);
1471 crpath
= vfs_s_get_path (vpath
, &super
, 0);
1475 rpath
= strutils_shell_escape (crpath
);
1477 fish_get_atime (times
, &atime
, &atime_nsec
);
1478 gmt
= gmtime (&atime
);
1479 g_snprintf (utcatime
, sizeof (utcatime
), "%04d%02d%02d%02d%02d.%02d",
1480 gmt
->tm_year
+ 1900, gmt
->tm_mon
+ 1, gmt
->tm_mday
,
1481 gmt
->tm_hour
, gmt
->tm_min
, gmt
->tm_sec
);
1482 g_snprintf (utcatime_w_nsec
, sizeof (utcatime_w_nsec
), "%04d-%02d-%02d %02d:%02d:%02d.%09ld",
1483 gmt
->tm_year
+ 1900, gmt
->tm_mon
+ 1, gmt
->tm_mday
,
1484 gmt
->tm_hour
, gmt
->tm_min
, gmt
->tm_sec
, atime_nsec
);
1486 fish_get_mtime (times
, &mtime
, &mtime_nsec
);
1487 gmt
= gmtime (&mtime
);
1488 g_snprintf (utcmtime
, sizeof (utcmtime
), "%04d%02d%02d%02d%02d.%02d",
1489 gmt
->tm_year
+ 1900, gmt
->tm_mon
+ 1, gmt
->tm_mday
,
1490 gmt
->tm_hour
, gmt
->tm_min
, gmt
->tm_sec
);
1491 g_snprintf (utcmtime_w_nsec
, sizeof (utcmtime_w_nsec
), "%04d-%02d-%02d %02d:%02d:%02d.%09ld",
1492 gmt
->tm_year
+ 1900, gmt
->tm_mon
+ 1, gmt
->tm_mday
,
1493 gmt
->tm_hour
, gmt
->tm_min
, gmt
->tm_sec
, mtime_nsec
);
1495 ret
= fish_send_command (path_element
->class, super
, OPT_FLUSH
, SUP
->scr_utime
,
1496 "FISH_FILENAME=%s FISH_FILEATIME=%ld FISH_FILEMTIME=%ld "
1497 "FISH_TOUCHATIME=%s FISH_TOUCHMTIME=%s FISH_TOUCHATIME_W_NSEC=\"%s\" "
1498 "FISH_TOUCHMTIME_W_NSEC=\"%s\";\n", rpath
, (long) atime
, (long) mtime
,
1499 utcatime
, utcmtime
, utcatime_w_nsec
, utcmtime_w_nsec
);
1506 /* --------------------------------------------------------------------------------------------- */
1509 fish_unlink (const vfs_path_t
* vpath
)
1513 struct vfs_s_super
*super
;
1514 const vfs_path_element_t
*path_element
;
1517 path_element
= vfs_path_get_by_index (vpath
, -1);
1519 crpath
= vfs_s_get_path (vpath
, &super
, 0);
1523 rpath
= strutils_shell_escape (crpath
);
1526 fish_send_command (path_element
->class, super
, OPT_FLUSH
, SUP
->scr_unlink
,
1527 "FISH_FILENAME=%s;\n", rpath
);
1534 /* --------------------------------------------------------------------------------------------- */
1537 fish_exists (const vfs_path_t
* vpath
)
1541 struct vfs_s_super
*super
;
1542 const vfs_path_element_t
*path_element
;
1545 path_element
= vfs_path_get_by_index (vpath
, -1);
1547 crpath
= vfs_s_get_path (vpath
, &super
, 0);
1551 rpath
= strutils_shell_escape (crpath
);
1554 fish_send_command (path_element
->class, super
, OPT_FLUSH
, SUP
->scr_exists
,
1555 "FISH_FILENAME=%s;\n", rpath
);
1559 return (ret
== 0 ? 1 : 0);
1562 /* --------------------------------------------------------------------------------------------- */
1565 fish_mkdir (const vfs_path_t
* vpath
, mode_t mode
)
1569 struct vfs_s_super
*super
;
1570 const vfs_path_element_t
*path_element
;
1575 path_element
= vfs_path_get_by_index (vpath
, -1);
1577 crpath
= vfs_s_get_path (vpath
, &super
, 0);
1581 rpath
= strutils_shell_escape (crpath
);
1584 fish_send_command (path_element
->class, super
, OPT_FLUSH
, SUP
->scr_mkdir
,
1585 "FISH_FILENAME=%s;\n", rpath
);
1591 if (fish_exists (vpath
) == 0)
1593 path_element
->class->verrno
= EACCES
;
1599 /* --------------------------------------------------------------------------------------------- */
1602 fish_rmdir (const vfs_path_t
* vpath
)
1606 struct vfs_s_super
*super
;
1607 const vfs_path_element_t
*path_element
;
1610 path_element
= vfs_path_get_by_index (vpath
, -1);
1612 crpath
= vfs_s_get_path (vpath
, &super
, 0);
1616 rpath
= strutils_shell_escape (crpath
);
1619 fish_send_command (path_element
->class, super
, OPT_FLUSH
, SUP
->scr_rmdir
,
1620 "FISH_FILENAME=%s;\n", rpath
);
1627 /* --------------------------------------------------------------------------------------------- */
1630 fish_fh_free_data (vfs_file_handler_t
* fh
)
1633 MC_PTR_FREE (fh
->data
);
1636 /* --------------------------------------------------------------------------------------------- */
1639 fish_fh_open (struct vfs_class
*me
, vfs_file_handler_t
* fh
, int flags
, mode_t mode
)
1641 fish_fh_data_t
*fish
;
1645 fh
->data
= g_new0 (fish_fh_data_t
, 1);
1646 fish
= (fish_fh_data_t
*) fh
->data
;
1648 /* File will be written only, so no need to retrieve it */
1649 if (((flags
& O_WRONLY
) == O_WRONLY
) && ((flags
& (O_RDONLY
| O_RDWR
)) == 0))
1651 /* user pressed the button [ Append ] in the "Copy" dialog */
1652 if ((flags
& O_APPEND
) != 0)
1653 fish
->append
= TRUE
;
1655 if (fh
->ino
->localname
== NULL
)
1660 tmp_handle
= vfs_mkstemps (&vpath
, me
->name
, fh
->ino
->ent
->name
);
1661 if (tmp_handle
== -1)
1663 vfs_path_free (vpath
);
1666 fh
->ino
->localname
= g_strdup (vfs_path_as_str (vpath
));
1667 vfs_path_free (vpath
);
1672 if (fh
->ino
->localname
== NULL
&& vfs_s_retrieve_file (me
, fh
->ino
) == -1)
1674 if (fh
->ino
->localname
== NULL
)
1675 vfs_die ("retrieve_file failed to fill in localname");
1679 fish_fh_free_data (fh
);
1683 /* --------------------------------------------------------------------------------------------- */
1686 fish_fill_names (struct vfs_class
*me
, fill_names_f func
)
1690 for (iter
= MEDATA
->supers
; iter
!= NULL
; iter
= g_list_next (iter
))
1692 const struct vfs_s_super
*super
= (const struct vfs_s_super
*) iter
->data
;
1696 const char *flags
= "";
1698 switch (super
->path_element
->port
)
1703 case FISH_FLAG_COMPRESSED
:
1707 if (super
->path_element
->port
> FISH_FLAG_RSH
)
1709 g_snprintf (gbuf
, sizeof (gbuf
), ":%d", super
->path_element
->port
);
1716 g_strconcat (vfs_fish_ops
->prefix
, VFS_PATH_URL_DELIMITER
,
1717 super
->path_element
->user
, "@", super
->path_element
->host
, flags
,
1718 PATH_SEP_STR
, super
->path_element
->path
, (char *) NULL
);
1724 /* --------------------------------------------------------------------------------------------- */
1727 fish_open (const vfs_path_t
* vpath
, int flags
, mode_t mode
)
1730 sorry, i've places hack here
1731 cause fish don't able to open files with O_EXCL flag
1734 return vfs_s_open (vpath
, flags
, mode
);
1737 /* --------------------------------------------------------------------------------------------- */
1738 /*** public functions ****************************************************************************/
1739 /* --------------------------------------------------------------------------------------------- */
1746 fish_subclass
.flags
= VFS_S_REMOTE
| VFS_S_USETMP
;
1747 fish_subclass
.archive_same
= fish_archive_same
;
1748 fish_subclass
.new_archive
= fish_new_archive
;
1749 fish_subclass
.open_archive
= fish_open_archive
;
1750 fish_subclass
.free_archive
= fish_free_archive
;
1751 fish_subclass
.fh_open
= fish_fh_open
;
1752 fish_subclass
.fh_free_data
= fish_fh_free_data
;
1753 fish_subclass
.dir_load
= fish_dir_load
;
1754 fish_subclass
.file_store
= fish_file_store
;
1755 fish_subclass
.linear_start
= fish_linear_start
;
1756 fish_subclass
.linear_read
= fish_linear_read
;
1757 fish_subclass
.linear_close
= fish_linear_close
;
1759 vfs_s_init_class (&fish_subclass
);
1760 vfs_fish_ops
->name
= "fish";
1761 vfs_fish_ops
->prefix
= "sh";
1762 vfs_fish_ops
->fill_names
= fish_fill_names
;
1763 vfs_fish_ops
->stat
= fish_stat
;
1764 vfs_fish_ops
->lstat
= fish_lstat
;
1765 vfs_fish_ops
->fstat
= fish_fstat
;
1766 vfs_fish_ops
->chmod
= fish_chmod
;
1767 vfs_fish_ops
->chown
= fish_chown
;
1768 vfs_fish_ops
->utime
= fish_utime
;
1769 vfs_fish_ops
->open
= fish_open
;
1770 vfs_fish_ops
->symlink
= fish_symlink
;
1771 vfs_fish_ops
->link
= fish_link
;
1772 vfs_fish_ops
->unlink
= fish_unlink
;
1773 vfs_fish_ops
->rename
= fish_rename
;
1774 vfs_fish_ops
->mkdir
= fish_mkdir
;
1775 vfs_fish_ops
->rmdir
= fish_rmdir
;
1776 vfs_fish_ops
->ctl
= fish_ctl
;
1777 vfs_register_class (vfs_fish_ops
);
1780 /* --------------------------------------------------------------------------------------------- */