os/kernelhwsrv/userlibandfileserver/fileserver/sfat/filesystem_fat.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
// Public header file for "FAT" file system. Contains this file system name and optional file system - specific declarations.
sl@0
    16
//
sl@0
    17
//
sl@0
    18
//
sl@0
    19
sl@0
    20
sl@0
    21
/**
sl@0
    22
 @file
sl@0
    23
 @publishedAll
sl@0
    24
 @released
sl@0
    25
*/
sl@0
    26
sl@0
    27
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sl@0
    28
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sl@0
    29
//!!
sl@0
    30
//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
sl@0
    31
//!!
sl@0
    32
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sl@0
    33
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sl@0
    34
sl@0
    35
sl@0
    36
#if !defined(__FILESYSTEM_FAT_H__)
sl@0
    37
#define __FILESYSTEM_FAT_H__
sl@0
    38
sl@0
    39
sl@0
    40
#if !defined(__F32FILE_H__)
sl@0
    41
#include <f32file.h>
sl@0
    42
#endif
sl@0
    43
sl@0
    44
sl@0
    45
sl@0
    46
/**
sl@0
    47
    FAT filesystem name, which shall be provided to RFs::MountFileSystem() and is returned by RFs::FileSystemName() if 
sl@0
    48
    this file system is mounted on the drive. The literal is case-insensitive.
sl@0
    49
    @see RFs::MountFileSystem()
sl@0
    50
    @see RFs::FileSystemName()
sl@0
    51
*/
sl@0
    52
_LIT(KFileSystemName_FAT, "FAT");
sl@0
    53
sl@0
    54
/**
sl@0
    55
    FAT file system subtypes, literal values. These values are returned by RFs::FileSystemSubType().
sl@0
    56
    The literals are case-insensitive.
sl@0
    57
    File sytem "FAT" mounted on the drive can be one of the FAT12/FAT16/FAT32
sl@0
    58
sl@0
    59
    @see RFs::::FileSystemSubType()
sl@0
    60
*/
sl@0
    61
_LIT(KFSSubType_FAT12, "FAT12"); ///< corresponds to FAT12
sl@0
    62
_LIT(KFSSubType_FAT16, "FAT16"); ///< corresponds to FAT16   
sl@0
    63
_LIT(KFSSubType_FAT32, "FAT32"); ///< corresponds to FAT32
sl@0
    64
sl@0
    65
//------------------------------------------------------------------------------
sl@0
    66
sl@0
    67
