Changeset e65e406 in mainline for uspace/srv/fs/fat/fat_dentry.c


Ignore:
Timestamp:
2011-06-12T14:45:38Z (14 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c6aca755
Parents:
17fa0280
Message:

Fixes for mips32 big endian.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_dentry.c

    r17fa0280 re65e406  
    4040#include <str.h>
    4141#include <errno.h>
     42#include <byteorder.h>
    4243
    4344static bool is_d_char(const char ch)
     
    307308}
    308309
    309 void fat_lfn_copy_part(const uint8_t *src, size_t src_size, uint8_t *dst, size_t *offset)
     310size_t fat_lfn_copy_part(const uint8_t *src, size_t src_size, uint8_t *dst, size_t offset)
    310311{
    311312        int i;
    312         for (i=src_size-1; i>0 && (*offset)>1; i-=2) {
     313        for (i=src_size-1; i>0 && offset>1; i-=2) {
    313314                if ((src[i] == 0x00 && src[i-1] == 0x00) ||
    314315                        (src[i] == 0xff && src[i-1] == 0xff))
    315316                        continue;
    316                 dst[(*offset)-1] = src[i];
    317                 dst[(*offset)-2] = src[i-1];
    318                 (*offset)-=2;
    319         }
    320 }
    321 
    322 void fat_lfn_copy_entry(const fat_dentry_t *d, uint8_t *dst, size_t *offset)
    323 {
    324         fat_lfn_copy_part(FAT_LFN_PART3(d), FAT_LFN_PART3_SIZE, dst, offset);
    325         fat_lfn_copy_part(FAT_LFN_PART2(d), FAT_LFN_PART2_SIZE, dst, offset);
    326         fat_lfn_copy_part(FAT_LFN_PART1(d), FAT_LFN_PART1_SIZE, dst, offset);
     317                dst[offset-1] = src[i];
     318                dst[offset-2] = src[i-1];
     319                offset-=2;
     320        }
     321        return offset;
     322}
     323
     324size_t fat_lfn_copy_entry(const fat_dentry_t *d, uint8_t *dst, size_t offset)
     325{
     326        offset = fat_lfn_copy_part(FAT_LFN_PART3(d),
     327            FAT_LFN_PART3_SIZE, dst, offset);
     328        offset = fat_lfn_copy_part(FAT_LFN_PART2(d),
     329            FAT_LFN_PART2_SIZE, dst, offset);
     330        offset = fat_lfn_copy_part(FAT_LFN_PART1(d),
     331            FAT_LFN_PART1_SIZE, dst, offset);
     332
     333        return offset;
    327334}
    328335
     
    339346                                return EOVERFLOW;
    340347                } else {
    341                         c = (src[i] << 8) | src[i+1];
     348                        c = uint16_t_le2host((src[i] << 8) | src[i+1]);
    342349                        rc = chr_encode(c, (char*)dst, &offset, dst_size);
    343350                        if (rc!=EOK) {
Note: See TracChangeset for help on using the changeset viewer.