Changeset 6a7e497 in mainline


Ignore:
Timestamp:
2011-06-02T19:05:17Z (13 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
16b2ea8
Parents:
18626b3 (diff), d030e0c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge with the original ext2 branch

Location:
uspace
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/blkdump/blkdump.c

    r18626b3 r6a7e497  
    202202        }
    203203       
    204         // Print hexadecimal values
     204        /* Print hexadecimal values */
    205205        for (pos = 0; pos < length; pos++) {
    206206                if (pos == length/2) {
     
    210210        }
    211211       
    212         // pad with spaces if we have less than 16 bytes
     212        /* Pad with spaces if we have less than 16 bytes */
    213213        for (pos = length; pos < bytes_per_row; pos++) {
    214214                if (pos == length/2) {
     
    218218        }
    219219       
    220         // Print printable characters
     220        /* Print printable characters */
    221221        for (pos = 0; pos < length; pos++) {
    222222                if (pos == length/2) {
  • uspace/app/bnchmark/bnchmark.c

    r18626b3 r6a7e497  
    210210static void syntax_print(void)
    211211{
    212         fprintf(stderr, "syntax: bnchmark <iterations> <test type> <log-str> <path>\n");
    213         fprintf(stderr, "  <iterations>    number of times to run a given test");
    214         fprintf(stderr, "  <test-type>     one of:");
    215         fprintf(stderr, "                    sequential-file-read");
    216         fprintf(stderr, "                    sequential-dir-read");
    217         fprintf(stderr, "  <log-str>       a string to attach to results");
    218         fprintf(stderr, "  <path>          file/directory to use for testing");
     212        fprintf(stderr, "syntax: " NAME " <iterations> <test type> <log-str> <path>\n");
     213        fprintf(stderr, "  <iterations>    number of times to run a given test\n");
     214        fprintf(stderr, "  <test-type>     one of:\n");
     215        fprintf(stderr, "                    sequential-file-read\n");
     216        fprintf(stderr, "                    sequential-dir-read\n");
     217        fprintf(stderr, "  <log-str>       a string to attach to results\n");
     218        fprintf(stderr, "  <path>          file/directory to use for testing\n");
    219219}
    220220
  • uspace/app/ext2info/ext2info.c

    r18626b3 r6a7e497  
    9595        }
    9696       
    97         // Skip program name
     97        /* Skip program name */
    9898        --argc; ++argv;
    9999       
     
    171171        assert(argc == 1);
    172172       
    173         // Display common things by default
     173        /* Display common things by default */
    174174        if ((arg_flags & ARG_ALL) == 0) {
    175175                arg_flags = ARG_COMMON;
  • uspace/app/testread/testread.c

    r18626b3 r6a7e497  
    8484        }
    8585       
    86         // Skip program name
     86        /* Skip program name */
    8787        --argc; ++argv;
    8888       
  • uspace/lib/ext2/libext2_directory.c

    r18626b3 r6a7e497  
    9393        it->fs = fs;
    9494       
    95         // Get the first data block, so we can get first entry
     95        /* Get the first data block, so we can get the first entry */
    9696        rc = ext2_filesystem_get_inode_data_block_index(fs, inode_ref->inode, 0,
    9797            &block_id);
     
    133133        size = ext2_inode_get_size(it->fs->superblock, it->inode_ref->inode);
    134134       
    135         // Are we at the end?
     135        /* Are we at the end? */
    136136        if (it->current_offset + skip >= size) {
    137137                rc = block_put(it->current_block);
     
    150150        next_block_idx = (it->current_offset + skip) / block_size;
    151151       
    152         // If we are moving accross block boundary,
    153         // we need to get another block
     152        /* If we are moving accross block boundary,
     153         * we need to get another block
     154         */
    154155        if (current_block_idx != next_block_idx) {
    155156                rc = block_put(it->current_block);
     
    176177        offset_in_block = (it->current_offset + skip) % block_size;
    177178       
    178         // Ensure proper alignment
     179        /* Ensure proper alignment */
    179180        if ((offset_in_block % 4) != 0) {
    180181                it->current = NULL;
     
    182183        }
    183184       
    184         // Ensure that the core of the entry does not overflow the block
     185        /* Ensure that the core of the entry does not overflow the block */
    185186        if (offset_in_block > block_size - 8) {
    186187                it->current = NULL;
     
    191192        it->current_offset += skip;
    192193       
    193         // Ensure that the whole entry does not overflow the block
     194        /* Ensure that the whole entry does not overflow the block */
    194195        skip = ext2_directory_entry_ll_get_entry_length(it->current);
    195196        if (offset_in_block + skip > block_size) {
     
    198199        }
    199200       
    200         // Ensure the name length is not too large
     201        /* Ensure the name length is not too large */
    201202        if (ext2_directory_entry_ll_get_name_length(it->fs->superblock,
    202203            it->current) > skip-8) {
  • uspace/lib/ext2/libext2_filesystem.c

    r18626b3 r6a7e497  
    117117int ext2_filesystem_check_flags(ext2_filesystem_t *fs, bool *o_read_only)
    118118{
    119         // feature flags are present in rev 1 and later
     119        /* feature flags are present in rev 1 and later */
    120120        if (ext2_superblock_get_rev_major(fs->superblock) == 0) {
    121121                *o_read_only = false;
    122                 return 0;
     122                return EOK;
    123123        }
    124124       
     
    129129        read_only = ext2_superblock_get_features_read_only(fs->superblock);
    130130       
    131         // unset any supported features
     131        /* check whether we support all features
     132         * first unset any supported feature flags
     133         * and see whether any unspported feature remains */
    132134        incompatible &= ~EXT2_SUPPORTED_INCOMPATIBLE_FEATURES;
    133135        read_only &= ~EXT2_SUPPORTED_READ_ONLY_FEATURES;
     
    171173            / EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE;
    172174       
    173         // Block group descriptor table starts at the next block after superblock
     175        /* Block group descriptor table starts at the next block after superblock */
    174176        block_id = ext2_superblock_get_first_block(fs->superblock) + 1;
    175177       
    176         // Find the block containing the descriptor we are looking for
     178        /* Find the block containing the descriptor we are looking for */
    177179        block_id += bgid / descriptors_per_block;
    178180        offset = (bgid % descriptors_per_block) * EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE;
     
    240242        inodes_per_group = ext2_superblock_get_inodes_per_group(fs->superblock);
    241243       
    242         // inode numbers are 1-based
     244        /* inode numbers are 1-based, but it is simpler to work with 0-based
     245         * when computing indices
     246         */
    243247        index -= 1;
    244248        block_group = index / inodes_per_group;
     
    269273       
    270274        newref->inode = newref->block->data + offset_in_block;
    271         newref->index = index+1; // we decremented index above
     275        /* we decremented index above, but need to store the original value
     276         * in the reference
     277         */
     278        newref->index = index+1;
    272279       
    273280        *ref = newref;
     
    315322        block_t *block;
    316323       
     324        /* Handle simple case when we are dealing with direct reference */
    317325        if (iblock < EXT2_INODE_DIRECT_BLOCKS) {
    318326                current_block = ext2_inode_get_direct_block(inode, (uint32_t)iblock);
     
    321329        }
    322330       
    323         // Compute limits for indirect block levels
    324         // TODO: compute this once when loading filesystem and store in ext2_filesystem_t
     331        /* Compute limits for indirect block levels
     332         * TODO: compute this once when loading filesystem and store in ext2_filesystem_t
     333         */
    325334        block_ids_per_block = ext2_superblock_get_block_size(fs->superblock) / sizeof(uint32_t);
    326335        limits[0] = EXT2_INODE_DIRECT_BLOCKS;
     
    332341        }
    333342       
    334         // Determine the indirection level needed to get the desired block
     343        /* Determine the indirection level needed to get the desired block */
    335344        level = -1;
    336345        for (i = 1; i < 4; i++) {
     
    345354        }
    346355       
     356        /* Compute offsets for the topmost level */
    347357        block_offset_in_level = iblock - limits[level-1];
    348358        current_block = ext2_inode_get_indirect_block(inode, level-1);
    349359        offset_in_block = block_offset_in_level / blocks_per_level[level-1];
    350360       
     361        /* Navigate through other levels, until we find the block number
     362         * or find null reference meaning we are dealing with sparse file
     363         */
    351364        while (level > 0) {
    352365                rc = block_get(&block, fs->device, current_block, 0);
     
    364377               
    365378                if (current_block == 0) {
     379                        /* This is a sparse file */
    366380                        *fblock = 0;
    367381                        return EOK;
     
    370384                level -= 1;
    371385               
     386                /* If we are on the last level, break here as
     387                 * there is no next level to visit
     388                 */
    372389                if (level == 0) {
    373390                        break;
    374391                }
    375392               
     393                /* Visit the next level */
    376394                block_offset_in_level %= blocks_per_level[level];
    377395                offset_in_block = block_offset_in_level / blocks_per_level[level-1];
     
    385403/**
    386404 * Allocate a given number of blocks and store their ids in blocks
     405 *
     406 * @todo TODO: This function is not finished and really has never been
     407 *             used (and tested) yet
    387408 *
    388409 * @param fs pointer to filesystem
     
    420441        idx = 0;
    421442       
    422         // Read the block group descriptor
     443        /* Read the block group descriptor */
    423444        rc = ext2_filesystem_get_block_group_ref(fs, block_group, &bg);
    424445        if (rc != EOK) {
     
    444465                }
    445466               
    446                 // We found a block group with free block, let's look at the block bitmap
     467                /* We found a block group with free block, let's look at the block bitmap */
    447468                bb_block = ext2_block_group_get_block_bitmap_block(bg->block_group);
    448469               
     
    452473                }
    453474               
    454                 // Use all blocks from this block group
     475                /* Use all blocks from this block group */
    455476                for (bb_idx = 0; bb_idx < block_size && idx < count; bb_idx++) {
    456477                        uint8_t *data = (uint8_t *) block->data;
     
    458479                                continue;
    459480                        }
    460                         // find an empty bit
     481                        /* find an empty bit */
    461482                        uint8_t mask;
    462483                        for (mask = 1, bb_bit = 0;
  • uspace/srv/fs/ext2fs/ext2fs.c

    r18626b3 r6a7e497  
    161161               
    162162        rc = fs_register(vfs_phone, &ext2fs_reg, &ext2fs_vfs_info, ext2fs_connection);
     163        if (rc != EOK) {
     164                fprintf(stdout, NAME ": Failed to register fs (%d)\n", rc);
     165                return 1;
     166        }
    163167       
    164168        printf(NAME ": Accepting connections\n");
  • uspace/srv/fs/ext2fs/ext2fs_ops.c

    r18626b3 r6a7e497  
    245245        }
    246246
    247         // Find length of component in bytes
    248         // TODO: check for library function call that does this
     247        /* Find length of component in bytes
     248         * TODO: check for library function call that does this
     249         */
    249250        component_size = 0;
    250251        while (*(component+component_size) != 0) {
     
    253254       
    254255        while (it.current != NULL) {
    255                 // ignore empty directory entries
     256                /* ignore empty directory entries */
    256257                if (it.current->inode != 0) {
    257258                        name_size = ext2_directory_entry_ll_get_name_length(fs->superblock,
     
    481482        }
    482483       
    483         // Find a non-empty directory entry
     484        /* Find a non-empty directory entry */
    484485        while (it.current != NULL) {
    485486                if (it.current->inode != 0) {
     
    717718        }
    718719       
    719         // Remove the instance from list
     720        /* Remove the instance from the list */
    720721        fibril_mutex_lock(&instance_list_mutex);
    721722        list_remove(&inst->link);
     
    787788        }
    788789        else {
    789                 // Other inode types not supported
     790                /* Other inode types not supported */
    790791                async_answer_0(callid, ENOTSUP);
    791792                async_answer_0(rid, ENOTSUP);
     
    828829        }
    829830       
    830         // Find the index we want to read
    831         // Note that we need to iterate and count as
    832         // the underlying structure is a linked list
    833         // Moreover, we want to skip . and .. entries
    834         // as these are not used in HelenOS
     831        /* Find the index we want to read
     832         * Note that we need to iterate and count as
     833         * the underlying structure is a linked list
     834         * Moreover, we want to skip . and .. entries
     835         * as these are not used in HelenOS
     836         */
    835837        cur = 0;
    836838        while (it.current != NULL) {
     
    842844                        inst->filesystem->superblock, it.current);
    843845               
    844                 // skip . and ..
     846                /* skip . and .. */
    845847                if (ext2fs_is_dots(&it.current->name, name_size)) {
    846848                        goto skip;
    847849                }
    848850               
    849                 // Is this the dir entry we want to read?
     851                /* Is this the dir entry we want to read? */
    850852                if (cur == pos) {
    851                         // The on-disk entry does not contain \0 at the end
    852                         // end of entry name, so we copy it to new buffer
    853                         // and add the \0 at the end
     853                        /* The on-disk entry does not contain \0 at the end
     854                         * end of entry name, so we copy it to new buffer
     855                         * and add the \0 at the end
     856                         */
    854857                        buf = malloc(name_size+1);
    855858                        if (buf == NULL) {
     
    910913       
    911914        if (pos >= file_size) {
    912                 // Read 0 bytes successfully
     915                /* Read 0 bytes successfully */
    913916                async_data_read_finalize(callid, NULL, 0);
    914917                async_answer_1(rid, EOK, 0);
     
    916919        }
    917920       
    918         // For now, we only read data from one block at a time
     921        /* For now, we only read data from one block at a time */
    919922        block_size = ext2_superblock_get_block_size(inst->filesystem->superblock);
    920923        file_block = pos / block_size;
     
    922925        bytes = min(block_size - offset_in_block, size);
    923926       
    924         // Handle end of file
     927        /* Handle end of file */
    925928        if (pos + bytes > file_size) {
    926929                bytes = file_size - pos;
    927930        }
    928931       
     932        /* Get the real block number */
    929933        rc = ext2_filesystem_get_inode_data_block_index(inst->filesystem,
    930934                inode_ref->inode, file_block, &fs_block);
     
    935939        }
    936940       
    937         // Check for sparse file
    938         // If ext2_filesystem_get_inode_data_block_index returned
    939         // fs_block == 0, it means that the given block is not allocated for the
    940         // file and we need to return a buffer of zeros
     941        /* Check for sparse file
     942         * If ext2_filesystem_get_inode_data_block_index returned
     943         * fs_block == 0, it means that the given block is not allocated for the
     944         * file and we need to return a buffer of zeros
     945         */
    941946        if (fs_block == 0) {
    942947                buffer = malloc(bytes);
     
    957962        }
    958963       
    959         // Usual case - we need to read a block from device
     964        /* Usual case - we need to read a block from device */
    960965        rc = block_get(&block, inst->devmap_handle, fs_block, BLOCK_FLAGS_NONE);
    961966        if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.