Changeset b4af128 in mainline


Ignore:
Timestamp:
2011-08-15T21:44:16Z (13 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bca3eac
Parents:
e0d98b2
Message:

exFAT: function for calculating hash for file name

Location:
uspace/srv/fs/exfat
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/exfat/exfat_dentry.c

    re0d98b2 rb4af128  
    7070}
    7171
    72 uint16_t exfat_name_hash(const uint16_t *name)
     72uint16_t exfat_name_hash(const uint16_t *name, const uint16_t *uctable, size_t chars)
    7373{
    74         /* TODO */
    75         return 0;
    76 }
     74        uint16_t hash = 0;
     75        uint16_t ch;
     76        while (*name) {
     77                if (*name < chars)
     78                        ch = uint16_t_le2host(uctable[*name]);
     79                else
     80                        ch = *name;
     81                name++;
    7782
    78 void exfat_set_checksum(const exfat_dentry_t *d, uint16_t *chksum)
    79 {
    80         /* TODO */
     83                hash = ((hash << 15) | (hash >> 1)) + (ch & 0xff);
     84                hash = ((hash << 15) | (hash >> 1)) + (ch >> 8);
     85        }
     86
     87        return hash;
    8188}
    8289
     
    9097        }
    9198        dst[*offset] = '\0';
    92 }
    93 
    94 void exfat_dentry_set_name(const uint16_t *src, size_t *offset, exfat_name_dentry_t *name)
    95 {
    96         /* TODO */
    97         size_t idx=0;
    98         while (src[*offset] && idx < EXFAT_NAME_PART_LEN) {
    99                 name->name[idx] = src[*offset];
    100                 (*offset)++;
    101                 idx++;
    102         }
    10399}
    104100
     
    115111}
    116112
     113size_t utf16_length(const uint16_t *wstr)
     114{
     115        size_t len = 0;
     116       
     117        while (*wstr++ != 0)
     118                len++;
     119       
     120        return len;
     121}
     122
    117123/**
    118124 * @}
  • uspace/srv/fs/exfat/exfat_dentry.h

    re0d98b2 rb4af128  
    151151extern exfat_dentry_clsf_t exfat_classify_dentry(const exfat_dentry_t *d);
    152152
    153 extern uint16_t exfat_name_hash(const uint16_t *name);
    154 extern void exfat_set_checksum(const exfat_dentry_t *d, uint16_t *chksum);
     153extern uint16_t exfat_name_hash(const uint16_t *name, const uint16_t *uctable,
     154    size_t chars);
    155155
    156 extern void exfat_dentry_get_name(const exfat_name_dentry_t *name, size_t size, uint16_t *dst, size_t *offset);
    157 extern void exfat_dentry_set_name(const uint16_t *src, size_t *offset, exfat_name_dentry_t *name);
     156extern void exfat_dentry_get_name(const exfat_name_dentry_t *name, size_t size,
     157    uint16_t *dst, size_t *offset);
     158
    158159
    159160extern bool exfat_valid_char(wchar_t ch);
    160161extern bool exfat_valid_name(const char *name);
     162
     163extern size_t utf16_length(const uint16_t *wstr);
    161164
    162165
Note: See TracChangeset for help on using the changeset viewer.