4 * \brief Header: Virtual File System switch code
10 #include <sys/types.h>
17 char *vfs_strip_suffix_from_filename (const char *filename
);
18 char *vfs_canon (const char *path
);
19 char *mc_get_current_wd (char *buffer
, int bufsize
);
20 char *vfs_get_current_dir (void);
21 int vfs_current_is_local (void);
22 int vfs_file_is_local (const char *filename
);
23 /* translate path back to terminal encoding, remove all #enc:
24 * every invalid character is replaced with question mark
25 * return static buffer */
26 char *vfs_translate_path (const char *path
);
27 /* return new string */
28 char *vfs_translate_path_n (const char *path
);
29 /* return encoding after last #enc: or NULL, if part does not contain #enc:
30 * return static buffer */
31 const char *vfs_get_encoding (const char *path
);
32 /* canonize and translate path, return new string */
33 char *vfs_canon_and_translate (const char *path
);
35 /* Only the routines outside of the VFS module need the emulation macros */
37 int mc_open (const char *filename
, int flags
, ...);
38 int mc_close (int handle
);
39 ssize_t
mc_read (int handle
, void *buffer
, int count
);
40 ssize_t
mc_write (int handle
, const void *buffer
, int count
);
41 off_t
mc_lseek (int fd
, off_t offset
, int whence
);
42 int mc_chdir (const char *path
);
44 DIR *mc_opendir (const char *dirname
);
45 struct dirent
*mc_readdir (DIR * dirp
);
46 int mc_closedir (DIR * dir
);
48 int mc_stat (const char *path
, struct stat
*buf
);
49 int mc_lstat (const char *path
, struct stat
*buf
);
50 int mc_fstat (int fd
, struct stat
*buf
);
52 int mc_chmod (const char *path
, mode_t mode
);
53 int mc_chown (const char *path
, uid_t owner
, gid_t group
);
54 int mc_utime (const char *path
, struct utimbuf
*times
);
55 int mc_readlink (const char *path
, char *buf
, int bufsiz
);
56 int mc_unlink (const char *path
);
57 int mc_symlink (const char *name1
, const char *name2
);
58 int mc_link (const char *name1
, const char *name2
);
59 int mc_mknod (const char *, mode_t
, dev_t
);
60 int mc_rename (const char *original
, const char *target
);
61 int mc_rmdir (const char *path
);
62 int mc_mkdir (const char *path
, mode_t mode
);
64 char *mc_getlocalcopy (const char *pathname
);
65 int mc_ungetlocalcopy (const char *pathname
, const char *local
, int has_changed
);
66 int mc_ctl (int fd
, int ctlop
, void *arg
);
67 int mc_setctl (const char *path
, int ctlop
, void *arg
);
69 /* Operations for mc_ctl - on open file */
74 /* Operations for mc_setctl - on path */
79 VFS_SETCTL_FLUSH
, /* invalidate directory cache */
81 /* Setting this makes vfs layer give out potentially incorrect data,
82 but it also makes some operations much faster. Use with caution. */
86 #define O_ALL (O_CREAT | O_EXCL | O_NOCTTY | O_NDELAY | O_SYNC | O_WRONLY | O_RDWR | O_RDONLY)
87 /* Midnight commander code should _not_ use other flags than those
88 listed above and O_APPEND */
90 #if (O_ALL & O_APPEND)
91 #warning "Unexpected problem with flags, O_LINEAR disabled, contact pavel@ucw.cz"
93 #define IS_LINEAR(a) 0
94 #define NO_LINEAR(a) a
96 #define O_LINEAR O_APPEND
97 #define IS_LINEAR(a) ((a) == (O_RDONLY | O_LINEAR)) /* Return only 0 and 1 ! */
98 #define NO_LINEAR(a) (((a) == (O_RDONLY | O_LINEAR)) ? O_RDONLY : (a))
101 /* O_LINEAR is strange beast, be careful. If you open file asserting
102 * O_RDONLY | O_LINEAR, you promise:
104 * a) to read file linearly from beginning to the end
105 * b) not to open another file before you close this one
106 * (this will likely go away in future)
107 * as a special gift, you may
108 * c) lseek() immediately after open(), giving ftpfs chance to
109 * reget. Be warned that this lseek() can fail, and you _have_
110 * to handle that gratefully.
112 * O_LINEAR allows filesystems not to create temporary file in some
113 * cases (ftp transfer). -- pavel@ucw.cz
116 /* And now some defines for our errors. */
119 #define E_NOTSUPP ENOSYS /* for use in vfs when module does not provide function */
121 #define E_NOTSUPP EFAULT /* Does this happen? */
125 #define E_UNKNOWN ENOMSG /* if we do not know what error happened */
127 #define E_UNKNOWN EIO /* if we do not know what error happened */
131 #define E_REMOTE EREMOTEIO /* if other side of ftp/fish reports error */
133 #define E_REMOTE ENETUNREACH /* :-( there's no EREMOTEIO on some systems */
137 #define E_PROTO EPROTO /* if other side fails to follow protocol */