Changeset 6c501f8 in mainline
- Timestamp:
- 2011-09-30T20:00:30Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 00a8f1b
- Parents:
- 9875711
- Location:
- uspace
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/Makefile.common
r9875711 r6c501f8 115 115 116 116 LIBEXT2_PREFIX = $(LIB_PREFIX)/ext2 117 LIBEXT4_PREFIX = $(LIB_PREFIX)/ext4 117 118 118 119 LIBUSB_PREFIX = $(LIB_PREFIX)/usb -
uspace/lib/ext4/Makefile
r9875711 r6c501f8 33 33 34 34 SOURCES = \ 35 libext4_superblock.c \36 35 libext4_block_group.c \ 36 libext4_directory.c \ 37 libext4_filesystem.c \ 37 38 libext4_inode.c \ 38 libext4_directory.c 39 libext4_superblock.c 40 39 41 40 42 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/ext4/libext4.h
r9875711 r6c501f8 36 36 #include "libext4_block_group.h" 37 37 #include "libext4_directory.h" 38 #include "libext4_filesystem.h" 38 39 #include "libext4_inode.h" 39 40 #include "libext4_superblock.h" -
uspace/lib/ext4/libext4_block_group.c
r9875711 r6c501f8 36 36 */ 37 37 38 #include "libext4_block_group.h" 38 39 39 40 -
uspace/lib/ext4/libext4_block_group.h
r9875711 r6c501f8 34 34 #define LIBEXT4_LIBEXT4_BLOCK_GROUP_H_ 35 35 36 #include <sys/types.h> 37 38 /* 39 * Structure of a blocks group descriptor 40 */ 41 typedef struct ext4_block_group { 42 uint32_t bg_block_bitmap_lo; // Blocks bitmap block 43 uint32_t bg_inode_bitmap_lo; // Inodes bitmap block 44 uint32_t bg_inode_table_lo; // Inodes table block 45 uint16_t bg_free_blocks_count_lo; // Free blocks count 46 uint16_t bg_free_inodes_count_lo; // Free inodes count 47 uint16_t bg_used_dirs_count_lo; // Directories count 48 uint16_t bg_flags; // EXT4_BG_flags (INODE_UNINIT, etc) 49 uint32_t bg_reserved[2]; // Likely block/inode bitmap checksum 50 uint16_t bg_itable_unused_lo; // Unused inodes count 51 uint16_t bg_checksum; // crc16(sb_uuid+group+desc) 52 uint32_t bg_block_bitmap_hi; // Blocks bitmap block MSB 53 uint32_t bg_inode_bitmap_hi; // Inodes bitmap block MSB 54 uint32_t bg_inode_table_hi; // Inodes table block MSB 55 uint16_t bg_free_blocks_count_hi; // Free blocks count MSB 56 uint16_t bg_free_inodes_count_hi; // Free inodes count MSB 57 uint16_t bg_used_dirs_count_hi; // Directories count MSB 58 uint16_t bg_itable_unused_hi; // Unused inodes count MSB 59 uint32_t bg_reserved2[3]; // Padding 60 } ext4_group_desc_t; 36 61 37 62 #endif -
uspace/lib/ext4/libext4_directory.c
r9875711 r6c501f8 36 36 */ 37 37 38 #include "libext4_directory.h" 38 39 39 40 -
uspace/lib/ext4/libext4_inode.c
r9875711 r6c501f8 36 36 */ 37 37 38 #include "libext4.h" 38 #include "libext4_inode.h" 39 40 // TODO check return type 41 uint16_t ext4_inode_get_usage_count(ext4_inode_t *inode) 42 { 43 // TODO 44 return 0; 45 } 46 39 47 40 48 /** -
uspace/lib/ext4/libext4_inode.h
r9875711 r6c501f8 34 34 #define LIBEXT4_LIBEXT4_INODE_H_ 35 35 36 #include <libblock.h> 36 37 #include <sys/types.h> 37 38 … … 112 113 113 114 115 // TODO check value 116 #define EXT4_INODE_ROOT_INDEX 2 117 118 typedef struct ext4_inode_ref { 119 block_t *block; // Reference to a block containing this inode 120 ext4_inode_t *inode; 121 uint32_t index; // Index number of this inode 122 } ext4_inode_ref_t; 123 124 extern uint16_t ext4_inode_get_usage_count(ext4_inode_t *); 114 125 115 126 #endif -
uspace/lib/ext4/libext4_superblock.c
r9875711 r6c501f8 36 36 */ 37 37 38 #include "libext4 .h"38 #include "libext4_superblock.h" 39 39 40 40 -
uspace/srv/fs/ext4fs/Makefile
r9875711 r6c501f8 28 28 29 29 USPACE_PREFIX = ../../.. 30 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBFS_PREFIX)/libfs.a 31 EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX) 30 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBFS_PREFIX)/libfs.a $(LIBEXT4_PREFIX)/libext4.a 31 EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX) -I$(LIBEXT4_PREFIX) 32 32 BINARY = ext4fs 33 33 -
uspace/srv/fs/ext4fs/ext4fs_ops.c
r9875711 r6c501f8 37 37 38 38 #include <errno.h> 39 #include <fibril_synch.h> 40 #include <libext4.h> 39 41 #include <libfs.h> 42 #include <malloc.h> 40 43 #include <ipc/loc.h> 41 44 #include "ext4fs.h" 42 45 #include "../../vfs/vfs.h" 46 47 #define EXT4FS_NODE(node) ((node) ? (ext4fs_node_t *) (node)->data : NULL) 48 49 typedef struct ext4fs_instance { 50 link_t link; 51 service_id_t service_id; 52 ext4_filesystem_t *filesystem; 53 unsigned int open_nodes_count; 54 } ext4fs_instance_t; 55 56 typedef struct ext4fs_node { 57 ext4fs_instance_t *instance; 58 ext4_inode_ref_t *inode_ref; 59 fs_node_t *fs_node; 60 link_t link; 61 unsigned int references; 62 } ext4fs_node_t; 63 64 /* 65 * Forward declarations of auxiliary functions 66 */ 67 static int ext4fs_instance_get(service_id_t, ext4fs_instance_t **); 68 static int ext4fs_node_get_core(fs_node_t **, ext4fs_instance_t *, fs_index_t); 43 69 44 70 … … 63 89 static service_id_t ext4fs_service_get(fs_node_t *node); 64 90 91 /* 92 * Static variables 93 */ 94 static LIST_INITIALIZE(instance_list); 95 static FIBRIL_MUTEX_INITIALIZE(instance_list_mutex); 96 static FIBRIL_MUTEX_INITIALIZE(open_nodes_lock); 97 98 65 99 /** 66 100 * TODO comment … … 83 117 */ 84 118 119 int ext4fs_instance_get(service_id_t service_id, ext4fs_instance_t **inst) 120 { 121 ext4fs_instance_t *tmp; 122 123 fibril_mutex_lock(&instance_list_mutex); 124 125 if (list_empty(&instance_list)) { 126 fibril_mutex_unlock(&instance_list_mutex); 127 return EINVAL; 128 } 129 130 list_foreach(instance_list, link) { 131 tmp = list_get_instance(link, ext4fs_instance_t, link); 132 133 if (tmp->service_id == service_id) { 134 *inst = tmp; 135 fibril_mutex_unlock(&instance_list_mutex); 136 return EOK; 137 } 138 } 139 140 fibril_mutex_unlock(&instance_list_mutex); 141 return EINVAL; 142 } 143 85 144 int ext4fs_root_get(fs_node_t **rfn, service_id_t service_id) 86 145 { … … 99 158 // TODO 100 159 return 0; 160 } 161 162 int ext4fs_node_get_core(fs_node_t **rfn, ext4fs_instance_t *inst, 163 fs_index_t index) 164 { 165 // TODO 166 return EOK; 101 167 } 102 168 … … 210 276 fs_index_t *index, aoff64_t *size, unsigned *lnkcnt) 211 277 { 212 // TODO 278 279 int rc; 280 ext4_filesystem_t *fs; 281 ext4fs_instance_t *inst; 282 bool read_only; 283 284 /* Allocate libext4 filesystem structure */ 285 fs = (ext4_filesystem_t *) malloc(sizeof(ext4_filesystem_t)); 286 if (fs == NULL) { 287 return ENOMEM; 288 } 289 290 /* Allocate instance structure */ 291 inst = (ext4fs_instance_t *) malloc(sizeof(ext4fs_instance_t)); 292 if (inst == NULL) { 293 free(fs); 294 return ENOMEM; 295 } 296 297 /* Initialize the filesystem */ 298 rc = ext4_filesystem_init(fs, service_id); 299 if (rc != EOK) { 300 free(fs); 301 free(inst); 302 return rc; 303 } 304 305 /* Do some sanity checking */ 306 rc = ext4_filesystem_check_sanity(fs); 307 if (rc != EOK) { 308 ext4_filesystem_fini(fs); 309 free(fs); 310 free(inst); 311 return rc; 312 } 313 314 /* Check flags */ 315 rc = ext4_filesystem_check_flags(fs, &read_only); 316 if (rc != EOK) { 317 ext4_filesystem_fini(fs); 318 free(fs); 319 free(inst); 320 return rc; 321 } 322 323 /* Initialize instance */ 324 link_initialize(&inst->link); 325 inst->service_id = service_id; 326 inst->filesystem = fs; 327 inst->open_nodes_count = 0; 328 329 /* Read root node */ 330 fs_node_t *root_node; 331 rc = ext4fs_node_get_core(&root_node, inst, EXT4_INODE_ROOT_INDEX); 332 if (rc != EOK) { 333 ext4_filesystem_fini(fs); 334 free(fs); 335 free(inst); 336 return rc; 337 } 338 ext4fs_node_t *enode = EXT4FS_NODE(root_node); 339 340 /* Add instance to the list */ 341 fibril_mutex_lock(&instance_list_mutex); 342 list_append(&inst->link, &instance_list); 343 fibril_mutex_unlock(&instance_list_mutex); 344 345 *index = EXT4_INODE_ROOT_INDEX; 346 *size = 0; 347 *lnkcnt = ext4_inode_get_usage_count(enode->inode_ref->inode); 348 349 ext4fs_node_put(root_node); 350 213 351 return EOK; 214 352 } … … 216 354 static int ext4fs_unmounted(service_id_t service_id) 217 355 { 218 // TODO 356 357 int rc; 358 ext4fs_instance_t *inst; 359 360 rc = ext4fs_instance_get(service_id, &inst); 361 362 if (rc != EOK) { 363 return rc; 364 } 365 366 fibril_mutex_lock(&open_nodes_lock); 367 368 if (inst->open_nodes_count != 0) { 369 fibril_mutex_unlock(&open_nodes_lock); 370 return EBUSY; 371 } 372 373 /* Remove the instance from the list */ 374 fibril_mutex_lock(&instance_list_mutex); 375 list_remove(&inst->link); 376 fibril_mutex_unlock(&instance_list_mutex); 377 378 fibril_mutex_unlock(&open_nodes_lock); 379 380 ext4_filesystem_fini(inst->filesystem); 381 219 382 return EOK; 220 383 }
Note:
See TracChangeset
for help on using the changeset viewer.