1998-02-27 07:54:42 +03:00
|
|
|
#ifndef __VFS_H
|
|
|
|
#define __VFS_H
|
|
|
|
|
|
|
|
#ifdef HAVE_MMAP
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#endif
|
|
|
|
|
1998-09-27 23:27:58 +04:00
|
|
|
|
2003-10-11 10:25:29 +04:00
|
|
|
typedef void *vfsid;
|
2003-10-12 04:24:00 +04:00
|
|
|
|
|
|
|
struct vfs_stamping {
|
|
|
|
struct vfs_class *v;
|
|
|
|
vfsid id;
|
|
|
|
struct vfs_stamping *parent; /* At the moment applies to tarfs only */
|
|
|
|
struct vfs_stamping *next;
|
|
|
|
struct timeval time;
|
|
|
|
};
|
1998-10-13 14:45:02 +04:00
|
|
|
|
2003-10-11 13:05:49 +04:00
|
|
|
/* Flags of VFS classes */
|
|
|
|
#define VFSF_LOCAL 1 /* Class is local (not virtual) filesystem */
|
|
|
|
#define VFSF_NOLINKS 2 /* Hard links not supported */
|
|
|
|
|
2003-10-11 10:25:29 +04:00
|
|
|
struct vfs_class {
|
2003-10-12 04:24:00 +04:00
|
|
|
struct vfs_class *next;
|
2003-10-11 10:25:29 +04:00
|
|
|
char *name; /* "FIles over SHell" */
|
|
|
|
int flags;
|
|
|
|
char *prefix; /* "fish:" */
|
|
|
|
void *data; /* this is for filesystem's own use */
|
|
|
|
int verrno; /* can't use errno because glibc2 might define errno as function */
|
|
|
|
|
2003-10-12 04:24:00 +04:00
|
|
|
int (*init) (struct vfs_class *me);
|
|
|
|
void (*done) (struct vfs_class *me);
|
|
|
|
void (*fill_names) (struct vfs_class *me, void (*)(char *));
|
2003-10-11 10:25:29 +04:00
|
|
|
|
2003-10-12 04:24:00 +04:00
|
|
|
int (*which) (struct vfs_class *me, char *path);
|
2003-10-11 10:25:29 +04:00
|
|
|
|
2003-10-28 05:10:33 +03:00
|
|
|
void *(*open) (struct vfs_class *me, const char *fname, int flags,
|
|
|
|
int mode);
|
2003-10-11 10:25:29 +04:00
|
|
|
int (*close) (void *vfs_info);
|
|
|
|
int (*read) (void *vfs_info, char *buffer, int count);
|
|
|
|
int (*write) (void *vfs_info, char *buf, int count);
|
|
|
|
|
2003-10-12 04:24:00 +04:00
|
|
|
void *(*opendir) (struct vfs_class *me, char *dirname);
|
2003-10-11 10:25:29 +04:00
|
|
|
void *(*readdir) (void *vfs_info);
|
|
|
|
int (*closedir) (void *vfs_info);
|
|
|
|
|
2003-10-12 04:24:00 +04:00
|
|
|
int (*stat) (struct vfs_class *me, char *path, struct stat * buf);
|
|
|
|
int (*lstat) (struct vfs_class *me, char *path, struct stat * buf);
|
2003-10-11 10:25:29 +04:00
|
|
|
int (*fstat) (void *vfs_info, struct stat * buf);
|
|
|
|
|
2003-10-12 04:24:00 +04:00
|
|
|
int (*chmod) (struct vfs_class *me, char *path, int mode);
|
|
|
|
int (*chown) (struct vfs_class *me, char *path, int owner, int group);
|
2003-10-28 05:10:33 +03:00
|
|
|
int (*utime) (struct vfs_class *me, char *path,
|
|
|
|
struct utimbuf * times);
|
2003-10-12 04:24:00 +04:00
|
|
|
|
2003-10-28 05:10:33 +03:00
|
|
|
int (*readlink) (struct vfs_class *me, char *path, char *buf,
|
|
|
|
int size);
|
2003-10-12 04:24:00 +04:00
|
|
|
int (*symlink) (struct vfs_class *me, char *n1, char *n2);
|
|
|
|
int (*link) (struct vfs_class *me, char *p1, char *p2);
|
|
|
|
int (*unlink) (struct vfs_class *me, char *path);
|
|
|
|
int (*rename) (struct vfs_class *me, char *p1, char *p2);
|
|
|
|
int (*chdir) (struct vfs_class *me, char *path);
|
|
|
|
int (*ferrno) (struct vfs_class *me);
|
2003-10-11 10:25:29 +04:00
|
|
|
int (*lseek) (void *vfs_info, off_t offset, int whence);
|
2003-10-12 04:24:00 +04:00
|
|
|
int (*mknod) (struct vfs_class *me, char *path, int mode, int dev);
|
2003-10-11 10:25:29 +04:00
|
|
|
|
2003-10-12 04:24:00 +04:00
|
|
|
vfsid (*getid) (struct vfs_class *me, const char *path,
|
2003-10-11 13:05:49 +04:00
|
|
|
struct vfs_stamping ** parent);
|
2003-10-11 10:25:29 +04:00
|
|
|
|
|
|
|
int (*nothingisopen) (vfsid id);
|
|
|
|
void (*free) (vfsid id);
|
|
|
|
|
2003-10-28 05:10:33 +03:00
|
|
|
char *(*getlocalcopy) (struct vfs_class *me, const char *filename);
|
|
|
|
int (*ungetlocalcopy) (struct vfs_class *me, const char *filename,
|
2003-10-29 00:52:06 +03:00
|
|
|
const char *local, int has_changed);
|
2003-10-11 10:25:29 +04:00
|
|
|
|
2003-10-12 04:24:00 +04:00
|
|
|
int (*mkdir) (struct vfs_class *me, char *path, mode_t mode);
|
|
|
|
int (*rmdir) (struct vfs_class *me, char *path);
|
2003-10-11 10:25:29 +04:00
|
|
|
|
2003-10-16 20:12:19 +04:00
|
|
|
int (*ctl) (void *vfs_info, int ctlop, void *arg);
|
2003-10-28 05:10:33 +03:00
|
|
|
int (*setctl) (struct vfs_class *me, char *path, int ctlop,
|
|
|
|
void *arg);
|
1998-02-27 07:54:42 +03:00
|
|
|
#ifdef HAVE_MMAP
|
2003-10-28 05:10:33 +03:00
|
|
|
caddr_t (*mmap) (struct vfs_class *me, caddr_t addr, size_t len,
|
|
|
|
int prot, int flags, void *vfs_info, off_t offset);
|
|
|
|
int (*munmap) (struct vfs_class *me, caddr_t addr, size_t len,
|
|
|
|
void *vfs_info);
|
2003-10-11 10:25:29 +04:00
|
|
|
#endif
|
|
|
|
};
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2003-10-11 11:38:05 +04:00
|
|
|
/*
|
|
|
|
* This union is used to ensure that there is enough space for the
|
|
|
|
* filename (d_name) when the dirent structure is created.
|
|
|
|
*/
|
2003-10-11 10:25:29 +04:00
|
|
|
union vfs_dirent {
|
|
|
|
struct dirent dent;
|
|
|
|
char _extra_buffer[((int) &((struct dirent *) 0)->d_name) +
|
|
|
|
MC_MAXPATHLEN + 1];
|
|
|
|
};
|
2002-08-16 00:29:34 +04:00
|
|
|
|
2003-10-11 11:38:05 +04:00
|
|
|
/* Register a file system class */
|
2003-10-11 10:25:29 +04:00
|
|
|
int vfs_register_class (struct vfs_class *vfs);
|
2003-10-11 13:55:13 +04:00
|
|
|
|
2003-10-11 10:25:29 +04:00
|
|
|
void init_cpiofs (void);
|
2003-10-13 02:25:53 +04:00
|
|
|
void init_extfs (void);
|
2003-10-11 10:25:29 +04:00
|
|
|
void init_fish (void);
|
2003-10-11 13:27:37 +04:00
|
|
|
void init_ftpfs (void);
|
2003-10-12 23:57:27 +04:00
|
|
|
void init_localfs (void);
|
2003-10-13 02:25:53 +04:00
|
|
|
void init_mcfs (void);
|
|
|
|
void init_sfs (void);
|
|
|
|
void init_smbfs (void);
|
|
|
|
void init_tarfs (void);
|
|
|
|
void init_undelfs (void);
|
2003-10-11 10:25:29 +04:00
|
|
|
|
|
|
|
void vfs_init (void);
|
|
|
|
void vfs_shut (void);
|
|
|
|
|
2003-10-11 11:38:05 +04:00
|
|
|
struct vfs_class *vfs_get_class (const char *path);
|
2003-10-12 04:24:00 +04:00
|
|
|
struct vfs_class *vfs_split (const char *path, char **inpath, char **op);
|
2003-10-11 11:38:05 +04:00
|
|
|
char *vfs_path (const char *path);
|
2003-10-11 10:25:29 +04:00
|
|
|
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);
|
|
|
|
int vfs_file_class_flags (const char *filename);
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
vfs_file_is_local (const char *filename)
|
|
|
|
{
|
|
|
|
return vfs_file_class_flags (filename) & VFSF_LOCAL;
|
|
|
|
}
|
2003-10-11 10:25:29 +04:00
|
|
|
|
|
|
|
extern int vfs_timeout;
|
|
|
|
|
2003-10-12 04:24:00 +04:00
|
|
|
void vfs_stamp (struct vfs_class *, vfsid);
|
|
|
|
void vfs_rmstamp (struct vfs_class *, vfsid, int);
|
|
|
|
void vfs_add_noncurrent_stamps (struct vfs_class *, vfsid, struct vfs_stamping *);
|
2003-10-11 10:25:29 +04:00
|
|
|
void vfs_add_current_stamps (void);
|
|
|
|
void vfs_timeout_handler (void);
|
|
|
|
void vfs_expire (int);
|
|
|
|
int vfs_timeouts (void);
|
2003-10-11 11:38:05 +04:00
|
|
|
void vfs_release_path (const char *dir);
|
2003-10-11 10:25:29 +04:00
|
|
|
|
|
|
|
void vfs_fill_names (void (*)(char *));
|
2003-10-11 11:38:05 +04:00
|
|
|
char *vfs_translate_url (const char *);
|
2003-10-11 10:25:29 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
#ifdef USE_NETCODE
|
2003-10-11 10:25:29 +04:00
|
|
|
extern int use_netrc;
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
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);
|
|
|
|
int mc_write (int handle, char *buffer, int count);
|
|
|
|
off_t mc_lseek (int fd, off_t offset, int whence);
|
|
|
|
int mc_chdir (char *);
|
|
|
|
|
|
|
|
DIR *mc_opendir (char *dirname);
|
|
|
|
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);
|
|
|
|
|
|
|
|
int mc_chmod (char *path, int mode);
|
|
|
|
int mc_chown (char *path, int owner, int group);
|
|
|
|
int mc_utime (char *path, struct utimbuf *times);
|
|
|
|
int mc_readlink (char *path, char *buf, int bufsiz);
|
|
|
|
int mc_unlink (char *path);
|
|
|
|
int mc_symlink (char *name1, char *name2);
|
|
|
|
int mc_link (const char *name1, const char *name2);
|
|
|
|
int mc_mknod (char *, int, int);
|
|
|
|
int mc_rename (const char *original, const char *target);
|
|
|
|
int mc_rmdir (char *path);
|
|
|
|
int mc_mkdir (char *path, mode_t mode);
|
|
|
|
|
|
|
|
char *mc_getlocalcopy (const char *pathname);
|
|
|
|
int mc_ungetlocalcopy (const char *pathname, char *local, int has_changed);
|
2003-10-16 20:12:19 +04:00
|
|
|
int mc_ctl (int fd, int ctlop, void *arg);
|
|
|
|
int mc_setctl (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
|
|
|
|
1998-10-13 02:07:53 +04:00
|
|
|
/* These functions are meant for use by vfs modules */
|
2003-10-11 13:05:49 +04:00
|
|
|
int vfs_parse_ls_lga (const char *p, struct stat *s, char **filename,
|
|
|
|
char **linkname);
|
|
|
|
int vfs_split_text (char *p);
|
|
|
|
int vfs_parse_filetype (char c);
|
|
|
|
int vfs_parse_filemode (const char *p);
|
|
|
|
int vfs_parse_filedate (int idx, time_t * t);
|
1998-10-13 02:07:53 +04:00
|
|
|
|
2003-10-11 13:05:49 +04:00
|
|
|
void vfs_die (const char *msg);
|
|
|
|
char *vfs_get_password (char *msg);
|
2002-07-12 03:08:30 +04:00
|
|
|
|
2001-07-15 11:01:41 +04:00
|
|
|
#ifdef WITH_SMBFS
|
|
|
|
/* Interface for requesting SMB credentials. */
|
|
|
|
struct smb_authinfo {
|
|
|
|
char *host;
|
|
|
|
char *share;
|
|
|
|
char *domain;
|
|
|
|
char *user;
|
|
|
|
char *password;
|
|
|
|
};
|
|
|
|
|
2003-10-11 10:25:29 +04:00
|
|
|
struct smb_authinfo *vfs_smb_get_authinfo (const char *host,
|
|
|
|
const char *share,
|
|
|
|
const char *domain,
|
|
|
|
const char *user);
|
|
|
|
#endif /* WITH_SMBFS */
|
2001-07-15 11:01:41 +04:00
|
|
|
|
2003-10-11 13:05:49 +04:00
|
|
|
void vfs_print_stats (const char *fs_name, const char *action,
|
|
|
|
const char *file_name, off_t have, off_t need);
|
1998-09-27 23:27:58 +04: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
|
|
|
|
2003-10-11 10:25:29 +04:00
|
|
|
#endif /* __VFS_H */
|