1998-10-23 12:26:25 +04:00
|
|
|
#ifndef DIRENTRY_H
|
|
|
|
#define DIRENTRY_H
|
|
|
|
|
2000-02-02 19:59:19 +03:00
|
|
|
/* $Id$ */
|
|
|
|
|
1998-10-23 12:26:25 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <errno.h>
|
1998-11-21 22:36:01 +03:00
|
|
|
#include <pwd.h>
|
|
|
|
#include <grp.h>
|
|
|
|
|
1998-10-23 12:26:25 +04:00
|
|
|
#include "vfs.h"
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
typedef struct vfs_s_entry {
|
|
|
|
struct vfs_s_entry **prevp, *next;
|
1998-11-21 22:36:01 +03:00
|
|
|
struct vfs_s_inode *dir; /* Directory we are in - needed for invalidating directory when file in it changes */
|
1998-10-23 12:26:25 +04:00
|
|
|
char *name; /* Name of this entry */
|
|
|
|
struct vfs_s_inode *ino; /* ... and its inode */
|
1998-11-21 22:36:01 +03:00
|
|
|
int magic;
|
|
|
|
#define ENTRY_MAGIC 0x014512563
|
1998-10-23 12:26:25 +04:00
|
|
|
} vfs_s_entry;
|
|
|
|
|
|
|
|
typedef struct vfs_s_inode {
|
|
|
|
struct vfs_s_entry *subdir;
|
1998-11-21 22:36:01 +03:00
|
|
|
struct vfs_s_super *super;
|
1998-10-23 12:26:25 +04:00
|
|
|
struct stat st; /* Parameters of this inode */
|
|
|
|
char *linkname; /* Symlink's contents */
|
1998-11-21 22:36:01 +03:00
|
|
|
char *localname; /* Filename of local file, if we have one */
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
vfs_s_entry *ent; /* ftp needs this backpointer; don't use if you can avoid it */
|
1998-10-23 12:26:25 +04:00
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
long data_offset;
|
|
|
|
} tar;
|
2000-02-22 21:21:41 +03:00
|
|
|
struct {
|
|
|
|
long offset;
|
|
|
|
} cpio;
|
1998-11-21 22:36:01 +03:00
|
|
|
struct {
|
|
|
|
struct timeval timestamp;
|
|
|
|
struct stat local_stat;
|
|
|
|
} fish;
|
1999-11-11 17:23:40 +03:00
|
|
|
struct {
|
|
|
|
struct timeval timestamp;
|
|
|
|
} ftp;
|
1998-10-23 12:26:25 +04:00
|
|
|
} u;
|
1998-11-21 22:36:01 +03:00
|
|
|
int magic;
|
|
|
|
#define INODE_MAGIC 0x93451656
|
1998-10-23 12:26:25 +04:00
|
|
|
} vfs_s_inode;
|
|
|
|
|
|
|
|
typedef struct vfs_s_super {
|
|
|
|
struct vfs_s_super **prevp, *next;
|
|
|
|
vfs *me;
|
|
|
|
vfs_s_inode *root;
|
|
|
|
char *name; /* My name, whatever it means */
|
1998-12-31 18:54:49 +03:00
|
|
|
int fd_usage; /* Number of open files */
|
|
|
|
int ino_usage; /* Usage count of this superblock */
|
1998-11-21 22:36:01 +03:00
|
|
|
int want_stale; /* If set, we do not flush cache properly */
|
1998-10-23 12:26:25 +04:00
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
int fd;
|
|
|
|
struct stat tarstat;
|
|
|
|
} tar;
|
1998-11-21 22:36:01 +03:00
|
|
|
struct {
|
|
|
|
int sockr, sockw;
|
|
|
|
char *home, *cwdir;
|
|
|
|
char *host, *user;
|
|
|
|
char *password;
|
|
|
|
int flags;
|
|
|
|
} fish;
|
|
|
|
struct {
|
1999-11-11 17:23:40 +03:00
|
|
|
int sock;
|
1998-11-21 22:36:01 +03:00
|
|
|
char *home, *cwdir;
|
1999-11-11 17:23:40 +03:00
|
|
|
char *host, *user;
|
|
|
|
char *password;
|
|
|
|
int port;
|
|
|
|
|
2002-07-12 04:05:11 +04:00
|
|
|
char *proxy; /* proxy server, NULL if no proxy */
|
1999-11-11 17:23:40 +03:00
|
|
|
int failed_on_login; /* used to pass the failure reason to upper levels */
|
|
|
|
int use_source_route;
|
|
|
|
int use_passive_connection;
|
|
|
|
int remote_is_amiga; /* No leading slash allowed for AmiTCP (Amiga) */
|
1998-11-21 22:36:01 +03:00
|
|
|
int isbinary;
|
1999-11-11 17:23:40 +03:00
|
|
|
int cwd_defered; /* 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 */
|
2002-05-17 17:32:02 +04:00
|
|
|
int control_connection_buzy;
|
1999-11-11 17:23:40 +03:00
|
|
|
#define RFC_AUTODETECT 0
|
|
|
|
#define RFC_DARING 1
|
|
|
|
#define RFC_STRICT 2
|
1998-11-21 22:36:01 +03:00
|
|
|
} ftp;
|
2000-02-22 21:21:41 +03:00
|
|
|
struct {
|
|
|
|
int fd;
|
|
|
|
struct stat stat;
|
|
|
|
int type; /* Type of the archive */
|
2000-02-25 15:53:06 +03:00
|
|
|
/*int pos; In case reentrancy will be needed */
|
2000-02-22 21:21:41 +03:00
|
|
|
struct defer_inode *defered; /* List of inodes for which another entries may appear */
|
|
|
|
} cpio;
|
1998-10-23 12:26:25 +04:00
|
|
|
} u;
|
1998-11-21 22:36:01 +03:00
|
|
|
int magic;
|
|
|
|
#define SUPER_MAGIC 0x915ac312
|
1998-10-23 12:26:25 +04:00
|
|
|
} vfs_s_super;
|
|
|
|
|
|
|
|
typedef struct vfs_s_fh {
|
|
|
|
struct vfs_s_inode *ino;
|
|
|
|
long pos; /* This is for module's use */
|
|
|
|
int handle; /* This is for module's use, but if != -1, will be mc_close()d */
|
1998-11-21 22:36:01 +03:00
|
|
|
int changed; /* Did this file change? */
|
|
|
|
int linear; /* Is that file open with O_LINEAR? */
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
int got, total;
|
|
|
|
} fish;
|
1999-11-11 17:23:40 +03:00
|
|
|
struct {
|
2002-05-22 21:19:24 +04:00
|
|
|
int sock, append;
|
1999-11-11 17:23:40 +03:00
|
|
|
} ftp;
|
1998-11-21 22:36:01 +03:00
|
|
|
} u;
|
|
|
|
int magic;
|
|
|
|
#define FH_MAGIC 0x91324682
|
1998-10-23 12:26:25 +04:00
|
|
|
} vfs_s_fh;
|
|
|
|
|
|
|
|
struct vfs_s_data {
|
|
|
|
struct vfs_s_super *supers;
|
|
|
|
int inode_counter;
|
|
|
|
dev_t rdev;
|
1998-11-21 22:36:01 +03:00
|
|
|
FILE *logfile;
|
1998-10-23 12:26:25 +04:00
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
int (*init_inode) (vfs *me, vfs_s_inode *ino); /* optional */
|
|
|
|
void (*free_inode) (vfs *me, vfs_s_inode *ino); /* optional */
|
|
|
|
int (*init_entry) (vfs *me, vfs_s_entry *entry); /* optional */
|
1998-10-23 12:26:25 +04:00
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
void* (*archive_check) (vfs *me, char *name, char *op); /* optional */
|
|
|
|
int (*archive_same) (vfs *me, vfs_s_super *psup, char *archive_name, char *op, void *cookie);
|
1998-10-23 12:26:25 +04:00
|
|
|
int (*open_archive) (vfs *me, vfs_s_super *psup, char *archive_name, char *op);
|
|
|
|
void (*free_archive) (vfs *me, vfs_s_super *psup);
|
|
|
|
|
1998-11-21 22:36:01 +03:00
|
|
|
int (*fh_open) (vfs *me, vfs_s_fh *fh, int flags, int mode);
|
1998-10-23 12:26:25 +04:00
|
|
|
int (*fh_close) (vfs *me, vfs_s_fh *fh);
|
1998-11-21 22:36:01 +03:00
|
|
|
|
|
|
|
vfs_s_entry* (*find_entry) (vfs *me, vfs_s_inode *root, char *path, int follow, int flags);
|
|
|
|
int (*dir_load) (vfs *me, vfs_s_inode *ino, char *path);
|
|
|
|
int (*dir_uptodate) (vfs *me, vfs_s_inode *ino);
|
2002-05-22 21:19:24 +04:00
|
|
|
int (*file_store) (vfs *me, vfs_s_fh *fh, char *path, char *localname);
|
1998-11-21 22:36:01 +03:00
|
|
|
|
|
|
|
int (*linear_start) (vfs *me, vfs_s_fh *fh, int from);
|
|
|
|
int (*linear_read) (vfs *me, vfs_s_fh *fh, void *buf, int len);
|
|
|
|
void (*linear_close) (vfs *me, vfs_s_fh *fh);
|
1998-10-23 12:26:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* entries and inodes */
|
1999-01-11 03:48:23 +03:00
|
|
|
vfs_s_inode *vfs_s_new_inode (vfs *me, vfs_s_super *super,
|
|
|
|
struct stat *initstat);
|
|
|
|
vfs_s_entry *vfs_s_new_entry (vfs *me, char *name, vfs_s_inode *inode);
|
|
|
|
void vfs_s_free_entry (vfs *me, vfs_s_entry *ent);
|
|
|
|
void vfs_s_insert_entry (vfs *me, vfs_s_inode *dir,
|
|
|
|
vfs_s_entry *ent);
|
|
|
|
struct stat *vfs_s_default_stat (vfs *me, mode_t mode);
|
|
|
|
|
|
|
|
void vfs_s_add_dots (vfs *me, vfs_s_inode *dir,
|
|
|
|
vfs_s_inode *parent);
|
|
|
|
vfs_s_entry *vfs_s_generate_entry (vfs *me, char *name,
|
|
|
|
struct vfs_s_inode *parent, mode_t mode);
|
|
|
|
vfs_s_entry *vfs_s_automake (vfs *me, vfs_s_inode *dir, char *path,
|
|
|
|
int flags);
|
|
|
|
vfs_s_entry *vfs_s_find_entry_tree (vfs *me, vfs_s_inode *root, char *path,
|
|
|
|
int follow, int flags);
|
|
|
|
vfs_s_entry *vfs_s_find_entry_linear (vfs *me, vfs_s_inode *root, char *path,
|
|
|
|
int follow, int flags);
|
|
|
|
vfs_s_inode *vfs_s_find_inode (vfs *me, vfs_s_inode *root, char *path,
|
|
|
|
int follow, int flags);
|
|
|
|
vfs_s_inode *vfs_s_find_root (vfs *me, vfs_s_entry *entry);
|
1999-01-17 13:07:37 +03:00
|
|
|
vfs_s_entry *vfs_s_resolve_symlink (vfs *me, vfs_s_entry *entry, char *path,
|
1999-01-11 03:48:23 +03:00
|
|
|
int follow);
|
|
|
|
|
1998-10-23 12:26:25 +04:00
|
|
|
/* superblock games */
|
1999-01-11 03:48:23 +03:00
|
|
|
vfs_s_super *vfs_s_new_super (vfs *me);
|
|
|
|
void vfs_s_free_super (vfs *me, vfs_s_super *super);
|
|
|
|
|
1998-10-23 12:26:25 +04:00
|
|
|
/* outside interface */
|
1999-01-11 03:48:23 +03:00
|
|
|
char *vfs_s_get_path_mangle (vfs *me, char *inname, vfs_s_super **archive,
|
|
|
|
int flags);
|
|
|
|
char *vfs_s_get_path (vfs *me, char *inname, vfs_s_super **archive,
|
|
|
|
int flags);
|
|
|
|
void vfs_s_invalidate (vfs *me, vfs_s_super *super);
|
|
|
|
char *vfs_s_fullpath (vfs *me, vfs_s_inode *ino);
|
|
|
|
|
1998-10-23 12:26:25 +04:00
|
|
|
/* readdir & friends */
|
1999-01-11 03:48:23 +03:00
|
|
|
vfs_s_super *vfs_s_super_from_path (vfs *me, char *name);
|
|
|
|
vfs_s_inode *vfs_s_inode_from_path (vfs *me, char *name, int flags);
|
|
|
|
void *vfs_s_opendir (vfs *me, char *dirname);
|
|
|
|
void *vfs_s_readdir (void *data);
|
1998-10-23 12:26:25 +04:00
|
|
|
int vfs_s_telldir (void *data);
|
|
|
|
void vfs_s_seekdir (void *data, int offset);
|
|
|
|
int vfs_s_closedir (void *data);
|
|
|
|
int vfs_s_chdir (vfs *me, char *path);
|
1999-01-11 03:48:23 +03:00
|
|
|
|
1998-10-23 12:26:25 +04:00
|
|
|
/* stat & friends */
|
|
|
|
int vfs_s_stat (vfs *me, char *path, struct stat *buf);
|
|
|
|
int vfs_s_lstat (vfs *me, char *path, struct stat *buf);
|
|
|
|
int vfs_s_fstat (void *fh, struct stat *buf);
|
|
|
|
int vfs_s_readlink (vfs *me, char *path, char *buf, int size);
|
|
|
|
void *vfs_s_open (vfs *me, char *file, int flags, int mode);
|
1998-11-21 22:36:01 +03:00
|
|
|
int vfs_s_read (void *fh, char *buffer, int count);
|
|
|
|
int vfs_s_write (void *fh, char *buffer, int count);
|
1998-10-23 12:26:25 +04:00
|
|
|
int vfs_s_lseek (void *fh, off_t offset, int whence);
|
|
|
|
int vfs_s_close (void *fh);
|
1999-01-11 03:48:23 +03:00
|
|
|
|
1998-10-23 12:26:25 +04:00
|
|
|
/* mc support */
|
|
|
|
void vfs_s_fill_names (vfs *me, void (*func)(char *));
|
|
|
|
int vfs_s_ferrno(vfs *me);
|
|
|
|
void vfs_s_dump(vfs *me, char *prefix, vfs_s_inode *ino);
|
|
|
|
char *vfs_s_getlocalcopy (vfs *me, char *path);
|
1999-01-11 03:48:23 +03:00
|
|
|
|
1998-10-23 12:26:25 +04:00
|
|
|
/* stamping support */
|
|
|
|
vfsid vfs_s_getid (vfs *me, char *path, struct vfs_stamping **parent);
|
|
|
|
int vfs_s_nothingisopen (vfsid id);
|
|
|
|
void vfs_s_free (vfsid id);
|
1998-11-21 22:36:01 +03:00
|
|
|
int vfs_s_setctl (vfs *me, char *path, int ctlop, char *arg);
|
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);
|
|
|
|
int vfs_s_get_line (vfs *me, int sock, char *buf, int buf_len, char term);
|
|
|
|
int vfs_s_get_line_interruptible (vfs *me, char *buffer, int size, int fd);
|
1998-10-23 12:26:25 +04:00
|
|
|
|
2000-02-02 19:59:19 +03:00
|
|
|
/* misc */
|
|
|
|
int vfs_s_retrieve_file (vfs *me, struct vfs_s_inode *ino);
|
|
|
|
|
2000-10-31 18:43:49 +03:00
|
|
|
#if 0
|
|
|
|
#define ERRNOR(a, b) do { me->verrno = a; return b; } while (0)
|
|
|
|
#else
|
|
|
|
#define ERRNOR(a, b) { me->verrno = a; return b; }
|
|
|
|
#endif
|
1998-10-23 12:26:25 +04:00
|
|
|
|
|
|
|
#define MEDATA ((struct vfs_s_data *) me->data)
|
2000-10-31 18:43:49 +03:00
|
|
|
|
1998-10-23 12:26:25 +04:00
|
|
|
#define FH ((struct vfs_s_fh *) fh)
|
1998-11-21 22:36:01 +03:00
|
|
|
#define FH_SUPER FH->ino->super
|
|
|
|
|
|
|
|
#define LS_NOT_LINEAR 0
|
|
|
|
#define LS_LINEAR_CLOSED 1
|
|
|
|
#define LS_LINEAR_OPEN 2
|
1998-10-23 12:26:25 +04:00
|
|
|
|
|
|
|
#endif
|