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