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