1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfat/filesystem_fat.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,284 @@
1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +// Public header file for "FAT" file system. Contains this file system name and optional file system - specific declarations.
1.19 +//
1.20 +//
1.21 +//
1.22 +
1.23 +
1.24 +/**
1.25 + @file
1.26 + @publishedAll
1.27 + @released
1.28 +*/
1.29 +
1.30 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1.31 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1.32 +//!!
1.33 +//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
1.34 +//!!
1.35 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1.36 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1.37 +
1.38 +
1.39 +#if !defined(__FILESYSTEM_FAT_H__)
1.40 +#define __FILESYSTEM_FAT_H__
1.41 +
1.42 +
1.43 +#if !defined(__F32FILE_H__)
1.44 +#include <f32file.h>
1.45 +#endif
1.46 +
1.47 +
1.48 +
1.49 +/**
1.50 + FAT filesystem name, which shall be provided to RFs::MountFileSystem() and is returned by RFs::FileSystemName() if
1.51 + this file system is mounted on the drive. The literal is case-insensitive.
1.52 + @see RFs::MountFileSystem()
1.53 + @see RFs::FileSystemName()
1.54 +*/
1.55 +_LIT(KFileSystemName_FAT, "FAT");
1.56 +
1.57 +/**
1.58 + FAT file system subtypes, literal values. These values are returned by RFs::FileSystemSubType().
1.59 + The literals are case-insensitive.
1.60 + File sytem "FAT" mounted on the drive can be one of the FAT12/FAT16/FAT32
1.61 +
1.62 + @see RFs::::FileSystemSubType()
1.63 +*/
1.64 +_LIT(KFSSubType_FAT12, "FAT12"); ///< corresponds to FAT12
1.65 +_LIT(KFSSubType_FAT16, "FAT16"); ///< corresponds to FAT16
1.66 +_LIT(KFSSubType_FAT32, "FAT32"); ///< corresponds to FAT32
1.67 +
1.68 +//------------------------------------------------------------------------------
1.69 +
1.70 +namespace FileSystem_FAT
1.71 +{
1.72 +
1.73 + /** Numeric representation of FAT file system sub types */
1.74 + enum TFatSubType
1.75 + {
1.76 + EInvalid = 0, ///< invalid terminal value
1.77 + ENotSpecified = 0, ///< not specified
1.78 +
1.79 + EFat12 = 12, ///< corresponds to FAT12
1.80 + EFat16 = 16, ///< corresponds to FAT16
1.81 + EFat32 = 32 ///< corresponds to FAT32
1.82 + };
1.83 +
1.84 +
1.85 +const TUint64 KMaxSupportedFatFileSize = 0xFFFFFFFF; ///< theoretical maximum file size supported by all FAT filesystems (4GB-1)
1.86 +
1.87 +//------------------------------------------------------------------------------
1.88 +
1.89 +/**
1.90 + This class describes specific parameters for formatting volume with FAT file system.
1.91 + The parameters are: FAT sub type (FAT12/16/32), Number of Sectors per cluster, Number of FAT tables, Number of reserved sectors.
1.92 + All parameters are optional and if not set, it is up to the file system implementation to decide values.
1.93 +
1.94 + This class package (TVolFormatParam_FATBuf) shall be passed to the RFormat::Open() as "Special format information"
1.95 +
1.96 + Please note that the parameters may have invalid combinations and it is not always possible to format volume with the specified
1.97 + FAT sub type, like FAT12. In this case RFormat::Open() will return corresponding error code (the concrete code depends on file system implementation).
1.98 +
1.99 + RFormat::Open() does not modify any data in this structure.
1.100 +
1.101 + @see TVolFormatParam_FATBuf
1.102 + @see RFormat::Open()
1.103 +*/
1.104 +class TVolFormatParam_FAT : public TVolFormatParam
1.105 +{
1.106 + public:
1.107 + inline TVolFormatParam_FAT();
1.108 + inline void Init();
1.109 +
1.110 + inline void SetFatSubType(TFatSubType aSubType);
1.111 + inline void SetFatSubType(const TDesC& aSubType);
1.112 + inline TFatSubType FatSubType() const;
1.113 + //--
1.114 + inline void SetSectPerCluster(TUint32 aSpc);
1.115 + inline TUint32 SectPerCluster() const;
1.116 + //--
1.117 + inline void SetNumFATs(TUint32 aNumFATs);
1.118 + inline TUint32 NumFATs() const;
1.119 +
1.120 + //--
1.121 + inline void SetReservedSectors(TUint32 aReservedSectors);
1.122 + inline TUint32 ReservedSectors() const;
1.123 +
1.124 +
1.125 + private:
1.126 + void SetFileSystemName(const TDesC& aFsName);
1.127 +
1.128 + enum ///< offsets of the data units in parent class container
1.129 + {
1.130 + KOffsetSubType =0, //-- 0
1.131 + KOffsetReservedSec, //-- 1
1.132 + KOffsetSpc, //-- 2
1.133 + KOffsetNumFATs, //-- 3
1.134 +
1.135 + };
1.136 +
1.137 +}; //TVolFormatParam_FAT
1.138 +
1.139 +
1.140 +/**
1.141 + TVolFormatParam_FAT package buffer to be passed to RFormat::Open().
1.142 + @see TVolFormatParam_FAT
1.143 + @see RFormat::Open()
1.144 +*/
1.145 +typedef TPckgBuf<TVolFormatParam_FAT> TVolFormatParam_FATBuf;
1.146 +
1.147 +
1.148 +
1.149 +//------------------------------------------------------------------------------
1.150 +//-- inline functions
1.151 +//------------------------------------------------------------------------------
1.152 +
1.153 +TVolFormatParam_FAT::TVolFormatParam_FAT() : TVolFormatParam()
1.154 + {
1.155 + __ASSERT_COMPILE(sizeof(TVolFormatParam_FAT) == sizeof(TVolFormatParam));
1.156 + Init();
1.157 + }
1.158 +
1.159 +//------------------------------------------------------------------------------
1.160 +/** initialises the data structure with default values for all parameters and automatically sets file system name as "FAT" */
1.161 +void TVolFormatParam_FAT::Init()
1.162 + {
1.163 + TVolFormatParam::Init();
1.164 + TVolFormatParam::SetFileSystemName(KFileSystemName_FAT);
1.165 + }
1.166 +
1.167 +//------------------------------------------------------------------------------
1.168 +/**
1.169 + Set desired FAT subtype.
1.170 + @param aSubType specifies FAT12/16/32 subtype. Value 0 means "the file system will decide itself what to use"
1.171 +*/
1.172 +void TVolFormatParam_FAT::SetFatSubType(TFatSubType aSubType)
1.173 + {
1.174 + ASSERT(aSubType == ENotSpecified || aSubType == EFat12 || aSubType == EFat16 || aSubType == EFat32);
1.175 + SetVal(KOffsetSubType, aSubType);
1.176 + }
1.177 +
1.178 +//------------------------------------------------------------------------------
1.179 +/**
1.180 + Set desired FAT subtype using string literals, @see KFSSubType_FAT12, @see KFSSubType_FAT16, @see KFSSubType_FAT32
1.181 + @param aSubType string descriptor, like "FAT16"
1.182 +*/
1.183 +void TVolFormatParam_FAT::SetFatSubType(const TDesC& aSubType)
1.184 + {
1.185 + TFatSubType fatType = ENotSpecified;
1.186 +
1.187 + if(aSubType.CompareF(KFSSubType_FAT12) == 0)
1.188 + fatType = EFat12;
1.189 + else if(aSubType.CompareF(KFSSubType_FAT16) == 0)
1.190 + fatType = EFat16;
1.191 + else if(aSubType.CompareF(KFSSubType_FAT32) == 0)
1.192 + fatType = EFat32;
1.193 + else
1.194 + { ASSERT(0);}
1.195 +
1.196 +
1.197 + SetFatSubType(fatType);
1.198 + }
1.199 +
1.200 +//------------------------------------------------------------------------------
1.201 +/** @return FAT sub type value, which is set by SetFatSubType()*/
1.202 +TFatSubType TVolFormatParam_FAT::FatSubType() const
1.203 + {
1.204 + return (TFatSubType)GetVal(KOffsetSubType);
1.205 + }
1.206 +
1.207 +//------------------------------------------------------------------------------
1.208 +/**
1.209 + Set Number of "Sectors per cluster". For valid values see FAT specs.
1.210 + @param aSpc Number of "Sectors per cluster". Value 0 means "the file system will decide itself what to use"
1.211 +*/
1.212 +void TVolFormatParam_FAT::SetSectPerCluster(TUint32 aSpc)
1.213 + {
1.214 + SetVal(KOffsetSpc, aSpc);
1.215 + }
1.216 +
1.217 +//------------------------------------------------------------------------------
1.218 +/** @return value previously set by SetSectPerCluster() */
1.219 +TUint32 TVolFormatParam_FAT::SectPerCluster() const
1.220 + {
1.221 + return GetVal(KOffsetSpc);
1.222 + }
1.223 +
1.224 +//------------------------------------------------------------------------------
1.225 +/**
1.226 + Set Number of FAT tables on the volume. The maximum is supported by the FAT FS implementation is 2
1.227 + @param aNumFATs Number of FAT tables. Value 0 means "the file system will decide itself what to use"
1.228 +*/
1.229 +void TVolFormatParam_FAT::SetNumFATs(TUint32 aNumFATs)
1.230 + {
1.231 + SetVal(KOffsetNumFATs, aNumFATs);
1.232 + }
1.233 +
1.234 +//------------------------------------------------------------------------------
1.235 +/** @return value previously set by SetNumFATs() */
1.236 +TUint32 TVolFormatParam_FAT::NumFATs() const
1.237 + {
1.238 + return GetVal(KOffsetNumFATs);
1.239 + }
1.240 +
1.241 +//------------------------------------------------------------------------------
1.242 +/**
1.243 + Set number of reserved sectors on FAT volume. The file system will validate this parameter before formatting.
1.244 + @param aReservedSectors number of reserved sectors. Value 0 means "the file system will decide itself what to use"
1.245 +*/
1.246 +void TVolFormatParam_FAT::SetReservedSectors(TUint32 aReservedSectors)
1.247 + {
1.248 + SetVal(KOffsetReservedSec, aReservedSectors);
1.249 + }
1.250 +
1.251 +//------------------------------------------------------------------------------
1.252 +/** @return value previously set by SetReservedSectors() */
1.253 +TUint32 TVolFormatParam_FAT::ReservedSectors() const
1.254 + {
1.255 + return GetVal(KOffsetReservedSec);
1.256 + }
1.257 +
1.258 +
1.259 +
1.260 +
1.261 +//------------------------------------------------------------------------------
1.262 +
1.263 +
1.264 +
1.265 +}//namespace FileSystem_FAT
1.266 +
1.267 +
1.268 +
1.269 +
1.270 +
1.271 +
1.272 +#endif //__FILESYSTEM_FAT_H__
1.273 +
1.274 +
1.275 +
1.276 +
1.277 +
1.278 +
1.279 +
1.280 +
1.281 +
1.282 +
1.283 +
1.284 +
1.285 +
1.286 +
1.287 +