os/kernelhwsrv/userlibandfileserver/fileserver/smassstorage/inc/tfatbootsector.inl
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Inline methods of TFatBootSector class.
22 Returns Sectors in Fat table for 32 bit volume
26 inline TUint32 TFatBootSector::FatSectors32() const
27 {return iFatSectors32;}
33 inline TUint16 TFatBootSector::FATFlags() const
36 Version number of the file system
38 @return iVersionNumber
40 inline TUint16 TFatBootSector::VersionNumber() const
41 {return iVersionNumber;}
43 Cluster number of the root directory
45 @return iRootClusterNum
47 inline TUint32 TFatBootSector::RootClusterNum() const
48 {return iRootClusterNum;}
50 Sector number containing the FSIInfo structure
52 @return iFSInfoSectorNum
54 inline TUint16 TFatBootSector::FSInfoSectorNum() const
55 {return iFSInfoSectorNum;}
59 @return iBkBootRecSector
61 inline TUint16 TFatBootSector::BkBootRecSector() const
62 {return iBkBootRecSector;}
64 Sets the number of sectors in Fat table for 32 bit volume
68 inline void TFatBootSector::SetFatSectors32(TUint32 aFatSectors32)
69 {iFatSectors32 = aFatSectors32;}
75 inline void TFatBootSector::SetFATFlags(TUint16 aFATFlags)
76 {iFATFlags = aFATFlags;}
78 Sets the version number of the file system
82 inline void TFatBootSector::SetVersionNumber(TUint16 aVersionNumber)
83 {iVersionNumber = aVersionNumber;}
85 Sets the cluster number of the root directory
87 @param aRootClusterNum
89 inline void TFatBootSector::SetRootClusterNum(TUint32 aRootClusterNum)
90 {iRootClusterNum = aRootClusterNum;}
92 Set the sector number containing the FSIInfo structure
94 @param aFSInfoSectorNum
96 inline void TFatBootSector::SetFSInfoSectorNum(TUint16 aFSInfoSectorNum)
97 {iFSInfoSectorNum = aFSInfoSectorNum;}
99 Set the backup boot sector
101 @param aBkBootRecSector
103 inline void TFatBootSector::SetBkBootRecSector(TUint16 aBkBootRecSector)
104 {iBkBootRecSector = aBkBootRecSector;}
106 Quick test as to whether the volume is Fat32
108 @return True for Fat32
110 inline TBool TFatBootSector::Is32BitFat()
111 {return(iRootDirEntries==0);}
113 Returns the vendor ID of the file system that formatted the volume
115 @return A descriptor containing the vendor ID
117 inline const TPtrC8 TFatBootSector::VendorId() const
118 {return TPtrC8(iVendorId,KVendorIdSize);}
120 Return the bytes per sector
122 @return iBytesPerSector
124 inline TUint16 TFatBootSector::BytesPerSector() const
125 {return iBytesPerSector;}
127 Returns the sectors per cluster ratio
129 @return iSectorsPerCluster
131 inline TInt TFatBootSector::SectorsPerCluster() const
132 {return iSectorsPerCluster;}
134 Returns the number of reserved sectors on the volume
136 @return iReservedSectors
138 inline TInt TFatBootSector::ReservedSectors() const
139 {return iReservedSectors;}
141 Returns the number of Fats on the volume
143 @return iNumberOfFats
145 inline TInt TFatBootSector::NumberOfFats() const
146 {return iNumberOfFats;}
148 Returns the number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32
150 @return iRootDirEntries
152 inline TInt TFatBootSector::RootDirEntries() const
153 {return iRootDirEntries;}
155 Returns the total sectors on the volume, zero for FAT32
157 @return iTotalSectors
159 inline TInt TFatBootSector::TotalSectors() const
160 {return iTotalSectors;}
162 Returns the media descriptor
164 @return iMediaDescriptor
166 inline TUint8 TFatBootSector::MediaDescriptor() const
167 {return iMediaDescriptor;}
169 Returns sectors used for the Fat table, zero for FAT32
173 inline TInt TFatBootSector::FatSectors() const
174 {return iFatSectors;}
176 Returns sectors per track
178 @return iSectorsPerTrack
180 inline TInt TFatBootSector::SectorsPerTrack() const
181 {return iSectorsPerTrack;}
183 Returns the number of heads
185 @return iNumberOfHeads
187 inline TInt TFatBootSector::NumberOfHeads() const
188 {return iNumberOfHeads;}
190 Returns the number of hidden sectors in the volume
192 @return iHiddenSectors
194 inline TInt TFatBootSector::HiddenSectors() const
195 {return iHiddenSectors;}
197 Returns total sectors in the volume, Used if totalSectors > 65535
201 inline TInt TFatBootSector::HugeSectors() const
202 {return iHugeSectors;}
204 Returns the physical drive number, not used in Symbian OS
206 @return iPhysicalDriveNumber
208 inline TInt TFatBootSector::PhysicalDriveNumber() const
209 {return iPhysicalDriveNumber;}
211 Returns the extended boot signiture
213 @return iExtendedBootSignature
215 inline TInt TFatBootSector::ExtendedBootSignature() const
216 {return iExtendedBootSignature;}
218 Returns the unique volume ID
222 inline TUint32 TFatBootSector::UniqueID() const
225 Returns the volume's label
227 @return A descriptor containing the volume label
229 inline const TPtrC8 TFatBootSector::VolumeLabel() const
230 {return TPtrC8(iVolumeLabel,KVolumeLabelSize);}
232 Returns the file system type
234 @return A descriptor containing the file system type
236 inline const TPtrC8 TFatBootSector::FileSysType() const
237 {return TPtrC8(iFileSysType,KFileSysTypeSize);}
239 Returns the boot sector signiture
241 @return KBootSectorSignature
243 inline TInt TFatBootSector::BootSectorSignature() const
244 {return KBootSectorSignature;}
246 Set the jump instruction
248 inline void TFatBootSector::SetJumpInstruction()
249 {iJumpInstruction[0]=0xE9;iJumpInstruction[2]=0x90;}
251 Set the vendor ID of the file system that formatted the volume
253 @param aDes Descriptor containing the Vendor ID
255 inline void TFatBootSector::SetVendorID(const TDesC8& aDes)
257 __ASSERT_DEBUG(aDes.Length()<=KVendorIdSize,User::Panic(_L("FATFILESYS"),1));
258 TPtr8 buf(iVendorId,KVendorIdSize);
262 Sets the bytes per sector
264 @param aBytesPerSector Number of bytes per sector
266 inline void TFatBootSector::SetBytesPerSector(TInt aBytesPerSector)
268 __ASSERT_DEBUG(!(aBytesPerSector&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
269 iBytesPerSector=(TUint16)aBytesPerSector;
272 Set the sectors per cluster ratio
274 @param aSectorsPerCluster Number of sectors per cluster
276 inline void TFatBootSector::SetSectorsPerCluster(TInt aSectorsPerCluster)
278 __ASSERT_DEBUG(!(aSectorsPerCluster&~KMaxTUint8),User::Panic(_L("FATFILESYS"),1));
279 iSectorsPerCluster=(TUint8)aSectorsPerCluster;
282 Sets the number of reserved sectors on the volume
284 @param aReservedSectors Number of reserved sectors
286 inline void TFatBootSector::SetReservedSectors(TInt aReservedSectors)
288 __ASSERT_DEBUG(!(aReservedSectors&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
289 iReservedSectors=(TUint16)aReservedSectors;
292 Sets the number of Fats on the volume
294 @param aNumberOfFats Number of fats
296 inline void TFatBootSector::SetNumberOfFats(TInt aNumberOfFats)
298 __ASSERT_DEBUG(!(aNumberOfFats&~KMaxTUint8),User::Panic(_L("FATFILESYS"),1));
299 iNumberOfFats=(TUint8)aNumberOfFats;
302 Number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32
304 @param aRootDirEntries
306 inline void TFatBootSector::SetRootDirEntries(TInt aRootDirEntries)
308 __ASSERT_DEBUG(!(aRootDirEntries&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
309 iRootDirEntries=(TUint16)aRootDirEntries;
312 Total sectors on the volume, zero for FAT32
314 @param aTotalSectors Total number of sectors
316 inline void TFatBootSector::SetTotalSectors(TInt aTotalSectors)
318 __ASSERT_DEBUG(!(aTotalSectors&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
319 iTotalSectors=(TUint16)aTotalSectors;
322 Set the media descriptor
324 @param aMediaDescriptor
326 inline void TFatBootSector::SetMediaDescriptor(TUint8 aMediaDescriptor)
327 {iMediaDescriptor=aMediaDescriptor;}
329 Sectors used for the Fat table, zero for FAT32
331 @param aFatSectors Number of Fat sectors
333 inline void TFatBootSector::SetFatSectors(TInt aFatSectors)
335 __ASSERT_DEBUG(!(aFatSectors&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
336 iFatSectors=(TUint16)aFatSectors;
339 Set the sectors per track
341 @param aSectorsPerTrack Number of sectors per track
343 inline void TFatBootSector::SetSectorsPerTrack(TInt aSectorsPerTrack)
345 __ASSERT_DEBUG(!(aSectorsPerTrack&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
346 iSectorsPerTrack=(TUint16)aSectorsPerTrack;
349 Set the number of heads
351 @param aNumberOfHeads Number of heads
353 inline void TFatBootSector::SetNumberOfHeads(TInt aNumberOfHeads)
355 __ASSERT_DEBUG(!(aNumberOfHeads&~KMaxTUint16),User::Panic(_L("FATFILESYS"),1));
356 iNumberOfHeads=(TUint16)aNumberOfHeads;
359 Set the number of hidden sectors in the volume
361 @param aHiddenSectors Number of hidden sectors
363 inline void TFatBootSector::SetHiddenSectors(TUint32 aHiddenSectors)
365 iHiddenSectors=(TUint32)(aHiddenSectors);
368 Set the total sectors in the volume, Used if totalSectors > 65535
372 inline void TFatBootSector::SetHugeSectors(TUint32 aHugeSectors)
373 {iHugeSectors=aHugeSectors;}
375 Physical drive number, not used in Symbian OS
377 @param aPhysicalDriveNumber Physical drive number
379 inline void TFatBootSector::SetPhysicalDriveNumber(TInt aPhysicalDriveNumber)
381 __ASSERT_DEBUG(!(aPhysicalDriveNumber&~KMaxTUint8),User::Panic(_L("FATFILESYS"),1));
382 iPhysicalDriveNumber=(TUint8)aPhysicalDriveNumber;
385 Set the reserved byte value
387 @param aReservedByte Value for reserved byte
389 inline void TFatBootSector::SetReservedByte(TUint8 aReservedByte)
390 {iReserved=aReservedByte;}
392 Set the extended boot signiture
394 @param anExtendedBootSignature The extended boot signiture
396 inline void TFatBootSector::SetExtendedBootSignature(TInt anExtendedBootSignature)
398 __ASSERT_DEBUG(!(anExtendedBootSignature&~KMaxTUint8),User::Panic(_L("FATFILESYS"),1));
399 iExtendedBootSignature=(TUint8)anExtendedBootSignature;
402 Set the unique volume ID
404 @param anUniqueID Set the unique ID
406 inline void TFatBootSector::SetUniqueID(TUint32 anUniqueID)
407 {iUniqueID=anUniqueID;}
409 Set the volume's label
411 @param aDes A descriptor containg the volume label
413 inline void TFatBootSector::SetVolumeLabel(const TDesC8& aDes)
415 __ASSERT_DEBUG(aDes.Length()<=KVolumeLabelSize,User::Panic(_L("FATFILESYS"),1));
416 TPtr8 buf(iVolumeLabel,KVolumeLabelSize);
420 Set the file system type
422 @param aDes A descriptor containing the file system type
424 inline void TFatBootSector::SetFileSysType(const TDesC8& aDes)
426 __ASSERT_DEBUG(aDes.Length()<=8,User::Panic(_L("FATFILESYS"),1));
427 TPtr8 buf(iFileSysType,8);
431 Tests if the volume is Fat 16 or not
433 @return True if the volume is Fat16
435 inline TBool TFatBootSector::Is16BitFat()
436 {return(FileSysType()==_L8("FAT16 "));}
438 Returns the position of the first sector of the first Fat
440 @return The first Fat sector's byte position
442 inline TInt TFatBootSector::FirstFatSectorPos()
443 {return(ReservedSectors()*BytesPerSector());}
445 Returns the start sector number of the root directory
447 @return Start sector number of the root directory
449 inline TInt TFatBootSector::RootDirStartSector()
450 {return(ReservedSectors()+FatSectors()*NumberOfFats());}
452 Returns the sector number of the first sector after the root directory
456 inline TInt TFatBootSector::FirstFreeSector()
457 {return(RootDirStartSector()+(RootDirEntries()*KSizeOfFatDirEntry+BytesPerSector()-1)/BytesPerSector());}