[48e3190] | 1 | /*
|
---|
[7ae01d5] | 2 | * Copyright (c) 2024 Jiri Svoboda
|
---|
[48e3190] | 3 | * Copyright (c) 2008 Jakub Jermar
|
---|
| 4 | * Copyright (c) 2012 Julia Medvedeva
|
---|
| 5 | * All rights reserved.
|
---|
| 6 | *
|
---|
| 7 | * Redistribution and use in source and binary forms, with or without
|
---|
| 8 | * modification, are permitted provided that the following conditions
|
---|
| 9 | * are met:
|
---|
| 10 | *
|
---|
| 11 | * - Redistributions of source code must retain the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer.
|
---|
| 13 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 14 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 15 | * documentation and/or other materials provided with the distribution.
|
---|
| 16 | * - The name of the author may not be used to endorse or promote products
|
---|
| 17 | * derived from this software without specific prior written permission.
|
---|
| 18 | *
|
---|
| 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 29 | */
|
---|
| 30 |
|
---|
[b1834a01] | 31 | /** @addtogroup udf
|
---|
[48e3190] | 32 | * @{
|
---|
| 33 | */
|
---|
| 34 |
|
---|
| 35 | #ifndef UDF_UDF_H_
|
---|
| 36 | #define UDF_UDF_H_
|
---|
| 37 |
|
---|
| 38 | #include <fibril_synch.h>
|
---|
| 39 | #include <libfs.h>
|
---|
[8d2dd7f2] | 40 | #include <stddef.h>
|
---|
| 41 | #include <stdint.h>
|
---|
[3e6a98c5] | 42 | #include <stdbool.h>
|
---|
[48e3190] | 43 | #include "../../vfs/vfs.h"
|
---|
| 44 | #include "udf_types.h"
|
---|
[38fc00b] | 45 | #include <adt/hash_table.h>
|
---|
[48e3190] | 46 |
|
---|
| 47 | #define UDF_NODE(node) \
|
---|
| 48 | ((node) ? (udf_node_t *) (node)->data : NULL)
|
---|
| 49 |
|
---|
| 50 | #define FS_NODE(node) \
|
---|
| 51 | ((node) ? (fs_node_t *) ((node)->fs_node) : NULL)
|
---|
| 52 |
|
---|
| 53 | #define BS_BLOCK 0
|
---|
| 54 | #define DEFAULT_VOL 0
|
---|
| 55 |
|
---|
| 56 | #define NODE_DIR 0
|
---|
| 57 | #define NODE_FILE 1
|
---|
| 58 |
|
---|
| 59 | #define MAX_FILE_NAME_LEN 512
|
---|
| 60 |
|
---|
| 61 | #define MIN_FID_LEN 38
|
---|
| 62 |
|
---|
| 63 | #define SPACE_TABLE 0
|
---|
| 64 | #define SPACE_BITMAP 1
|
---|
| 65 |
|
---|
| 66 | typedef struct udf_partition {
|
---|
| 67 | /* Partition info */
|
---|
| 68 | uint16_t number;
|
---|
| 69 | uint32_t access_type;
|
---|
| 70 | uint32_t start;
|
---|
[c477c80] | 71 | uint32_t length;
|
---|
[48e3190] | 72 | } udf_partition_t;
|
---|
| 73 |
|
---|
| 74 | typedef struct udf_lvolume {
|
---|
| 75 | udf_partition_t **partitions;
|
---|
| 76 | size_t partition_cnt;
|
---|
| 77 | uint32_t logical_block_size;
|
---|
| 78 | fs_index_t root_dir;
|
---|
| 79 | } udf_lvolume_t;
|
---|
| 80 |
|
---|
| 81 | typedef struct {
|
---|
| 82 | service_id_t service_id;
|
---|
| 83 | size_t open_nodes_count;
|
---|
| 84 | udf_charspec_t charset;
|
---|
[a35b458] | 85 |
|
---|
[48e3190] | 86 | uint32_t sector_size;
|
---|
| 87 | udf_lvolume_t *volumes;
|
---|
| 88 | udf_partition_t *partitions;
|
---|
| 89 | size_t partition_cnt;
|
---|
| 90 | udf_unallocated_space_descriptor_t *uasd;
|
---|
| 91 | uint64_t uaspace_start;
|
---|
[c477c80] | 92 | uint64_t uaspace_length;
|
---|
[48e3190] | 93 | uint8_t space_type;
|
---|
| 94 | } udf_instance_t;
|
---|
| 95 |
|
---|
| 96 | typedef struct udf_allocator {
|
---|
| 97 | uint32_t length;
|
---|
| 98 | uint32_t position;
|
---|
| 99 | } udf_allocator_t;
|
---|
| 100 |
|
---|
| 101 | typedef struct udf_node {
|
---|
| 102 | udf_instance_t *instance;
|
---|
| 103 | fs_node_t *fs_node;
|
---|
| 104 | fibril_mutex_t lock;
|
---|
[a35b458] | 105 |
|
---|
[48e3190] | 106 | fs_index_t index; /* FID logical block */
|
---|
[38fc00b] | 107 | ht_link_t link;
|
---|
[48e3190] | 108 | size_t ref_cnt;
|
---|
| 109 | size_t link_cnt;
|
---|
[a35b458] | 110 |
|
---|
[48e3190] | 111 | uint8_t type; /* 1 - file, 0 - directory */
|
---|
| 112 | uint64_t data_size;
|
---|
| 113 | uint8_t *data;
|
---|
| 114 | udf_allocator_t *allocators;
|
---|
| 115 | size_t alloc_size;
|
---|
| 116 | } udf_node_t;
|
---|
| 117 |
|
---|
| 118 | extern vfs_out_ops_t udf_ops;
|
---|
| 119 | extern libfs_ops_t udf_libfs_ops;
|
---|
| 120 |
|
---|
| 121 | #endif
|
---|
| 122 |
|
---|
| 123 | /**
|
---|
| 124 | * @}
|
---|
| 125 | */
|
---|