os/kernelhwsrv/userlibandfileserver/fileserver/smassstorage/inc/tfatbootsector.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2004-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
// Inline methods of TFatBootSector class.
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
/**
sl@0
    19
 @file
sl@0
    20
 @internalTechnology
sl@0
    21
 
sl@0
    22
 Returns Sectors in Fat table for 32 bit volume
sl@0
    23
 
sl@0
    24
 @return iFatSectors32
sl@0
    25
*/
sl@0
    26
inline TUint32 TFatBootSector::FatSectors32() const	
sl@0
    27
	{return iFatSectors32;}
sl@0
    28
/**
sl@0
    29
Fat flags
sl@0
    30
sl@0
    31
@return iFATFlags
sl@0
    32
*/
sl@0
    33
inline TUint16 TFatBootSector::FATFlags() const		
sl@0
    34
	{return iFATFlags;}
sl@0
    35
/**
sl@0
    36
Version number of the file system
sl@0
    37
sl@0
    38
@return iVersionNumber
sl@0
    39
*/
sl@0
    40
inline TUint16 TFatBootSector::VersionNumber() const		
sl@0
    41
	{return iVersionNumber;}
sl@0
    42
/**
sl@0
    43
Cluster number of the root directory
sl@0
    44
sl@0
    45
@return iRootClusterNum
sl@0
    46
*/
sl@0
    47
inline TUint32 TFatBootSector::RootClusterNum() const	
sl@0
    48
	{return iRootClusterNum;}
sl@0
    49
/**
sl@0
    50
Sector number containing the FSIInfo structure
sl@0
    51
sl@0
    52
@return iFSInfoSectorNum
sl@0
    53
*/
sl@0
    54
inline TUint16 TFatBootSector::FSInfoSectorNum() const
sl@0
    55
	{return iFSInfoSectorNum;}
sl@0
    56
/**
sl@0
    57
Backup boot sector
sl@0
    58
sl@0
    59
@return iBkBootRecSector
sl@0
    60
*/
sl@0
    61
inline TUint16 TFatBootSector::BkBootRecSector() const
sl@0
    62
	{return iBkBootRecSector;}
sl@0
    63
/**
sl@0
    64
Sets the number of sectors in Fat table for 32 bit volume
sl@0
    65
sl@0
    66
@param aFatSectors32
sl@0
    67
*/
sl@0
    68
inline void TFatBootSector::SetFatSectors32(TUint32	aFatSectors32)
sl@0
    69
	{iFatSectors32 = aFatSectors32;}
sl@0
    70
/**
sl@0
    71
Sets the Fat flags
sl@0
    72
sl@0
    73
@param aFATFlags
sl@0
    74
*/
sl@0
    75
inline void TFatBootSector::SetFATFlags(TUint16 aFATFlags)
sl@0
    76
	{iFATFlags = aFATFlags;}
sl@0
    77
/**
sl@0
    78
Sets the version number of the file system
sl@0
    79
sl@0
    80
@param aVersionNumber
sl@0
    81
*/
sl@0
    82
inline void TFatBootSector::SetVersionNumber(TUint16 aVersionNumber)
sl@0
    83
	{iVersionNumber = aVersionNumber;}
sl@0
    84
/**
sl@0
    85
Sets the cluster number of the root directory
sl@0
    86
sl@0
    87
@param aRootClusterNum
sl@0
    88
*/
sl@0
    89
inline void TFatBootSector::SetRootClusterNum(TUint32 aRootClusterNum)	
sl@0
    90
	{iRootClusterNum = aRootClusterNum;}
sl@0
    91
/**
sl@0
    92
Set the sector number containing the FSIInfo structure
sl@0
    93
sl@0
    94
@param aFSInfoSectorNum
sl@0
    95
*/
sl@0
    96
inline void TFatBootSector::SetFSInfoSectorNum(TUint16 aFSInfoSectorNum)
sl@0
    97
	{iFSInfoSectorNum = aFSInfoSectorNum;}
sl@0
    98
/**
sl@0
    99
Set the backup boot sector
sl@0
   100
sl@0
   101
@param aBkBootRecSector
sl@0
   102
*/
sl@0
   103
inline void TFatBootSector::SetBkBootRecSector(TUint16 aBkBootRecSector)
sl@0
   104
	{iBkBootRecSector = aBkBootRecSector;}	
sl@0
   105
/**
sl@0
   106
Quick test as to whether the volume is Fat32
sl@0
   107
sl@0
   108
@return True for Fat32
sl@0
   109
*/
sl@0
   110
