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

4.104.114.84.95
Last change on this file since b17ff491 was b17ff491, checked in by Joel Sherrill <joel.sherrill@…>, on 05/06/05 at 14:57:43

2005-05-06 Joel Sherrill <joel@…>

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