source: rtems/cpukit/libfs/src/imfs/imfs.h @ 07d6fd5

4.104.115
Last change on this file since 07d6fd5 was 07d6fd5, checked in by Chris Johns <chrisj@…>, on 04/29/09 at 08:31:27

2009-04-29 Chris Johns <chrisj@…>

  • libcsupport/include/rtems/libio.h: Add rtems_off64_t for internal use. Update the internal off_t to the 64bit offset.
  • libnetworking/lib/ftpfs.c, libnetworking/lib/tftpDriver.c, libfs/src/nfsclient/src/nfs.c, libfs/src/imfs/imfs_fifo.c, libfs/src/imfs/memfile.c, libfs/src/imfs/imfs_directory.c, libfs/src/imfs/imfs.h, libfs/src/imfs/deviceio.c: Change off_t to rtems_off64_t.
  • libmisc/shell/main_msdosfmt.c: Add an info level so the format code can tell the user what is happening. Add more options to control the format configuration.
  • libfs/src/dosfs/msdos_format.c: Add a print function to display the format progress and print statements. Select a better default cluster size depending on the size of the disk. This lowers the size of the FAT on large disks. Read and maintain the MRB partition information.
  • libfs/src/dosfs/dosfs.h, libfs/src/dosfs/fat.h, libfs/src/dosfs/fat_file.c, libfs/src/dosfs/fat_file.h, libfs/src/dosfs/msdos.h, libfs/src/dosfs/msdos_conv.c, libfs/src/dosfs/msdos_create.c, libfs/src/dosfs/msdos_file.c, libfs/src/dosfs/msdos_handlers_dir.c, libfs/src/dosfs/msdos_handlers_file.c, libfs/src/dosfs/msdos_init.c, libfs/src/dosfs/msdos_initsupp.c, libfs/src/dosfs/msdos_misc.c, libfs/src/dosfs/msdos_mknod.c: Add long file name support. Change off_t to rtems_off64_t.
  • Property mode set to 100644
