From 92572bc3aea19b98f3150784a470fd592ad64286 Mon Sep 17 00:00:00 2001 From: Tyler Dauwalder Date: Tue, 9 Dec 2003 00:46:38 +0000 Subject: [PATCH] Added udf partition descriptor output to Build(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5635 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/bin/makeudfimage/UdfBuilder.cpp | 65 ++++++++++++++++++++++-- src/apps/bin/makeudfimage/UdfBuilder.h | 4 +- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/src/apps/bin/makeudfimage/UdfBuilder.cpp b/src/apps/bin/makeudfimage/UdfBuilder.cpp index 0e80deb333..945d269eb8 100644 --- a/src/apps/bin/makeudfimage/UdfBuilder.cpp +++ b/src/apps/bin/makeudfimage/UdfBuilder.cpp @@ -342,13 +342,72 @@ UdfBuilder::Build() } } } - vdsNumber++; + + // write partition descriptor + if (!error) { + _PrintUpdate(VERBOSITY_MEDIUM, "udf: Writing partition descriptor"); + // build partition descriptor + vdsNumber++; + uint16 partitionNumber = 0; + Udf::partition_descriptor partition; + partition.set_vds_number(vdsNumber); + partition.set_partition_flags(1); + partition.set_partition_number(partitionNumber); + partition.partition_contents() = Udf::kPartitionContentsId; + memset(partition.partition_contents_use().data, 0, + partition.partition_contents_use().size()); + partition.set_access_type(Udf::ACCESS_READ_ONLY); + partition.set_start(_Allocator().Tail()); + partition.set_length(0); + // Can't set the length till we've built most of rest of the image, + // so we'll set it to 0 now and fix it once we know how big + // the partition really is. + partition.implementation_id() = Udf::kImplementationId; + memset(partition.implementation_use().data, 0, + partition.implementation_use().size()); + memset(partition.reserved().data, 0, + partition.reserved().size()); + partition.tag().set_id(Udf::TAGID_PARTITION_DESCRIPTOR); + partition.tag().set_version(3); + partition.tag().set_serial_number(0); + // note that the checksums haven't been set yet, since the + // location is dependent on which sequence (primary or reserve) + // the descriptor is currently being written to. Thus we have to + // recalculate the checksums for each sequence. + DUMP(partition); + // write partition descriptor to primary vds + partition.tag().set_location(primaryExtent.location()+vdsNumber); + partition.tag().set_checksums(partition); + ssize_t bytes = _OutputFile().WriteAt(partition.tag().location() << _BlockShift(), + &partition, sizeof(partition)); + error = check_size_error(bytes, sizeof(partition)); + if (!error && bytes < ssize_t(_BlockSize())) { + ssize_t bytesLeft = _BlockSize() - bytes; + bytes = _OutputFile().ZeroAt((partition.tag().location() << _BlockShift()) + + bytes, bytesLeft); + error = check_size_error(bytes, bytesLeft); + } + // write partition descriptor to reserve vds + if (!error) { + partition.tag().set_location(reserveExtent.location()+vdsNumber); + partition.tag().set_checksums(partition); + ssize_t bytes = _OutputFile().WriteAt(partition.tag().location() << _BlockShift(), + &partition, sizeof(partition)); + error = check_size_error(bytes, sizeof(partition)); + if (!error && bytes < ssize_t(_BlockSize())) { + ssize_t bytesLeft = _BlockSize() - bytes; + bytes = _OutputFile().ZeroAt((partition.tag().location() << _BlockShift()) + + bytes, bytesLeft); + error = check_size_error(bytes, bytesLeft); + } + } + } + + // write logical vds // Udf::logical_volume_descriptor logical; - // write partition descriptor -// Udf::partition_descriptor partition; // Error check if (error) { diff --git a/src/apps/bin/makeudfimage/UdfBuilder.h b/src/apps/bin/makeudfimage/UdfBuilder.h index 167dd04b72..ff0e4b306c 100644 --- a/src/apps/bin/makeudfimage/UdfBuilder.h +++ b/src/apps/bin/makeudfimage/UdfBuilder.h @@ -34,8 +34,8 @@ private: static const int kMaxUpdateStringLength = 1024; OutputFile& _OutputFile() { return fOutputFile; } - uint32 _BlockSize() const { return fBlockSize; } - uint32 _BlockShift() const { return fBlockShift; } + uint32 _BlockSize() const { return fBlockSize; } + uint32 _BlockShift() const { return fBlockShift; } bool _DoUdf() const { return fDoUdf; } bool _DoIso() const { return fDoIso; } Udf::String& _UdfVolumeName() { return fUdfVolumeName; }