2005-02-19 00:15:37 +03:00
|
|
|
#ifndef MC_VFS_VFS_H
|
|
|
|
#define MC_VFS_VFS_H
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
#ifdef HAVE_MMAP
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#endif
|
|
|
|
|
2003-10-11 10:25:29 +04:00
|
|
|
void vfs_init (void);
|
|
|
|
void vfs_shut (void);
|
|
|
|
|
|
|
|
char *vfs_strip_suffix_from_filename (const char *filename);
|
|
|
|
char *vfs_canon (const char *path);
|
|
|
|
char *mc_get_current_wd (char *buffer, int bufsize);
|
|
|
|
char *vfs_get_current_dir (void);
|
2003-10-11 12:21:16 +04:00
|
|
|
int vfs_current_is_local (void);
|
2004-08-17 03:25:49 +04:00
|
|
|
int vfs_file_is_local (const char *filename);
|
2003-10-11 10:25:29 +04:00
|
|
|
|
2003-10-11 11:38:05 +04:00
|
|
|
/* Only the routines outside of the VFS module need the emulation macros */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2003-10-11 10:25:29 +04:00
|
|
|
int mc_open (const char *filename, int flags, ...);
|
|
|
|
int mc_close (int handle);
|
|
|
|
int mc_read (int handle, char *buffer, int count);
|
2004-08-17 02:40:31 +04:00
|
|
|
int mc_write (int handle, const char *buffer, int count);
|
2003-10-11 10:25:29 +04:00
|
|
|
off_t mc_lseek (int fd, off_t offset, int whence);
|
2003-11-13 11:29:37 +03:00
|
|
|
int mc_chdir (const char *path);
|
2003-10-11 10:25:29 +04:00
|
|
|
|
2003-11-13 11:29:37 +03:00
|
|
|
DIR *mc_opendir (const char *dirname);
|
2003-10-11 10:25:29 +04:00
|
|
|
struct dirent *mc_readdir (DIR * dirp);
|
|
|
|
int mc_closedir (DIR * dir);
|
|
|
|
|
|
|
|
int mc_stat (const char *path, struct stat *buf);
|
|
|
|
int mc_lstat (const char *path, struct stat *buf);
|
|
|
|
int mc_fstat (int fd, struct stat *buf);
|
|
|
|
|
2004-11-16 19:16:08 +03:00
|
|
|
int mc_chmod (const char *path, mode_t mode);
|
|
|
|
int mc_chown (const char *path, uid_t owner, gid_t group);
|
2004-08-17 02:40:31 +04:00
|
|
|
int mc_utime (const char *path, struct utimbuf *times);
|
|
|
|
int mc_readlink (const char *path, char *buf, int bufsiz);
|
|
|
|
int mc_unlink (const char *path);
|
|
|
|
int mc_symlink (const char *name1, const char *name2);
|
2003-10-11 10:25:29 +04:00
|
|
|
int mc_link (const char *name1, const char *name2);
|
2004-11-16 19:16:08 +03:00
|
|
|
int mc_mknod (const char *, mode_t, dev_t);
|
2003-10-11 10:25:29 +04:00
|
|
|
int mc_rename (const char *original, const char *target);
|
2004-08-17 02:40:31 +04:00
|
|
|
int mc_rmdir (const char *path);
|
|
|
|
int mc_mkdir (const char *path, mode_t mode);
|
2003-10-11 10:25:29 +04:00
|
|
|
|
|
|
|
char *mc_getlocalcopy (const char *pathname);
|
2004-08-16 19:18:18 +04:00
|
|
|
int mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed);
|
2003-10-16 20:12:19 +04:00
|
|
|
int mc_ctl (int fd, int ctlop, void *arg);
|
2004-08-17 02:40:31 +04:00
|
|
|
int mc_setctl (const char *path, int ctlop, void *arg);
|
1998-02-27 07:54:42 +03:00
|
|
|
#ifdef HAVE_MMAP
|
2003-10-11 10:25:29 +04:00
|
|
|
caddr_t mc_mmap (caddr_t, size_t, int, int, int, off_t);
|
|
|
|
int mc_munmap (caddr_t addr, size_t len);
|
|
|
|
#endif /* HAVE_MMAP */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2003-10-16 20:12:19 +04:00
|
|
|
/* Operations for mc_ctl - on open file */
|
|
|
|
enum {
|
|
|
|
VFS_CTL_IS_NOTREADY
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Operations for mc_setctl - on path */
|
|
|
|
enum {
|
|
|
|
VFS_SETCTL_FORGET,
|
|
|
|
VFS_SETCTL_RUN,
|
|
|
|
VFS_SETCTL_LOGFILE,
|
2003-10-16 22:51:41 +04:00
|
|
|
VFS_SETCTL_FLUSH, /* invalidate directory cache */
|
2003-10-16 20:12:19 +04:00
|
|
|
|
|
|
|
/* Setting this makes vfs layer give out potentially incorrect data,
|
|
|
|
but it also makes some operations much faster. Use with caution. */
|
|
|
|
VFS_SETCTL_STALE_DATA
|
|
|
|
};
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1998-09-18 15:02:04 +04:00
|
|
|
#define O_ALL (O_CREAT | O_EXCL | O_NOCTTY | O_NDELAY | O_SYNC | O_WRONLY | O_RDWR | O_RDONLY)
|
|
|
|
/* Midnight commander code should _not_ use other flags than those
|
|
|
|
listed above and O_APPEND */
|
|
|
|
|
|
|
|
#if (O_ALL & O_APPEND)
|
2001-06-14 19:26:29 +04:00
|
|
|
#warning "Unexpected problem with flags, O_LINEAR disabled, contact pavel@ucw.cz"
|
1998-09-18 15:02:04 +04:00
|
|
|
#define O_LINEAR 0
|
|
|
|
#define IS_LINEAR(a) 0
|
|
|
|
#define NO_LINEAR(a) a
|
|
|
|
#else
|
|
|
|
#define O_LINEAR O_APPEND
|
1998-10-13 02:07:53 +04:00
|
|
|
#define IS_LINEAR(a) ((a) == (O_RDONLY | O_LINEAR)) /* Return only 0 and 1 ! */
|
1998-09-18 15:02:04 +04:00
|
|
|
#define NO_LINEAR(a) (((a) == (O_RDONLY | O_LINEAR)) ? O_RDONLY : (a))
|
|
|
|
#endif
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2003-06-02 23:47:30 +04:00
|
|
|
/* O_LINEAR is strange beast, be careful. If you open file asserting
|
1998-09-21 13:52:07 +04:00
|
|
|
* O_RDONLY | O_LINEAR, you promise:
|
|
|
|
*
|
2002-01-21 14:10:57 +03:00
|
|
|
* a) to read file linearly from beginning to the end
|
1998-09-21 13:52:07 +04:00
|
|
|
* b) not to open another file before you close this one
|
|
|
|
* (this will likely go away in future)
|
1998-10-13 02:07:53 +04:00
|
|
|
* as a special gift, you may
|
|
|
|
* c) lseek() immediately after open(), giving ftpfs chance to
|
|
|
|
* reget. Be warned that this lseek() can fail, and you _have_
|
|
|
|
* to handle that gratefully.
|
1998-09-21 13:52:07 +04:00
|
|
|
*
|
|
|
|
* O_LINEAR allows filesystems not to create temporary file in some
|
|
|
|
* cases (ftp transfer). -- pavel@ucw.cz
|
|
|
|
*/
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
/* And now some defines for our errors. */
|
|
|
|
|
1998-11-29 02:56:59 +03:00
|
|
|
#ifdef ENOSYS
|
1998-11-21 22:36:01 +03:00
|
|
|
#define E_NOTSUPP ENOSYS /* for use in vfs when module does not provide function */
|
1998-11-29 02:56:59 +03:00
|
|
|
#else
|
1998-12-09 23:22:53 +03:00
|
|
|
#define E_NOTSUPP EFAULT /* Does this happen? */
|
1998-11-29 02:56:59 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ENOMSG
|
1998-11-21 22:36:01 +03:00
|
|
|
#define E_UNKNOWN ENOMSG /* if we do not know what error happened */
|
1998-11-29 02:56:59 +03:00
|
|
|
#else
|
2003-10-11 10:25:29 +04:00
|
|
|
#define E_UNKNOWN EIO /* if we do not know what error happened */
|
1998-11-29 02:56:59 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef EREMOTEIO
|
1998-11-21 22:36:01 +03:00
|
|
|
#define E_REMOTE EREMOTEIO /* if other side of ftp/fish reports error */
|
1998-11-29 02:56:59 +03:00
|
|
|
#else
|
1998-12-09 23:22:53 +03:00
|
|
|
#define E_REMOTE ENETUNREACH /* :-( there's no EREMOTEIO on some systems */
|
1998-11-29 02:56:59 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef EPROTO
|
1998-11-21 22:36:01 +03:00
|
|
|
#define E_PROTO EPROTO /* if other side fails to follow protocol */
|
1998-11-29 02:56:59 +03:00
|
|
|
#else
|
1998-12-09 23:22:53 +03:00
|
|
|
#define E_PROTO EIO
|
1998-11-29 02:56:59 +03:00
|
|
|
#endif
|
1998-11-21 22:36:01 +03:00
|
|
|
|
2005-02-19 00:15:37 +03:00
|
|
|
#endif
|