namespace FileSystem_FAT
sl@0
    68
{
sl@0
    69
sl@0
    70
    /** Numeric representation of FAT file system sub types */
sl@0
    71
    enum TFatSubType
sl@0
    72
        {
sl@0
    73
        EInvalid = 0,       ///< invalid terminal value
sl@0
    74
        ENotSpecified = 0,  ///< not specified
sl@0
    75
sl@0
    76
        EFat12  = 12,   ///< corresponds to FAT12
sl@0
    77
        EFat16  = 16,   ///< corresponds to FAT16
sl@0
    78
        EFat32  = 32    ///< corresponds to FAT32
sl@0
    79
        };
sl@0
    80
sl@0
    81
sl@0
    82
const TUint64 KMaxSupportedFatFileSize = 0xFFFFFFFF; ///< theoretical maximum file size supported by all FAT filesystems (4GB-1)
sl@0
    83
sl@0
    84
//------------------------------------------------------------------------------
sl@0
    85
sl@0
    86
/** 
sl@0
    87
    This class describes specific parameters for formatting volume with FAT file system.
sl@0
    88
    The parameters are: FAT sub type (FAT12/16/32), Number of Sectors per cluster, Number of FAT tables, Number of reserved sectors.
sl@0
    89
    All parameters are optional and if not set, it is up to the file system implementation to decide values.
sl@0
    90
sl@0
    91
    This class package (TVolFormatParam_FATBuf) shall be passed to the RFormat::Open() as "Special format information"
sl@0
    92
sl@0
    93
    Please note that the parameters may have invalid combinations and it is not always possible to format volume with the specified
sl@0
    94
    FAT sub type, like FAT12. In this case RFormat::Open() will return corresponding error code (the concrete code depends on file system implementation).
sl@0
    95
sl@0
    96
    RFormat::Open() does not modify any data in this structure.
sl@0
    97
sl@0
    98
    @see TVolFormatParam_FATBuf
sl@0
    99
    @see RFormat::Open()
sl@0
   100
*/ 
sl@0
   101
class TVolFormatParam_FAT : public TVolFormatParam
sl@0
   102
{
sl@0
   103
 public:    
sl@0
   104
    inline TVolFormatParam_FAT();
sl@0
   105
    inline void Init();
sl@0
   106
sl@0
   107
    inline void SetFatSubType(TFatSubType aSubType);
sl@0
   108
    inline void SetFatSubType(const TDesC& aSubType);
sl@0
   109
    inline TFatSubType FatSubType() const;
sl@0
   110
    //--
sl@0
   111
    inline void SetSectPerCluster(TUint32 aSpc);
sl@0
   112
    inline TUint32 SectPerCluster() const;
sl@0
   113
    //--
sl@0
   114
    inline void SetNumFATs(TUint32 aNumFATs);
sl@0
   115
    inline TUint32 NumFATs() const;
sl@0
   116
sl@0
   117
    //--
sl@0
   118
    inline void SetReservedSectors(TUint32 aReservedSectors);
sl@0
   119
    inline TUint32 ReservedSectors() const;
sl@0
   120
sl@0
   121
sl@0
   122
 private:
sl@0
   123
    void SetFileSystemName(const TDesC& aFsName);
sl@0
   124
    
sl@0
   125
    enum ///< offsets of the data units in parent class container
sl@0
   126
        {
sl@0
   127
        KOffsetSubType =0,  //-- 0
sl@0
   128
        KOffsetReservedSec, //-- 1
sl@0
   129
        KOffsetSpc,         //-- 2
sl@0
   130
        KOffsetNumFATs,     //-- 3
sl@0
   131
        
sl@0
   132
        };
sl@0
   133
sl@0
   134
}; //TVolFormatParam_FAT
sl@0
   135
sl@0
   136
sl@0
   137
/**
sl@0
   138
    TVolFormatParam_FAT package buffer to be passed to RFormat::Open().
sl@0
   139
    @see TVolFormatParam_FAT
sl@0
   140
    @see RFormat::Open()
sl@0
   141
*/ 
sl@0
   142
typedef TPckgBuf<TVolFormatParam_FAT> TVolFormatParam_FATBuf;
sl@0
   143
sl@0
   144
sl@0
   145
sl@0
   146
//------------------------------------------------------------------------------
sl@0
   147
//-- inline functions 
sl@0
   148
//------------------------------------------------------------------------------
sl@0
   149
sl@0
   150
TVolFormatParam_FAT::TVolFormatParam_FAT() : TVolFormatParam() 
sl@0
   151
    {
sl@0
   152
     __ASSERT_COMPILE(sizeof(TVolFormatParam_FAT) == sizeof(TVolFormatParam));
sl@0
   153
     Init();
sl@0
   154
    }
sl@0
   155
sl@0
   156
//------------------------------------------------------------------------------
sl@0
   157
/** initialises the data structure with default values for all parameters and automatically sets file system name as "FAT" */
sl@0
   158
void TVolFormatParam_FAT::Init() 
sl@0
   159
    {
sl@0
   160
    TVolFormatParam::Init(); 
sl@0
   161
    TVolFormatParam::SetFileSystemName(KFileSystemName_FAT);
sl@0
   162
    }
sl@0
   163
sl@0
   164
//------------------------------------------------------------------------------
sl@0
   165
/**
sl@0
   166
    Set desired FAT subtype. 
sl@0
   167
    @param  aSubType specifies FAT12/16/32 subtype. Value 0 means "the file system will decide itself what to use"
sl@0
   168
*/
sl@0
   169
void TVolFormatParam_FAT::SetFatSubType(TFatSubType aSubType)
sl@0
   170
    {
sl@0
   171
    ASSERT(aSubType == ENotSpecified || aSubType == EFat12 || aSubType == EFat16 || aSubType == EFat32);
sl@0
   172
    SetVal(KOffsetSubType, aSubType);
sl@0
   173
    }
sl@0
   174
sl@0
   175
//------------------------------------------------------------------------------
sl@0
   176
/**
sl@0
   177
    Set desired FAT subtype using string literals, @see KFSSubType_FAT12, @see KFSSubType_FAT16, @see KFSSubType_FAT32               
sl@0
   178
    @param  aSubType    string descriptor, like "FAT16"
sl@0
   179
*/
sl@0
   180
void TVolFormatParam_FAT::SetFatSubType(const TDesC& aSubType)
sl@0
   181
    {
sl@0
   182
    TFatSubType fatType = ENotSpecified;
sl@0
   183
sl@0
   184
    if(aSubType.CompareF(KFSSubType_FAT12) == 0)
sl@0
   185
        fatType = EFat12;
sl@0
   186
    else if(aSubType.CompareF(KFSSubType_FAT16) == 0)
sl@0
   187
        fatType = EFat16;
sl@0
   188
    else if(aSubType.CompareF(KFSSubType_FAT32) == 0)
sl@0
   189
        fatType = EFat32;
sl@0
   190
    else
sl@0
   191
        { ASSERT(0);}
sl@0
   192
sl@0
   193
sl@0
   194
        SetFatSubType(fatType);
sl@0
   195
    }
sl@0
   196
sl@0
   197
//------------------------------------------------------------------------------
sl@0
   198
/** @return FAT sub type value, which is set by SetFatSubType()*/
sl@0
   199
TFatSubType TVolFormatParam_FAT::FatSubType() const 
sl@0
   200
    {
sl@0
   201
    return (TFatSubType)GetVal(KOffsetSubType);
sl@0
   202
    }
sl@0
   203
sl@0
   204
//------------------------------------------------------------------------------
sl@0
   205
/**
sl@0
   206
    Set Number of "Sectors per cluster". For valid values see FAT specs.
sl@0
   207
    @param  aSpc    Number of "Sectors per cluster". Value 0 means "the file system will decide itself what to use"       
sl@0
   208
*/
sl@0
   209
void TVolFormatParam_FAT::SetSectPerCluster(TUint32 aSpc)
sl@0
   210
    {
sl@0
   211
    SetVal(KOffsetSpc, aSpc);
sl@0
   212
    }
sl@0
   213
sl@0
   214
//------------------------------------------------------------------------------
sl@0
   215
/** @return value previously set by SetSectPerCluster() */
sl@0
   216
TUint32 TVolFormatParam_FAT::SectPerCluster() const 
sl@0
   217
    {
sl@0
   218
    return GetVal(KOffsetSpc);
sl@0
   219
    }
sl@0
   220
sl@0
   221
//------------------------------------------------------------------------------
sl@0
   222
/**
sl@0
   223
    Set Number of FAT tables on the volume. The maximum is supported by the FAT FS implementation is 2
sl@0
   224
    @param  aNumFATs    Number of FAT tables. Value 0 means "the file system will decide itself what to use"       
sl@0
   225
*/
sl@0
   226
void TVolFormatParam_FAT::SetNumFATs(TUint32 aNumFATs) 
sl@0
   227
    {
sl@0
   228
    SetVal(KOffsetNumFATs, aNumFATs);
sl@0
   229
    }
sl@0
   230
sl@0
   231
//------------------------------------------------------------------------------
sl@0
   232
/** @return value previously set by SetNumFATs() */
sl@0
   233
TUint32 TVolFormatParam_FAT::NumFATs() const 
sl@0
   234
    {
sl@0
   235
    return GetVal(KOffsetNumFATs);
sl@0
   236
    } 
sl@0
   237
sl@0
   238
//------------------------------------------------------------------------------
sl@0
   239
/**
sl@0
   240
    Set number of reserved sectors on FAT volume. The file system will validate this parameter before formatting.
sl@0
   241
    @param  aReservedSectors  number of reserved sectors. Value 0 means "the file system will decide itself what to use"       
sl@0
   242
*/
sl@0
   243
void TVolFormatParam_FAT::SetReservedSectors(TUint32 aReservedSectors)
sl@0
   244
    {
sl@0
   245
    SetVal(KOffsetReservedSec, aReservedSectors);
sl@0
   246
    }
sl@0
   247
sl@0
   248
//------------------------------------------------------------------------------
sl@0
   249
/** @return value previously set by SetReservedSectors() */
sl@0
   250
TUint32 TVolFormatParam_FAT::ReservedSectors() const 
sl@0
   251
    {
sl@0
   252
    return GetVal(KOffsetReservedSec);
sl@0
   253
    } 
sl@0
   254
sl@0
   255
sl@0
   256
sl@0
   257
sl@0
   258
//------------------------------------------------------------------------------
sl@0
   259
sl@0
   260
sl@0
   261
sl@0
   262
}//namespace FileSystem_FAT
sl@0
   263
sl@0
   264
sl@0
   265
sl@0
   266
sl@0
   267
sl@0
   268
sl@0
   269
#endif //__FILESYSTEM_FAT_H__
sl@0
   270
sl@0
   271
sl@0
   272
sl@0
   273
sl@0
   274
sl@0
   275
sl@0
   276
sl@0
   277
sl@0
   278
sl@0
   279
sl@0
   280
sl@0
   281
sl@0
   282
sl@0
   283
sl@0
   284