root/lib/vfs/xdirentry.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. vfs_s_store_filename_leading_spaces

   1 
   2 /**
   3  * \file
   4  * \brief Header: Virtual File System directory structure
   5  */
   6 
   7 
   8 #ifndef MC__VFS_XDIRENTRY_H
   9 #define MC__VFS_XDIRENTRY_H
  10 
  11 #include <stdio.h>
  12 #include <sys/types.h>
  13 
  14 #include "lib/global.h"         /* GList */
  15 #include "lib/vfs/path.h"       /* vfs_path_t */
  16 
  17 /*** typedefs(not structures) and defined constants **********************************************/
  18 
  19 #define LINK_FOLLOW 15
  20 #define LINK_NO_FOLLOW -1
  21 
  22 /* For vfs_s_find_entry and vfs_s_find_inode */
  23 #define FL_NONE 0
  24 #define FL_MKDIR 1
  25 #define FL_MKFILE 2
  26 #define FL_DIR 4
  27 
  28 /* For open_super */
  29 #define FL_NO_OPEN 1
  30 
  31 /* For vfs_s_entry_from_path */
  32 #define FL_FOLLOW 1
  33 #define FL_DIR 4
  34 
  35 #define ERRNOR(a, b) do { me->verrno = a; return b; } while (0)
  36 
  37 #define VFS_SUBCLASS(a) ((struct vfs_s_subclass *) (a))
  38 
  39 #define VFS_SUPER(a) ((struct vfs_s_super *) (a))
  40 #define CONST_VFS_SUPER(a) ((const struct vfs_s_super *) (a))
  41 #define VFS_ENTRY(a) ((struct vfs_s_entry *) (a))
  42 #define VFS_INODE(a) ((struct vfs_s_inode *) (a))
  43 
  44 #define VFS_FILE_HANDLER(a) ((vfs_file_handler_t *) a)
  45 #define VFS_FILE_HANDLER_SUPER(a) VFS_FILE_HANDLER (a)->ino->super
  46 
  47 /*** enums ***************************************************************************************/
  48 
  49 typedef enum
  50 {
  51     LS_NOT_LINEAR = 0,
  52     LS_LINEAR_CLOSED = 1,
  53     LS_LINEAR_OPEN = 2,
  54     LS_LINEAR_PREOPEN = 3
  55 } vfs_linear_state_t;
  56 
  57 /*** structures declarations (and typedefs of structures)*****************************************/
  58 
  59 /* Single connection or archive */
  60 struct vfs_s_super
  61 {
  62     struct vfs_class *me;
  63     struct vfs_s_inode *root;
  64     char *name;                 /* My name, whatever it means */
  65     int fd_usage;               /* Number of open files */
  66     int ino_usage;              /* Usage count of this superblock */
  67     gboolean want_stale;        /* If set, we do not flush cache properly */
  68 #ifdef ENABLE_VFS_NET
  69     vfs_path_element_t *path_element;
  70 #endif                          /* ENABLE_VFS_NET */
  71 };
  72 
  73 /*
  74  * Single virtual file - directory entry.  The same inode can have many
  75  * entries (i.e. hard links), but usually has only one.
  76  */
  77 struct vfs_s_entry
  78 {
  79     struct vfs_s_inode *dir;    /* Directory we are in, i.e. our parent */
  80     char *name;                 /* Name of this entry */
  81     struct vfs_s_inode *ino;    /* ... and its inode */
  82     ssize_t leading_spaces;     /* number of leading spases in the file name */
  83 };
  84 
  85 /* Single virtual file - inode */
  86 struct vfs_s_inode
  87 {
  88     struct vfs_s_super *super;  /* Archive the file is on */
  89     struct vfs_s_entry *ent;    /* Our entry in the parent directory -
  90                                    use only for directories because they
  91                                    cannot be hardlinked */
  92     GQueue *subdir;             /* If this is a directory, its entry. List of vfs_s_entry */
  93     struct stat st;             /* Parameters of this inode */
  94     char *linkname;             /* Symlink's contents */
  95     char *localname;            /* Filename of local file, if we have one */
  96     gint64 timestamp;           /* Subclass specific */
  97     off_t data_offset;          /* Subclass specific */
  98     void *user_data;            /* Subclass specific */
  99 };
 100 
 101 /* Data associated with an open file */
 102 typedef struct
 103 {
 104     struct vfs_s_inode *ino;
 105     off_t pos;                  /* This is for module's use */
 106     int handle;                 /* This is for module's use, but if != -1, will be mc_close()d */
 107     gboolean changed;           /* Did this file change? */
 108     vfs_linear_state_t linear;  /* Is that file open with O_LINEAR? */
 109 } vfs_file_handler_t;
 110 
 111 /*
 112  * One of our subclasses (tar, cpio, shell, ftpfs) with data and methods.
 113  * Extends vfs_class.
 114  */
 115 struct vfs_s_subclass
 116 {
 117     struct vfs_class base;      /* base class */
 118 
 119     GList *supers;
 120     int inode_counter;
 121     dev_t rdev;
 122 
 123     /* *INDENT-OFF* */
 124     int (*init_inode) (struct vfs_class * me, struct vfs_s_inode * ino);        /* optional */
 125     void (*free_inode) (struct vfs_class * me, struct vfs_s_inode * ino);       /* optional */
 126     int (*init_entry) (struct vfs_class * me, struct vfs_s_entry * entry);      /* optional */
 127 
 128     void *(*archive_check) (const vfs_path_t * vpath);  /* optional */
 129     int (*archive_same) (const vfs_path_element_t * vpath_element, struct vfs_s_super * psup,
 130                          const vfs_path_t * vpath, void *cookie);
 131     struct vfs_s_super *(*new_archive) (struct vfs_class * me);
 132     int (*open_archive) (struct vfs_s_super * psup,
 133                          const vfs_path_t * vpath, const vfs_path_element_t * vpath_element);
 134     void (*free_archive) (struct vfs_class * me, struct vfs_s_super * psup);
 135 
 136     vfs_file_handler_t *(*fh_new) (struct vfs_s_inode * ino, gboolean changed);
 137     int (*fh_open) (struct vfs_class * me, vfs_file_handler_t * fh, int flags, mode_t mode);
 138     int (*fh_close) (struct vfs_class * me, vfs_file_handler_t * fh);
 139     void (*fh_free) (vfs_file_handler_t * fh);
 140 
 141     struct vfs_s_entry *(*find_entry) (struct vfs_class * me,
 142                                        struct vfs_s_inode * root,
 143                                        const char *path, int follow, int flags);
 144     int (*dir_load) (struct vfs_class * me, struct vfs_s_inode * ino, const char *path);
 145     gboolean (*dir_uptodate) (struct vfs_class * me, struct vfs_s_inode * ino);
 146     int (*file_store) (struct vfs_class * me, vfs_file_handler_t * fh, char *path, char *localname);
 147 
 148     int (*linear_start) (struct vfs_class * me, vfs_file_handler_t * fh, off_t from);
 149     ssize_t (*linear_read) (struct vfs_class * me, vfs_file_handler_t * fh, void *buf, size_t len);
 150     void (*linear_close) (struct vfs_class * me, vfs_file_handler_t * fh);
 151     /* *INDENT-ON* */
 152 };
 153 
 154 /*** global variables defined in .c file *********************************************************/
 155 
 156 /*** declarations of public functions ************************************************************/
 157 
 158 /* entries and inodes */
 159 struct vfs_s_inode *vfs_s_new_inode (struct vfs_class *me,
 160                                      struct vfs_s_super *super, struct stat *initstat);
 161 void vfs_s_free_inode (struct vfs_class *me, struct vfs_s_inode *ino);
 162 
 163 struct vfs_s_entry *vfs_s_new_entry (struct vfs_class *me, const char *name,
 164                                      struct vfs_s_inode *inode);
 165 void vfs_s_free_entry (struct vfs_class *me, struct vfs_s_entry *ent);
 166 void vfs_s_insert_entry (struct vfs_class *me, struct vfs_s_inode *dir, struct vfs_s_entry *ent);
 167 int vfs_s_entry_compare (const void *a, const void *b);
 168 struct stat *vfs_s_default_stat (struct vfs_class *me, mode_t mode);
 169 
 170 struct vfs_s_entry *vfs_s_generate_entry (struct vfs_class *me, const char *name,
 171                                           struct vfs_s_inode *parent, mode_t mode);
 172 struct vfs_s_inode *vfs_s_find_inode (struct vfs_class *me,
 173                                       const struct vfs_s_super *super,
 174                                       const char *path, int follow, int flags);
 175 struct vfs_s_inode *vfs_s_find_root (struct vfs_class *me, struct vfs_s_entry *entry);
 176 
 177 /* outside interface */
 178 void vfs_init_subclass (struct vfs_s_subclass *sub, const char *name, vfs_flags_t flags,
 179                         const char *prefix);
 180 const char *vfs_s_get_path (const vfs_path_t * vpath, struct vfs_s_super **archive, int flags);
 181 struct vfs_s_super *vfs_get_super_by_vpath (const vfs_path_t * vpath);
 182 
 183 void vfs_s_invalidate (struct vfs_class *me, struct vfs_s_super *super);
 184 char *vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino);
 185 
 186 void vfs_s_init_fh (vfs_file_handler_t * fh, struct vfs_s_inode *ino, gboolean changed);
 187 
 188 /* network filesystems support */
 189 int vfs_s_select_on_two (int fd1, int fd2);
 190 int vfs_s_get_line (struct vfs_class *me, int sock, char *buf, int buf_len, char term);
 191 int vfs_s_get_line_interruptible (struct vfs_class *me, char *buffer, int size, int fd);
 192 /* misc */
 193 int vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino);
 194 
 195 void vfs_s_normalize_filename_leading_spaces (struct vfs_s_inode *root_inode, size_t final_filepos);
 196 
 197 /*** inline functions ****************************************************************************/
 198 
 199 static inline void
 200 vfs_s_store_filename_leading_spaces (struct vfs_s_entry *entry, size_t position)
     /* [previous][next][first][last][top][bottom][index][help]  */
 201 {
 202     entry->leading_spaces = (ssize_t) position;
 203 }
 204 
 205 #endif

/* [previous][next][first][last][top][bottom][index][help]  */