inline TBool TFatBootSector::Is32BitFat()
sl@0
   111
	{return(iRootDirEntries==0);}
sl@0
   112
/**
sl@0
   113
Returns the vendor ID of the file system that formatted the volume
sl@0
   114
sl@0
   115
@return A descriptor containing the vendor ID 
sl@0
   116
*/
sl@0
   117
inline const TPtrC8 TFatBootSector::VendorId() const
sl@0
   118
	{return TPtrC8(iVendorId,KVendorIdSize);}
sl@0
   119
/**
sl@0
   120
Return the bytes per sector
sl@0
   121
sl@0
   122
@return iBytesPerSector
sl@0
   123
*/
sl@0
   124
inline TUint16 TFatBootSector::BytesPerSector() const
sl@0
   125
	{return iBytesPerSector;}
sl@0
   126
/**
sl@0
   127
Returns the sectors per cluster ratio
sl@0
   128
sl@0
   129
@return iSectorsPerCluster
sl@0
   130
*/
sl@0
   131
inline TInt TFatBootSector::SectorsPerCluster() const
sl@0
   132
	{return iSectorsPerCluster;}
sl@0
   133
/**
sl@0
   134
Returns the number of reserved sectors on the volume
sl@0
   135
sl@0
   136
@return iReservedSectors
sl@0
   137
*/
sl@0
   138
inline TInt TFatBootSector::ReservedSectors() const
sl@0
   139
	{return iReservedSectors;}
sl@0
   140
/**
sl@0
   141
Returns the number of Fats on the volume
sl@0
   142
sl@0
   143
@return iNumberOfFats
sl@0
   144
*/
sl@0
   145
inline TInt TFatBootSector::NumberOfFats() const
sl@0
   146
	{return iNumberOfFats;}
sl@0
   147
/**
sl@0
   148
Returns the number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32
sl@0
   149
sl@0
   150
@return iRootDirEntries
sl@0
   151
*/
sl@0
   152
inline TInt TFatBootSector::RootDirEntries() const
sl@0
   153
	{return iRootDirEntries;}
sl@0
   154
/**
sl@0
   155
Returns the total sectors on the volume, zero for FAT32
sl@0
   156
sl@0
   157
@return iTotalSectors
sl@0
   158
*/
sl@0
   159
inline TInt TFatBootSector::TotalSectors() const
sl@0
   160
	{return iTotalSectors;}
sl@0
   161
/**
sl@0
   162
Returns the media descriptor
sl@0
   163
sl@0
   164
@return iMediaDescriptor
sl@0
   165
*/
sl@0
   166
inline TUint8 TFatBootSector::MediaDescriptor() const
sl@0
   167
	{return iMediaDescriptor;}
sl@0
   168
/**
sl@0
   169
Returns sectors used for the Fat table, zero for FAT32
sl@0
   170
sl@0
   171
@return iFatSectors
sl@0
   172
*/
sl@0
   173
inline TInt TFatBootSector::FatSectors() const
sl@0
   174
	{return iFatSectors;}
sl@0
   175
/**
sl@0
   176
Returns sectors per track
sl@0
   177
sl@0
   178
@return iSectorsPerTrack
sl@0
   179
*/
sl@0
   180
inline TInt TFatBootSector::SectorsPerTrack() const
sl@0
   181
	{return iSectorsPerTrack;}
sl@0
   182
/**
sl@0
   183
Returns the number of heads 
sl@0
   184
sl@0
   185
@return iNumberOfHeads
sl@0
   186
*/
sl@0
   187
inline TInt TFatBootSector::NumberOfHeads() const
sl@0
   188
	{return iNumberOfHeads;}
sl@0
   189
/**
sl@0
   190
Returns the number of hidden sectors in the volume
sl@0
   191
sl@0
   192
@return iHiddenSectors
sl@0
   193
*/
sl@0
   194
inline TInt TFatBootSector::HiddenSectors() const
sl@0
   195
	{return iHiddenSectors;}
sl@0
   196
/**
sl@0
   197
Returns total sectors in the volume, Used if totalSectors > 65535
sl@0
   198
sl@0
   199
@return iHugeSectors
sl@0
   200
*/
sl@0
   201
inline TInt TFatBootSector::HugeSectors() const
sl@0
   202
	{return iHugeSectors;}
sl@0
   203
/**
sl@0
   204
Returns the physical drive number, not used in Symbian OS
sl@0
   205
sl@0
   206
@return iPhysicalDriveNumber
sl@0
   207
*/
sl@0
   208