File size: 14.9 KB
Line 
1/*
2 *  Header file for the In-Memory File System
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#ifndef _RTEMS_IMFS_H
15#define _RTEMS_IMFS_H
16
17#include <rtems.h>
18#include <rtems/chain.h>
19
20#include <sys/types.h>
21#include <limits.h>
22#include <rtems/libio.h>
23
24#include <rtems/pipe.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/*
31 *  File name macros
32 */
33
34#define IMFS_is_valid_name_char( _ch ) ( 1 )
35
36#define IMFS_is_separator( _ch ) \
37   rtems_filesystem_is_separator( _ch )
38
39/*
40 *  Data types
41 */
42
43struct IMFS_jnode_tt;
44typedef struct IMFS_jnode_tt IMFS_jnode_t;
45
46typedef struct {
47  rtems_chain_control                    Entries;
48  rtems_filesystem_mount_table_entry_t  *mt_fs;
49}  IMFS_directory_t;
50
51typedef struct {
52  rtems_device_major_number  major;
53  rtems_device_minor_number  minor;
54}  IMFS_device_t;
55
56typedef struct {
57  IMFS_jnode_t  *link_node;
58} IMFS_link_t;
59
60typedef struct {
61  char *name;
62} IMFS_sym_link_t;
63
64typedef struct {
65  pipe_control_t  *pipe;
66} IMFS_fifo_t;
67
68/*
69 *  IMFS "memfile" information
70 *
71 *  The data structure for the in-memory "memfiles" is based on classic UNIX.
72 *
73 *  block_ptr is a pointer to a block of IMFS_MEMFILE_BYTES_PER_BLOCK in
74 *  length which could be data or a table of pointers to blocks.
75 *
76 *  Setting IMFS_MEMFILE_BYTES_PER_BLOCK to different values has a significant
77 *  impact on the maximum file size supported as well as the amount of
78 *  memory wasted due to internal file fragmentation.  The following
79 *  is a list of maximum file sizes based on various settings
80 *
81 *    max_filesize with blocks of   16 is         1,328
82 *    max_filesize with blocks of   32 is        18,656
83 *    max_filesize with blocks of   64 is       279,488
84 *    max_filesize with blocks of  128 is     4,329,344
85 *    max_filesize with blocks of  256 is    68,173,568
86 *    max_filesize with blocks of  512 is 1,082,195,456
87 */
88
89#define IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK     128
90  extern int imfs_rq_memfile_bytes_per_block;
91  extern int imfs_memfile_bytes_per_block;
92
93#define IMFS_MEMFILE_BYTES_PER_BLOCK imfs_memfile_bytes_per_block
94#define IMFS_MEMFILE_BLOCK_SLOTS \
95  (IMFS_MEMFILE_BYTES_PER_BLOCK / sizeof(void *))
96
97typedef uint8_t *block_p;
98typedef block_p *block_ptr;
99
100typedef struct {
101  rtems_off64_t size;             /* size of file in bytes */
102  block_ptr     indirect;         /* array of 128 data blocks pointers */
103  block_ptr     doubly_indirect;  /* 128 indirect blocks */
104  block_ptr     triply_indirect;  /* 128 doubly indirect blocks */
105} IMFS_memfile_t;
106
107typedef struct {
108  rtems_off64_t size;             /* size of file in bytes */
109  block_p       direct;           /* pointer to file image */
110} IMFS_linearfile_t;
111
112/*
113 *  Important block numbers for "memfiles"
114 */
115
116#define FIRST_INDIRECT           (0)
117#define LAST_INDIRECT            (IMFS_MEMFILE_BLOCK_SLOTS - 1)
118
119#define FIRST_DOUBLY_INDIRECT    (LAST_INDIRECT + 1)
120#define LAST_DOUBLY_INDIRECT     \
121   (LAST_INDIRECT + \
122     (IMFS_MEMFILE_BLOCK_SLOTS * IMFS_MEMFILE_BLOCK_SLOTS))
123
124#define FIRST_TRIPLY_INDIRECT    (LAST_DOUBLY_INDIRECT + 1)
125#define LAST_TRIPLY_INDIRECT \
126   (LAST_DOUBLY_INDIRECT +\
127     (IMFS_MEMFILE_BLOCK_SLOTS * \
128        IMFS_MEMFILE_BLOCK_SLOTS * IMFS_MEMFILE_BLOCK_SLOTS))
129
130#define IMFS_MEMFILE_MAXIMUM_SIZE \
131  (LAST_TRIPLY_INDIRECT * IMFS_MEMFILE_BYTES_PER_BLOCK)
132
133/*
134 *  What types of IMFS file systems entities there can be.
135 */
136
137#define IMFS_jnode_types_t rtems_filesystem_node_types_t
138#define IMFS_DIRECTORY     RTEMS_FILESYSTEM_DIRECTORY
139#define IMFS_DEVICE        RTEMS_FILESYSTEM_DEVICE
140#define IMFS_HARD_LINK     RTEMS_FILESYSTEM_HARD_LINK
141#define IMFS_SYM_LINK      RTEMS_FILESYSTEM_SYM_LINK
142#define IMFS_MEMORY_FILE   RTEMS_FILESYSTEM_MEMORY_FILE
143#define IMFS_LINEAR_FILE   (IMFS_MEMORY_FILE + 1)
144#define IMFS_FIFO          (IMFS_LINEAR_FILE + 1)
145
146#define IMFS_NUMBER_OF_TYPES  (IMFS_FIFO + 1)
147
148typedef union {
149  IMFS_directory_t   directory;
150  IMFS_device_t      device;
151  IMFS_link_t        hard_link;
152  IMFS_sym_link_t    sym_link;
153  IMFS_memfile_t     file;
154  IMFS_linearfile_t  linearfile;
155  IMFS_fifo_t        fifo;
156} IMFS_types_union;
157
158/*
159 *  Maximum length of a "basename" of an IMFS file/node.
160 */
161
162#define IMFS_NAME_MAX  32
163
164/*
165 *  The control structure for an IMFS jnode.
166 */
167
168struct IMFS_jnode_tt {
169  rtems_chain_node    Node;                  /* for chaining them together */
170  IMFS_jnode_t       *Parent;                /* Parent node */
171  char                name[IMFS_NAME_MAX+1]; /* "basename" */
172  mode_t              st_mode;               /* File mode */
173  nlink_t             st_nlink;              /* Link count */
174  ino_t               st_ino;                /* inode */
175
176  uid_t               st_uid;                /* User ID of owner */
177  gid_t               st_gid;                /* Group ID of owner */
178
179  time_t              stat_atime;            /* Time of last access */
180  time_t              stat_mtime;            /* Time of last modification */
181  time_t              stat_ctime;            /* Time of last status change */
182  IMFS_jnode_types_t  type;                  /* Type of this entry */
183  IMFS_types_union    info;
184};
185
186#define IMFS_update_atime( _jnode )         \
187  do {                                      \
188    struct timeval tv;                      \
189    gettimeofday( &tv, 0 );                 \
190    _jnode->stat_atime  = (time_t) tv.tv_sec; \
191  } while (0)
192
193#define IMFS_update_mtime( _jnode )         \
194  do {                                      \
195    struct timeval tv;                      \
196    gettimeofday( &tv, 0 );                 \
197    _jnode->stat_mtime  = (time_t) tv.tv_sec; \
198  } while (0)
199
200#define IMFS_update_ctime( _jnode )         \
201  do {                                      \
202    struct timeval tv;                      \
203    gettimeofday( &tv, 0 );                 \
204    _jnode->stat_ctime  = (time_t) tv.tv_sec; \
205  } while (0)
206
207#define IMFS_mtime_ctime_update( _jnode )   \
208  do {                                      \
209    struct timeval tv;                      \
210    gettimeofday( &tv, 0 );                 \
211    _jnode->stat_mtime  = (time_t) tv.tv_sec; \
212    _jnode->stat_ctime  = (time_t) tv.tv_sec; \
213  } while (0)
214
215typedef struct {
216  ino_t                                   ino_count;
217  const rtems_filesystem_file_handlers_r *memfile_handlers;
218  const rtems_filesystem_file_handlers_r *directory_handlers;
219} IMFS_fs_info_t;
220
221/*
222 *  Type defination for tokens returned from IMFS_get_token
223 */
224
225typedef enum {
226  IMFS_NO_MORE_PATH,
227  IMFS_CURRENT_DIR,
228  IMFS_UP_DIR,
229  IMFS_NAME,
230  IMFS_INVALID_TOKEN
231} IMFS_token_types;
232
233/*
234 *  Shared Data
235 */
236
237extern const rtems_filesystem_file_handlers_r       IMFS_directory_handlers;
238extern const rtems_filesystem_file_handlers_r       IMFS_device_handlers;
239extern const rtems_filesystem_file_handlers_r       IMFS_link_handlers;
240extern const rtems_filesystem_file_handlers_r       IMFS_memfile_handlers;
241extern const rtems_filesystem_file_handlers_r       IMFS_fifo_handlers;
242extern const rtems_filesystem_operations_table      IMFS_ops;
243extern const rtems_filesystem_operations_table      miniIMFS_ops;
244extern const rtems_filesystem_limits_and_options_t  IMFS_LIMITS_AND_OPTIONS;
245
246/*
247 *  Routines
248 */
249
250extern int IMFS_initialize(
251   rtems_filesystem_mount_table_entry_t *mt_entry
252);
253
254extern int miniIMFS_initialize(
255   rtems_filesystem_mount_table_entry_t *mt_entry
256);
257
258extern int IMFS_initialize_support(
259   rtems_filesystem_mount_table_entry_t       *mt_entry,
260   const rtems_filesystem_operations_table    *op_table,
261   const rtems_filesystem_file_handlers_r     *memfile_handlers,
262   const rtems_filesystem_file_handlers_r     *directory_handlers
263);
264
265extern int IMFS_fsunmount(
266   rtems_filesystem_mount_table_entry_t *mt_entry
267);
268
269extern int rtems_tarfs_load(
270   char         *mountpoint,
271   uint8_t      *tar_image,
272   size_t        tar_size
273);
274
275/*
276 * Returns the number of characters copied from path to token.
277 */
278extern IMFS_token_types IMFS_get_token(
279  const char       *path,
280  char             *token,
281  int              *token_len
282);
283
284extern void IMFS_dump( void );
285
286extern void IMFS_initialize_jnode(
287  IMFS_jnode_t        *the_jnode,
288  IMFS_jnode_types_t   type,
289  IMFS_jnode_t        *the_parent,
290  char                *name,
291  mode_t               mode
292);
293
294extern IMFS_jnode_t *IMFS_find_match_in_dir(
295  IMFS_jnode_t *directory,                         /* IN */
296  char         *name                               /* IN */
297);
298
299extern rtems_filesystem_node_types_t IMFS_node_type(
300  rtems_filesystem_location_info_t    *pathloc     /* IN */
301);
302
303extern int IMFS_stat(
304  rtems_filesystem_location_info_t *loc,           /* IN  */
305  struct stat                      *buf            /* OUT */
306);
307
308extern int IMFS_Set_handlers(
309  rtems_filesystem_location_info_t   *loc
310);
311
312extern int IMFS_evaluate_link(
313  rtems_filesystem_location_info_t *node,        /* IN/OUT */
314  int                               flags        /* IN     */
315);
316
317extern int IMFS_eval_path(
318  const char                        *pathname,     /* IN     */
319  int                               flags,         /* IN     */
320  rtems_filesystem_location_info_t  *pathloc       /* IN/OUT */
321);
322
323
324extern int IMFS_link(
325  rtems_filesystem_location_info_t  *to_loc,      /* IN */
326  rtems_filesystem_location_info_t  *parent_loc,  /* IN */
327  const char                        *token        /* IN */
328);
329
330extern int IMFS_unlink(
331  rtems_filesystem_location_info_t  *pathloc       /* IN */
332);
333
334extern int IMFS_chown(
335  rtems_filesystem_location_info_t  *pathloc,      /* IN */
336  uid_t                              owner,        /* IN */
337  gid_t                              group         /* IN */
338);
339
340extern int IMFS_freenodinfo(
341  rtems_filesystem_location_info_t  *pathloc       /* IN */
342);
343
344extern int IMFS_mknod(
345  const char                        *path,         /* IN */
346  mode_t                             mode,         /* IN */
347  dev_t                              dev,          /* IN */
348  rtems_filesystem_location_info_t  *pathloc       /* IN/OUT */
349);
350
351extern IMFS_jnode_t *IMFS_create_node(
352  rtems_filesystem_location_info_t *parent_loc,   /* IN  */
353  IMFS_jnode_types_t                type,         /* IN  */
354  const char                       *name,         /* IN  */
355  mode_t                            mode,         /* IN  */
356  const IMFS_types_union           *info          /* IN  */
357);
358
359extern int IMFS_evaluate_for_make(
360  const char                         *path,        /* IN     */
361  rtems_filesystem_location_info_t   *pathloc,     /* IN/OUT */
362  const char                        **name         /* OUT    */
363);
364
365extern int IMFS_mount(
366  rtems_filesystem_mount_table_entry_t *mt_entry  /* IN */
367);
368
369extern int IMFS_unmount(
370  rtems_filesystem_mount_table_entry_t *mt_entry  /* IN */
371);
372
373extern int IMFS_freenod(
374  rtems_filesystem_location_info_t  *node         /* IN/OUT */
375);
376
377extern int IMFS_memfile_remove(
378 IMFS_jnode_t  *the_jnode         /* IN/OUT */
379);
380
381extern int memfile_ftruncate(
382  rtems_libio_t *iop,               /* IN  */
383  rtems_off64_t  length             /* IN  */
384);
385
386extern int imfs_dir_open(
387  rtems_libio_t *iop,             /* IN  */
388  const char    *pathname,        /* IN  */
389  uint32_t       flag,            /* IN  */
390  uint32_t       mode             /* IN  */
391);
392
393extern int imfs_dir_close(
394  rtems_libio_t *iop             /* IN  */
395);
396
397extern ssize_t imfs_dir_read(
398  rtems_libio_t *iop,              /* IN  */
399  void          *buffer,           /* IN  */
400  size_t         count             /* IN  */
401);
402
403extern rtems_off64_t imfs_dir_lseek(
404  rtems_libio_t        *iop,              /* IN  */
405  rtems_off64_t         offset,           /* IN  */
406  int                   whence            /* IN  */
407);
408
409extern int imfs_dir_fstat(
410  rtems_filesystem_location_info_t *loc,         /* IN  */
411  struct stat                      *buf          /* OUT */
412);
413
414extern int imfs_dir_rmnod(
415  rtems_filesystem_location_info_t      *pathloc       /* IN */
416);
417
418extern int memfile_open(
419  rtems_libio_t *iop,             /* IN  */
420  const char    *pathname,        /* IN  */
421  uint32_t       flag,            /* IN  */
422  uint32_t       mode             /* IN  */
423);
424
425extern int memfile_close(
426  rtems_libio_t *iop             /* IN  */
427);
428
429extern ssize_t memfile_read(
430  rtems_libio_t *iop,             /* IN  */
431  void          *buffer,          /* IN  */
432  size_t         count            /* IN  */
433);
434
435extern ssize_t memfile_write(
436  rtems_libio_t *iop,             /* IN  */
437  const void    *buffer,          /* IN  */
438  size_t         count            /* IN  */
439);
440
441extern int memfile_ioctl(
442  rtems_libio_t *iop,             /* IN  */
443  uint32_t       command,         /* IN  */
444  void          *buffer           /* IN  */
445);
446
447extern rtems_off64_t memfile_lseek(
448  rtems_libio_t        *iop,        /* IN  */
449  rtems_off64_t         offset,     /* IN  */
450  int                   whence      /* IN  */
451);
452
453extern int memfile_rmnod(
454  rtems_filesystem_location_info_t      *pathloc       /* IN */
455);
456
457extern int device_open(
458  rtems_libio_t *iop,            /* IN  */
459  const char    *pathname,       /* IN  */
460  uint32_t       flag,           /* IN  */
461  uint32_t       mode            /* IN  */
462);
463
464extern int device_close(
465  rtems_libio_t *iop             /* IN  */
466);
467
468extern ssize_t device_read(
469  rtems_libio_t *iop,            /* IN  */
470  void          *buffer,         /* IN  */
471  size_t         count           /* IN  */
472);
473
474extern ssize_t device_write(
475  rtems_libio_t *iop,               /* IN  */
476  const void    *buffer,            /* IN  */
477  size_t         count              /* IN  */
478);
479
480extern int device_ioctl(
481  rtems_libio_t *iop,               /* IN  */
482  uint32_t       command,           /* IN  */
483  void          *buffer             /* IN  */
484);
485
486extern rtems_off64_t device_lseek(
487  rtems_libio_t *iop,               /* IN  */
488  rtems_off64_t  offset,            /* IN  */
489  int            whence             /* IN  */
490);
491
492extern int device_ftruncate(
493  rtems_libio_t *iop,               /* IN  */
494  rtems_off64_t  length             /* IN  */
495);
496
497extern int IMFS_utime(
498  rtems_filesystem_location_info_t  *pathloc,       /* IN */
499  time_t                             actime,        /* IN */
500  time_t                             modtime        /* IN */
501);
502
503extern int IMFS_fchmod(
504  rtems_filesystem_location_info_t *loc,
505  mode_t                            mode
506);
507
508extern int IMFS_symlink(
509  rtems_filesystem_location_info_t  *parent_loc,  /* IN */
510  const char                        *link_name,
511  const char                        *node_name
512);
513
514extern int IMFS_readlink(
515 rtems_filesystem_location_info_t   *loc,         /* IN */
516 char                               *buf,         /* OUT */
517 size_t                             bufsize
518);
519
520extern int IMFS_fdatasync(
521  rtems_libio_t *iop
522);
523
524extern int IMFS_fcntl(
525  int            cmd,
526  rtems_libio_t *iop
527);
528
529extern int IMFS_rmnod(
530  rtems_filesystem_location_info_t      *pathloc       /* IN */
531);
532
533#ifdef __cplusplus
534}
535#endif
536
537#endif
538/* end of include file */
Note: See TracBrowser for help on using the repository browser.