2009-02-07 15:54:58 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* \brief Header: Virtual File System directory structure
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
#ifndef MC__VFS_XDIRENTRY_H
|
|
|
|
#define MC__VFS_XDIRENTRY_H
|
1998-10-23 12:26:25 +04:00
|
|
|
|
2005-07-04 02:55:55 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/*** typedefs(not structures) and defined constants **********************************************/
|
|
|
|
|
1998-12-02 16:17:24 +03:00
|
|
|
#define LINK_FOLLOW 15
|
|
|
|
#define LINK_NO_FOLLOW -1
|
1998-10-23 12:26:25 +04:00
|
|
|
|
|
|
|
/* For vfs_s_find_entry */
|
|
|
|
#define FL_NONE 0
|
|
|
|
#define FL_MKDIR 1
|
|
|
|
#define FL_MKFILE 2
|
1998-11-21 22:36:01 +03:00
|
|
|
#define FL_DIR 4
|
1998-10-23 12:26:25 +04:00
|
|
|
|
|
|
|
/* For open_super */
|
|
|
|
#define FL_NO_OPEN 1
|
|
|
|
|
|
|
|
/* For vfs_s_entry_from_path */
|
|
|
|
#define FL_FOLLOW 1
|
1998-11-21 22:36:01 +03:00
|
|
|
#define FL_DIR 4
|
1998-10-23 12:26:25 +04:00
|
|
|
|
2003-10-28 10:09:39 +03:00
|
|
|
/* For vfs_s_subclass->flags */
|
|
|
|
#define VFS_S_REMOTE 1
|
|
|
|
#define VFS_S_READONLY 2
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
#define ERRNOR(a, b) do { me->verrno = a; return b; } while (0)
|
|
|
|
|
|
|
|
#define MEDATA ((struct vfs_s_subclass *) me->data)
|
|
|
|
|
|
|
|
#define FH ((struct vfs_s_fh *) fh)
|
|
|
|
#define FH_SUPER FH->ino->super
|
|
|
|
|
|
|
|
#define LS_NOT_LINEAR 0
|
|
|
|
#define LS_LINEAR_CLOSED 1
|
|
|
|
#define LS_LINEAR_OPEN 2
|
|
|
|
#define LS_LINEAR_PREOPEN 3
|
|
|
|
|
|
|
|
/*** enums ***************************************************************************************/
|
|
|
|
|
|
|
|
/*** structures declarations (and typedefs of structures)*****************************************/
|
1998-10-23 12:26:25 +04:00
|
|
|
|
2003-10-16 10:50:05 +04:00
|
|
|
/* Single connection or archive */
|
2010-07-05 20:49:01 +04:00
|
|
|
struct vfs_s_super
|
|
|
|
{
|
1998-10-23 12:26:25 +04:00
|
|
|
struct vfs_s_super **prevp, *next;
|
2003-10-12 04:24:00 +04:00
|
|
|
struct vfs_class *me;
|
2003-10-12 05:00:44 +04:00
|
|
|
struct vfs_s_inode *root;
|
2010-07-05 20:49:01 +04:00
|
|
|
char *name; /* My name, whatever it means */
|
|
|
|
int fd_usage; /* Number of open files */
|
|
|
|
int ino_usage; /* Usage count of this superblock */
|
|
|
|
int want_stale; /* If set, we do not flush cache properly */
|
|
|
|
|
|
|
|
union
|
|
|
|
{
|
2010-07-22 15:55:23 +04:00
|
|
|
#ifdef ENABLE_VFS_FISH
|
2010-07-05 20:49:01 +04:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
int sockr, sockw;
|
|
|
|
char *cwdir;
|
|
|
|
char *host, *user;
|
|
|
|
char *password;
|
|
|
|
int flags;
|
|
|
|
char *scr_ls;
|
|
|
|
char *scr_chmod;
|
|
|
|
char *scr_exists;
|
|
|
|
char *scr_mkdir;
|
|
|
|
char *scr_unlink;
|
|
|
|
char *scr_chown;
|
|
|
|
char *scr_rmdir;
|
|
|
|
char *scr_ln;
|
|
|
|
char *scr_mv;
|
|
|
|
char *scr_hardlink;
|
|
|
|
char *scr_get;
|
|
|
|
char *scr_send;
|
|
|
|
char *scr_append;
|
|
|
|
char *scr_info;
|
|
|
|
int host_flags;
|
|
|
|
char *scr_env;
|
|
|
|
} fish;
|
2010-11-08 13:21:45 +03:00
|
|
|
#endif /* ENABLE_VFS_FISH */
|
2010-07-22 15:55:23 +04:00
|
|
|
#ifdef ENABLE_VFS_FTP
|
2010-07-05 20:49:01 +04:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
int sock;
|
|
|
|
char *cwdir;
|
|
|
|
char *host, *user;
|
|
|
|
char *password;
|
|
|
|
int port;
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
char *proxy; /* proxy server, NULL if no proxy */
|
2010-07-05 20:49:01 +04:00
|
|
|
int failed_on_login; /* used to pass the failure reason to upper levels */
|
|
|
|
int use_passive_connection;
|
|
|
|
int remote_is_amiga; /* No leading slash allowed for AmiTCP (Amiga) */
|
|
|
|
int isbinary;
|
2010-11-08 13:21:45 +03:00
|
|
|
int cwd_deferred; /* current_directory was changed but CWD command hasn't
|
|
|
|
been sent yet */
|
|
|
|
int strict; /* ftp server doesn't understand
|
|
|
|
* "LIST -la <path>"; use "CWD <path>"/
|
|
|
|
* "LIST" instead
|
|
|
|
*/
|
2010-07-05 20:49:01 +04:00
|
|
|
int ctl_connection_busy;
|
|
|
|
} ftp;
|
2010-11-08 13:21:45 +03:00
|
|
|
#endif /* ENABLE_VFS_FTP */
|
2010-07-22 15:55:23 +04:00
|
|
|
#if defined(ENABLE_VFS_CPIO) || defined(ENABLE_VFS_TAR)
|
2010-07-05 20:49:01 +04:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
struct stat st;
|
2010-11-08 13:21:45 +03:00
|
|
|
int type; /* Type of the archive */
|
|
|
|
struct defer_inode *deferred; /* List of inodes for which another entries may appear */
|
2010-07-05 20:49:01 +04:00
|
|
|
} arch;
|
2010-11-08 13:21:45 +03:00
|
|
|
#endif /* ENABLE_VFS_CPIO || ENABLE_VFS_TAR */
|
1998-10-23 12:26:25 +04:00
|
|
|
} u;
|
2003-10-12 05:00:44 +04:00
|
|
|
};
|
1998-10-23 12:26:25 +04:00
|
|
|
|
2003-10-16 12:00:05 +04:00
|
|
|
/*
|
|
|
|
* Single virtual file - directory entry. The same inode can have many
|
|
|
|
* entries (i.e. hard links), but usually has only one.
|
|
|
|
*/
|
2010-07-05 20:49:01 +04:00
|
|
|
struct vfs_s_entry
|
|
|
|
{
|
|
|
|
struct vfs_s_entry **prevp, *next; /* Pointers in the entry list */
|
|
|
|
struct vfs_s_inode *dir; /* Directory we are in, i.e. our parent */
|
|
|
|
char *name; /* Name of this entry */
|
|
|
|
struct vfs_s_inode *ino; /* ... and its inode */
|
2003-10-16 12:00:05 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Single virtual file - inode */
|
2010-07-05 20:49:01 +04:00
|
|
|
struct vfs_s_inode
|
|
|
|
{
|
|
|
|
struct vfs_s_super *super; /* Archive the file is on */
|
|
|
|
struct vfs_s_entry *ent; /* Our entry in the parent directory -
|
|
|
|
use only for directories because they
|
|
|
|
cannot be hardlinked */
|
2003-10-16 12:00:05 +04:00
|
|
|
struct vfs_s_entry *subdir; /* If this is a directory, its entry */
|
2010-07-05 20:49:01 +04:00
|
|
|
struct stat st; /* Parameters of this inode */
|
|
|
|
char *linkname; /* Symlink's contents */
|
|
|
|
char *localname; /* Filename of local file, if we have one */
|
|
|
|
struct timeval timestamp; /* Subclass specific */
|
2010-07-21 21:35:10 +04:00
|
|
|
off_t data_offset; /* Subclass specific */
|
2003-10-16 12:00:05 +04:00
|
|
|
};
|
|
|
|
|
2003-10-16 10:50:05 +04:00
|
|
|
/* Data associated with an open file */
|
2010-07-05 20:49:01 +04:00
|
|
|
struct vfs_s_fh
|
|
|
|
{
|
1998-10-23 12:26:25 +04:00
|
|
|
struct vfs_s_inode *ino;
|
2010-07-21 21:35:10 +04:00
|
|
|
off_t pos; /* This is for module's use */
|
2010-07-05 20:49:01 +04:00
|
|
|
int handle; /* This is for module's use, but if != -1, will be mc_close()d */
|
|
|
|
int changed; /* Did this file change? */
|
|
|
|
int linear; /* Is that file open with O_LINEAR? */
|
|
|
|
union
|
|
|
|
{
|
2010-07-22 15:55:23 +04:00
|
|
|
#ifdef ENABLE_VFS_FISH
|
2010-07-05 20:49:01 +04:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
off_t got, total;
|
|
|
|
int append;
|
|
|
|
} fish;
|
2010-11-08 13:21:45 +03:00
|
|
|
#endif /* ENABLE_VFS_FISH */
|
2010-07-22 15:55:23 +04:00
|
|
|
#ifdef ENABLE_VFS_FTP
|
2010-07-05 20:49:01 +04:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
int sock, append;
|
|
|
|
} ftp;
|
2010-11-08 13:21:45 +03:00
|
|
|
#endif /* ENABLE_VFS_FTP */
|
1998-11-21 22:36:01 +03:00
|
|
|
} u;
|
2003-10-12 05:00:44 +04:00
|
|
|
};
|
1998-10-23 12:26:25 +04:00
|
|
|
|
2003-10-16 10:50:05 +04:00
|
|
|
/*
|
|
|
|
* One of our subclasses (tar, cpio, fish, ftpfs) with data and methods.
|
2003-10-16 12:00:05 +04:00
|
|
|
* Extends vfs_class. Stored in the "data" field of vfs_class.
|
2003-10-16 10:50:05 +04:00
|
|
|
*/
|
2010-07-05 20:49:01 +04:00
|
|
|
struct vfs_s_subclass
|
|
|
|
{
|
1998-10-23 12:26:25 +04:00
|
|
|
struct vfs_s_super *supers;
|
|
|
|
int inode_counter;
|
2010-07-05 20:49:01 +04:00
|
|
|
int flags; /* whether the subclass is remove, read-only etc */
|
1998-10-23 12:26:25 +04:00
|
|
|
dev_t rdev;
|
1998-11-21 22:36:01 +03:00
|
|
|
FILE *logfile;
|
2010-07-05 20:49:01 +04:00
|
|
|
int flush; /* if set to 1, invalidate directory cache */
|
|
|
|
|
|
|
|
int (*init_inode) (struct vfs_class * me, struct vfs_s_inode * ino); /* optional */
|
|
|
|
void (*free_inode) (struct vfs_class * me, struct vfs_s_inode * ino); /* optional */
|
|
|
|
int (*init_entry) (struct vfs_class * me, struct vfs_s_entry * entry); /* optional */
|
|
|
|
|
|
|
|
void *(*archive_check) (struct vfs_class * me, const char *name, char *op); /* optional */
|
|
|
|
int (*archive_same) (struct vfs_class * me, struct vfs_s_super * psup,
|
|
|
|
const char *archive_name, char *op, void *cookie);
|
|
|
|
int (*open_archive) (struct vfs_class * me, struct vfs_s_super * psup,
|
|
|
|
const char *archive_name, char *op);
|
|
|
|
void (*free_archive) (struct vfs_class * me, struct vfs_s_super * psup);
|
|
|
|
|
2010-07-18 17:46:59 +04:00
|
|
|
int (*fh_open) (struct vfs_class * me, struct vfs_s_fh * fh, int flags, mode_t mode);
|
2010-07-05 20:49:01 +04:00
|
|
|
int (*fh_close) (struct vfs_class * me, struct vfs_s_fh * fh);
|
|
|
|
|
|
|
|
struct vfs_s_entry *(*find_entry) (struct vfs_class * me,
|
|
|
|
struct vfs_s_inode * root,
|
|
|
|
const char *path, int follow, int flags);
|
|
|
|
int (*dir_load) (struct vfs_class * me, struct vfs_s_inode * ino, char *path);
|
|
|
|
int (*dir_uptodate) (struct vfs_class * me, struct vfs_s_inode * ino);
|
|
|
|
int (*file_store) (struct vfs_class * me, struct vfs_s_fh * fh, char *path, char *localname);
|
|
|
|
|
|
|
|
int (*linear_start) (struct vfs_class * me, struct vfs_s_fh * fh, off_t from);
|
2010-07-18 17:46:59 +04:00
|
|
|
int (*linear_read) (struct vfs_class * me, struct vfs_s_fh * fh, void *buf, size_t len);
|
2010-07-05 20:49:01 +04:00
|
|
|
void (*linear_close) (struct vfs_class * me, struct vfs_s_fh * fh);
|
1998-10-23 12:26:25 +04:00
|
|
|
};
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/*** global variables defined in .c file *********************************************************/
|
|
|
|
|
|
|
|
/*** declarations of public functions ************************************************************/
|
2003-10-16 12:00:05 +04:00
|
|
|
|
1998-10-23 12:26:25 +04:00
|
|
|
/* entries and inodes */
|
2003-10-12 05:00:44 +04:00
|
|
|
struct vfs_s_inode *vfs_s_new_inode (struct vfs_class *me,
|
2010-07-05 20:49:01 +04:00
|
|
|
struct vfs_s_super *super, struct stat *initstat);
|
2004-09-22 15:28:14 +04:00
|
|
|
struct vfs_s_entry *vfs_s_new_entry (struct vfs_class *me, const char *name,
|
2010-07-05 20:49:01 +04:00
|
|
|
struct vfs_s_inode *inode);
|
2003-10-12 05:00:44 +04:00
|
|
|
void vfs_s_free_entry (struct vfs_class *me, struct vfs_s_entry *ent);
|
2010-07-05 20:49:01 +04:00
|
|
|
void vfs_s_insert_entry (struct vfs_class *me, struct vfs_s_inode *dir, struct vfs_s_entry *ent);
|
2003-10-12 05:00:44 +04:00
|
|
|
struct stat *vfs_s_default_stat (struct vfs_class *me, mode_t mode);
|
|
|
|
|
2004-09-22 15:28:14 +04:00
|
|
|
struct vfs_s_entry *vfs_s_generate_entry (struct vfs_class *me, const char *name,
|
2010-07-05 20:49:01 +04:00
|
|
|
struct vfs_s_inode *parent, mode_t mode);
|
2003-10-12 05:00:44 +04:00
|
|
|
struct vfs_s_inode *vfs_s_find_inode (struct vfs_class *me,
|
2010-07-05 20:49:01 +04:00
|
|
|
const struct vfs_s_super *super,
|
|
|
|
const char *path, int follow, int flags);
|
|
|
|
struct vfs_s_inode *vfs_s_find_root (struct vfs_class *me, struct vfs_s_entry *entry);
|
1999-01-11 03:48:23 +03:00
|
|
|
|
1998-10-23 12:26:25 +04:00
|
|
|
/* outside interface */
|
2010-07-05 20:49:01 +04:00
|
|
|
void vfs_s_init_class (struct vfs_class *vclass, struct vfs_s_subclass *sub);
|
2005-09-05 04:52:56 +04:00
|
|
|
const char *vfs_s_get_path_mangle (struct vfs_class *me, char *inname,
|
2010-07-05 20:49:01 +04:00
|
|
|
struct vfs_s_super **archive, int flags);
|
2003-10-12 05:00:44 +04:00
|
|
|
void vfs_s_invalidate (struct vfs_class *me, struct vfs_s_super *super);
|
|
|
|
char *vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino);
|
1999-01-11 03:48:23 +03:00
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
/* network filesystems support */
|
|
|
|
int vfs_s_select_on_two (int fd1, int fd2);
|
2010-07-05 20:49:01 +04:00
|
|
|
int vfs_s_get_line (struct vfs_class *me, int sock, char *buf, int buf_len, char term);
|
|
|
|
int vfs_s_get_line_interruptible (struct vfs_class *me, char *buffer, int size, int fd);
|
2000-02-02 19:59:19 +03:00
|
|
|
/* misc */
|
2003-10-12 04:24:00 +04:00
|
|
|
int vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino);
|
2000-02-02 19:59:19 +03:00
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/*** inline functions ****************************************************************************/
|
1998-10-23 12:26:25 +04:00
|
|
|
#endif
|