inline TInt TFatBootSector::PhysicalDriveNumber() const
sl@0
   209
	{return iPhysicalDriveNumber;}
sl@0
   210
/**
sl@0
   211
Returns the extended boot signiture
sl@0
   212
sl@0
   213
@return iExtendedBootSignature
sl@0
   214
*/
sl@0
   215
inline TInt TFatBootSector::ExtendedBootSignature() const
sl@0
   216
	{return iExtendedBootSignature;}
sl@0
   217
/**
sl@0
   218
Returns the unique volume ID
sl@0
   219
sl@0
   220
@return iUniqueID
sl@0
   221
*/
sl@0
   222
inline TUint32 TFatBootSector::UniqueID() const
sl@0
   223
	{return iUniqueID;}
sl@0
   224
/**
sl@0
   225
Returns the volume's label
sl@0
   226
sl@0
   227
@return A descriptor containing the volume label
sl@0
   228
*/
sl@0
   229
inline const TPtrC8 TFatBootSector::VolumeLabel() const
sl@0
   230
	{return TPtrC8(iVolumeLabel,KVolumeLabelSize);}
sl@0
   231
/**
sl@0
   232
Returns the file system type
sl@0
   233
sl@0
   234
@return A descriptor containing the file system type
sl@0
   235
*/
sl@0
   236
inline const TPtrC8 TFatBootSector::FileSysType() const
sl@0
   237
	{return TPtrC8(iFileSysType,KFileSysTypeSize);}
sl@0
   238
/**
sl@0
   239
Returns the boot sector signiture
sl@0
   240
sl@0
   241
@return KBootSectorSignature
sl@0
   242
*/
sl@0
   243
inline TInt TFatBootSector::BootSectorSignature() const
sl@0
   244
	{return KBootSectorSignature;}
sl@0
   245
/**
sl@0
   246
Set the jump instruction 
sl@0
   247
*/
sl@0
   248
inline void TFatBootSector::SetJumpInstruction()
sl@0
   249
	{iJumpInstruction[0]=0xE9;iJumpInstruction[2]=0x90;}
sl@0
   250
/**
sl@0
   251
Set the vendor ID of the file system that formatted the volume
sl@0
   252
sl@0
   253
@param aDes Descriptor containing the Vendor ID
sl@0
   254
*/
sl@0
   255
inline void TFatBootSector::SetVendorID(const TDesC8& aDes)
sl@0
   256
	{
sl@0
   257
	__ASSERT_DEBUG(aDes.Length()<=KVendorIdSize,User::Panic(_L("FATFILESYS"),1));
sl@0
   258
	TPtr8 buf(iVendorId,KVendorIdSize);
sl@0
   259
	buf=aDes;
sl@0
   260
	}
sl@0
   261
/**
sl@0
   262
Sets the bytes per sector 
sl@0
   263
sl@0
   264
@param aBytesPerSector Number of bytes per sector
sl@0
   265
*/
sl@0
   266
