fat_dentry.h

00001 /*
00002  * Copyright (c) 2008 Jakub Jermar
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00033 #ifndef FAT_FAT_DENTRY_H_
00034 #define FAT_FAT_DENTRY_H_
00035 
00036 #include <stdint.h>
00037 #include <bool.h>
00038 
00039 #define FAT_NAME_LEN            8
00040 #define FAT_EXT_LEN             3
00041 
00042 #define FAT_NAME_DOT            ".       "
00043 #define FAT_NAME_DOT_DOT        "..      "
00044 #define FAT_EXT_PAD             "   "
00045 
00046 #define FAT_ATTR_RDONLY         (1 << 0)
00047 #define FAT_ATTR_VOLLABEL       (1 << 3)
00048 #define FAT_ATTR_SUBDIR         (1 << 4)
00049 
00050 #define FAT_LCASE_LOWER_NAME    0x08
00051 #define FAT_LCASE_LOWER_EXT     0x10
00052 
00053 #define FAT_PAD                 ' ' 
00054 
00055 #define FAT_DENTRY_UNUSED       0x00
00056 #define FAT_DENTRY_E5_ESC       0x05
00057 #define FAT_DENTRY_DOT          0x2e
00058 #define FAT_DENTRY_ERASED       0xe5
00059 
00060 typedef enum {
00061         FAT_DENTRY_SKIP,
00062         FAT_DENTRY_LAST,
00063         FAT_DENTRY_FREE,
00064         FAT_DENTRY_VALID
00065 } fat_dentry_clsf_t;
00066 
00067 typedef struct {
00068         uint8_t         name[8];
00069         uint8_t         ext[3];
00070         uint8_t         attr;
00071         uint8_t         lcase;
00072         uint8_t         ctime_fine;
00073         uint16_t        ctime;
00074         uint16_t        cdate;
00075         uint16_t        adate;
00076         union {
00077                 uint16_t        eaidx;          /* FAT12/FAT16 */
00078                 uint16_t        firstc_hi;      /* FAT32 */
00079         } __attribute__ ((packed));
00080         uint16_t        mtime;
00081         uint16_t        mdate;
00082         union {
00083                 uint16_t        firstc;         /* FAT12/FAT16 */
00084                 uint16_t        firstc_lo;      /* FAT32 */
00085         } __attribute__ ((packed));
00086         uint32_t        size;
00087 } __attribute__ ((packed)) fat_dentry_t;
00088 
00089 extern int fat_dentry_namecmp(char *, const char *);
00090 extern bool fat_dentry_name_verify(const char *);
00091 extern void fat_dentry_name_get(const fat_dentry_t *, char *);
00092 extern void fat_dentry_name_set(fat_dentry_t *, const char *);
00093 extern fat_dentry_clsf_t fat_classify_dentry(const fat_dentry_t *);
00094 
00095 #endif
00096 

Generated on Thu Jun 2 07:45:49 2011 for HelenOS/USB by  doxygen 1.4.7