libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
Loading...
Searching...
No Matches
metadata_write.c
Go to the documentation of this file.
1/*
2 * This file is part of the Aaru Data Preservation Suite.
3 * Copyright (c) 2019-2026 Natalia Portillo.
4 *
5 * This library is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as
7 * published by the Free Software Foundation; either version 2.1 of the
8 * License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 */
28
29#include <stddef.h>
30#include <stdint.h>
31
32#include "aaruformat.h"
33#include "log.h"
34
128AARU_EXPORT int32_t AARU_CALL aaruf_set_geometry(void *context, const uint32_t cylinders, const uint32_t heads,
129 const uint32_t sectors_per_track)
130{
131 TRACE("Entering aaruf_set_geometry(%p, %u, %u, %u)", context, cylinders, heads, sectors_per_track);
132
133 aaruformat_context *ctx = NULL;
134
135 if(context == NULL)
136 {
137 FATAL("Invalid context");
138
139 TRACE("Exiting aaruf_set_geometry() = AARUF_ERROR_NOT_AARUFORMAT");
141 }
142
143 ctx = context;
144
145 // Not a libaaruformat context
146 if(ctx->magic != AARU_MAGIC)
147 {
148 FATAL("Invalid context");
149
150 TRACE("Exiting aaruf_set_geometry() = AARUF_ERROR_NOT_AARUFORMAT");
152 }
153
154 // Check we are writing
155 if(!ctx->is_writing)
156 {
157 FATAL("Trying to write a read-only image");
158
159 TRACE("Exiting aaruf_write_sector() = AARUF_READ_ONLY");
160 return AARUF_READ_ONLY;
161 }
162
164 ctx->geometry_block.cylinders = cylinders;
165 ctx->geometry_block.heads = heads;
166 ctx->geometry_block.sectorsPerTrack = sectors_per_track;
167 ctx->cylinders = cylinders;
168 ctx->heads = heads;
169 ctx->sectors_per_track = sectors_per_track;
170 ctx->dirty_geometry_block = true; // Mark geometry block as dirty
171
172 TRACE("Exiting aaruf_set_geometry(%p, %u, %u, %u) = AARUF_STATUS_OK", context, cylinders, heads, sectors_per_track);
173 return AARUF_STATUS_OK;
174}
175
263AARU_EXPORT int32_t AARU_CALL aaruf_set_media_sequence(void *context, const int32_t sequence,
264 const int32_t last_sequence)
265{
266 TRACE("Entering aaruf_set_media_sequence(%p, %d, %d)", context, sequence, last_sequence);
267
268 // Check context is correct AaruFormat context
269 if(context == NULL)
270 {
271 FATAL("Invalid context");
272
273 TRACE("Exiting aaruf_set_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
275 }
276
277 aaruformat_context *ctx = context;
278
279 // Not a libaaruformat context
280 if(ctx->magic != AARU_MAGIC)
281 {
282 FATAL("Invalid context");
283
284 TRACE("Exiting aaruf_set_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
286 }
287
288 // Check we are writing
289 if(!ctx->is_writing)
290 {
291 FATAL("Trying to write a read-only image");
292
293 TRACE("Exiting aaruf_set_media_sequence() = AARUF_READ_ONLY");
294 return AARUF_READ_ONLY;
295 }
296
297 // Initialize
299
300 ctx->metadata_block_header.mediaSequence = sequence;
301 ctx->metadata_block_header.lastMediaSequence = last_sequence;
302
303 TRACE("Exiting aaruf_set_media_sequence(%p, %d, %d) = AARUF_STATUS_OK", context, sequence, last_sequence);
304 return AARUF_STATUS_OK;
305}
306
394AARU_EXPORT int32_t AARU_CALL aaruf_set_creator(void *context, const uint8_t *data, const int32_t length)
395{
396 TRACE("Entering aaruf_set_creator(%p, %p, %d)", context, data, length);
397
398 // Check context is correct AaruFormat context
399 if(context == NULL)
400 {
401 FATAL("Invalid context");
402
403 TRACE("Exiting aaruf_set_creator() = AARUF_ERROR_NOT_AARUFORMAT");
405 }
406
407 aaruformat_context *ctx = context;
408
409 // Not a libaaruformat context
410 if(ctx->magic != AARU_MAGIC)
411 {
412 FATAL("Invalid context");
413
414 TRACE("Exiting aaruf_set_creator() = AARUF_ERROR_NOT_AARUFORMAT");
416 }
417
418 // Check we are writing
419 if(!ctx->is_writing)
420 {
421 FATAL("Trying to write a read-only image");
422
423 TRACE("Exiting aaruf_set_creator() = AARUF_READ_ONLY");
424 return AARUF_READ_ONLY;
425 }
426
427 // Initialize
429
430 // Reserve memory
431 uint8_t *copy = malloc(length);
432 if(copy == NULL)
433 {
434 FATAL("Could not allocate memory for creator");
436 }
437
438 // Copy opaque UTF-16LE string
439 memcpy(copy, data, length);
440 if(ctx->creator != NULL) free(ctx->creator);
441 ctx->creator = copy;
443
444 TRACE("Exiting aaruf_set_creator(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
445 return AARUF_STATUS_OK;
446}
447
508AARU_EXPORT int32_t AARU_CALL aaruf_set_comments(void *context, const uint8_t *data, const int32_t length)
509{
510 TRACE("Entering aaruf_set_comments(%p, %p, %d)", context, data, length);
511
512 // Check context is correct AaruFormat context
513 if(context == NULL)
514 {
515 FATAL("Invalid context");
516
517 TRACE("Exiting aaruf_set_comments() = AARUF_ERROR_NOT_AARUFORMAT");
519 }
520
521 aaruformat_context *ctx = context;
522
523 // Not a libaaruformat context
524 if(ctx->magic != AARU_MAGIC)
525 {
526 FATAL("Invalid context");
527
528 TRACE("Exiting aaruf_set_comments() = AARUF_ERROR_NOT_AARUFORMAT");
530 }
531
532 // Check we are writing
533 if(!ctx->is_writing)
534 {
535 FATAL("Trying to write a read-only image");
536
537 TRACE("Exiting aaruf_set_comments() = AARUF_READ_ONLY");
538 return AARUF_READ_ONLY;
539 }
540
541 // Initialize
543
544 // Reserve memory
545 uint8_t *copy = malloc(length);
546 if(copy == NULL)
547 {
548 FATAL("Could not allocate memory for comments");
550 }
551
552 // Copy opaque UTF-16LE string
553 memcpy(copy, data, length);
554 if(ctx->comments != NULL) free(ctx->comments);
555 ctx->comments = copy;
557
558 TRACE("Exiting aaruf_set_comments(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
559 return AARUF_STATUS_OK;
560}
561
621AARU_EXPORT int32_t AARU_CALL aaruf_set_media_title(void *context, const uint8_t *data, const int32_t length)
622{
623 TRACE("Entering aaruf_set_media_title(%p, %p, %d)", context, data, length);
624
625 // Check context is correct AaruFormat context
626 if(context == NULL)
627 {
628 FATAL("Invalid context");
629
630 TRACE("Exiting aaruf_set_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
632 }
633
634 aaruformat_context *ctx = context;
635
636 // Not a libaaruformat context
637 if(ctx->magic != AARU_MAGIC)
638 {
639 FATAL("Invalid context");
640
641 TRACE("Exiting aaruf_set_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
643 }
644
645 // Check we are writing
646 if(!ctx->is_writing)
647 {
648 FATAL("Trying to write a read-only image");
649
650 TRACE("Exiting aaruf_set_media_title() = AARUF_READ_ONLY");
651 return AARUF_READ_ONLY;
652 }
653
654 // Initialize
656
657 // Reserve memory
658 uint8_t *copy = malloc(length);
659 if(copy == NULL)
660 {
661 FATAL("Could not allocate memory for media title");
663 }
664
665 // Copy opaque UTF-16LE string
666 memcpy(copy, data, length);
667 if(ctx->media_title != NULL) free(ctx->media_title);
668 ctx->media_title = copy;
670 ctx->dirty_metadata_block = true; // Mark metadata block as dirty
671
672 TRACE("Exiting aaruf_set_media_title(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
673 return AARUF_STATUS_OK;
674}
675
734AARU_EXPORT int32_t AARU_CALL aaruf_set_media_manufacturer(void *context, const uint8_t *data, const int32_t length)
735{
736 TRACE("Entering aaruf_set_media_manufacturer(%p, %p, %d)", context, data, length);
737
738 // Check context is correct AaruFormat context
739 if(context == NULL)
740 {
741 FATAL("Invalid context");
742
743 TRACE("Exiting aaruf_set_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
745 }
746
747 aaruformat_context *ctx = context;
748
749 // Not a libaaruformat context
750 if(ctx->magic != AARU_MAGIC)
751 {
752 FATAL("Invalid context");
753
754 TRACE("Exiting aaruf_set_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
756 }
757
758 // Check we are writing
759 if(!ctx->is_writing)
760 {
761 FATAL("Trying to write a read-only image");
762
763 TRACE("Exiting aaruf_set_media_manufacturer() = AARUF_READ_ONLY");
764 return AARUF_READ_ONLY;
765 }
766
767 // Initialize
769
770 // Reserve memory
771 uint8_t *copy = malloc(length);
772 if(copy == NULL)
773 {
774 FATAL("Could not allocate memory for media manufacturer");
776 }
777
778 // Copy opaque UTF-16LE string
779 memcpy(copy, data, length);
780 if(ctx->media_manufacturer != NULL) free(ctx->media_manufacturer);
781 ctx->media_manufacturer = copy;
783
784 TRACE("Exiting aaruf_set_media_manufacturer(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
785 return AARUF_STATUS_OK;
786}
787
841AARU_EXPORT int32_t AARU_CALL aaruf_set_media_model(void *context, const uint8_t *data, const int32_t length)
842{
843 TRACE("Entering aaruf_set_media_model(%p, %p, %d)", context, data, length);
844
845 // Check context is correct AaruFormat context
846 if(context == NULL)
847 {
848 FATAL("Invalid context");
849
850 TRACE("Exiting aaruf_set_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
852 }
853
854 aaruformat_context *ctx = context;
855
856 // Not a libaaruformat context
857 if(ctx->magic != AARU_MAGIC)
858 {
859 FATAL("Invalid context");
860
861 TRACE("Exiting aaruf_set_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
863 }
864
865 // Check we are writing
866 if(!ctx->is_writing)
867 {
868 FATAL("Trying to write a read-only image");
869
870 TRACE("Exiting aaruf_set_media_model() = AARUF_READ_ONLY");
871 return AARUF_READ_ONLY;
872 }
873
874 // Initialize
876
877 // Reserve memory
878 uint8_t *copy = malloc(length);
879 if(copy == NULL)
880 {
881 FATAL("Could not allocate memory for media model");
883 }
884
885 // Copy opaque UTF-16LE string
886 memcpy(copy, data, length);
887 if(ctx->media_model != NULL) free(ctx->media_model);
888 ctx->media_model = copy;
890
891 TRACE("Exiting aaruf_set_media_model(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
892 return AARUF_STATUS_OK;
893}
894
956AARU_EXPORT int32_t AARU_CALL aaruf_set_media_serial_number(void *context, const uint8_t *data, const int32_t length)
957{
958 TRACE("Entering aaruf_set_media_serial_number(%p, %p, %d)", context, data, length);
959
960 // Check context is correct AaruFormat context
961 if(context == NULL)
962 {
963 FATAL("Invalid context");
964
965 TRACE("Exiting aaruf_set_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
967 }
968
969 aaruformat_context *ctx = context;
970
971 // Not a libaaruformat context
972 if(ctx->magic != AARU_MAGIC)
973 {
974 FATAL("Invalid context");
975
976 TRACE("Exiting aaruf_set_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
978 }
979
980 // Check we are writing
981 if(!ctx->is_writing)
982 {
983 FATAL("Trying to write a read-only image");
984
985 TRACE("Exiting aaruf_set_media_serial_number() = AARUF_READ_ONLY");
986 return AARUF_READ_ONLY;
987 }
988
989 // Initialize
991
992 // Reserve memory
993 uint8_t *copy = malloc(length);
994 if(copy == NULL)
995 {
996 FATAL("Could not allocate memory for media serial number");
998 }
999
1000 // Copy opaque UTF-16LE string
1001 memcpy(copy, data, length);
1002 if(ctx->media_serial_number != NULL) free(ctx->media_serial_number);
1003 ctx->media_serial_number = copy;
1005
1006 TRACE("Exiting aaruf_set_media_serial_number(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1007 return AARUF_STATUS_OK;
1008}
1009
1078AARU_EXPORT int32_t AARU_CALL aaruf_set_media_barcode(void *context, const uint8_t *data, const int32_t length)
1079{
1080 TRACE("Entering aaruf_set_media_barcode(%p, %p, %d)", context, data, length);
1081
1082 // Check context is correct AaruFormat context
1083 if(context == NULL)
1084 {
1085 FATAL("Invalid context");
1086
1087 TRACE("Exiting aaruf_set_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
1089 }
1090
1091 aaruformat_context *ctx = context;
1092
1093 // Not a libaaruformat context
1094 if(ctx->magic != AARU_MAGIC)
1095 {
1096 FATAL("Invalid context");
1097
1098 TRACE("Exiting aaruf_set_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
1100 }
1101
1102 // Check we are writing
1103 if(!ctx->is_writing)
1104 {
1105 FATAL("Trying to write a read-only image");
1106
1107 TRACE("Exiting aaruf_set_media_barcode() = AARUF_READ_ONLY");
1108 return AARUF_READ_ONLY;
1109 }
1110
1111 // Initialize
1113
1114 // Reserve memory
1115 uint8_t *copy = malloc(length);
1116 if(copy == NULL)
1117 {
1118 FATAL("Could not allocate memory for media barcode");
1120 }
1121
1122 // Copy opaque UTF-16LE string
1123 memcpy(copy, data, length);
1124 if(ctx->media_barcode != NULL) free(ctx->media_barcode);
1125 ctx->media_barcode = copy;
1127
1128 TRACE("Exiting aaruf_set_media_barcode(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1129 return AARUF_STATUS_OK;
1130}
1131
1199AARU_EXPORT int32_t AARU_CALL aaruf_set_media_part_number(void *context, const uint8_t *data, const int32_t length)
1200{
1201 TRACE("Entering aaruf_set_media_part_number(%p, %p, %d)", context, data, length);
1202
1203 // Check context is correct AaruFormat context
1204 if(context == NULL)
1205 {
1206 FATAL("Invalid context");
1207
1208 TRACE("Exiting aaruf_set_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
1210 }
1211
1212 aaruformat_context *ctx = context;
1213
1214 // Not a libaaruformat context
1215 if(ctx->magic != AARU_MAGIC)
1216 {
1217 FATAL("Invalid context");
1218
1219 TRACE("Exiting aaruf_set_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
1221 }
1222
1223 // Check we are writing
1224 if(!ctx->is_writing)
1225 {
1226 FATAL("Trying to write a read-only image");
1227
1228 TRACE("Exiting aaruf_set_media_part_number() = AARUF_READ_ONLY");
1229 return AARUF_READ_ONLY;
1230 }
1231
1232 // Initialize
1234
1235 // Reserve memory
1236 uint8_t *copy = malloc(length);
1237 if(copy == NULL)
1238 {
1239 FATAL("Could not allocate memory for creator");
1241 }
1242
1243 // Copy opaque UTF-16LE string
1244 memcpy(copy, data, length);
1245 if(ctx->media_part_number != NULL) free(ctx->media_part_number);
1246 ctx->media_part_number = copy;
1248
1249 TRACE("Exiting aaruf_set_media_part_number(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1250 return AARUF_STATUS_OK;
1251}
1252
1314AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_manufacturer(void *context, const uint8_t *data, const int32_t length)
1315{
1316 TRACE("Entering aaruf_set_drive_manufacturer(%p, %p, %d)", context, data, length);
1317
1318 // Check context is correct AaruFormat context
1319 if(context == NULL)
1320 {
1321 FATAL("Invalid context");
1322
1323 TRACE("Exiting aaruf_set_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
1325 }
1326
1327 aaruformat_context *ctx = context;
1328
1329 // Not a libaaruformat context
1330 if(ctx->magic != AARU_MAGIC)
1331 {
1332 FATAL("Invalid context");
1333
1334 TRACE("Exiting aaruf_set_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
1336 }
1337
1338 // Check we are writing
1339 if(!ctx->is_writing)
1340 {
1341 FATAL("Trying to write a read-only image");
1342
1343 TRACE("Exiting aaruf_set_drive_manufacturer() = AARUF_READ_ONLY");
1344 return AARUF_READ_ONLY;
1345 }
1346
1347 // Initialize
1349
1350 // Reserve memory
1351 uint8_t *copy = malloc(length);
1352 if(copy == NULL)
1353 {
1354 FATAL("Could not allocate memory for drive manufacturer");
1356 }
1357
1358 // Copy opaque UTF-16LE string
1359 memcpy(copy, data, length);
1360 if(ctx->drive_manufacturer != NULL) free(ctx->drive_manufacturer);
1361 ctx->drive_manufacturer = copy;
1363
1364 TRACE("Exiting aaruf_set_drive_manufacturer(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1365 return AARUF_STATUS_OK;
1366}
1367
1436AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_model(void *context, const uint8_t *data, const int32_t length)
1437{
1438 TRACE("Entering aaruf_set_drive_model(%p, %p, %d)", context, data, length);
1439
1440 // Check context is correct AaruFormat context
1441 if(context == NULL)
1442 {
1443 FATAL("Invalid context");
1444
1445 TRACE("Exiting aaruf_set_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
1447 }
1448
1449 aaruformat_context *ctx = context;
1450
1451 // Not a libaaruformat context
1452 if(ctx->magic != AARU_MAGIC)
1453 {
1454 FATAL("Invalid context");
1455
1456 TRACE("Exiting aaruf_set_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
1458 }
1459
1460 // Check we are writing
1461 if(!ctx->is_writing)
1462 {
1463 FATAL("Trying to write a read-only image");
1464
1465 TRACE("Exiting aaruf_set_drive_model() = AARUF_READ_ONLY");
1466 return AARUF_READ_ONLY;
1467 }
1468
1469 // Initialize
1471
1472 // Reserve memory
1473 uint8_t *copy = malloc(length);
1474 if(copy == NULL)
1475 {
1476 FATAL("Could not allocate memory for media model");
1478 }
1479
1480 // Copy opaque UTF-16LE string
1481 memcpy(copy, data, length);
1482 if(ctx->drive_model != NULL) free(ctx->drive_model);
1483 ctx->drive_model = copy;
1485
1486 TRACE("Exiting aaruf_set_drive_model(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1487 return AARUF_STATUS_OK;
1488}
1489
1560AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_serial_number(void *context, const uint8_t *data, const int32_t length)
1561{
1562 TRACE("Entering aaruf_set_drive_serial_number(%p, %p, %d)", context, data, length);
1563
1564 // Check context is correct AaruFormat context
1565 if(context == NULL)
1566 {
1567 FATAL("Invalid context");
1568
1569 TRACE("Exiting aaruf_set_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
1571 }
1572
1573 aaruformat_context *ctx = context;
1574
1575 // Not a libaaruformat context
1576 if(ctx->magic != AARU_MAGIC)
1577 {
1578 FATAL("Invalid context");
1579
1580 TRACE("Exiting aaruf_set_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
1582 }
1583
1584 // Check we are writing
1585 if(!ctx->is_writing)
1586 {
1587 FATAL("Trying to write a read-only image");
1588
1589 TRACE("Exiting aaruf_set_drive_serial_number() = AARUF_READ_ONLY");
1590 return AARUF_READ_ONLY;
1591 }
1592
1593 // Initialize
1595
1596 // Reserve memory
1597 uint8_t *copy = malloc(length);
1598 if(copy == NULL)
1599 {
1600 FATAL("Could not allocate memory for drive serial number");
1602 }
1603
1604 // Copy opaque UTF-16LE string
1605 memcpy(copy, data, length);
1606 if(ctx->drive_serial_number != NULL) free(ctx->drive_serial_number);
1607 ctx->drive_serial_number = copy;
1609
1610 TRACE("Exiting aaruf_set_drive_serial_number(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1611 return AARUF_STATUS_OK;
1612}
1613
1695AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_firmware_revision(void *context, const uint8_t *data,
1696 const int32_t length)
1697{
1698 TRACE("Entering aaruf_set_drive_firmware_revision(%p, %p, %d)", context, data, length);
1699
1700 // Check context is correct AaruFormat context
1701 if(context == NULL)
1702 {
1703 FATAL("Invalid context");
1704
1705 TRACE("Exiting aaruf_set_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
1707 }
1708
1709 aaruformat_context *ctx = context;
1710
1711 // Not a libaaruformat context
1712 if(ctx->magic != AARU_MAGIC)
1713 {
1714 FATAL("Invalid context");
1715
1716 TRACE("Exiting aaruf_set_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
1718 }
1719
1720 // Check we are writing
1721 if(!ctx->is_writing)
1722 {
1723 FATAL("Trying to write a read-only image");
1724
1725 TRACE("Exiting aaruf_set_drive_firmware_revision() = AARUF_READ_ONLY");
1726 return AARUF_READ_ONLY;
1727 }
1728
1729 // Initialize
1731
1732 // Reserve memory
1733 uint8_t *copy = malloc(length);
1734 if(copy == NULL)
1735 {
1736 FATAL("Could not allocate memory for creator");
1738 }
1739
1740 // Copy opaque UTF-16LE string
1741 memcpy(copy, data, length);
1742 if(ctx->drive_firmware_revision != NULL) free(ctx->drive_firmware_revision);
1743 ctx->drive_firmware_revision = copy;
1745
1746 TRACE("Exiting aaruf_set_drive_firmware_revision(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1747 return AARUF_STATUS_OK;
1748}
1749
1858AARU_EXPORT int32_t AARU_CALL aaruf_set_aaru_json_metadata(void *context, uint8_t *data, size_t length)
1859{
1860 TRACE("Entering aaruf_set_aaru_json_metadata(%p, %p, %d)", context, data, length);
1861
1862 // Check context is correct AaruFormat context
1863 if(context == NULL)
1864 {
1865 FATAL("Invalid context");
1866
1867 TRACE("Exiting aaruf_set_aaru_json_metadata() = AARUF_ERROR_NOT_AARUFORMAT");
1869 }
1870
1871 aaruformat_context *ctx = context;
1872
1873 // Not a libaaruformat context
1874 if(ctx->magic != AARU_MAGIC)
1875 {
1876 FATAL("Invalid context");
1877
1878 TRACE("Exiting aaruf_set_aaru_json_metadata() = AARUF_ERROR_NOT_AARUFORMAT");
1880 }
1881
1882 // Check we are writing
1883 if(!ctx->is_writing)
1884 {
1885 FATAL("Trying to write a read-only image");
1886
1887 TRACE("Exiting aaruf_set_aaru_json_metadata() = AARUF_READ_ONLY");
1888 return AARUF_READ_ONLY;
1889 }
1890
1891 // Reserve memory
1892 uint8_t *copy = malloc(length);
1893 if(copy == NULL)
1894 {
1895 FATAL("Could not allocate memory for Aaru metadata JSON");
1897 }
1898
1899 // Copy opaque UTF-8 string
1900 memcpy(copy, data, length);
1901 if(ctx->json_block != NULL) free(ctx->json_block);
1902 ctx->json_block = copy;
1904 ctx->json_block_header.length = (uint32_t)length;
1905 ctx->dirty_json_block = true; // Mark JSON block as dirty
1906
1907 TRACE("Exiting aaruf_set_aaru_json_metadata(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1908 return AARUF_STATUS_OK;
1909}
1910
1979{
1980 TRACE("Entering aaruf_clear_media_sequence(%p)", context);
1981
1982 // Check context is correct AaruFormat context
1983 if(context == NULL)
1984 {
1985 FATAL("Invalid context");
1986
1987 TRACE("Exiting aaruf_clear_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
1989 }
1990
1991 aaruformat_context *ctx = context;
1992
1993 // Not a libaaruformat context
1994 if(ctx->magic != AARU_MAGIC)
1995 {
1996 FATAL("Invalid context");
1997
1998 TRACE("Exiting aaruf_clear_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
2000 }
2001
2002 // Check we are writing
2003 if(!ctx->is_writing)
2004 {
2005 FATAL("Trying to write a read-only image");
2006
2007 TRACE("Exiting aaruf_clear_media_sequence() = AARUF_READ_ONLY");
2008 return AARUF_READ_ONLY;
2009 }
2010
2012 {
2013 TRACE("Exiting aaruf_clear_media_sequence() = AARUF_STATUS_OK");
2014 return AARUF_STATUS_OK;
2015 }
2016
2019
2020 // Check if all metadata is clear
2029
2030 TRACE("Exiting aaruf_clear_media_sequence() = AARUF_STATUS_OK");
2031 return AARUF_STATUS_OK;
2032}
2033
2110{
2111 TRACE("Entering aaruf_clear_creator(%p)", context);
2112
2113 // Check context is correct AaruFormat context
2114 if(context == NULL)
2115 {
2116 FATAL("Invalid context");
2117
2118 TRACE("Exiting aaruf_clear_creator() = AARUF_ERROR_NOT_AARUFORMAT");
2120 }
2121
2122 aaruformat_context *ctx = context;
2123
2124 // Not a libaaruformat context
2125 if(ctx->magic != AARU_MAGIC)
2126 {
2127 FATAL("Invalid context");
2128
2129 TRACE("Exiting aaruf_clear_creator() = AARUF_ERROR_NOT_AARUFORMAT");
2131 }
2132
2133 // Check we are writing
2134 if(!ctx->is_writing)
2135 {
2136 FATAL("Trying to write a read-only image");
2137
2138 TRACE("Exiting aaruf_clear_creator() = AARUF_READ_ONLY");
2139 return AARUF_READ_ONLY;
2140 }
2141
2143 {
2144 TRACE("Exiting aaruf_clear_creator() = AARUF_STATUS_OK");
2145 return AARUF_STATUS_OK;
2146 }
2147
2148 if(ctx->creator != NULL) free(ctx->creator);
2149
2150 ctx->creator = NULL;
2152
2153 // Check if all metadata is clear
2163
2164 TRACE("Exiting aaruf_clear_creator() = AARUF_STATUS_OK");
2165 return AARUF_STATUS_OK;
2166}
2167
2239{
2240 TRACE("Entering aaruf_clear_comments(%p)", context);
2241
2242 // Check context is correct AaruFormat context
2243 if(context == NULL)
2244 {
2245 FATAL("Invalid context");
2246
2247 TRACE("Exiting aaruf_clear_comments() = AARUF_ERROR_NOT_AARUFORMAT");
2249 }
2250
2251 aaruformat_context *ctx = context;
2252
2253 // Not a libaaruformat context
2254 if(ctx->magic != AARU_MAGIC)
2255 {
2256 FATAL("Invalid context");
2257
2258 TRACE("Exiting aaruf_clear_comments() = AARUF_ERROR_NOT_AARUFORMAT");
2260 }
2261
2262 // Check we are writing
2263 if(!ctx->is_writing)
2264 {
2265 FATAL("Trying to write a read-only image");
2266
2267 TRACE("Exiting aaruf_clear_comments() = AARUF_READ_ONLY");
2268 return AARUF_READ_ONLY;
2269 }
2270
2272 {
2273 TRACE("Exiting aaruf_clear_comments() = AARUF_STATUS_OK");
2274 return AARUF_STATUS_OK;
2275 }
2276
2277 if(ctx->comments != NULL) free(ctx->comments);
2278
2279 ctx->comments = NULL;
2281
2282 // Check if all metadata is clear
2292
2293 TRACE("Exiting aaruf_clear_comments() = AARUF_STATUS_OK");
2294 return AARUF_STATUS_OK;
2295}
2296
2322{
2323 TRACE("Entering aaruf_clear_media_title(%p)", context);
2324
2325 // Check context is correct AaruFormat context
2326 if(context == NULL)
2327 {
2328 FATAL("Invalid context");
2329
2330 TRACE("Exiting aaruf_clear_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
2332 }
2333
2334 aaruformat_context *ctx = context;
2335
2336 // Not a libaaruformat context
2337 if(ctx->magic != AARU_MAGIC)
2338 {
2339 FATAL("Invalid context");
2340
2341 TRACE("Exiting aaruf_clear_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
2343 }
2344
2345 // Check we are writing
2346 if(!ctx->is_writing)
2347 {
2348 FATAL("Trying to write a read-only image");
2349
2350 TRACE("Exiting aaruf_clear_media_title() = AARUF_READ_ONLY");
2351 return AARUF_READ_ONLY;
2352 }
2353
2355 {
2356 TRACE("Exiting aaruf_clear_media_title() = AARUF_STATUS_OK");
2357 return AARUF_STATUS_OK;
2358 }
2359
2360 if(ctx->media_title != NULL) free(ctx->media_title);
2361
2362 ctx->media_title = NULL;
2364
2365 // Check if all metadata is clear
2375
2376 TRACE("Exiting aaruf_clear_media_title() = AARUF_STATUS_OK");
2377 return AARUF_STATUS_OK;
2378}
2379
2406{
2407 TRACE("Entering aaruf_clear_media_manufacturer(%p)", context);
2408
2409 // Check context is correct AaruFormat context
2410 if(context == NULL)
2411 {
2412 FATAL("Invalid context");
2413
2414 TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
2416 }
2417
2418 aaruformat_context *ctx = context;
2419
2420 // Not a libaaruformat context
2421 if(ctx->magic != AARU_MAGIC)
2422 {
2423 FATAL("Invalid context");
2424
2425 TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
2427 }
2428
2429 // Check we are writing
2430 if(!ctx->is_writing)
2431 {
2432 FATAL("Trying to write a read-only image");
2433
2434 TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_READ_ONLY");
2435 return AARUF_READ_ONLY;
2436 }
2437
2439 {
2440 TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_STATUS_OK");
2441 return AARUF_STATUS_OK;
2442 }
2443
2444 if(ctx->media_manufacturer != NULL) free(ctx->media_manufacturer);
2445
2446 ctx->media_manufacturer = NULL;
2448
2449 // Check if all metadata is clear
2459
2460 TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_STATUS_OK");
2461 return AARUF_STATUS_OK;
2462}
2463
2490{
2491 TRACE("Entering aaruf_clear_media_model(%p)", context);
2492
2493 // Check context is correct AaruFormat context
2494 if(context == NULL)
2495 {
2496 FATAL("Invalid context");
2497
2498 TRACE("Exiting aaruf_clear_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
2500 }
2501
2502 aaruformat_context *ctx = context;
2503
2504 // Not a libaaruformat context
2505 if(ctx->magic != AARU_MAGIC)
2506 {
2507 FATAL("Invalid context");
2508
2509 TRACE("Exiting aaruf_clear_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
2511 }
2512
2513 // Check we are writing
2514 if(!ctx->is_writing)
2515 {
2516 FATAL("Trying to write a read-only image");
2517
2518 TRACE("Exiting aaruf_clear_media_model() = AARUF_READ_ONLY");
2519 return AARUF_READ_ONLY;
2520 }
2521
2523 {
2524 TRACE("Exiting aaruf_clear_media_model() = AARUF_STATUS_OK");
2525 return AARUF_STATUS_OK;
2526 }
2527
2528 if(ctx->media_model != NULL) free(ctx->media_model);
2529
2530 ctx->media_model = NULL;
2532
2533 // Check if all metadata is clear
2543
2544 TRACE("Exiting aaruf_clear_media_model() = AARUF_STATUS_OK");
2545 return AARUF_STATUS_OK;
2546}
2547
2576{
2577 TRACE("Entering aaruf_clear_media_serial_number(%p)", context);
2578
2579 // Check context is correct AaruFormat context
2580 if(context == NULL)
2581 {
2582 FATAL("Invalid context");
2583
2584 TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
2586 }
2587
2588 aaruformat_context *ctx = context;
2589
2590 // Not a libaaruformat context
2591 if(ctx->magic != AARU_MAGIC)
2592 {
2593 FATAL("Invalid context");
2594
2595 TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
2597 }
2598
2599 // Check we are writing
2600 if(!ctx->is_writing)
2601 {
2602 FATAL("Trying to write a read-only image");
2603
2604 TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_READ_ONLY");
2605 return AARUF_READ_ONLY;
2606 }
2607
2609 {
2610 TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_STATUS_OK");
2611 return AARUF_STATUS_OK;
2612 }
2613
2614 if(ctx->media_serial_number != NULL) free(ctx->media_serial_number);
2615
2616 ctx->media_serial_number = NULL;
2618
2619 // Check if all metadata is clear
2629
2630 TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_STATUS_OK");
2631 return AARUF_STATUS_OK;
2632}
2633
2662{
2663 TRACE("Entering aaruf_clear_media_barcode(%p)", context);
2664
2665 // Check context is correct AaruFormat context
2666 if(context == NULL)
2667 {
2668 FATAL("Invalid context");
2669
2670 TRACE("Exiting aaruf_clear_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
2672 }
2673
2674 aaruformat_context *ctx = context;
2675
2676 // Not a libaaruformat context
2677 if(ctx->magic != AARU_MAGIC)
2678 {
2679 FATAL("Invalid context");
2680
2681 TRACE("Exiting aaruf_clear_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
2683 }
2684
2685 // Check we are writing
2686 if(!ctx->is_writing)
2687 {
2688 FATAL("Trying to write a read-only image");
2689
2690 TRACE("Exiting aaruf_clear_media_barcode() = AARUF_READ_ONLY");
2691 return AARUF_READ_ONLY;
2692 }
2693
2695 {
2696 TRACE("Exiting aaruf_clear_media_barcode() = AARUF_STATUS_OK");
2697 return AARUF_STATUS_OK;
2698 }
2699
2700 if(ctx->media_barcode != NULL) free(ctx->media_barcode);
2701
2702 ctx->media_barcode = NULL;
2704
2705 // Check if all metadata is clear
2715
2716 TRACE("Exiting aaruf_clear_media_barcode() = AARUF_STATUS_OK");
2717 return AARUF_STATUS_OK;
2718}
2719
2748{
2749 TRACE("Entering aaruf_clear_media_part_number(%p)", context);
2750
2751 // Check context is correct AaruFormat context
2752 if(context == NULL)
2753 {
2754 FATAL("Invalid context");
2755
2756 TRACE("Exiting aaruf_clear_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
2758 }
2759
2760 aaruformat_context *ctx = context;
2761
2762 // Not a libaaruformat context
2763 if(ctx->magic != AARU_MAGIC)
2764 {
2765 FATAL("Invalid context");
2766
2767 TRACE("Exiting aaruf_clear_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
2769 }
2770
2771 // Check we are writing
2772 if(!ctx->is_writing)
2773 {
2774 FATAL("Trying to write a read-only image");
2775
2776 TRACE("Exiting aaruf_clear_media_part_number() = AARUF_READ_ONLY");
2777 return AARUF_READ_ONLY;
2778 }
2779
2781 {
2782 TRACE("Exiting aaruf_clear_media_part_number() = AARUF_STATUS_OK");
2783 return AARUF_STATUS_OK;
2784 }
2785
2786 if(ctx->media_part_number != NULL) free(ctx->media_part_number);
2787
2788 ctx->media_part_number = NULL;
2790
2791 // Check if all metadata is clear
2801
2802 TRACE("Exiting aaruf_clear_media_part_number() = AARUF_STATUS_OK");
2803 return AARUF_STATUS_OK;
2804}
2805
2834{
2835 TRACE("Entering aaruf_clear_drive_manufacturer(%p)", context);
2836
2837 // Check context is correct AaruFormat context
2838 if(context == NULL)
2839 {
2840 FATAL("Invalid context");
2841
2842 TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
2844 }
2845
2846 aaruformat_context *ctx = context;
2847
2848 // Not a libaaruformat context
2849 if(ctx->magic != AARU_MAGIC)
2850 {
2851 FATAL("Invalid context");
2852
2853 TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
2855 }
2856
2857 // Check we are writing
2858 if(!ctx->is_writing)
2859 {
2860 FATAL("Trying to write a read-only image");
2861
2862 TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_READ_ONLY");
2863 return AARUF_READ_ONLY;
2864 }
2865
2867 {
2868 TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_STATUS_OK");
2869 return AARUF_STATUS_OK;
2870 }
2871
2872 if(ctx->drive_manufacturer != NULL) free(ctx->drive_manufacturer);
2873
2874 ctx->drive_manufacturer = NULL;
2876
2877 // Check if all metadata is clear
2886
2887 TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_STATUS_OK");
2888 return AARUF_STATUS_OK;
2889}
2890
2920{
2921 TRACE("Entering aaruf_clear_drive_model(%p)", context);
2922
2923 // Check context is correct AaruFormat context
2924 if(context == NULL)
2925 {
2926 FATAL("Invalid context");
2927
2928 TRACE("Exiting aaruf_clear_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
2930 }
2931
2932 aaruformat_context *ctx = context;
2933
2934 // Not a libaaruformat context
2935 if(ctx->magic != AARU_MAGIC)
2936 {
2937 FATAL("Invalid context");
2938
2939 TRACE("Exiting aaruf_clear_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
2941 }
2942
2943 // Check we are writing
2944 if(!ctx->is_writing)
2945 {
2946 FATAL("Trying to write a read-only image");
2947
2948 TRACE("Exiting aaruf_clear_drive_model() = AARUF_READ_ONLY");
2949 return AARUF_READ_ONLY;
2950 }
2951
2953 {
2954 TRACE("Exiting aaruf_clear_drive_model() = AARUF_STATUS_OK");
2955 return AARUF_STATUS_OK;
2956 }
2957
2958 if(ctx->drive_model != NULL) free(ctx->drive_model);
2959
2960 ctx->drive_model = NULL;
2962
2963 // Check if all metadata is clear
2973
2974 TRACE("Exiting aaruf_clear_drive_model() = AARUF_STATUS_OK");
2975 return AARUF_STATUS_OK;
2976}
2977
3009{
3010 TRACE("Entering aaruf_clear_drive_serial_number(%p)", context);
3011
3012 // Check context is correct AaruFormat context
3013 if(context == NULL)
3014 {
3015 FATAL("Invalid context");
3016
3017 TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
3019 }
3020
3021 aaruformat_context *ctx = context;
3022
3023 // Not a libaaruformat context
3024 if(ctx->magic != AARU_MAGIC)
3025 {
3026 FATAL("Invalid context");
3027
3028 TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
3030 }
3031
3032 // Check we are writing
3033 if(!ctx->is_writing)
3034 {
3035 FATAL("Trying to write a read-only image");
3036
3037 TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_READ_ONLY");
3038 return AARUF_READ_ONLY;
3039 }
3040
3042 {
3043 TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_STATUS_OK");
3044 return AARUF_STATUS_OK;
3045 }
3046
3047 if(ctx->drive_serial_number != NULL) free(ctx->drive_serial_number);
3048
3049 ctx->drive_serial_number = NULL;
3051
3052 // Check if all metadata is clear
3061
3062 TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_STATUS_OK");
3063 return AARUF_STATUS_OK;
3064}
3065
3097{
3098 TRACE("Entering aaruf_clear_drive_firmware_revision(%p)", context);
3099
3100 // Check context is correct AaruFormat context
3101 if(context == NULL)
3102 {
3103 FATAL("Invalid context");
3104
3105 TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
3107 }
3108
3109 aaruformat_context *ctx = context;
3110
3111 // Not a libaaruformat context
3112 if(ctx->magic != AARU_MAGIC)
3113 {
3114 FATAL("Invalid context");
3115
3116 TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
3118 }
3119
3120 // Check we are writing
3121 if(!ctx->is_writing)
3122 {
3123 FATAL("Trying to write a read-only image");
3124
3125 TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_READ_ONLY");
3126 return AARUF_READ_ONLY;
3127 }
3128
3130 {
3131 TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_STATUS_OK");
3132 return AARUF_STATUS_OK;
3133 }
3134
3135 if(ctx->drive_firmware_revision != NULL) free(ctx->drive_firmware_revision);
3136
3137 ctx->drive_firmware_revision = NULL;
3139
3140 // Check if all metadata is clear
3149
3150 TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_STATUS_OK");
3151 return AARUF_STATUS_OK;
3152}
3153
#define AARU_MAGIC
Magic identifier for AaruFormat container (ASCII "AARUFRMT").
Definition consts.h:64
#define AARU_CALL
Definition decls.h:46
#define AARU_EXPORT
Definition decls.h:55
@ GeometryBlock
Block containing logical geometry.
Definition enums.h:172
@ AaruMetadataJsonBlock
Block containing JSON version of Aaru Metadata.
Definition enums.h:183
@ MetadataBlock
Block containing metadata.
Definition enums.h:173
#define AARUF_STATUS_OK
Sector present and read without uncorrectable errors.
Definition errors.h:81
#define AARUF_READ_ONLY
Operation requires write mode but context is read-only.
Definition errors.h:61
#define AARUF_ERROR_NOT_ENOUGH_MEMORY
Memory allocation failure (critical).
Definition errors.h:48
#define AARUF_ERROR_NOT_AARUFORMAT
Input file/stream failed magic or structural validation.
Definition errors.h:40
#define FATAL(fmt,...)
Definition log.h:40
#define TRACE(fmt,...)
Definition log.h:25
int32_t aaruf_clear_media_sequence(void *context)
Clears the media sequence information from the image metadata.
int32_t aaruf_clear_drive_firmware_revision(void *context)
Clears the drive firmware revision from the image metadata.
int32_t aaruf_set_media_barcode(void *context, const uint8_t *data, const int32_t length)
Sets the media barcode information for the image.
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.
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.
int32_t aaruf_clear_media_serial_number(void *context)
Clears the media serial number from the image metadata.
int32_t aaruf_set_drive_manufacturer(void *context, const uint8_t *data, const int32_t length)
Sets the drive manufacturer information for the image.
int32_t aaruf_set_drive_model(void *context, const uint8_t *data, const int32_t length)
Sets the drive model information for the image.
int32_t aaruf_clear_media_barcode(void *context)
Clears the media barcode information from the image metadata.
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.
int32_t aaruf_clear_media_title(void *context)
Clears the media title or label from the image metadata.
int32_t aaruf_clear_media_manufacturer(void *context)
Clears the media manufacturer information from the image metadata.
int32_t aaruf_clear_drive_model(void *context)
Clears the drive model information from the image metadata.
int32_t aaruf_clear_drive_manufacturer(void *context)
Clears the drive manufacturer information from the image 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.
int32_t aaruf_clear_media_part_number(void *context)
Clears the media part number or model designation from the image metadata.
int32_t aaruf_clear_comments(void *context)
Clears user comments or notes from the image metadata.
int32_t aaruf_clear_media_model(void *context)
Clears the media model or product designation from the image metadata.
int32_t aaruf_clear_drive_serial_number(void *context)
Clears the drive serial number from the image metadata.
int32_t aaruf_clear_creator(void *context)
Clears the creator (person/operator) information from the image metadata.
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.
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.
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.
int32_t aaruf_set_comments(void *context, const uint8_t *data, const int32_t length)
Sets user comments or notes for the image.
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.
int32_t aaruf_set_media_manufacturer(void *context, const uint8_t *data, const int32_t length)
Sets the media manufacturer information for the image.
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.
int32_t aaruf_set_creator(void *context, const uint8_t *data, const int32_t length)
Sets the creator (person/operator) information for the image.
uint32_t identifier
Block identifier, must be BlockType::AaruMetadataJsonBlock.
Definition metadata.h:121
uint32_t length
Length in bytes of the Aaru metadata JSON payload that follows.
Definition metadata.h:122
uint32_t identifier
Block identifier, must be BlockType::GeometryBlock.
Definition data.h:92
uint32_t cylinders
Number of cylinders.
Definition data.h:93
uint32_t heads
Number of heads (tracks per cylinder).
Definition data.h:94
uint32_t sectorsPerTrack
Number of sectors per track.
Definition data.h:95
uint32_t commentsLength
Length in bytes (including null) of comments string.
Definition metadata.h:78
int32_t mediaSequence
Sequence number within a multi-disc / multi-volume set (0-based or 1-based as producer defines).
Definition metadata.h:72
uint32_t identifier
Block identifier, must be BlockType::MetadataBlock.
Definition metadata.h:70
uint32_t driveModelLength
Length in bytes (including null) of drive model string.
Definition metadata.h:94
uint32_t driveManufacturerLength
Length in bytes (including null) of drive manufacturer string.
Definition metadata.h:92
uint32_t mediaTitleLength
Length in bytes (including null) of media title string.
Definition metadata.h:80
uint32_t driveSerialNumberLength
Length in bytes (including null) of drive serial number string.
Definition metadata.h:96
uint32_t mediaManufacturerLength
Length in bytes (including null) of media manufacturer string.
Definition metadata.h:82
uint32_t mediaModelLength
Length in bytes (including null) of media model string.
Definition metadata.h:84
int32_t lastMediaSequence
Total number of media in the set; 0 or 1 if single item.
Definition metadata.h:74
uint32_t mediaSerialNumberLength
Length in bytes (including null) of media serial number string.
Definition metadata.h:86
uint32_t mediaPartNumberLength
Length in bytes (including null) of media part number string.
Definition metadata.h:90
uint32_t mediaBarcodeLength
Length in bytes (including null) of media barcode string.
Definition metadata.h:88
uint32_t creatorLength
Length in bytes (including null) of creator string (0 if absent).
Definition metadata.h:76
uint32_t driveFirmwareRevisionLength
Length in bytes (including null) of drive firmware revision string.
Definition metadata.h:98
Master context representing an open or in‑creation Aaru image.
Definition context.h:175
uint8_t * media_barcode
Barcode of the media represented by the image.
Definition context.h:225
uint8_t * creator
Who (person) created the image?
Definition context.h:219
uint32_t cylinders
Cylinders of the media represented by the image.
Definition context.h:237
uint8_t * drive_firmware_revision
Firmware revision of the drive used to read the media represented by the image.
Definition context.h:231
uint8_t * media_serial_number
Serial number of the media represented by the image.
Definition context.h:224
MetadataBlockHeader metadata_block_header
Metadata block header.
Definition context.h:233
uint8_t * media_model
Model of the media represented by the image.
Definition context.h:223
uint8_t * drive_serial_number
Serial number of the drive used to read the media represented by the image.
Definition context.h:229
uint8_t * drive_manufacturer
Manufacturer of the drive used to read the media represented by the image.
Definition context.h:227
bool dirty_json_block
True if JSON metadata block should be written during close.
Definition context.h:343
bool is_writing
True if context opened/created for writing.
Definition context.h:295
uint8_t * drive_model
Model of the drive used to read the media represented by the image.
Definition context.h:228
uint64_t magic
File magic (AARU_MAGIC) post-open.
Definition context.h:177
GeometryBlockHeader geometry_block
Logical geometry block (if present).
Definition context.h:232
uint8_t * json_block
JSON metadata block payload (UTF-8).
Definition context.h:218
uint8_t * media_part_number
Part number of the media represented by the image.
Definition context.h:226
AaruMetadataJsonBlockHeader json_block_header
JSON metadata block header (if present).
Definition context.h:236
bool dirty_metadata_block
True if metadata block should be written during close.
Definition context.h:340
uint32_t sectors_per_track
Sectors per track of the media represented by the image (for variable image, the smallest).
Definition context.h:239
uint8_t * comments
Image comments.
Definition context.h:221
uint32_t heads
Heads of the media represented by the image.
Definition context.h:238
uint8_t * media_title
Title of the media represented by the image.
Definition context.h:220
bool dirty_geometry_block
True if geometry block should be written during close.
Definition context.h:339
uint8_t * media_manufacturer
Manufacturer of the media represented by the image.
Definition context.h:222