VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/libzip/zip_source_begin_write_cloning.c
blob: 41b4c73c3d94fc84ca8c6662ab7fa4747770566d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
  zip_source_begin_write_cloning.c -- clone part of file for writing
  Copyright (C) 2017-2019 Dieter Baron and Thomas Klausner

  This file is part of libzip, a library to manipulate ZIP archives.
  The authors can be contacted at <libzip@nih.at>

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met:
  1. Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
     distribution.
  3. The names of the authors may not be used to endorse or promote
     products derived from this software without specific prior
     written permission.

  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/


#include "zipint.h"


ZIP_EXTERN int
zip_source_begin_write_cloning(zip_source_t *src, zip_uint64_t offset) {
    if (ZIP_SOURCE_IS_OPEN_WRITING(src)) {
	zip_error_set(&src->error, ZIP_ER_INVAL, 0);
	return -1;
    }

    if (_zip_source_call(src, NULL, offset, ZIP_SOURCE_BEGIN_WRITE_CLONING) < 0) {
	return -1;
    }

    src->write_state = ZIP_SOURCE_WRITE_OPEN;

    return 0;
}
span>446]; PartitionEntryMBR Partitions[4]; uint16 Signature; }; struct BiosLbaPacket { byte Size; byte Reserved; uint16 SectorCount; uint32 Buffer; uint64 Sector; }; #pragma pack() struct ChsAddress { uint16 Cylinder; byte Head; byte Sector; }; struct Partition { byte Number; byte Drive; bool Active; uint64 EndSector; bool Primary; uint64 SectorCount; uint64 StartSector; byte Type; }; struct DriveGeometry { uint16 Cylinders; byte Heads; byte Sectors; }; #ifdef TC_BOOT_DEBUG_ENABLED void AcquireSectorBuffer (); void ReleaseSectorBuffer (); #else # define AcquireSectorBuffer() # define ReleaseSectorBuffer() #endif void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba); bool GetActivePartition (byte drive); BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent = false); BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly = false, Partition *findPartitionFollowingThis = nullptr, bool silent = false); bool IsLbaSupported (byte drive); void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs); void Print (const ChsAddress &chs); void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs = nullptr); void PrintSectorCountInMB (const uint64 &sectorCount); BiosResult ReadWriteMBR (bool write, byte drive, bool silent = false); BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 &sector, uint16 sectorCount, bool silent = false); BiosResult ReadSectors (byte *buffer, byte drive, const uint64 &sector, uint16 sectorCount, bool silent = false); BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false); BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 &sector, uint16 sectorCount, bool silent); BiosResult WriteSectors (byte *buffer, byte drive, const uint64 &sector, uint16 sectorCount, bool silent = false); BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false); extern byte SectorBuffer[TC_LB_SIZE]; #endif // TC_HEADER_Boot_BootDiskIo