source: rtems/cpukit/libfs/src/dosfs/msdos.h @ 2742cc3

Last change on this file since 2742cc3 was a36e988, checked in by Joel Sherrill <joel.sherrill@…>, on 12/02/02 at 19:14:27

2002-12-02 Joel Sherrill <joel@…>

  • src/dosfs/fat.h, src/dosfs/msdos.h: Added casts to remove warnings on 16 bit targets like the h8300.
  • Property mode set to 100644
File size: 13.2 KB
Line 
1/*
2 *  msdos.h
3 *
4 *  The MSDOS filesystem constants/data structures/prototypes
5 *
6 *  Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
7 *  Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  @(#) $Id$
14 */
15#ifndef __DOSFS_MSDOS_H__
16#define __DOSFS_MSDOS_H__
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22#include <rtems.h>
23#include <rtems/libio_.h>
24
25#include "fat.h"
26#include "fat_file.h"
27 
28#ifndef RC_OK
29#define RC_OK 0x00000000
30#endif
31
32#define MSDOS_NAME_NOT_FOUND_ERR  0xDD000001
33
34/*
35 * This structure identifies the instance of the filesystem on the MSDOS
36 * level.
37 */
38typedef struct msdos_fs_info_s
39{
40    fat_fs_info_t                     fat;                /*
41                                                           * volume
42                                                           * description
43                                                           */
44    rtems_filesystem_file_handlers_r *directory_handlers; /*
45                                                           * a set of routines
46                                                           * that handles the
47                                                           * nodes of directory
48                                                           * type
49                                                           */
50    rtems_filesystem_file_handlers_r *file_handlers;      /*
51                                                           * a set of routines
52                                                           * that handles the
53                                                           * nodes of file
54                                                           * type
55                                                           */
56    rtems_id                          vol_sema;           /*
57                                                           * semaphore
58                                                           * associated with
59                                                           * the volume
60                                                           */
61    unsigned8                        *cl_buf;              /*
62                                                            * just placeholder
63                                                            * for anything
64                                                            */
65} msdos_fs_info_t;
66
67/* a set of routines that handle the nodes which are directories */
68extern rtems_filesystem_file_handlers_r  msdos_dir_handlers;
69
70/* a set of routines that handle the nodes which are files */
71extern rtems_filesystem_file_handlers_r  msdos_file_handlers;
72
73/* Volume semaphore timeout value */
74#define MSDOS_VOLUME_SEMAPHORE_TIMEOUT    100
75
76/* Node types */
77#define MSDOS_DIRECTORY     RTEMS_FILESYSTEM_DIRECTORY
78#define MSDOS_REGULAR_FILE  RTEMS_FILESYSTEM_MEMORY_FILE
79   
80typedef rtems_filesystem_node_types_t msdos_node_type_t;
81
82/*
83 * Macros for fetching fields from 32 bytes long FAT Directory Entry
84 * Structure (see M$ White Paper)
85 */
86#define MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE    32 /* 32 bytes */
87
88#define MSDOS_DIR_NAME(x)                 (unsigned8 *)((x) + 0)
89#define MSDOS_DIR_ATTR(x)                 (unsigned8 *)((x) + 11)
90#define MSDOS_DIR_NT_RES(x)               (unsigned8 *)((x) + 12)
91#define MSDOS_DIR_CRT_TIME_TENTH(x)       (unsigned8 *)((x) + 13)
92#define MSDOS_DIR_CRT_TIME(x)             (unsigned16 *)((x) + 14)
93#define MSDOS_DIR_CRT_DATE(x)             (unsigned16 *)((x) + 16)
94#define MSDOS_DIR_LAST_ACCESS_DATE(x)     (unsigned16 *)((x) + 18)
95#define MSDOS_DIR_FIRST_CLUSTER_HI(x)     (unsigned16 *)((x) + 20)
96#define MSDOS_DIR_WRITE_TIME(x)           (unsigned16 *)((x) + 22)
97#define MSDOS_DIR_WRITE_DATE(x)           (unsigned16 *)((x) + 24)
98#define MSDOS_DIR_FIRST_CLUSTER_LOW(x)    (unsigned16 *)((x) + 26)
99#define MSDOS_DIR_FILE_SIZE(x)            (unsigned32 *)((x) + 28)
100
101#define MSDOS_EXTRACT_CLUSTER_NUM(p)                                         \
102            (unsigned32)( (CF_LE_W(*MSDOS_DIR_FIRST_CLUSTER_LOW(p))) |       \
103                          ((unsigned32)(CF_LE_W((*MSDOS_DIR_FIRST_CLUSTER_HI(p))))<<16) )
104
105/*
106 * Fields offset in 32 bytes long FAT Directory Entry
107 * Structure (see M$ White Paper)
108 */
109#define MSDOS_FILE_SIZE_OFFSET            28
110#define MSDOS_FILE_NAME_OFFSET             0
111#define MSDOS_FIRST_CLUSTER_HI_OFFSET     20
112#define MSDOS_FIRST_CLUSTER_LOW_OFFSET    26
113#define MSDOS_FILE_WDATE_OFFSET           24
114#define MSDOS_FILE_WTIME_OFFSET           22
115
116/*
117 * Possible values of DIR_Attr field of 32 bytes long FAT Directory Entry
118 * Structure (see M$ White Paper)
119 */
120#define MSDOS_ATTR_READ_ONLY    0x01
121#define MSDOS_ATTR_HIDDEN       0x02
122#define MSDOS_ATTR_SYSTEM       0x04
123#define MSDOS_ATTR_VOLUME_ID    0x08
124#define MSDOS_ATTR_DIRECTORY    0x10
125#define MSDOS_ATTR_ARCHIVE      0x20
126
127/*
128 * Possible values of DIR_Name[0] field of 32 bytes long FAT Directory Entry
129 * Structure (see M$ White Paper)
130 */
131#define MSDOS_THIS_DIR_ENTRY_EMPTY             0xE5
132#define MSDOS_THIS_DIR_ENTRY_AND_REST_EMPTY    0x00
133
134
135/*
136 *  Macros for names parsing and formatting
137 */
138#define msdos_is_valid_name_char(_ch)    (1)
139#define msdos_is_separator(_ch)          rtems_filesystem_is_separator(_ch)
140
141#define MSDOS_SHORT_NAME_LEN             11 /* 11 characters */
142#define MSDOS_NAME_MAX                   MSDOS_SHORT_NAME_LEN
143#define MSDOS_NAME_MAX_WITH_DOT          (MSDOS_NAME_MAX + 1)
144
145#define MSDOS_DOT_NAME     ".          " /* ".", padded to MSDOS_NAME chars */
146#define MSDOS_DOTDOT_NAME  "..         " /* "..", padded to MSDOS_NAME chars */
147
148typedef enum msdos_token_types_e
149{
150    MSDOS_NO_MORE_PATH,
151    MSDOS_CURRENT_DIR,
152    MSDOS_UP_DIR,
153    MSDOS_NAME,
154    MSDOS_INVALID_TOKEN
155} msdos_token_types_t;
156
157/* Others macros */
158#define MSDOS_RES_NT_VALUE     0x00
159#define MSDOS_INIT_DIR_SIZE    0x00
160
161/* "dot" entry offset in a directory */
162#define MSDOS_DOT_DIR_ENTRY_OFFSET       0x00 /* first entry in directory */
163
164/* "dotdot" entry offset in a directory */
165#define MSDOS_DOTDOT_DIR_ENTRY_OFFSET    0x20 /* second entry in directory */
166
167/* 'p' should be char* */
168#define DOT_NODE_P(p)     ((char *)(p))
169#define DOTDOT_NODE_P(p)  ((char *)((p) + MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE))
170
171/* Size limits for files and directories (see M$ White Paper) */
172#define MSDOS_MAX_DIR_LENGHT               0x200000   /* 2,097,152 bytes */
173#define MSDOS_MAX_FILE_SIZE                0xFFFFFFFF /* 4 Gb */
174
175/*
176 * The number of 32 bytes long FAT Directory Entry
177 * Structures per 512 bytes sector
178 */
179#define MSDOS_DPS512_NUM    16
180
181/* Prototypes */
182int
183msdos_initialize(rtems_filesystem_mount_table_entry_t *temp_mt_entry);
184
185int
186msdos_shut_down(rtems_filesystem_mount_table_entry_t *temp_mt_entry);
187
188int
189msdos_eval_path(const char                       *pathname, /* IN */
190                int                               flags,    /* IN */
191                rtems_filesystem_location_info_t *pathloc   /* IN/OUT */);
192
193int
194msdos_eval4make(const char                       *path,     /* IN */
195                rtems_filesystem_location_info_t *pathloc,  /* IN/OUT */
196                const char                       **name     /* OUT    */);
197         
198int
199msdos_unlink(rtems_filesystem_location_info_t *pathloc /* IN */);
200
201int
202msdos_free_node_info(rtems_filesystem_location_info_t *pathloc /* IN */);
203
204rtems_filesystem_node_types_t
205msdos_node_type(rtems_filesystem_location_info_t    *pathloc);
206
207int
208msdos_mknod(const char                       *path,   /* IN */
209            mode_t                            mode,   /* IN */
210            dev_t                             dev,    /* IN */
211            rtems_filesystem_location_info_t *pathloc /* IN/OUT */);
212
213int
214msdos_utime(rtems_filesystem_location_info_t *pathloc, /* IN */
215            time_t                            actime,  /* IN */
216            time_t                            modtime  /* IN */);
217
218int
219msdos_initialize_support(
220  rtems_filesystem_mount_table_entry_t *temp_mt_entry,
221  rtems_filesystem_operations_table    *op_table,
222  rtems_filesystem_file_handlers_r     *file_handlers,
223  rtems_filesystem_file_handlers_r     *directory_handlers
224);
225
226int
227msdos_file_open(
228  rtems_libio_t *iop,             /* IN  */
229  const char    *pathname,        /* IN  */
230  unsigned32     flag,            /* IN  */
231  unsigned32     mode             /* IN  */
232);
233
234int
235msdos_file_close(rtems_libio_t *iop /* IN  */);
236
237ssize_t
238msdos_file_read(
239  rtems_libio_t *iop,              /* IN  */
240  void          *buffer,           /* IN  */
241  unsigned32     count             /* IN  */
242);
243
244ssize_t
245msdos_file_write(
246  rtems_libio_t *iop,             /* IN  */
247  const void    *buffer,          /* IN  */
248  unsigned32     count            /* IN  */
249);
250
251int
252msdos_file_lseek(
253  rtems_libio_t        *iop,              /* IN  */
254  off_t                 offset,           /* IN  */
255  int                   whence            /* IN  */
256);
257
258int
259msdos_file_stat(rtems_filesystem_location_info_t *loc, /* IN  */
260                struct stat                      *buf  /* OUT */);
261
262int
263msdos_file_ftruncate(
264  rtems_libio_t *iop,               /* IN  */
265  off_t          length             /* IN  */
266);
267
268int
269msdos_file_sync(rtems_libio_t *iop);
270
271int
272msdos_file_datasync(rtems_libio_t *iop);
273 
274int
275msdos_file_ioctl(
276  rtems_libio_t *iop,             /* IN  */
277  unsigned32     command,         /* IN  */
278  void          *buffer           /* IN  */
279);
280
281int
282msdos_file_rmnod(rtems_filesystem_location_info_t *pathloc /* IN */);
283 
284int
285msdos_dir_open(
286  rtems_libio_t *iop,             /* IN  */
287  const char    *pathname,        /* IN  */
288  unsigned32     flag,            /* IN  */
289  unsigned32     mode             /* IN  */
290);
291
292int
293msdos_dir_close(rtems_libio_t *iop /* IN  */);
294
295ssize_t
296msdos_dir_read(
297  rtems_libio_t *iop,              /* IN  */
298  void          *buffer,           /* IN  */
299  unsigned32     count             /* IN  */
300);
301
302int
303msdos_dir_lseek(
304  rtems_libio_t        *iop,              /* IN  */
305  off_t                 offset,           /* IN  */
306  int                   whence            /* IN  */
307);
308
309int
310msdos_dir_rmnod(rtems_filesystem_location_info_t *pathloc /* IN */);
311
312int
313msdos_dir_sync(rtems_libio_t *iop);
314
315int
316msdos_dir_stat(
317  rtems_filesystem_location_info_t *loc,         /* IN  */
318  struct stat                      *buf          /* OUT */
319);
320
321int
322msdos_creat_node(rtems_filesystem_location_info_t  *parent_loc,
323                 msdos_node_type_t                  type,
324                 char                              *name,
325                 mode_t                             mode);
326
327/* Misc prototypes */
328msdos_token_types_t msdos_get_token(const char *path,
329                                    char       *token,
330                                    int        *token_len);
331
332int
333msdos_find_name(rtems_filesystem_location_info_t *parent_loc,
334                char                             *name);
335
336int
337msdos_get_name_node(rtems_filesystem_location_info_t *parent_loc,
338                    char                             *name,
339                    fat_auxiliary_t                  *paux,
340                    char                             *name_dir_entry);
341
342int
343msdos_dir_info_remove(rtems_filesystem_location_info_t *pathloc);
344
345void
346msdos_date_unix2dos(int             unix_date,
347                    unsigned short *time_val,
348                    unsigned short *date);
349
350unsigned int 
351msdos_date_dos2unix(unsigned short time_val, unsigned short date);
352
353int
354msdos_set_first_cluster_num(rtems_filesystem_mount_table_entry_t *mt_entry,
355                            fat_file_fd_t                        *fat_fd);
356
357int
358msdos_set_file_size(rtems_filesystem_mount_table_entry_t *mt_entry,
359                    fat_file_fd_t                        *fat_fd);
360
361int
362msdos_set_first_char4file_name(rtems_filesystem_mount_table_entry_t *mt_entry,
363                               unsigned32  cl,
364                               unsigned32  ofs,
365                               unsigned char first_char);
366
367int
368msdos_set_dir_wrt_time_and_date(
369    rtems_filesystem_mount_table_entry_t *mt_entry,
370    fat_file_fd_t                        *fat_fd
371);
372                               
373
374int
375msdos_dir_is_empty(rtems_filesystem_mount_table_entry_t *mt_entry,
376                   fat_file_fd_t                        *fat_fd,
377                   rtems_boolean                        *ret_val);
378
379int
380msdos_find_name_in_fat_file(
381    rtems_filesystem_mount_table_entry_t *mt_entry,
382    fat_file_fd_t                        *fat_fd,
383    char                                 *name,
384    fat_auxiliary_t                      *paux,
385    char                                 *name_dir_entry);
386                           
387int
388msdos_find_node_by_cluster_num_in_fat_file(
389    rtems_filesystem_mount_table_entry_t *mt_entry,
390    fat_file_fd_t                        *fat_fd,
391    unsigned32                            cl4find,
392    fat_auxiliary_t                      *paux,
393    char                                 *dir_entry
394);
395
396int
397msdos_get_dotdot_dir_info_cluster_num_and_offset(
398    rtems_filesystem_mount_table_entry_t *mt_entry,
399    unsigned32                            cln,
400    fat_auxiliary_t                      *paux,
401    char                                 *dir_entry
402);
403
404#ifdef __cplusplus
405}
406#endif
407
408#endif /* __DOSFS_MSDOS_H__ */
Note: See TracBrowser for help on using the repository browser.