inline void TFatBootSector::SetBytesPerSector(TInt aBytesPerSector)
sl@0
   267
	{
sl@0
   268
	__ASSERT_DEBUG(!(aBytesPerSector&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
sl@0
   269
	iBytesPerSector=(TUint16)aBytesPerSector;
sl@0
   270
	}
sl@0
   271
/**
sl@0
   272
Set the sectors per cluster ratio
sl@0
   273
sl@0
   274
@param aSectorsPerCluster Number of sectors per cluster
sl@0
   275
*/
sl@0
   276
inline void TFatBootSector::SetSectorsPerCluster(TInt aSectorsPerCluster)
sl@0
   277
	{
sl@0
   278
	__ASSERT_DEBUG(!(aSectorsPerCluster&~KMaxTUint8),User::Panic(_L("FATFILESYS"),1));
sl@0
   279
	iSectorsPerCluster=(TUint8)aSectorsPerCluster;
sl@0
   280
	}
sl@0
   281
/**
sl@0
   282
Sets the number of reserved sectors on the volume
sl@0
   283
sl@0
   284
@param aReservedSectors Number of reserved sectors
sl@0
   285
*/
sl@0
   286
inline void TFatBootSector::SetReservedSectors(TInt aReservedSectors)
sl@0
   287
	{
sl@0
   288
	__ASSERT_DEBUG(!(aReservedSectors&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
sl@0
   289
	iReservedSectors=(TUint16)aReservedSectors;
sl@0
   290
	}
sl@0
   291
/**
sl@0
   292
Sets the number of Fats on the volume
sl@0
   293
sl@0
   294
@param aNumberOfFats Number of fats
sl@0
   295
*/
sl@0
   296
inline void TFatBootSector::SetNumberOfFats(TInt aNumberOfFats)
sl@0
   297
	{
sl@0
   298
	__ASSERT_DEBUG(!(aNumberOfFats&~KMaxTUint8),User::Panic(_L("FATFILESYS"),1));
sl@0
   299
	iNumberOfFats=(TUint8)aNumberOfFats;
sl@0
   300
	}
sl@0
   301
/**
sl@0
   302
Number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32
sl@0
   303
sl@0
   304
@param aRootDirEntries
sl@0
   305
*/
sl@0
   306
inline void TFatBootSector::SetRootDirEntries(TInt aRootDirEntries)
sl@0
   307
	{
sl@0
   308
	__ASSERT_DEBUG(!(aRootDirEntries&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
sl@0
   309
	iRootDirEntries=(TUint16)aRootDirEntries;
sl@0
   310
	}
sl@0
   311
/**
sl@0
   312
Total sectors on the volume, zero for FAT32
sl@0
   313
sl@0
   314
@param aTotalSectors Total number of sectors
sl@0
   315
*/
sl@0
   316
inline void TFatBootSector::SetTotalSectors(TInt aTotalSectors)
sl@0
   317
	{
sl@0
   318
	__ASSERT_DEBUG(!(aTotalSectors&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
sl@0
   319
	iTotalSectors=(TUint16)aTotalSectors;
sl@0
   320
	}
sl@0
   321
/**
sl@0
   322
Set the media descriptor
sl@0
   323
sl@0
   324
@param aMediaDescriptor
sl@0
   325
*/
sl@0
   326
inline void TFatBootSector::SetMediaDescriptor(TUint8 aMediaDescriptor)
sl@0
   327
	{iMediaDescriptor=aMediaDescriptor;}
sl@0
   328
/**
sl@0
   329
Sectors used for the Fat table, zero for FAT32
sl@0
   330
sl@0
   331
@param aFatSectors Number of Fat sectors
sl@0
   332
*/
sl@0
   333
inline void TFatBootSector::SetFatSectors(TInt aFatSectors)
sl@0
   334
	{
sl@0
   335
	__ASSERT_DEBUG(!(aFatSectors&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
sl@0
   336
	iFatSectors=(TUint16)aFatSectors;
sl@0
   337
	}
sl@0
   338
/**
sl@0
   339
Set the sectors per track
sl@0
   340
sl@0
   341
@param aSectorsPerTrack Number of sectors per track
sl@0
   342
*/
sl@0
   343
inline void TFatBootSector::SetSectorsPerTrack(TInt aSectorsPerTrack)
sl@0
   344
	{
sl@0
   345
	__ASSERT_DEBUG(!(aSectorsPerTrack&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
sl@0
   346
	iSectorsPerTrack=(TUint16)aSectorsPerTrack;
sl@0
   347
	}
sl@0
   348
/**
sl@0
   349
Set the number of heads
sl@0
   350
sl@0
   351
@param aNumberOfHeads Number of heads
sl@0
   352
*/
sl@0
   353
inline void TFatBootSector::SetNumberOfHeads(TInt aNumberOfHeads)
sl@0
   354
	{
sl@0
   355
	__ASSERT_DEBUG(!(aNumberOfHeads&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
sl@0
   356
	iNumberOfHeads=(TUint16)aNumberOfHeads;
sl@0
   357
	}
sl@0
   358
/**
sl@0
   359
Set the number of hidden sectors in the volume
sl@0
   360
sl@0
   361
@param aHiddenSectors Number of hidden sectors
sl@0
   362
*/
sl@0
   363
inline void TFatBootSector::SetHiddenSectors(TUint32 aHiddenSectors)
sl@0
   364
	{
sl@0
   365
	iHiddenSectors=(TUint32)(aHiddenSectors);
sl@0
   366
	}
sl@0
   367
/**
sl@0
   368
Set the total sectors in the volume, Used if totalSectors > 65535
sl@0
   369
sl@0
   370
@param aHugeSectors
sl@0
   371
*/
sl@0
   372
inline void TFatBootSector::SetHugeSectors(TUint32 aHugeSectors)
sl@0
   373
	{iHugeSectors=aHugeSectors;}
sl@0
   374
/**
sl@0
   375
Physical drive number, not used in Symbian OS
sl@0
   376
sl@0
   377
@param aPhysicalDriveNumber Physical drive number 
sl@0
   378
*/
sl@0
   379
inline void TFatBootSector::SetPhysicalDriveNumber(TInt aPhysicalDriveNumber)
sl@0
   380
	{
sl@0
   381
	__ASSERT_DEBUG(!(aPhysicalDriveNumber&~KMaxTUint8),User::Panic(_L("FATFILESYS"),1));
sl@0
   382
	iPhysicalDriveNumber=(TUint8)aPhysicalDriveNumber;
sl@0
   383
	}
sl@0
   384
/**
sl@0
   385
Set the reserved byte value
sl@0
   386
sl@0
   387
@param aReservedByte Value for reserved byte
sl@0
   388
*/
sl@0
   389
inline void TFatBootSector::SetReservedByte(TUint8 aReservedByte)
sl@0
   390
	{iReserved=aReservedByte;}
sl@0
   391
/**
sl@0
   392
Set the extended boot signiture
sl@0
   393
sl@0
   394
@param anExtendedBootSignature The extended boot signiture
sl@0
   395
*/
sl@0
   396
inline void TFatBootSector::SetExtendedBootSignature(TInt anExtendedBootSignature)
sl@0
   397
	{
sl@0
   398
	__ASSERT_DEBUG(!(anExtendedBootSignature&~KMaxTUint8),User::Panic(_L("FATFILESYS"),1));
sl@0
   399
	iExtendedBootSignature=(TUint8)anExtendedBootSignature;
sl@0
   400
	}
sl@0
   401
/**
sl@0
   402
Set the unique volume ID
sl@0
   403
sl@0
   404
@param anUniqueID Set the unique ID
sl@0
   405
*/
sl@0
   406
inline void TFatBootSector::SetUniqueID(TUint32 anUniqueID)
sl@0
   407
	{iUniqueID=anUniqueID;}
sl@0
   408
/**
sl@0
   409
Set the volume's label
sl@0
   410
sl@0
   411
@param aDes A descriptor containg the volume label
sl@0
   412
*/
sl@0
   413
inline void TFatBootSector::SetVolumeLabel(const TDesC8& aDes)
sl@0
   414
	{
sl@0
   415
	__ASSERT_DEBUG(aDes.Length()<=KVolumeLabelSize,User::Panic(_L("FATFILESYS"),1));
sl@0
   416
	TPtr8 buf(iVolumeLabel,KVolumeLabelSize);
sl@0
   417
	buf=aDes;
sl@0
   418
	}
sl@0
   419
/**
sl@0
   420
Set the file system type
sl@0
   421
sl@0
   422
@param aDes A descriptor containing the file system type
sl@0
   423
*/
sl@0
   424
inline void TFatBootSector::SetFileSysType(const TDesC8& aDes)
sl@0
   425
	{
sl@0
   426
	__ASSERT_DEBUG(aDes.Length()<=8,User::Panic(_L("FATFILESYS"),1));
sl@0
   427
	TPtr8 buf(iFileSysType,8);
sl@0
   428
	buf=aDes;
sl@0
   429
	}
sl@0
   430
/**
sl@0
   431
Tests if the volume is Fat 16 or not
sl@0
   432
sl@0
   433
@return True if the volume is Fat16
sl@0
   434
*/
sl@0
   435
inline TBool TFatBootSector::Is16BitFat()
sl@0
   436
	{return(FileSysType()==_L8("FAT16   "));}
sl@0
   437
/**
sl@0
   438
Returns the position of the first sector of the first Fat
sl@0
   439
sl@0
   440
@return The first Fat sector's byte position
sl@0
   441
*/
sl@0
   442
inline TInt TFatBootSector::FirstFatSectorPos()
sl@0
   443
	{return(ReservedSectors()*BytesPerSector());}
sl@0
   444
/**
sl@0
   445
Returns the start sector number of the root directory
sl@0
   446
sl@0
   447
@return Start sector number of the root directory
sl@0
   448
*/
sl@0
   449
inline TInt TFatBootSector::RootDirStartSector()
sl@0
   450
	{return(ReservedSectors()+FatSectors()*NumberOfFats());}
sl@0
   451
/**
sl@0
   452
Returns the sector number of the first sector after the root directory 
sl@0
   453
sl@0
   454
@return 
sl@0
   455
*/
sl@0
   456
inline TInt TFatBootSector::FirstFreeSector()
sl@0
   457
	{return(RootDirStartSector()+(RootDirEntries()*KSizeOfFatDirEntry+BytesPerSector()-1)/BytesPerSector());}
sl@0
   458