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

4.104.115
Last change on this file since 29e92b0 was 29e92b0, checked in by Chris Johns <chrisj@…>, on 05/31/10 at 13:56:37

2010-05-31 Chris Johns <chrisj@…>

  • libcsupport/Makefile.am: Add mount-mgr.c.
  • libcsupport/src/mount-mgr.c: New.
  • include/rtems/fs.h: Added rtems_filesystem_location_mount.
  • libcsupport/include/rtems/libio.h, libcsupport/src/mount.c: New mount interface. It is similar to Linux.
  • libcsupport/include/rtems/libio_.h: Remove the init_fs_mount_table call.
  • libcsupport/src/base_fs.c: Remove init_fs_mount_table_call. Use the new mount call. Remove setting the root node in the global pathloc. Mount does this now.
  • libcsupport/src/privateenv.c: Remove the hack to set the root mount table entry in the environment.
  • libcsupport/src/unmount.cL Free the target string.
  • libblock/src/bdpart-mount.c: New mount API.
  • libfs/src/devfs/devfs.h, libfs/src/devfs/devfs_init.c, libfs/src/dosfs/dosfs.h, libfs/src/dosfs/msdos.h, libfs/src/dosfs/msdos_init.c, libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_eval.c, libfs/src/imfs/imfs_init.c, libfs/src/imfs/miniimfs_init.c, libfs/src/nfsclient/src/librtemsNfs.h, libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs.h, libnetworking/lib/ftpfs.c, libnetworking/rtems/ftpfs.h, libnetworking/rtems/tftp.h: New mount_h API.
  • libfs/src/devfs/devfs_eval.c: Local include of extern ops.
  • libfs/src/nfsclient/src/nfs.c: New mount API. Removed the mount me call and fixed the initialisation to happen when mounting.
  • libmisc/Makefile.am, libmisc/shell/shellconfig.h: Remove mount filesystem files.
  • libmisc/fsmount/fsmount.c, libmisc/fsmount/fsmount.h: Updated to the new mount table values.
  • libmisc/shell/main_mount_ftp.c, libmisc/shell/main_mount_msdos.c, libmisc/shell/main_mount_rfs.c, libmisc/shell/main_mount_tftp.c: Removed.
  • libmisc/shell/main_mount.c: Use the new mount API. Also access the file system table for the file system types.
  • libnetworking/lib/tftpDriver.c: Updated to the new mount API. Fixed to allow mounting from any mount point. Also can now have more than file system mounted.
  • sapi/include/confdefs.h: Add file system configuration support.
  • Property mode set to 100644
