Changeset 8ceba1e in mainline


Ignore:
Timestamp:
2011-03-09T22:02:53Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c4c7f5a
Parents:
b00a2f2
Message:

Improve minixfs server check_magic_number() function

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    rb00a2f2 r8ceba1e  
    9797        $(USPACE_PATH)/srv/fs/tmpfs/tmpfs \
    9898        $(USPACE_PATH)/srv/fs/fat/fat \
     99        $(USPACE_PATH)/srv/fs/minixfs/mfs \
    99100        $(USPACE_PATH)/srv/taskmon/taskmon \
    100101        $(USPACE_PATH)/srv/hw/netif/ne2000/ne2000 \
  • uspace/app/mkminix/mkminix.c

    rb00a2f2 r8ceba1e  
    5757#define USED    1
    5858
    59 #define UPPER(n, size) (((n) / (size)) + (((n) % (size)) != 0))
    60 #define NEXT_DENTRY(p, dirsize) (p += dirsize)
    61 #define FIRST_ZONE(bs)          ((MFS_BOOTBLOCK_SIZE + MFS_SUPERBLOCK_SIZE) / (bs))
     59#define UPPER(n, size)                  (((n) / (size)) + (((n) % (size)) != 0))
     60#define NEXT_DENTRY(p, dirsize)         (p += dirsize)
     61#define FIRST_ZONE(bs)                  ((MFS_BOOTBLOCK_SIZE + MFS_SUPERBLOCK_SIZE) / (bs))
     62#define CONVERT_1K_OFF(off, bs)         ((off) * ((bs) / MFS_MIN_BLOCKSIZE))
    6263
    6364typedef enum {
     
    319320        int rc;
    320321        long itable_off;
     322        unsigned long itable_size;
    321323
    322324        itable_off = FIRST_ZONE(sb->block_size);
     
    324326
    325327        /*Convert to 1K offset*/
    326         itable_off *= sb->block_size / MFS_MIN_BLOCKSIZE;
     328        itable_off = CONVERT_1K_OFF(itable_off, sb->block_size);
     329        itable_size = CONVERT_1K_OFF(sb->itable_size, sb->block_size);
    327330
    328331        itable_buf = malloc(sb->block_size);
     
    333336        memset(itable_buf, 0x00, sb->block_size);
    334337
    335         for (i = 0; i < sb->itable_size * (sb->block_size / MFS_MIN_BLOCKSIZE); ++i, ++itable_off) {
     338        for (i = 0; i < itable_size; ++i, ++itable_off) {
    336339                rc = block_write_direct(sb->handle, itable_off, 1, itable_buf);
    337340
     
    386389
    387390        /*Convert to 1K block offset*/
    388         itable_off *= sb->block_size / MFS_MIN_BLOCKSIZE;
     391        itable_off = CONVERT_1K_OFF(itable_off, sb->block_size);
    389392
    390393        const time_t sec = time(NULL);
     
    570573
    571574        /*Convert to 1K block offsets*/
    572         ibmap_nblocks *= sb->block_size / MFS_BLOCKSIZE;
    573         zbmap_nblocks *= sb->block_size / MFS_BLOCKSIZE;
     575        ibmap_nblocks = CONVERT_1K_OFF(ibmap_nblocks, sb->block_size);
     576        zbmap_nblocks = CONVERT_1K_OFF(zbmap_nblocks, sb->block_size);
    574577
    575578        ibmap_buf8 = (uint8_t *) ibmap_buf;
    576579        zbmap_buf8 = (uint8_t *) zbmap_buf;
    577580
     581        int start_block = FIRST_ZONE(sb->block_size);
     582
    578583        for (i = 0; i < ibmap_nblocks; ++i) {
    579                 if ((rc = block_write_direct(sb->handle, 2 + i,
     584                if ((rc = block_write_direct(sb->handle, start_block + i,
    580585                                1, (ibmap_buf8 + i * MFS_BLOCKSIZE))) != EOK)
    581586                        return rc;
    582587        }
    583588
     589        start_block = FIRST_ZONE(sb->block_size) + ibmap_nblocks;
     590
    584591        for (i = 0; i < zbmap_nblocks; ++i) {
    585                 if ((rc = block_write_direct(sb->handle, 2 + ibmap_nblocks + i,
     592                if ((rc = block_write_direct(sb->handle, start_block + i,
    586593                                1, (zbmap_buf8 + i * MFS_BLOCKSIZE))) != EOK)
    587594                        return rc;
  • uspace/srv/fs/minixfs/mfs.c

    rb00a2f2 r8ceba1e  
    9999                default:
    100100                case IPC_M_PHONE_HUNGUP:
    101                         return;         
     101                        return;
     102                case VFS_OUT_MOUNTED:
     103                        mfs_mounted(callid, &call);
     104                        break;
    102105                }
    103106        }
  • uspace/srv/fs/minixfs/mfs_super.c

    rb00a2f2 r8ceba1e  
    4040#include "../../vfs/vfs.h"
    4141
    42 static bool check_magic_number(int16_t magic, bool *native, mfs_version_t *version);
     42static bool check_magic_number(uint16_t magic, bool *native,
     43                                mfs_version_t *version, bool *longfilenames);
    4344
    4445void mfs_mounted(ipc_callid_t rid, ipc_call_t *request)
     
    4748        enum cache_mode cmode; 
    4849        struct mfs3_superblock *sp;
    49         bool native;
     50        bool native, longnames;
    5051        mfs_version_t version;
    5152
     
    8586        sp = block_bb_get(devmap_handle);
    8687
    87         if (!check_magic_number(sp->s_magic, &native, &version)) {
     88        if (!check_magic_number(sp->s_magic, &native, &version, &longnames)) {
    8889                /*Magic number is invalid!*/
    8990                block_fini(devmap_handle);
     
    9394}
    9495
    95 static bool check_magic_number(int16_t magic, bool *native, mfs_version_t *version)
     96static bool check_magic_number(uint16_t magic, bool *native,
     97                                mfs_version_t *version, bool *longfilenames)
    9698{
     99        *longfilenames = false;
     100
    97101        if (magic == MFS_MAGIC_V1 || magic == MFS_MAGIC_V1R) {
    98102                *native = magic == MFS_MAGIC_V1;
    99103                *version = MFS_VERSION_V1;
    100104                return true;
     105        } else if (magic == MFS_MAGIC_V1L || magic == MFS_MAGIC_V1LR) {
     106                *native = magic == MFS_MAGIC_V1L;
     107                *version = MFS_VERSION_V1;
     108                *longfilenames = true;
     109                return true;
    101110        } else if (magic == MFS_MAGIC_V2 || magic == MFS_MAGIC_V2R) {
    102111                *native = magic == MFS_MAGIC_V2;
    103112                *version = MFS_VERSION_V2;
     113                return true;
     114        } else if (magic == MFS_MAGIC_V2L || magic == MFS_MAGIC_V2LR) {
     115                *native = magic == MFS_MAGIC_V2L;
     116                *version = MFS_VERSION_V2;
     117                *longfilenames = true;
    104118                return true;
    105119        } else if (magic == MFS_MAGIC_V3 || magic == MFS_MAGIC_V3R) {
Note: See TracChangeset for help on using the changeset viewer.