Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 038b289 in mainline


Ignore:
Timestamp:
2011-09-06T23:34:35Z (10 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
888207c9, c05642d, c0e53ff
Parents:
7e9fce6 (diff), fb7e5a9a (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 MFS improvements from lp:mfs.

Files:
2 edited
11 moved

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    r7e9fce6 r038b289  
    102102        $(USPACE_PATH)/srv/fs/tmpfs/tmpfs \
    103103        $(USPACE_PATH)/srv/fs/fat/fat \
     104        $(USPACE_PATH)/srv/fs/mfs/mfs \
    104105        $(USPACE_PATH)/srv/fs/cdfs/cdfs \
    105         $(USPACE_PATH)/srv/fs/minixfs/mfs \
    106106        $(USPACE_PATH)/srv/fs/exfat/exfat \
    107107        $(USPACE_PATH)/srv/fs/ext2fs/ext2fs \
     
    156156        $(USPACE_PATH)/app/locinfo/locinfo \
    157157        $(USPACE_PATH)/app/mkfat/mkfat \
    158         $(USPACE_PATH)/app/mkminix/mkminix \
     158        $(USPACE_PATH)/app/mkmfs/mkmfs \
    159159        $(USPACE_PATH)/app/lsusb/lsusb \
    160160        $(USPACE_PATH)/app/sbi/sbi \
  • uspace/Makefile

    r7e9fce6 r038b289  
    4848        app/lsusb \
    4949        app/mkfat \
    50         app/mkminix \
     50        app/mkmfs \
    5151        app/redir \
    5252        app/sbi \
     
    8484        srv/fs/cdfs \
    8585        srv/fs/tmpfs \
    86         srv/fs/minixfs \
     86        srv/fs/mfs \
    8787        srv/fs/locfs \
    8888        srv/fs/ext2fs \
  • uspace/app/mkmfs/Makefile

    r7e9fce6 r038b289  
    3131LIBS = $(LIBBLOCK_PREFIX)/libblock.a
    3232EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBMINIX_PREFIX)
    33 BINARY = mkminix
     33BINARY = mkmfs
    3434
    3535SOURCES = \
    36         mkminix.c
     36        mkmfs.c
    3737
    3838include $(USPACE_PREFIX)/Makefile.common
  • uspace/app/mkmfs/mkmfs.c

    r7e9fce6 r038b289  
    3333
    3434/**
    35  * @file        mkminix.c
     35 * @file        mkmfs.c
    3636 * @brief       Tool for creating new Minix file systems.
    3737 *
     
    5151#include <minix.h>
    5252
    53 #define NAME    "mkminix"
     53#define NAME    "mkmfs"
    5454
    5555#define FREE    0
     
    8383};
    8484
    85 static void     help_cmd_mkminix(help_level_t level);
     85static void     help_cmd_mkmfs(help_level_t level);
    8686static int      num_of_set_bits(uint32_t n);
    8787static int      init_superblock(struct mfs_sb_info *sb);
     
    130130
    131131        if (argc == 1) {
    132                 help_cmd_mkminix(HELP_SHORT);
    133                 printf("Incorrect number of arguments, try `mkminix --help'\n");
     132                help_cmd_mkmfs(HELP_SHORT);
     133                printf("Incorrect number of arguments, try `mkmfs --help'\n");
    134134                exit(0);
    135135        }
     
    139139                switch (c) {
    140140                case 'h':
    141                         help_cmd_mkminix(HELP_LONG);
     141                        help_cmd_mkmfs(HELP_LONG);
    142142                        exit(0);
    143143                case '1':
     
    197197
    198198        if (!device_name) {
    199                 help_cmd_mkminix(HELP_LONG);
     199                help_cmd_mkmfs(HELP_LONG);
    200200                exit(0);
    201201        }
     
    705705}
    706706
    707 static void help_cmd_mkminix(help_level_t level)
     707static void help_cmd_mkmfs(help_level_t level)
    708708{
    709709        if (level == HELP_SHORT) {
  • uspace/srv/fs/mfs/mfs_balloc.c

    r7e9fce6 r038b289  
    5656{
    5757        int r = mfs_alloc_bit(inst, inum, BMAP_INODE);
    58 
    59         *inum += 1;
    6058        return r;
    6159}
     
    7169mfs_free_inode(struct mfs_instance *inst, uint32_t inum)
    7270{
    73         return mfs_free_bit(inst, inum - 1, BMAP_INODE);
     71        return mfs_free_bit(inst, inum, BMAP_INODE);
    7472}
    7573
     
    202200                start_block = 2 + sbi->ibmap_blocks;
    203201                nblocks = sbi->zbmap_blocks;
    204                 limit = sbi->nzones;
     202                limit = sbi->nzones - sbi->firstdatazone - 1;
    205203        } else {
    206204                /*bid == BMAP_INODE*/
  • uspace/srv/fs/mfs/mfs_rw.c

    r7e9fce6 r038b289  
    8383        const struct mfs_sb_info *sbi = mnode->instance->sbi;
    8484
     85        if (pos >= sbi->max_file_size) {
     86                /*Can't write beyond the maximum file size*/
     87                return EINVAL;
     88        }
     89
    8590        /*Compute the relative block number in file*/
    8691        int rblock = pos / sbi->block_size;
     
    97102        uint32_t *ind_zone, *ind2_zone;
    98103
    99         assert(mnode);
    100104        struct mfs_ino_info *ino_i = mnode->ino_i;
    101 
    102         assert(ino_i);
    103         assert(mnode->instance);
    104 
    105105        struct mfs_instance *inst = mnode->instance;
    106106        struct mfs_sb_info *sbi = inst->sbi;
    107         assert(sbi);
    108107
    109108        const mfs_version_t fs_version = sbi->fs_version;
     109        const bool deleting = write_mode && (w_block == 0);
    110110
    111111        if (fs_version == MFS_VERSION_V1) {
     
    132132                /*The wanted block is in the single indirect zone chain*/
    133133                if (ino_i->i_izone[0] == 0) {
    134                         if (write_mode) {
     134                        if (write_mode && !deleting) {
    135135                                uint32_t zone;
    136136                                r = alloc_zone_and_clear(inst, &zone);
     
    166166        /*read the first indirect zone of the chain*/
    167167        if (ino_i->i_izone[1] == 0) {
    168                 if (write_mode) {
     168                if (write_mode && !deleting) {
    169169                        uint32_t zone;
    170170                        r = alloc_zone_and_clear(inst, &zone);
     
    193193        /*read the second indirect zone of the chain*/
    194194        if (ind_zone[ind2_off] == 0) {
    195                 if (write_mode) {
     195                if (write_mode && !deleting) {
    196196                        uint32_t zone;
    197197                        r = alloc_zone_and_clear(inst, &zone);
     
    213213                goto out_free_ind1;
    214214
    215         *b = ind2_zone[ind2_off % ptrs_per_block];
     215        *b = ind2_zone[rblock - (ind2_off * ptrs_per_block)];
    216216        if (write_mode) {
    217                 ind2_zone[ind2_off % ptrs_per_block] = w_block;
     217                ind2_zone[rblock - (ind2_off * ptrs_per_block)] = w_block;
    218218                write_ind_zone(inst, ind_zone[ind2_off], ind2_zone);
    219219        }
     
    371371        block_t *b;
    372372
    373         r = block_get(&b, inst->service_id, zone, BLOCK_FLAGS_NONE);
     373        r = block_get(&b, inst->service_id, zone, BLOCK_FLAGS_NOREAD);
    374374        if (r != EOK)
    375375                return r;
Note: See TracChangeset for help on using the changeset viewer.