File size: 16.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.rtems.com/license/LICENSE.
12 *
13 *  @(#) $Id$
14 */
15#ifndef __DOSFS_MSDOS_H__
16#define __DOSFS_MSDOS_H__
17
18#include <rtems.h>
19#include <rtems/libio_.h>
20
21#include "fat.h"
22#include "fat_file.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#define MSDOS_NAME_NOT_FOUND_ERR  0x7D01
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    const rtems_filesystem_file_handlers_r *directory_handlers; /*
41                                                                 * a set of routines
42                                                                 * that handles the
43                                                                 * nodes of directory
44                                                                 * type
45                                                                 */
46    const 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 const rtems_filesystem_file_handlers_r  msdos_dir_handlers;
65
66/* a set of routines that handle the nodes which are files */
67extern const 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_ENTRY_TYPE(x)           (uint8_t  *)((x) + 0)
88#define MSDOS_DIR_ATTR(x)                 (uint8_t  *)((x) + 11)
89#define MSDOS_DIR_NT_RES(x)               (uint8_t  *)((x) + 12)
90#define MSDOS_DIR_LFN_CHECKSUM(x)         (uint8_t  *)((x) + 13)
91#define MSDOS_DIR_CRT_TIME_TENTH(x)       (uint8_t  *)((x) + 13)
92#define MSDOS_DIR_CRT_TIME(x)             (uint16_t *)((x) + 14)
93#define MSDOS_DIR_CRT_DATE(x)             (uint16_t *)((x) + 16)
94#define MSDOS_DIR_LAST_ACCESS_DATE(x)     (uint16_t *)((x) + 18)
95#define MSDOS_DIR_FIRST_CLUSTER_HI(x)     (uint16_t *)((x) + 20)
96#define MSDOS_DIR_WRITE_TIME(x)           (uint16_t *)((x) + 22)
97#define MSDOS_DIR_WRITE_DATE(x)           (uint16_t *)((x) + 24)
98#define MSDOS_DIR_FIRST_CLUSTER_LOW(x)    (uint16_t *)((x) + 26)
99#define MSDOS_DIR_FILE_SIZE(x)            (uint32_t *)((x) + 28)
100
101#define MSDOS_EXTRACT_CLUSTER_NUM(p)                                         \
102            (uint32_t)( (CF_LE_W(*MSDOS_DIR_FIRST_CLUSTER_LOW(p))) |       \
103                          ((uint32_t)(CF_LE_W((*MSDOS_DIR_FIRST_CLUSTER_HI(p))))<<16) )
104
105/*
106 * Fields offset in 32 bytes long FAT Directory Entry
107 * Structure
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
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#define MSDOS_ATTR_LFN          (MSDOS_ATTR_READ_ONLY | \
127                                 MSDOS_ATTR_HIDDEN | \
128                                 MSDOS_ATTR_SYSTEM | \
129                                 MSDOS_ATTR_VOLUME_ID)
130#define MSDOS_ATTR_LFN_MASK     (MSDOS_ATTR_READ_ONLY | \
131                                 MSDOS_ATTR_HIDDEN | \
132                                 MSDOS_ATTR_SYSTEM | \
133                                 MSDOS_ATTR_VOLUME_ID | \
134                                 MSDOS_ATTR_DIRECTORY | \
135                                 MSDOS_ATTR_ARCHIVE)
136
137#define MSDOS_LAST_LONG_ENTRY         0x40
138#define MSDOS_LAST_LONG_ENTRY_MASK    0x3F
139
140#define MSDOS_DT_2SECONDS_MASK        0x1F    /* seconds divided by 2 */
141#define MSDOS_DT_2SECONDS_SHIFT       0
142#define MSDOS_DT_MINUTES_MASK         0x7E0   /* minutes */
143#define MSDOS_DT_MINUTES_SHIFT        5
144#define MSDOS_DT_HOURS_MASK           0xF800  /* hours */
145#define MSDOS_DT_HOURS_SHIFT          11
146
147#define MSDOS_DD_DAY_MASK             0x1F    /* day of month */
148#define MSDOS_DD_DAY_SHIFT            0
149#define MSDOS_DD_MONTH_MASK           0x1E0   /* month */
150#define MSDOS_DD_MONTH_SHIFT          5
151#define MSDOS_DD_YEAR_MASK            0xFE00  /* year - 1980 */
152#define MSDOS_DD_YEAR_SHIFT           9
153
154
155/*
156 * Possible values of DIR_Name[0] field of 32 bytes long FAT Directory Entry
157 * Structure
158 */
159#define MSDOS_THIS_DIR_ENTRY_EMPTY             0xE5
160#define MSDOS_THIS_DIR_ENTRY_AND_REST_EMPTY    0x00
161
162/*
163 * Number of characters per directory entry for a long filename.
164 */
165#define MSDOS_LFN_LEN_PER_ENTRY (13)
166
167/*
168 *  Macros for names parsing and formatting
169 */
170#define msdos_is_separator(_ch)          rtems_filesystem_is_separator(_ch)
171
172#define MSDOS_SHORT_BASE_LEN             8  /* 8 characters */
173#define MSDOS_SHORT_EXT_LEN              3  /* 3 characters */
174#define MSDOS_SHORT_NAME_LEN             (MSDOS_SHORT_BASE_LEN+\
175                                          MSDOS_SHORT_EXT_LEN) /* 11 chars */
176#define MSDOS_NAME_MAX_LNF_LEN           (255)
177#define MSDOS_NAME_MAX                   MSDOS_SHORT_NAME_LEN
178#define MSDOS_NAME_MAX_WITH_DOT          (MSDOS_NAME_MAX + 1)
179#define MSDOS_NAME_MAX_LFN_WITH_DOT      (260)
180
181
182extern const char const* MSDOS_DOT_NAME;    /* ".", padded to MSDOS_NAME chars */
183extern const char const* MSDOS_DOTDOT_NAME; /* ".", padded to MSDOS_NAME chars */
184
185typedef enum msdos_name_types_e
186{
187    MSDOS_NAME_INVALID = 0, /* Unknown name type. Has invalid characters. */
188    MSDOS_NAME_SHORT,       /* Name can be short. */
189    MSDOS_NAME_LONG         /* Name is long; cannot be short. */
190} msdos_name_type_t;
191
192typedef enum msdos_token_types_e
193{
194    MSDOS_NO_MORE_PATH,
195    MSDOS_CURRENT_DIR,
196    MSDOS_UP_DIR,
197    MSDOS_NAME,
198    MSDOS_INVALID_TOKEN
199} msdos_token_types_t;
200
201/* Others macros */
202#define MSDOS_RES_NT_VALUE     0x00
203#define MSDOS_INIT_DIR_SIZE    0x00
204
205/* "dot" entry offset in a directory */
206#define MSDOS_DOT_DIR_ENTRY_OFFSET       0x00 /* first entry in directory */
207
208/* "dotdot" entry offset in a directory */
209#define MSDOS_DOTDOT_DIR_ENTRY_OFFSET    0x20 /* second entry in directory */
210
211/* 'p' should be char* */
212#define DOT_NODE_P(p)     ((char *)(p))
213#define DOTDOT_NODE_P(p)  ((char *)((p) + MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE))
214
215/* Size limits for files and directories */
216#define MSDOS_MAX_DIR_LENGHT               0x200000   /* 2,097,152 bytes */
217#define MSDOS_MAX_FILE_SIZE                0xFFFFFFFF /* 4 Gb */
218
219/*
220 * The number of 32 bytes long FAT Directory Entry
221 * Structures per 512 bytes sector
222 */
223#define MSDOS_DPS512_NUM    16
224
225/* Prototypes */
226int msdos_shut_down(rtems_filesystem_mount_table_entry_t *temp_mt_entry);
227
228int msdos_eval_path(
229  const char                       *pathname,    /* IN */
230  size_t                            pathnamelen, /* IN */
231  int                               flags,       /* IN */
232  rtems_filesystem_location_info_t *pathloc      /* IN/OUT */
233);
234
235int msdos_eval4make(
236  const char                       *path,     /* IN */
237  rtems_filesystem_location_info_t *pathloc,  /* IN/OUT */
238  const char                       **name     /* OUT    */
239);
240
241int msdos_unlink(rtems_filesystem_location_info_t *pathloc /* IN */);
242
243int msdos_free_node_info(rtems_filesystem_location_info_t *pathloc /* IN */);
244
245int msdos_node_type(rtems_filesystem_location_info_t    *pathloc);
246
247int msdos_mknod(
248  const char                       *path,   /* IN */
249  mode_t                            mode,   /* IN */
250  dev_t                             dev,    /* IN */
251  rtems_filesystem_location_info_t *pathloc /* IN/OUT */
252);
253
254int msdos_utime(
255  rtems_filesystem_location_info_t *pathloc, /* IN */
256  time_t                            actime,  /* IN */
257  time_t                            modtime  /* IN */
258);
259
260int msdos_rename(rtems_filesystem_location_info_t  *old_parent_loc,
261                 rtems_filesystem_location_info_t  *old_loc,
262                 rtems_filesystem_location_info_t  *new_parent_loc,
263                 const char                        *new_name);
264
265int msdos_initialize_support(
266  rtems_filesystem_mount_table_entry_t    *temp_mt_entry,
267  const rtems_filesystem_operations_table *op_table,
268  const rtems_filesystem_file_handlers_r  *file_handlers,
269  const rtems_filesystem_file_handlers_r  *directory_handlers
270);
271
272int msdos_file_open(
273  rtems_libio_t *iop,             /* IN  */
274  const char    *pathname,        /* IN  */
275  uint32_t       flag,            /* IN  */
276  uint32_t       mode             /* IN  */
277);
278
279int msdos_file_close(rtems_libio_t *iop /* IN  */);
280
281ssize_t msdos_file_read(
282  rtems_libio_t *iop,              /* IN  */
283  void          *buffer,           /* IN  */
284  size_t         count             /* IN  */
285);
286
287ssize_t msdos_file_write(
288  rtems_libio_t *iop,             /* IN  */
289  const void    *buffer,          /* IN  */
290  size_t         count            /* IN  */
291);
292
293rtems_off64_t msdos_file_lseek(
294  rtems_libio_t        *iop,              /* IN  */
295  rtems_off64_t         offset,           /* IN  */
296  int                   whence            /* IN  */
297);
298
299int msdos_file_stat(
300  rtems_filesystem_location_info_t *loc, /* IN  */
301  struct stat                      *buf  /* OUT */
302);
303
304int
305msdos_file_ftruncate(
306  rtems_libio_t *iop,               /* IN  */
307  rtems_off64_t  length            /* IN  */
308);
309
310int msdos_file_sync(rtems_libio_t *iop);
311
312int msdos_file_datasync(rtems_libio_t *iop);
313
314int msdos_file_ioctl(
315  rtems_libio_t *iop,             /* IN  */
316  uint32_t       command,         /* IN  */
317  void          *buffer           /* IN  */
318);
319
320int
321msdos_dir_chmod(
322  rtems_filesystem_location_info_t *pathloc, /* IN */
323  mode_t                            mode     /* IN */
324);
325
326int msdos_file_rmnod(rtems_filesystem_location_info_t *parent_pathloc, /* IN */
327                     rtems_filesystem_location_info_t *pathloc /* IN */);
328
329int msdos_dir_open(
330  rtems_libio_t *iop,             /* IN  */
331  const char    *pathname,        /* IN  */
332  uint32_t       flag,            /* IN  */
333  uint32_t       mode             /* IN  */
334);
335
336int msdos_dir_close(rtems_libio_t *iop /* IN  */);
337
338ssize_t msdos_dir_read(
339  rtems_libio_t *iop,              /* IN  */
340  void          *buffer,           /* IN  */
341  size_t         count             /* IN  */
342);
343
344rtems_off64_t msdos_dir_lseek(
345  rtems_libio_t        *iop,              /* IN  */
346  rtems_off64_t         offset,           /* IN  */
347  int                   whence            /* IN  */
348);
349
350int
351msdos_file_chmod(
352  rtems_filesystem_location_info_t *pathloc, /* IN */
353  mode_t                            mode     /* IN */
354);
355
356int msdos_dir_rmnod(rtems_filesystem_location_info_t *parent_pathloc, /* IN */
357                    rtems_filesystem_location_info_t *pathloc /* IN */);
358
359int msdos_dir_sync(rtems_libio_t *iop);
360
361int msdos_dir_stat(
362  rtems_filesystem_location_info_t *loc,         /* IN  */
363  struct stat                      *buf          /* OUT */
364);
365
366int msdos_creat_node(rtems_filesystem_location_info_t  *parent_loc,
367                     msdos_node_type_t                  type,
368                     const char                        *name,
369                     int                                name_len,
370                     mode_t                             mode,
371                     const fat_file_fd_t               *link_fd);
372
373/* Misc prototypes */
374msdos_token_types_t msdos_get_token(const char  *path,
375                                    int          pathlen,
376                                    const char **token,
377                                    int         *token_len);
378
379int msdos_find_name(
380  rtems_filesystem_location_info_t *parent_loc,
381  const char                       *name,
382  int                               name_len
383);
384
385int msdos_get_name_node(
386  rtems_filesystem_location_info_t *parent_loc,
387  bool                              create_node,
388  const char                       *name,
389  int                               name_len,
390  msdos_name_type_t                 name_type,
391  fat_dir_pos_t                    *dir_pos,
392  char                             *name_dir_entry
393);
394
395int msdos_dir_info_remove(rtems_filesystem_location_info_t *pathloc);
396
397msdos_name_type_t msdos_long_to_short(const char *lfn, int lfn_len,
398                                      char* sfn, int sfn_len);
399
400int msdos_filename_unix2dos(const char *un, int unlen, char *dn);
401
402void msdos_date_unix2dos(
403  unsigned int tsp, uint16_t *ddp,
404  uint16_t *dtp);
405
406unsigned int msdos_date_dos2unix(unsigned int dd, unsigned int dt);
407
408int msdos_set_first_cluster_num(
409  rtems_filesystem_mount_table_entry_t *mt_entry,
410  fat_file_fd_t                        *fat_fd
411);
412
413int msdos_set_file_size(
414  rtems_filesystem_mount_table_entry_t *mt_entry,
415  fat_file_fd_t                        *fat_fd
416);
417
418int msdos_set_first_char4file_name(
419  rtems_filesystem_mount_table_entry_t *mt_entry,
420  fat_dir_pos_t                        *dir_pos,
421  unsigned char                         first_char
422);
423
424int msdos_set_dir_wrt_time_and_date(
425    rtems_filesystem_mount_table_entry_t *mt_entry,
426    fat_file_fd_t                        *fat_fd
427);
428
429
430int msdos_dir_is_empty(
431  rtems_filesystem_mount_table_entry_t *mt_entry,
432  fat_file_fd_t                        *fat_fd,
433  bool                                 *ret_val
434);
435
436int msdos_find_name_in_fat_file(
437    rtems_filesystem_mount_table_entry_t *mt_entry,
438    fat_file_fd_t                        *fat_fd,
439    bool                                  create_node,
440    const char                           *name,
441    int                                   name_len,
442    msdos_name_type_t                     name_type,
443    fat_dir_pos_t                        *dir_pos,
444    char                                 *name_dir_entry
445);
446
447int msdos_find_node_by_cluster_num_in_fat_file(
448    rtems_filesystem_mount_table_entry_t *mt_entry,
449    fat_file_fd_t                        *fat_fd,
450    uint32_t                              cl4find,
451    fat_dir_pos_t                        *dir_pos,
452    char                                 *dir_entry
453);
454
455int msdos_get_dotdot_dir_info_cluster_num_and_offset(
456    rtems_filesystem_mount_table_entry_t *mt_entry,
457    uint32_t                              cln,
458    fat_dir_pos_t                        *dir_pos,
459    char                                 *dir_entry
460);
461
462#ifdef __cplusplus
463}
464#endif
465
466#endif /* __DOSFS_MSDOS_H__ */
Note: See TracBrowser for help on using the repository browser.