Nut/OS  5.0.5
API Reference
phatfs.h
Go to the documentation of this file.
00001 #ifndef FS_PHATFS_H_
00002 #define FS_PHATFS_H_
00003 
00004 /*
00005  * Copyright (C) 2005-2006 by egnite Software GmbH. All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  * 3. Neither the name of the copyright holders nor the names of
00017  *    contributors may be used to endorse or promote products derived
00018  *    from this software without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00027  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00028  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00029  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00030  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00031  * SUCH DAMAGE.
00032  *
00033  * For additional information see http://www.ethernut.de/
00034  */
00035 
00074 #include <sys/types.h>
00075 #include <sys/file.h>
00076 #include <sys/device.h>
00077 
00078 #include <fs/phatdir.h>
00079 
00084 
00088 typedef struct _PHATFILE {
00090     uint32_t f_pos;
00092     uint32_t f_clust;
00094     uint32_t f_clust_pos;
00096     uint32_t f_sect_pos;
00098     uint32_t f_clust_prv;
00100     uint32_t f_mode;
00102     PHATDIRENT f_dirent;
00108     uint32_t f_de_sect;
00110     uint32_t f_de_offs;
00112     unsigned int f_de_dirty;
00117     uint16_t f_pde_clust;
00119     uint16_t f_pde_clusthi;
00120 } PHATFILE;
00121 
00123 #define PHATEOC     0x0FFFFFF8
00124 
00129 
00131 #define PHAT_FATTR_RDONLY    0x01
00132 
00133 #define PHAT_FATTR_HIDDEN    0x02
00134 
00135 #define PHAT_FATTR_SYSTEM    0x04
00136 
00137 #define PHAT_FATTR_VOLID     0x08
00138 
00139 #define PHAT_FATTR_DIR       0x10
00140 
00143 #define PHAT_FATTR_ARCHIV    0x20
00144 
00146 #define PHAT_FATTR_LFN      (PHAT_FATTR_RDONLY | PHAT_FATTR_HIDDEN | PHAT_FATTR_SYSTEM | PHAT_FATTR_VOLID)
00147 
00149 #define PHAT_FATTR_FILEMASK  0x37
00150 
00153 
00154 
00155 #include <fs/phat12.h>
00156 #include <fs/phat16.h>
00157 #include <fs/phat32.h>
00158 
00159 extern NUTDEVICE devPhat0;
00160 extern NUTDEVICE devPhat1;
00161 
00162 extern uint32_t AllocFirstCluster(NUTFILE * nfp);
00163 
00164 extern NUTFILE *PhatFileOpen(NUTDEVICE * dev, const char *path, int mode, int acc);
00165 extern int PhatFileClose(NUTFILE * nfp);
00166 extern int PhatFileWrite(NUTFILE * nfp, const void *buffer, int len);
00167 #ifdef __HARVARD_ARCH__
00168 extern int PhatFileWrite_P(NUTFILE * nfp, PGM_P buffer, int len);
00169 #endif
00170 extern int PhatFileRead(NUTFILE * nfp, void *buffer, int size);
00171 
00172 #endif