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

4.104.114.84.95
Last change on this file since 83c5fc1 was f91bbe64, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/22/04 at 17:10:43

2004-03-22 Ralf Corsepius <ralf_corsepius@…>

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