Loading...
Searching...
No Matches
metadata.c
Go to the documentation of this file.
/*
* This file is part of the Aaru Data Preservation Suite.
* Copyright (c) 2019-2026 Natalia Portillo.
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include <stddef.h>
#include <stdint.h>
#include "aaruformat.h"
#include "log.h"
AARU_EXPORT int32_t AARU_CALL aaruf_get_geometry(const void *context, uint32_t *cylinders, uint32_t *heads,
uint32_t *sectors_per_track)
{
TRACE("Entering aaruf_get_geometry(%p, %p, %p, %p)", context, cylinders, heads, sectors_per_track);
const aaruformat_context *ctx = NULL;
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_geometry() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_geometry() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->geometry_block.identifier != GeometryBlock)
{
FATAL("No geometry block present");
TRACE("Exiting aaruf_get_geometry() = AARUF_ERROR_CANNOT_READ_BLOCK");
return AARUF_ERROR_CANNOT_READ_BLOCK;
}
*cylinders = ctx->geometry_block.cylinders;
*heads = ctx->geometry_block.heads;
*sectors_per_track = ctx->geometry_block.sectorsPerTrack;
TRACE("Exiting aaruf_get_geometry(%p, %u, %u, %u) = AARUF_STATUS_OK", context, *cylinders, *heads,
*sectors_per_track);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_geometry(void *context, const uint32_t cylinders, const uint32_t heads,
const uint32_t sectors_per_track)
{
TRACE("Entering aaruf_set_geometry(%p, %u, %u, %u)", context, cylinders, heads, sectors_per_track);
aaruformat_context *ctx = NULL;
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_geometry() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_geometry() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_write_sector() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
ctx->geometry_block.identifier = GeometryBlock;
ctx->geometry_block.cylinders = cylinders;
ctx->geometry_block.heads = heads;
ctx->geometry_block.sectorsPerTrack = sectors_per_track;
ctx->cylinders = cylinders;
ctx->heads = heads;
ctx->sectors_per_track = sectors_per_track;
ctx->dirty_geometry_block = true; // Mark geometry block as dirty
TRACE("Exiting aaruf_set_geometry(%p, %u, %u, %u) = AARUF_STATUS_OK", context, cylinders, heads, sectors_per_track);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_media_sequence(void *context, const int32_t sequence,
const int32_t last_sequence)
{
TRACE("Entering aaruf_set_media_sequence(%p, %d, %d)", context, sequence, last_sequence);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_set_media_sequence() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
// Initialize
if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
ctx->metadata_block_header.mediaSequence = sequence;
ctx->metadata_block_header.lastMediaSequence = last_sequence;
TRACE("Exiting aaruf_set_media_sequence(%p, %d, %d) = AARUF_STATUS_OK", context, sequence, last_sequence);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_creator(void *context, const uint8_t *data, const int32_t length)
{
TRACE("Entering aaruf_set_creator(%p, %p, %d)", context, data, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_creator() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_creator() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_set_creator() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
// Initialize
if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
// Reserve memory
uint8_t *copy = malloc(length);
if(copy == NULL)
{
FATAL("Could not allocate memory for creator");
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
}
// Copy opaque UTF-16LE string
memcpy(copy, data, length);
if(ctx->creator != NULL) free(ctx->creator);
ctx->creator = copy;
ctx->metadata_block_header.creatorLength = length;
TRACE("Exiting aaruf_set_creator(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_comments(void *context, const uint8_t *data, const int32_t length)
{
TRACE("Entering aaruf_set_comments(%p, %p, %d)", context, data, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_comments() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_comments() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_set_comments() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
// Initialize
if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
// Reserve memory
uint8_t *copy = malloc(length);
if(copy == NULL)
{
FATAL("Could not allocate memory for comments");
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
}
// Copy opaque UTF-16LE string
memcpy(copy, data, length);
if(ctx->comments != NULL) free(ctx->comments);
ctx->comments = copy;
ctx->metadata_block_header.commentsLength = length;
TRACE("Exiting aaruf_set_comments(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_media_title(void *context, const uint8_t *data, const int32_t length)
{
TRACE("Entering aaruf_set_media_title(%p, %p, %d)", context, data, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_set_media_title() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
// Initialize
if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
// Reserve memory
uint8_t *copy = malloc(length);
if(copy == NULL)
{
FATAL("Could not allocate memory for media title");
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
}
// Copy opaque UTF-16LE string
memcpy(copy, data, length);
if(ctx->media_title != NULL) free(ctx->media_title);
ctx->media_title = copy;
ctx->metadata_block_header.mediaTitleLength = length;
ctx->dirty_metadata_block = true; // Mark metadata block as dirty
TRACE("Exiting aaruf_set_media_title(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_media_manufacturer(void *context, const uint8_t *data, const int32_t length)
{
TRACE("Entering aaruf_set_media_manufacturer(%p, %p, %d)", context, data, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_set_media_manufacturer() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
// Initialize
if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
// Reserve memory
uint8_t *copy = malloc(length);
if(copy == NULL)
{
FATAL("Could not allocate memory for media manufacturer");
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
}
// Copy opaque UTF-16LE string
memcpy(copy, data, length);
if(ctx->media_manufacturer != NULL) free(ctx->media_manufacturer);
ctx->media_manufacturer = copy;
ctx->metadata_block_header.mediaManufacturerLength = length;
TRACE("Exiting aaruf_set_media_manufacturer(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_media_model(void *context, const uint8_t *data, const int32_t length)
{
TRACE("Entering aaruf_set_media_model(%p, %p, %d)", context, data, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_set_media_model() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
// Initialize
if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
// Reserve memory
uint8_t *copy = malloc(length);
if(copy == NULL)
{
FATAL("Could not allocate memory for media model");
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
}
// Copy opaque UTF-16LE string
memcpy(copy, data, length);
if(ctx->media_model != NULL) free(ctx->media_model);
ctx->media_model = copy;
ctx->metadata_block_header.mediaModelLength = length;
TRACE("Exiting aaruf_set_media_model(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_media_serial_number(void *context, const uint8_t *data, const int32_t length)
{
TRACE("Entering aaruf_set_media_serial_number(%p, %p, %d)", context, data, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_set_media_serial_number() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
// Initialize
if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
// Reserve memory
uint8_t *copy = malloc(length);
if(copy == NULL)
{
FATAL("Could not allocate memory for media serial number");
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
}
// Copy opaque UTF-16LE string
memcpy(copy, data, length);
if(ctx->media_serial_number != NULL) free(ctx->media_serial_number);
ctx->media_serial_number = copy;
ctx->metadata_block_header.mediaSerialNumberLength = length;
TRACE("Exiting aaruf_set_media_serial_number(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_media_barcode(void *context, const uint8_t *data, const int32_t length)
{
TRACE("Entering aaruf_set_media_barcode(%p, %p, %d)", context, data, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_set_media_barcode() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
// Initialize
if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
// Reserve memory
uint8_t *copy = malloc(length);
if(copy == NULL)
{
FATAL("Could not allocate memory for media barcode");
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
}
// Copy opaque UTF-16LE string
memcpy(copy, data, length);
if(ctx->media_barcode != NULL) free(ctx->media_barcode);
ctx->media_barcode = copy;
ctx->metadata_block_header.mediaBarcodeLength = length;
TRACE("Exiting aaruf_set_media_barcode(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_media_part_number(void *context, const uint8_t *data, const int32_t length)
{
TRACE("Entering aaruf_set_media_part_number(%p, %p, %d)", context, data, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_set_media_part_number() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
// Initialize
if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
// Reserve memory
uint8_t *copy = malloc(length);
if(copy == NULL)
{
FATAL("Could not allocate memory for creator");
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
}
// Copy opaque UTF-16LE string
memcpy(copy, data, length);
if(ctx->media_part_number != NULL) free(ctx->media_part_number);
ctx->media_part_number = copy;
ctx->metadata_block_header.mediaPartNumberLength = length;
TRACE("Exiting aaruf_set_media_part_number(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_manufacturer(void *context, const uint8_t *data, const int32_t length)
{
TRACE("Entering aaruf_set_drive_manufacturer(%p, %p, %d)", context, data, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_set_drive_manufacturer() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
// Initialize
if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
// Reserve memory
uint8_t *copy = malloc(length);
if(copy == NULL)
{
FATAL("Could not allocate memory for drive manufacturer");
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
}
// Copy opaque UTF-16LE string
memcpy(copy, data, length);
if(ctx->drive_manufacturer != NULL) free(ctx->drive_manufacturer);
ctx->drive_manufacturer = copy;
ctx->metadata_block_header.driveManufacturerLength = length;
TRACE("Exiting aaruf_set_drive_manufacturer(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_model(void *context, const uint8_t *data, const int32_t length)
{
TRACE("Entering aaruf_set_drive_model(%p, %p, %d)", context, data, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_set_drive_model() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
// Initialize
if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
// Reserve memory
uint8_t *copy = malloc(length);
if(copy == NULL)
{
FATAL("Could not allocate memory for media model");
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
}
// Copy opaque UTF-16LE string
memcpy(copy, data, length);
if(ctx->drive_model != NULL) free(ctx->drive_model);
ctx->drive_model = copy;
ctx->metadata_block_header.driveModelLength = length;
TRACE("Exiting aaruf_set_drive_model(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_serial_number(void *context, const uint8_t *data, const int32_t length)
{
TRACE("Entering aaruf_set_drive_serial_number(%p, %p, %d)", context, data, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_set_drive_serial_number() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
// Initialize
if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
// Reserve memory
uint8_t *copy = malloc(length);
if(copy == NULL)
{
FATAL("Could not allocate memory for drive serial number");
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
}
// Copy opaque UTF-16LE string
memcpy(copy, data, length);
if(ctx->drive_serial_number != NULL) free(ctx->drive_serial_number);
ctx->drive_serial_number = copy;
ctx->metadata_block_header.driveSerialNumberLength = length;
TRACE("Exiting aaruf_set_drive_serial_number(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_firmware_revision(void *context, const uint8_t *data,
const int32_t length)
{
TRACE("Entering aaruf_set_drive_firmware_revision(%p, %p, %d)", context, data, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_set_drive_firmware_revision() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
// Initialize
if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
// Reserve memory
uint8_t *copy = malloc(length);
if(copy == NULL)
{
FATAL("Could not allocate memory for creator");
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
}
// Copy opaque UTF-16LE string
memcpy(copy, data, length);
if(ctx->drive_firmware_revision != NULL) free(ctx->drive_firmware_revision);
ctx->drive_firmware_revision = copy;
ctx->metadata_block_header.driveFirmwareRevisionLength = length;
TRACE("Exiting aaruf_set_drive_firmware_revision(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_cicm_metadata(const void *context, uint8_t *buffer, size_t *length)
{
TRACE("Entering aaruf_get_cicm_metadata(%p, %p, %p)", context, buffer, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_cicm_metadata() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_cicm_metadata() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->cicm_block == NULL || ctx->cicm_block_header.length == 0 || ctx->cicm_block_header.identifier != CicmBlock)
{
TRACE("No CICM XML metadata present");
*length = 0;
TRACE("Exiting aaruf_get_cicm_metadata() = AARUF_ERROR_CANNOT_READ_BLOCK");
return AARUF_ERROR_CANNOT_READ_BLOCK;
}
if(*length < ctx->cicm_block_header.length)
{
TRACE("Buffer too small for CICM XML metadata, required %u bytes", ctx->cicm_block_header.length);
*length = ctx->cicm_block_header.length;
TRACE("Exiting aaruf_get_cicm_metadata() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
*length = ctx->cicm_block_header.length;
memcpy(buffer, ctx->cicm_block, ctx->cicm_block_header.length);
TRACE("CICM XML metadata read successfully, length %u", *length);
TRACE("Exiting aaruf_get_cicm_metadata(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_aaru_json_metadata(const void *context, uint8_t *buffer, size_t *length)
{
TRACE("Entering aaruf_get_aaru_json_metadata(%p, %p, %p)", context, buffer, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_aaru_json_metadata() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_aaru_json_metadata() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->json_block == NULL || ctx->json_block_header.length == 0 ||
ctx->json_block_header.identifier != AaruMetadataJsonBlock)
{
TRACE("No Aaru metadata JSON present");
*length = 0;
TRACE("Exiting aaruf_get_aaru_json_metadata() = AARUF_ERROR_CANNOT_READ_BLOCK");
return AARUF_ERROR_CANNOT_READ_BLOCK;
}
if(*length < ctx->json_block_header.length)
{
TRACE("Buffer too small for Aaru metadata JSON, required %u bytes", ctx->json_block_header.length);
*length = ctx->json_block_header.length;
TRACE("Exiting aaruf_get_aaru_json_metadata() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
*length = ctx->json_block_header.length;
memcpy(buffer, ctx->json_block, ctx->json_block_header.length);
TRACE("Aaru metadata JSON read successfully, length %u", *length);
TRACE("Exiting aaruf_get_aaru_json_metadata(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_set_aaru_json_metadata(void *context, uint8_t *data, size_t length)
{
TRACE("Entering aaruf_set_aaru_json_metadata(%p, %p, %d)", context, data, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_aaru_json_metadata() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_aaru_json_metadata() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_set_aaru_json_metadata() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
// Reserve memory
uint8_t *copy = malloc(length);
if(copy == NULL)
{
FATAL("Could not allocate memory for Aaru metadata JSON");
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
}
// Copy opaque UTF-8 string
memcpy(copy, data, length);
if(ctx->json_block != NULL) free(ctx->json_block);
ctx->json_block = copy;
ctx->json_block_header.identifier = AaruMetadataJsonBlock;
ctx->json_block_header.length = (uint32_t)length;
ctx->dirty_json_block = true; // Mark JSON block as dirty
TRACE("Exiting aaruf_set_aaru_json_metadata(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_media_sequence(const void *context, int32_t *sequence, int32_t *last_sequence)
{
TRACE("Entering aaruf_get_media_sequence(%p, %p, %p)", context, sequence, last_sequence);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_set_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->metadata_block_header.identifier != MetadataBlock)
{
FATAL("No metadata block present");
TRACE("Exiting aaruf_set_media_sequence() = AARUF_ERROR_METADATA_NOT_PRESENT");
return AARUF_ERROR_METADATA_NOT_PRESENT;
}
*sequence = ctx->metadata_block_header.mediaSequence;
*last_sequence = ctx->metadata_block_header.lastMediaSequence;
TRACE("Exiting aaruf_set_media_sequence(%p, %d, %d) = AARUF_STATUS_OK", context, *sequence, *last_sequence);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_creator(const void *context, uint8_t *buffer, int32_t *length)
{
TRACE("Entering aaruf_get_creator(%p, %p, %p)", context, buffer, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_creator() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_creator() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->creator == NULL ||
ctx->metadata_block_header.creatorLength == 0)
{
FATAL("No metadata block present");
TRACE("Exiting aaruf_get_creator() = AARUF_ERROR_METADATA_NOT_PRESENT");
return AARUF_ERROR_METADATA_NOT_PRESENT;
}
if(buffer == NULL || *length < ctx->metadata_block_header.creatorLength)
{
*length = ctx->metadata_block_header.creatorLength;
TRACE("Exiting aaruf_get_creator() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
// Copy opaque UTF-16LE string
memcpy(buffer, ctx->creator, ctx->metadata_block_header.creatorLength);
*length = ctx->metadata_block_header.creatorLength;
TRACE("Exiting aaruf_get_creator(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_comments(const void *context, uint8_t *buffer, int32_t *length)
{
TRACE("Entering aaruf_get_comments(%p, %p, %p)", context, buffer, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_comments() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_comments() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->comments == NULL ||
ctx->metadata_block_header.commentsLength == 0)
{
FATAL("No metadata block present");
TRACE("Exiting aaruf_get_comments() = AARUF_ERROR_METADATA_NOT_PRESENT");
return AARUF_ERROR_METADATA_NOT_PRESENT;
}
if(buffer == NULL || *length < ctx->metadata_block_header.commentsLength)
{
*length = ctx->metadata_block_header.commentsLength;
TRACE("Exiting aaruf_get_comments() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
// Copy opaque UTF-16LE string
memcpy(buffer, ctx->comments, ctx->metadata_block_header.commentsLength);
*length = ctx->metadata_block_header.commentsLength;
TRACE("Exiting aaruf_get_comments(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_media_title(const void *context, uint8_t *buffer, int32_t *length)
{
TRACE("Entering aaruf_get_media_title(%p, %p, %p)", context, buffer, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->media_title == NULL ||
ctx->metadata_block_header.mediaTitleLength == 0)
{
FATAL("No metadata block present");
TRACE("Exiting aaruf_get_media_title() = AARUF_ERROR_METADATA_NOT_PRESENT");
return AARUF_ERROR_METADATA_NOT_PRESENT;
}
if(buffer == NULL || *length < ctx->metadata_block_header.mediaTitleLength)
{
*length = ctx->metadata_block_header.mediaTitleLength;
TRACE("Exiting aaruf_get_media_title() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
// Copy opaque UTF-16LE string
memcpy(buffer, ctx->media_title, ctx->metadata_block_header.mediaTitleLength);
*length = ctx->metadata_block_header.mediaTitleLength;
TRACE("Exiting aaruf_get_media_title(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_media_manufacturer(const void *context, uint8_t *buffer, int32_t *length)
{
TRACE("Entering aaruf_get_media_manufacturer(%p, %p, %p)", context, buffer, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->media_manufacturer == NULL ||
ctx->metadata_block_header.mediaManufacturerLength == 0)
{
FATAL("No metadata block present");
TRACE("Exiting aaruf_get_media_manufacturer() = AARUF_ERROR_METADATA_NOT_PRESENT");
return AARUF_ERROR_METADATA_NOT_PRESENT;
}
if(buffer == NULL || *length < ctx->metadata_block_header.mediaManufacturerLength)
{
*length = ctx->metadata_block_header.mediaManufacturerLength;
TRACE("Exiting aaruf_get_media_manufacturer() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
// Copy opaque UTF-16LE string
memcpy(buffer, ctx->media_manufacturer, ctx->metadata_block_header.mediaManufacturerLength);
*length = ctx->metadata_block_header.mediaManufacturerLength;
TRACE("Exiting aaruf_get_media_manufacturer(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_media_model(const void *context, uint8_t *buffer, int32_t *length)
{
TRACE("Entering aaruf_get_media_model(%p, %p, %p)", context, buffer, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->media_model == NULL ||
ctx->metadata_block_header.mediaModelLength == 0)
{
FATAL("No metadata block present");
TRACE("Exiting aaruf_get_media_model() = AARUF_ERROR_METADATA_NOT_PRESENT");
return AARUF_ERROR_METADATA_NOT_PRESENT;
}
if(buffer == NULL || *length < ctx->metadata_block_header.mediaModelLength)
{
*length = ctx->metadata_block_header.mediaModelLength;
TRACE("Exiting aaruf_get_media_model() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
// Copy opaque UTF-16LE string
memcpy(buffer, ctx->media_model, ctx->metadata_block_header.mediaModelLength);
*length = ctx->metadata_block_header.mediaModelLength;
TRACE("Exiting aaruf_get_media_model(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_media_serial_number(const void *context, uint8_t *buffer, int32_t *length)
{
TRACE("Entering aaruf_get_media_serial_number(%p, %p, %p)", context, buffer, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->media_serial_number == NULL ||
ctx->metadata_block_header.mediaSerialNumberLength == 0)
{
FATAL("No metadata block present");
TRACE("Exiting aaruf_get_media_serial_number() = AARUF_ERROR_METADATA_NOT_PRESENT");
return AARUF_ERROR_METADATA_NOT_PRESENT;
}
if(buffer == NULL || *length < ctx->metadata_block_header.mediaSerialNumberLength)
{
*length = ctx->metadata_block_header.mediaSerialNumberLength;
TRACE("Exiting aaruf_get_media_serial_number() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
// Copy opaque UTF-16LE string
memcpy(buffer, ctx->media_serial_number, ctx->metadata_block_header.mediaSerialNumberLength);
*length = ctx->metadata_block_header.mediaSerialNumberLength;
TRACE("Exiting aaruf_get_media_serial_number(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_media_barcode(const void *context, uint8_t *buffer, int32_t *length)
{
TRACE("Entering aaruf_get_media_barcode(%p, %p, %p)", context, buffer, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->media_barcode == NULL ||
ctx->metadata_block_header.mediaBarcodeLength == 0)
{
FATAL("No metadata block present");
TRACE("Exiting aaruf_get_media_barcode() = AARUF_ERROR_METADATA_NOT_PRESENT");
return AARUF_ERROR_METADATA_NOT_PRESENT;
}
if(buffer == NULL || *length < ctx->metadata_block_header.mediaBarcodeLength)
{
*length = ctx->metadata_block_header.mediaBarcodeLength;
TRACE("Exiting aaruf_get_media_barcode() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
// Copy opaque UTF-16LE string
memcpy(buffer, ctx->media_barcode, ctx->metadata_block_header.mediaBarcodeLength);
*length = ctx->metadata_block_header.mediaBarcodeLength;
TRACE("Exiting aaruf_get_media_barcode(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_media_part_number(const void *context, uint8_t *buffer, int32_t *length)
{
TRACE("Entering aaruf_get_media_part_number(%p, %p, %p)", context, buffer, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->media_part_number == NULL ||
ctx->metadata_block_header.mediaPartNumberLength == 0)
{
FATAL("No metadata block present");
TRACE("Exiting aaruf_get_media_part_number() = AARUF_ERROR_METADATA_NOT_PRESENT");
return AARUF_ERROR_METADATA_NOT_PRESENT;
}
if(buffer == NULL || *length < ctx->metadata_block_header.mediaPartNumberLength)
{
*length = ctx->metadata_block_header.mediaPartNumberLength;
TRACE("Exiting aaruf_get_media_part_number() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
// Copy opaque UTF-16LE string
memcpy(buffer, ctx->media_part_number, ctx->metadata_block_header.mediaPartNumberLength);
*length = ctx->metadata_block_header.mediaPartNumberLength;
TRACE("Exiting aaruf_get_media_part_number(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_drive_manufacturer(const void *context, uint8_t *buffer, int32_t *length)
{
TRACE("Entering aaruf_get_drive_manufacturer(%p, %p, %p)", context, buffer, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->drive_manufacturer == NULL ||
ctx->metadata_block_header.driveManufacturerLength == 0)
{
FATAL("No metadata block present");
TRACE("Exiting aaruf_get_drive_manufacturer() = AARUF_ERROR_METADATA_NOT_PRESENT");
return AARUF_ERROR_METADATA_NOT_PRESENT;
}
if(buffer == NULL || *length < ctx->metadata_block_header.driveManufacturerLength)
{
*length = ctx->metadata_block_header.driveManufacturerLength;
TRACE("Exiting aaruf_get_drive_manufacturer() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
// Copy opaque UTF-16LE string
memcpy(buffer, ctx->drive_manufacturer, ctx->metadata_block_header.driveManufacturerLength);
*length = ctx->metadata_block_header.driveManufacturerLength;
TRACE("Exiting aaruf_get_drive_manufacturer(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_drive_model(const void *context, uint8_t *buffer, int32_t *length)
{
TRACE("Entering aaruf_get_drive_model(%p, %p, %p)", context, buffer, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->drive_model == NULL ||
ctx->metadata_block_header.driveModelLength == 0)
{
FATAL("No metadata block present");
TRACE("Exiting aaruf_get_drive_model() = AARUF_ERROR_METADATA_NOT_PRESENT");
return AARUF_ERROR_METADATA_NOT_PRESENT;
}
if(buffer == NULL || *length < ctx->metadata_block_header.driveModelLength)
{
*length = ctx->metadata_block_header.driveModelLength;
TRACE("Exiting aaruf_get_drive_model() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
// Copy opaque UTF-16LE string
memcpy(buffer, ctx->drive_model, ctx->metadata_block_header.driveModelLength);
*length = ctx->metadata_block_header.driveModelLength;
TRACE("Exiting aaruf_get_drive_model(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_drive_serial_number(const void *context, uint8_t *buffer, int32_t *length)
{
TRACE("Entering aaruf_get_drive_serial_number(%p, %p, %p)", context, buffer, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->drive_serial_number == NULL ||
ctx->metadata_block_header.driveSerialNumberLength == 0)
{
FATAL("No metadata block present");
TRACE("Exiting aaruf_get_drive_serial_number() = AARUF_ERROR_METADATA_NOT_PRESENT");
return AARUF_ERROR_METADATA_NOT_PRESENT;
}
if(buffer == NULL || *length < ctx->metadata_block_header.driveSerialNumberLength)
{
*length = ctx->metadata_block_header.driveSerialNumberLength;
TRACE("Exiting aaruf_get_drive_serial_number() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
// Copy opaque UTF-16LE string
memcpy(buffer, ctx->drive_serial_number, ctx->metadata_block_header.driveSerialNumberLength);
*length = ctx->metadata_block_header.driveSerialNumberLength;
TRACE("Exiting aaruf_get_drive_serial_number(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_drive_firmware_revision(const void *context, uint8_t *buffer, int32_t *length)
{
TRACE("Entering aaruf_get_drive_firmware_revision(%p, %p, %p)", context, buffer, length);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->drive_firmware_revision == NULL ||
ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
{
FATAL("No metadata block present");
TRACE("Exiting aaruf_get_drive_firmware_revision() = AARUF_ERROR_METADATA_NOT_PRESENT");
return AARUF_ERROR_METADATA_NOT_PRESENT;
}
if(buffer == NULL || *length < ctx->metadata_block_header.driveFirmwareRevisionLength)
{
*length = ctx->metadata_block_header.driveFirmwareRevisionLength;
TRACE("Exiting aaruf_get_drive_firmware_revision() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
// Copy opaque UTF-16LE string
memcpy(buffer, ctx->drive_firmware_revision, ctx->metadata_block_header.driveFirmwareRevisionLength);
*length = ctx->metadata_block_header.driveFirmwareRevisionLength;
TRACE("Exiting aaruf_get_drive_firmware_revision(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_user_sectors(const void *context, uint64_t *sectors)
{
TRACE("Entering aaruf_get_user_sectors(%p, %p)", context, sectors);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_user_sectors() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_user_sectors() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
*sectors = ctx->user_data_ddt_header.blocks;
TRACE("Exiting aaruf_get_user_sectors(%p, %llu) = AARUF_STATUS_OK", context, *sectors);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_negative_sectors(const void *context, uint32_t *sectors)
{
TRACE("Entering aaruf_get_negative_sectors(%p, %p)", context, sectors);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_negative_sectors() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_negative_sectors() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
*sectors = ctx->user_data_ddt_header.negative;
TRACE("Exiting aaruf_get_negative_sectors(%p, %u) = AARUF_STATUS_OK", context, *sectors);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_overflow_sectors(const void *context, uint32_t *sectors)
{
TRACE("Entering aaruf_get_overflow_sectors(%p, %p)", context, sectors);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_overflow_sectors() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_overflow_sectors() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
*sectors = ctx->user_data_ddt_header.overflow;
TRACE("Exiting aaruf_get_overflow_sectors(%p, %u) = AARUF_STATUS_OK", context, *sectors);
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_get_image_info(const void *context, ImageInfo *image_info)
{
TRACE("Entering aaruf_get_image_info(%p, %p)", context, image_info);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_image_info() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
const aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_get_image_info() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
if(image_info == NULL)
{
FATAL("image_info parameter is NULL");
TRACE("Exiting aaruf_get_image_info() = AARUF_ERROR_INCORRECT_DATA_SIZE");
return AARUF_ERROR_INCORRECT_DATA_SIZE;
}
// Perform deep copy of the image_info structure
memcpy(image_info, &ctx->image_info, sizeof(ImageInfo));
TRACE("Exiting aaruf_get_image_info() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_sequence(void *context)
{
TRACE("Entering aaruf_clear_media_sequence(%p)", context);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_clear_media_sequence() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
if(ctx->metadata_block_header.identifier != MetadataBlock)
{
TRACE("Exiting aaruf_clear_media_sequence() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
ctx->metadata_block_header.mediaSequence = 0;
ctx->metadata_block_header.lastMediaSequence = 0;
// Check if all metadata is clear
if(ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaSerialNumberLength == 0 &&
ctx->metadata_block_header.mediaBarcodeLength == 0 && ctx->metadata_block_header.mediaPartNumberLength == 0 &&
ctx->metadata_block_header.driveModelLength == 0 && ctx->metadata_block_header.driveManufacturerLength == 0 &&
ctx->metadata_block_header.driveSerialNumberLength == 0 &&
ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
ctx->metadata_block_header.identifier = 0;
TRACE("Exiting aaruf_clear_media_sequence() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_clear_creator(void *context)
{
TRACE("Entering aaruf_clear_creator(%p)", context);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_creator() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_creator() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_clear_creator() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
if(ctx->metadata_block_header.identifier != MetadataBlock)
{
TRACE("Exiting aaruf_clear_creator() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
if(ctx->creator != NULL) free(ctx->creator);
ctx->creator = NULL;
ctx->metadata_block_header.creatorLength = 0;
// Check if all metadata is clear
if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
ctx->metadata_block_header.commentsLength == 0 && ctx->metadata_block_header.mediaTitleLength == 0 &&
ctx->metadata_block_header.mediaManufacturerLength == 0 && ctx->metadata_block_header.mediaModelLength == 0 &&
ctx->metadata_block_header.mediaSerialNumberLength == 0 && ctx->metadata_block_header.mediaBarcodeLength == 0 &&
ctx->metadata_block_header.mediaPartNumberLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
ctx->metadata_block_header.driveManufacturerLength == 0 &&
ctx->metadata_block_header.driveSerialNumberLength == 0 &&
ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
ctx->metadata_block_header.identifier = 0;
TRACE("Exiting aaruf_clear_creator() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_clear_comments(void *context)
{
TRACE("Entering aaruf_clear_comments(%p)", context);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_comments() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_comments() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_clear_comments() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
if(ctx->metadata_block_header.identifier != MetadataBlock)
{
TRACE("Exiting aaruf_clear_comments() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
if(ctx->comments != NULL) free(ctx->comments);
ctx->comments = NULL;
ctx->metadata_block_header.commentsLength = 0;
// Check if all metadata is clear
if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.mediaTitleLength == 0 &&
ctx->metadata_block_header.mediaManufacturerLength == 0 && ctx->metadata_block_header.mediaModelLength == 0 &&
ctx->metadata_block_header.mediaSerialNumberLength == 0 && ctx->metadata_block_header.mediaBarcodeLength == 0 &&
ctx->metadata_block_header.mediaPartNumberLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
ctx->metadata_block_header.driveManufacturerLength == 0 &&
ctx->metadata_block_header.driveSerialNumberLength == 0 &&
ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
ctx->metadata_block_header.identifier = 0;
TRACE("Exiting aaruf_clear_comments() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_title(void *context)
{
TRACE("Entering aaruf_clear_media_title(%p)", context);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_clear_media_title() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
if(ctx->metadata_block_header.identifier != MetadataBlock)
{
TRACE("Exiting aaruf_clear_media_title() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
if(ctx->media_title != NULL) free(ctx->media_title);
ctx->media_title = NULL;
ctx->metadata_block_header.mediaTitleLength = 0;
// Check if all metadata is clear
if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
ctx->metadata_block_header.mediaManufacturerLength == 0 && ctx->metadata_block_header.mediaModelLength == 0 &&
ctx->metadata_block_header.mediaSerialNumberLength == 0 && ctx->metadata_block_header.mediaBarcodeLength == 0 &&
ctx->metadata_block_header.mediaPartNumberLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
ctx->metadata_block_header.driveManufacturerLength == 0 &&
ctx->metadata_block_header.driveSerialNumberLength == 0 &&
ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
ctx->metadata_block_header.identifier = 0;
TRACE("Exiting aaruf_clear_media_title() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_manufacturer(void *context)
{
TRACE("Entering aaruf_clear_media_manufacturer(%p)", context);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
if(ctx->metadata_block_header.identifier != MetadataBlock)
{
TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
if(ctx->media_manufacturer != NULL) free(ctx->media_manufacturer);
ctx->media_manufacturer = NULL;
ctx->metadata_block_header.mediaManufacturerLength = 0;
// Check if all metadata is clear
if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaModelLength == 0 &&
ctx->metadata_block_header.mediaSerialNumberLength == 0 && ctx->metadata_block_header.mediaBarcodeLength == 0 &&
ctx->metadata_block_header.mediaPartNumberLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
ctx->metadata_block_header.driveManufacturerLength == 0 &&
ctx->metadata_block_header.driveSerialNumberLength == 0 &&
ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
ctx->metadata_block_header.identifier = 0;
TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_model(void *context)
{
TRACE("Entering aaruf_clear_media_model(%p)", context);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_clear_media_model() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
if(ctx->metadata_block_header.identifier != MetadataBlock)
{
TRACE("Exiting aaruf_clear_media_model() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
if(ctx->media_model != NULL) free(ctx->media_model);
ctx->media_model = NULL;
ctx->metadata_block_header.mediaModelLength = 0;
// Check if all metadata is clear
if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
ctx->metadata_block_header.mediaSerialNumberLength == 0 && ctx->metadata_block_header.mediaBarcodeLength == 0 &&
ctx->metadata_block_header.mediaPartNumberLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
ctx->metadata_block_header.driveManufacturerLength == 0 &&
ctx->metadata_block_header.driveSerialNumberLength == 0 &&
ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
ctx->metadata_block_header.identifier = 0;
TRACE("Exiting aaruf_clear_media_model() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_serial_number(void *context)
{
TRACE("Entering aaruf_clear_media_serial_number(%p)", context);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
if(ctx->metadata_block_header.identifier != MetadataBlock)
{
TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
if(ctx->media_serial_number != NULL) free(ctx->media_serial_number);
ctx->media_serial_number = NULL;
ctx->metadata_block_header.mediaSerialNumberLength = 0;
// Check if all metadata is clear
if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaBarcodeLength == 0 &&
ctx->metadata_block_header.mediaPartNumberLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
ctx->metadata_block_header.driveManufacturerLength == 0 &&
ctx->metadata_block_header.driveSerialNumberLength == 0 &&
ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
ctx->metadata_block_header.identifier = 0;
TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_barcode(void *context)
{
TRACE("Entering aaruf_clear_media_barcode(%p)", context);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_clear_media_barcode() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
if(ctx->metadata_block_header.identifier != MetadataBlock)
{
TRACE("Exiting aaruf_clear_media_barcode() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
if(ctx->media_barcode != NULL) free(ctx->media_barcode);
ctx->media_barcode = NULL;
ctx->metadata_block_header.mediaBarcodeLength = 0;
// Check if all metadata is clear
if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaSerialNumberLength == 0 &&
ctx->metadata_block_header.mediaPartNumberLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
ctx->metadata_block_header.driveManufacturerLength == 0 &&
ctx->metadata_block_header.driveSerialNumberLength == 0 &&
ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
ctx->metadata_block_header.identifier = 0;
TRACE("Exiting aaruf_clear_media_barcode() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_part_number(void *context)
{
TRACE("Entering aaruf_clear_media_part_number(%p)", context);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_clear_media_part_number() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
if(ctx->metadata_block_header.identifier != MetadataBlock)
{
TRACE("Exiting aaruf_clear_media_part_number() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
if(ctx->media_part_number != NULL) free(ctx->media_part_number);
ctx->media_part_number = NULL;
ctx->metadata_block_header.mediaPartNumberLength = 0;
// Check if all metadata is clear
if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaSerialNumberLength == 0 &&
ctx->metadata_block_header.mediaBarcodeLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
ctx->metadata_block_header.driveManufacturerLength == 0 &&
ctx->metadata_block_header.driveSerialNumberLength == 0 &&
ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
ctx->metadata_block_header.identifier = 0;
TRACE("Exiting aaruf_clear_media_part_number() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_manufacturer(void *context)
{
TRACE("Entering aaruf_clear_drive_manufacturer(%p)", context);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
if(ctx->metadata_block_header.identifier != MetadataBlock)
{
TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
if(ctx->drive_manufacturer != NULL) free(ctx->drive_manufacturer);
ctx->drive_manufacturer = NULL;
ctx->metadata_block_header.driveManufacturerLength = 0;
// Check if all metadata is clear
if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaSerialNumberLength == 0 &&
ctx->metadata_block_header.mediaBarcodeLength == 0 && ctx->metadata_block_header.mediaPartNumberLength == 0 &&
ctx->metadata_block_header.driveModelLength == 0 && ctx->metadata_block_header.driveSerialNumberLength == 0 &&
ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
ctx->metadata_block_header.identifier = 0;
TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_model(void *context)
{
TRACE("Entering aaruf_clear_drive_model(%p)", context);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_clear_drive_model() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
if(ctx->metadata_block_header.identifier != MetadataBlock)
{
TRACE("Exiting aaruf_clear_drive_model() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
if(ctx->drive_model != NULL) free(ctx->drive_model);
ctx->drive_model = NULL;
ctx->metadata_block_header.driveModelLength = 0;
// Check if all metadata is clear
if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaSerialNumberLength == 0 &&
ctx->metadata_block_header.mediaBarcodeLength == 0 && ctx->metadata_block_header.mediaPartNumberLength == 0 &&
ctx->metadata_block_header.driveManufacturerLength == 0 &&
ctx->metadata_block_header.driveSerialNumberLength == 0 &&
ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
ctx->metadata_block_header.identifier = 0;
TRACE("Exiting aaruf_clear_drive_model() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_serial_number(void *context)
{
TRACE("Entering aaruf_clear_drive_serial_number(%p)", context);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
if(ctx->metadata_block_header.identifier != MetadataBlock)
{
TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
if(ctx->drive_serial_number != NULL) free(ctx->drive_serial_number);
ctx->drive_serial_number = NULL;
ctx->metadata_block_header.driveSerialNumberLength = 0;
// Check if all metadata is clear
if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaSerialNumberLength == 0 &&
ctx->metadata_block_header.mediaBarcodeLength == 0 && ctx->metadata_block_header.mediaPartNumberLength == 0 &&
ctx->metadata_block_header.driveModelLength == 0 && ctx->metadata_block_header.driveManufacturerLength == 0 &&
ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
ctx->metadata_block_header.identifier = 0;
TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_firmware_revision(void *context)
{
TRACE("Entering aaruf_clear_drive_firmware_revision(%p)", context);
// Check context is correct AaruFormat context
if(context == NULL)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
aaruformat_context *ctx = context;
// Not a libaaruformat context
if(ctx->magic != AARU_MAGIC)
{
FATAL("Invalid context");
TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
return AARUF_ERROR_NOT_AARUFORMAT;
}
// Check we are writing
if(!ctx->is_writing)
{
FATAL("Trying to write a read-only image");
TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_READ_ONLY");
return AARUF_READ_ONLY;
}
if(ctx->metadata_block_header.identifier != MetadataBlock)
{
TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
if(ctx->drive_firmware_revision != NULL) free(ctx->drive_firmware_revision);
ctx->drive_firmware_revision = NULL;
ctx->metadata_block_header.driveFirmwareRevisionLength = 0;
// Check if all metadata is clear
if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaSerialNumberLength == 0 &&
ctx->metadata_block_header.mediaBarcodeLength == 0 && ctx->metadata_block_header.mediaPartNumberLength == 0 &&
ctx->metadata_block_header.driveModelLength == 0 && ctx->metadata_block_header.driveManufacturerLength == 0 &&
ctx->metadata_block_header.driveSerialNumberLength == 0)
ctx->metadata_block_header.identifier = 0;
TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_STATUS_OK");
return AARUF_STATUS_OK;
}
aaruformat.h
AARU_MAGIC
#define AARU_MAGIC
Magic identifier for AaruFormat container (ASCII "AARUFRMT").
Definition consts.h:64
AARU_CALL
#define AARU_CALL
Definition decls.h:46
AARU_EXPORT
#define AARU_EXPORT
Definition decls.h:55
GeometryBlock
@ GeometryBlock
Block containing logical geometry.
Definition enums.h:152
AaruMetadataJsonBlock
@ AaruMetadataJsonBlock
Block containing JSON version of Aaru Metadata.
Definition enums.h:163
CicmBlock
@ CicmBlock
Block containing CICM XML metadata.
Definition enums.h:155
MetadataBlock
@ MetadataBlock
Block containing metadata.
Definition enums.h:153
AARUF_STATUS_OK
#define AARUF_STATUS_OK
Sector present and read without uncorrectable errors.
Definition errors.h:77
AARUF_READ_ONLY
#define AARUF_READ_ONLY
Operation requires write mode but context is read-only.
Definition errors.h:61
AARUF_ERROR_NOT_ENOUGH_MEMORY
#define AARUF_ERROR_NOT_ENOUGH_MEMORY
Memory allocation failure (critical).
Definition errors.h:48
AARUF_ERROR_CANNOT_READ_BLOCK
#define AARUF_ERROR_CANNOT_READ_BLOCK
Generic block read failure (seek/read error).
Definition errors.h:46
AARUF_ERROR_INCORRECT_DATA_SIZE
#define AARUF_ERROR_INCORRECT_DATA_SIZE
Data size does not match expected size.
Definition errors.h:65
AARUF_ERROR_METADATA_NOT_PRESENT
#define AARUF_ERROR_METADATA_NOT_PRESENT
Requested metadata not present in image.
Definition errors.h:69
AARUF_ERROR_NOT_AARUFORMAT
#define AARUF_ERROR_NOT_AARUFORMAT
Input file/stream failed magic or structural validation.
Definition errors.h:40
AARUF_ERROR_BUFFER_TOO_SMALL
#define AARUF_ERROR_BUFFER_TOO_SMALL
Caller-supplied buffer insufficient for data.
Definition errors.h:49
log.h
FATAL
#define FATAL(fmt,...)
Definition log.h:40
TRACE
#define TRACE(fmt,...)
Definition log.h:25
aaruf_get_aaru_json_metadata
int32_t aaruf_get_aaru_json_metadata(const void *context, uint8_t *buffer, size_t *length)
Retrieves the embedded Aaru metadata JSON from the image.
Definition metadata.c:2104
aaruf_clear_media_sequence
int32_t aaruf_clear_media_sequence(void *context)
Clears the media sequence information from the image metadata.
Definition metadata.c:3746
aaruf_clear_drive_firmware_revision
int32_t aaruf_clear_drive_firmware_revision(void *context)
Clears the drive firmware revision from the image metadata.
Definition metadata.c:4864
aaruf_set_media_barcode
int32_t aaruf_set_media_barcode(void *context, const uint8_t *data, const int32_t length)
Sets the media barcode information for the image.
Definition metadata.c:1180
aaruf_set_media_model
int32_t aaruf_set_media_model(void *context, const uint8_t *data, const int32_t length)
Sets the media model or product designation for the image.
Definition metadata.c:943
aaruf_get_overflow_sectors
int32_t aaruf_get_overflow_sectors(const void *context, uint32_t *sectors)
Retrieves the number of overflow (post-gap) sectors in the AaruFormat image.
Definition metadata.c:3558
aaruf_set_media_sequence
int32_t aaruf_set_media_sequence(void *context, const int32_t sequence, const int32_t last_sequence)
Sets the media sequence information for multi-volume media sets.
Definition metadata.c:365
aaruf_get_drive_serial_number
int32_t aaruf_get_drive_serial_number(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the imaging drive's serial number metadata.
Definition metadata.c:3114
aaruf_clear_media_serial_number
int32_t aaruf_clear_media_serial_number(void *context)
Clears the media serial number from the image metadata.
Definition metadata.c:4343
aaruf_set_drive_manufacturer
int32_t aaruf_set_drive_manufacturer(void *context, const uint8_t *data, const int32_t length)
Sets the drive manufacturer information for the image.
Definition metadata.c:1416
aaruf_set_drive_model
int32_t aaruf_set_drive_model(void *context, const uint8_t *data, const int32_t length)
Sets the drive model information for the image.
Definition metadata.c:1538
aaruf_clear_media_barcode
int32_t aaruf_clear_media_barcode(void *context)
Clears the media barcode information from the image metadata.
Definition metadata.c:4429
aaruf_set_media_title
int32_t aaruf_set_media_title(void *context, const uint8_t *data, const int32_t length)
Sets the media title or label for the image.
Definition metadata.c:723
aaruf_get_negative_sectors
int32_t aaruf_get_negative_sectors(const void *context, uint32_t *sectors)
Retrieves the number of negative (pre-gap) sectors in the AaruFormat image.
Definition metadata.c:3423
aaruf_get_creator
int32_t aaruf_get_creator(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the recorded creator (operator) name from the MetadataBlock.
Definition metadata.c:2410
aaruf_get_drive_firmware_revision
int32_t aaruf_get_drive_firmware_revision(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the firmware revision metadata for the imaging drive.
Definition metadata.c:3184
aaruf_clear_media_title
int32_t aaruf_clear_media_title(void *context)
Clears the media title or label from the image metadata.
Definition metadata.c:4089
aaruf_clear_media_manufacturer
int32_t aaruf_clear_media_manufacturer(void *context)
Clears the media manufacturer information from the image metadata.
Definition metadata.c:4173
aaruf_get_cicm_metadata
int32_t aaruf_get_cicm_metadata(const void *context, uint8_t *buffer, size_t *length)
Retrieves the embedded CICM XML metadata sidecar from the image.
Definition metadata.c:1949
aaruf_clear_drive_model
int32_t aaruf_clear_drive_model(void *context)
Clears the drive model information from the image metadata.
Definition metadata.c:4687
aaruf_get_media_serial_number
int32_t aaruf_get_media_serial_number(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the media serial number recorded in the image metadata.
Definition metadata.c:2762
aaruf_get_media_part_number
int32_t aaruf_get_media_part_number(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the media part number recorded in the MetadataBlock.
Definition metadata.c:2902
aaruf_get_media_model
int32_t aaruf_get_media_model(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the media model or product designation metadata.
Definition metadata.c:2692
aaruf_get_media_manufacturer
int32_t aaruf_get_media_manufacturer(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the recorded media manufacturer name.
Definition metadata.c:2622
aaruf_get_drive_model
int32_t aaruf_get_drive_model(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the device model information for the imaging drive.
Definition metadata.c:3044
aaruf_get_media_barcode
int32_t aaruf_get_media_barcode(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the barcode assigned to the physical media or its packaging.
Definition metadata.c:2831
aaruf_get_drive_manufacturer
int32_t aaruf_get_drive_manufacturer(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the drive manufacturer metadata captured during imaging.
Definition metadata.c:2974
aaruf_clear_drive_manufacturer
int32_t aaruf_clear_drive_manufacturer(void *context)
Clears the drive manufacturer information from the image metadata.
Definition metadata.c:4601
aaruf_get_image_info
int32_t aaruf_get_image_info(const void *context, ImageInfo *image_info)
Retrieves a deep copy of the ImageInfo structure from the AaruFormat image.
Definition metadata.c:3640
aaruf_get_user_sectors
int32_t aaruf_get_user_sectors(const void *context, uint64_t *sectors)
Retrieves the total number of user-accessible sectors in the AaruFormat image.
Definition metadata.c:3298
aaruf_set_aaru_json_metadata
int32_t aaruf_set_aaru_json_metadata(void *context, uint8_t *data, size_t length)
Sets the Aaru metadata JSON for the image during creation.
Definition metadata.c:2263
aaruf_clear_media_part_number
int32_t aaruf_clear_media_part_number(void *context)
Clears the media part number or model designation from the image metadata.
Definition metadata.c:4515
aaruf_clear_comments
int32_t aaruf_clear_comments(void *context)
Clears user comments or notes from the image metadata.
Definition metadata.c:4006
aaruf_clear_media_model
int32_t aaruf_clear_media_model(void *context)
Clears the media model or product designation from the image metadata.
Definition metadata.c:4257
aaruf_get_comments
int32_t aaruf_get_comments(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the user comments or notes stored in the MetadataBlock.
Definition metadata.c:2482
aaruf_get_media_sequence
int32_t aaruf_get_media_sequence(const void *context, int32_t *sequence, int32_t *last_sequence)
Retrieves the media sequence metadata for multi-volume image sets.
Definition metadata.c:2343
aaruf_clear_drive_serial_number
int32_t aaruf_clear_drive_serial_number(void *context)
Clears the drive serial number from the image metadata.
Definition metadata.c:4776
aaruf_get_geometry
int32_t aaruf_get_geometry(const void *context, uint32_t *cylinders, uint32_t *heads, uint32_t *sectors_per_track)
Retrieves the logical CHS geometry from the AaruFormat image.
Definition metadata.c:94
aaruf_clear_creator
int32_t aaruf_clear_creator(void *context)
Clears the creator (person/operator) information from the image metadata.
Definition metadata.c:3877
aaruf_set_media_part_number
int32_t aaruf_set_media_part_number(void *context, const uint8_t *data, const int32_t length)
Sets the media part number or model designation for the image.
Definition metadata.c:1301
aaruf_set_media_serial_number
int32_t aaruf_set_media_serial_number(void *context, const uint8_t *data, const int32_t length)
Sets the media serial number for the image.
Definition metadata.c:1058
aaruf_set_geometry
int32_t aaruf_set_geometry(void *context, const uint32_t cylinders, const uint32_t heads, const uint32_t sectors_per_track)
Sets the logical CHS geometry for the AaruFormat image.
Definition metadata.c:230
aaruf_set_comments
int32_t aaruf_set_comments(void *context, const uint8_t *data, const int32_t length)
Sets user comments or notes for the image.
Definition metadata.c:610
aaruf_set_drive_firmware_revision
int32_t aaruf_set_drive_firmware_revision(void *context, const uint8_t *data, const int32_t length)
Sets the drive firmware revision for the image.
Definition metadata.c:1797
aaruf_set_media_manufacturer
int32_t aaruf_set_media_manufacturer(void *context, const uint8_t *data, const int32_t length)
Sets the media manufacturer information for the image.
Definition metadata.c:836
aaruf_set_drive_serial_number
int32_t aaruf_set_drive_serial_number(void *context, const uint8_t *data, const int32_t length)
Sets the drive serial number for the image.
Definition metadata.c:1662
aaruf_get_media_title
int32_t aaruf_get_media_title(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the media title or label captured during image creation.
Definition metadata.c:2552
aaruf_set_creator
int32_t aaruf_set_creator(void *context, const uint8_t *data, const int32_t length)
Sets the creator (person/operator) information for the image.
Definition metadata.c:496
AaruMetadataJsonBlockHeader::identifier
uint32_t identifier
Block identifier, must be BlockType::AaruMetadataJsonBlock.
Definition metadata.h:121
AaruMetadataJsonBlockHeader::length
uint32_t length
Length in bytes of the Aaru metadata JSON payload that follows.
Definition metadata.h:122
CicmMetadataBlock::length
uint32_t length
Length in bytes of the CICM metadata payload that follows.
Definition metadata.h:110
CicmMetadataBlock::identifier
uint32_t identifier
Block identifier, must be BlockType::CicmBlock.
Definition metadata.h:109
DdtHeader2::blocks
uint64_t blocks
Total internal span (negative + usable + overflow) in logical sectors.
Definition ddt.h:150
DdtHeader2::overflow
uint32_t overflow
Trailing dumped sectors beyond user area (overflow range), still mapped with entries.
Definition ddt.h:151
DdtHeader2::negative
uint32_t negative
Leading negative LBA count; added to external L to build internal index.
Definition ddt.h:149
GeometryBlockHeader::identifier
uint32_t identifier
Block identifier, must be BlockType::GeometryBlock.
Definition data.h:92
GeometryBlockHeader::cylinders
uint32_t cylinders
Number of cylinders.
Definition data.h:93
GeometryBlockHeader::heads
uint32_t heads
Number of heads (tracks per cylinder).
Definition data.h:94
GeometryBlockHeader::sectorsPerTrack
uint32_t sectorsPerTrack
Number of sectors per track.
Definition data.h:95
ImageInfo
High-level summary of an opened Aaru image containing metadata and media characteristics.
Definition aaru.h:932
MetadataBlockHeader::commentsLength
uint32_t commentsLength
Length in bytes (including null) of comments string.
Definition metadata.h:78
MetadataBlockHeader::mediaSequence
int32_t mediaSequence
Sequence number within a multi-disc / multi-volume set (0-based or 1-based as producer defines).
Definition metadata.h:72
MetadataBlockHeader::identifier
uint32_t identifier
Block identifier, must be BlockType::MetadataBlock.
Definition metadata.h:70
MetadataBlockHeader::driveModelLength
uint32_t driveModelLength
Length in bytes (including null) of drive model string.
Definition metadata.h:94
MetadataBlockHeader::driveManufacturerLength
uint32_t driveManufacturerLength
Length in bytes (including null) of drive manufacturer string.
Definition metadata.h:92
MetadataBlockHeader::mediaTitleLength
uint32_t mediaTitleLength
Length in bytes (including null) of media title string.
Definition metadata.h:80
MetadataBlockHeader::driveSerialNumberLength
uint32_t driveSerialNumberLength
Length in bytes (including null) of drive serial number string.
Definition metadata.h:96
MetadataBlockHeader::mediaManufacturerLength
uint32_t mediaManufacturerLength
Length in bytes (including null) of media manufacturer string.
Definition metadata.h:82
MetadataBlockHeader::mediaModelLength
uint32_t mediaModelLength
Length in bytes (including null) of media model string.
Definition metadata.h:84
MetadataBlockHeader::lastMediaSequence
int32_t lastMediaSequence
Total number of media in the set; 0 or 1 if single item.
Definition metadata.h:74
MetadataBlockHeader::mediaSerialNumberLength
uint32_t mediaSerialNumberLength
Length in bytes (including null) of media serial number string.
Definition metadata.h:86
MetadataBlockHeader::mediaPartNumberLength
uint32_t mediaPartNumberLength
Length in bytes (including null) of media part number string.
Definition metadata.h:90
MetadataBlockHeader::mediaBarcodeLength
uint32_t mediaBarcodeLength
Length in bytes (including null) of media barcode string.
Definition metadata.h:88
MetadataBlockHeader::creatorLength
uint32_t creatorLength
Length in bytes (including null) of creator string (0 if absent).
Definition metadata.h:76
MetadataBlockHeader::driveFirmwareRevisionLength
uint32_t driveFirmwareRevisionLength
Length in bytes (including null) of drive firmware revision string.
Definition metadata.h:98
aaruformat_context
Master context representing an open or in‑creation Aaru image.
Definition context.h:175
aaruformat_context::media_barcode
uint8_t * media_barcode
Barcode of the media represented by the image.
Definition context.h:225
aaruformat_context::user_data_ddt_header
DdtHeader2 user_data_ddt_header
Active user data DDT v2 header (primary table meta).
Definition context.h:192
aaruformat_context::creator
uint8_t * creator
Who (person) created the image?
Definition context.h:219
aaruformat_context::cicm_block
uint8_t * cicm_block
CICM XML payload.
Definition context.h:217
aaruformat_context::cylinders
uint32_t cylinders
Cylinders of the media represented by the image.
Definition context.h:237
aaruformat_context::drive_firmware_revision
uint8_t * drive_firmware_revision
Firmware revision of the drive used to read the media represented by the image.
Definition context.h:231
aaruformat_context::media_serial_number
uint8_t * media_serial_number
Serial number of the media represented by the image.
Definition context.h:224
aaruformat_context::metadata_block_header
MetadataBlockHeader metadata_block_header
Metadata block header.
Definition context.h:233
aaruformat_context::media_model
uint8_t * media_model
Model of the media represented by the image.
Definition context.h:223
aaruformat_context::drive_serial_number
uint8_t * drive_serial_number
Serial number of the drive used to read the media represented by the image.
Definition context.h:229
aaruformat_context::drive_manufacturer
uint8_t * drive_manufacturer
Manufacturer of the drive used to read the media represented by the image.
Definition context.h:227
aaruformat_context::dirty_json_block
bool dirty_json_block
True if JSON metadata block should be written during close.
Definition context.h:338
aaruformat_context::is_writing
bool is_writing
True if context opened/created for writing.
Definition context.h:295
aaruformat_context::cicm_block_header
CicmMetadataBlock cicm_block_header
CICM metadata header (if present).
Definition context.h:234
aaruformat_context::drive_model
uint8_t * drive_model
Model of the drive used to read the media represented by the image.
Definition context.h:228
aaruformat_context::magic
uint64_t magic
File magic (AARU_MAGIC) post-open.
Definition context.h:177
aaruformat_context::geometry_block
GeometryBlockHeader geometry_block
Logical geometry block (if present).
Definition context.h:232
aaruformat_context::json_block
uint8_t * json_block
JSON metadata block payload (UTF-8).
Definition context.h:218
aaruformat_context::media_part_number
uint8_t * media_part_number
Part number of the media represented by the image.
Definition context.h:226
aaruformat_context::json_block_header
AaruMetadataJsonBlockHeader json_block_header
JSON metadata block header (if present).
Definition context.h:236
aaruformat_context::dirty_metadata_block
bool dirty_metadata_block
True if metadata block should be written during close.
Definition context.h:335
aaruformat_context::sectors_per_track
uint32_t sectors_per_track
Sectors per track of the media represented by the image (for variable image, the smallest).
Definition context.h:239
aaruformat_context::comments
uint8_t * comments
Image comments.
Definition context.h:221
aaruformat_context::heads
uint32_t heads
Heads of the media represented by the image.
Definition context.h:238
aaruformat_context::image_info
ImageInfo image_info
Exposed high-level image info summary.
Definition context.h:263
aaruformat_context::media_title
uint8_t * media_title
Title of the media represented by the image.
Definition context.h:220
aaruformat_context::dirty_geometry_block
bool dirty_geometry_block
True if geometry block should be written during close.
Definition context.h:334
aaruformat_context::media_manufacturer
uint8_t * media_manufacturer
Manufacturer of the media represented by the image.
Definition context.h:222