Changeset e65e406 in mainline
- Timestamp:
- 2011-06-12T14:45:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c6aca755
- Parents:
- 17fa0280
- Location:
- uspace/srv/fs/fat
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_dentry.c
r17fa0280 re65e406 40 40 #include <str.h> 41 41 #include <errno.h> 42 #include <byteorder.h> 42 43 43 44 static bool is_d_char(const char ch) … … 307 308 } 308 309 309 void fat_lfn_copy_part(const uint8_t *src, size_t src_size, uint8_t *dst, size_t *offset)310 size_t fat_lfn_copy_part(const uint8_t *src, size_t src_size, uint8_t *dst, size_t offset) 310 311 { 311 312 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) { 313 314 if ((src[i] == 0x00 && src[i-1] == 0x00) || 314 315 (src[i] == 0xff && src[i-1] == 0xff)) 315 316 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 324 size_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; 327 334 } 328 335 … … 339 346 return EOVERFLOW; 340 347 } else { 341 c = (src[i] << 8) | src[i+1];348 c = uint16_t_le2host((src[i] << 8) | src[i+1]); 342 349 rc = chr_encode(c, (char*)dst, &offset, dst_size); 343 350 if (rc!=EOK) { -
uspace/srv/fs/fat/fat_dentry.h
r17fa0280 re65e406 138 138 extern size_t fat_lfn_str_nlength(const uint8_t *, size_t); 139 139 extern size_t fat_lfn_size(const fat_dentry_t *); 140 extern void fat_lfn_copy_part(const uint8_t *, size_t, uint8_t *, size_t *);141 extern void fat_lfn_copy_entry(const fat_dentry_t *, uint8_t *, size_t *);140 extern size_t fat_lfn_copy_part(const uint8_t *, size_t, uint8_t *, size_t); 141 extern size_t fat_lfn_copy_entry(const fat_dentry_t *, uint8_t *, size_t); 142 142 extern int fat_lfn_convert_name(const uint8_t *, size_t, uint8_t *, size_t); 143 143 -
uspace/srv/fs/fat/fat_directory.c
r17fa0280 re65e406 118 118 (di->checksum == FAT_LFN_CHKSUM(d))) { 119 119 /* Right order! */ 120 fat_lfn_copy_entry(d, di->lfn_utf16, &di->lfn_offset); 120 di->lfn_offset = fat_lfn_copy_entry(d, di->lfn_utf16, 121 di->lfn_offset); 121 122 } else { 122 123 /* Something wrong with order. Skip this long entries set */ … … 133 134 (FAT_LFN_COUNT(d) - 1)) + fat_lfn_size(d); 134 135 di->lfn_offset = di->lfn_size; 135 fat_lfn_copy_entry(d, di->lfn_utf16, &di->lfn_offset); 136 di->lfn_offset = fat_lfn_copy_entry(d, di->lfn_utf16, 137 di->lfn_offset); 136 138 di->checksum = FAT_LFN_CHKSUM(d); 137 139 }
Note:
See TracChangeset
for help on using the changeset viewer.