fat_fat.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_FAT_H_
00034 #define FAT_FAT_FAT_H_
00035 
00036 #include "../../vfs/vfs.h"
00037 #include <stdint.h>
00038 #include <libblock.h>
00039 
00040 #define FAT1            0
00041 
00042 #define FAT_CLST_RES0   0x0000
00043 #define FAT_CLST_RES1   0x0001
00044 #define FAT_CLST_FIRST  0x0002
00045 #define FAT_CLST_BAD    0xfff7
00046 #define FAT_CLST_LAST1  0xfff8
00047 #define FAT_CLST_LAST8  0xffff
00048 
00049 /* internally used to mark root directory's parent */
00050 #define FAT_CLST_ROOTPAR        FAT_CLST_RES0
00051 /* internally used to mark root directory */
00052 #define FAT_CLST_ROOT           FAT_CLST_RES1
00053 
00054 /* forward declarations */
00055 struct block;
00056 struct fat_node;
00057 struct fat_bs;
00058 
00059 typedef uint16_t fat_cluster_t;
00060 
00061 #define fat_clusters_get(numc, bs, dh, fc) \
00062     fat_cluster_walk((bs), (dh), (fc), NULL, (numc), (uint16_t) -1)
00063 extern int fat_cluster_walk(struct fat_bs *, devmap_handle_t, fat_cluster_t,
00064     fat_cluster_t *, uint16_t *, uint16_t);
00065 
00066 extern int fat_block_get(block_t **, struct fat_bs *, struct fat_node *,
00067     aoff64_t, int);
00068 extern int _fat_block_get(block_t **, struct fat_bs *, devmap_handle_t,
00069     fat_cluster_t, fat_cluster_t *, aoff64_t, int);
00070 
00071 extern int fat_append_clusters(struct fat_bs *, struct fat_node *,
00072     fat_cluster_t, fat_cluster_t);
00073 extern int fat_chop_clusters(struct fat_bs *, struct fat_node *,
00074     fat_cluster_t);
00075 extern int fat_alloc_clusters(struct fat_bs *, devmap_handle_t, unsigned,
00076     fat_cluster_t *, fat_cluster_t *);
00077 extern int fat_free_clusters(struct fat_bs *, devmap_handle_t, fat_cluster_t);
00078 extern int fat_alloc_shadow_clusters(struct fat_bs *, devmap_handle_t,
00079     fat_cluster_t *, unsigned);
00080 extern int fat_get_cluster(struct fat_bs *, devmap_handle_t, unsigned,
00081     fat_cluster_t, fat_cluster_t *);
00082 extern int fat_set_cluster(struct fat_bs *, devmap_handle_t, unsigned,
00083     fat_cluster_t, fat_cluster_t);
00084 extern int fat_fill_gap(struct fat_bs *, struct fat_node *, fat_cluster_t,
00085     aoff64_t);
00086 extern int fat_zero_cluster(struct fat_bs *, devmap_handle_t, fat_cluster_t);
00087 extern int fat_sanity_check(struct fat_bs *, devmap_handle_t);
00088 
00089 #endif
00090 

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