Changeset 3e018e45 in mainline


Ignore:
Timestamp:
2011-07-07T20:03:19Z (13 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
af4dec0
Parents:
411e9ca
Message:
  1. Rewrite fat_directory_write to support:
  • using new fat_valid_name and fat_valid_short_name functions
  • flag for disabling/enabling LFN support on writing
  • using uint16_t instead of wchar_t for UTF16
  1. Rewrite fat_directory_create_sfn to support using uint16_t

instead of wchar_t for UTF16

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

Legend:

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

    r411e9ca r3e018e45  
    255255{
    256256        int rc;
    257         int long_entry_count;
    258         uint8_t checksum;
    259         wchar_t wname[FAT_LFN_NAME_SIZE];
    260         size_t lfn_size, lfn_offset;
    261        
    262         rc = str_to_wstr(wname, FAT_LFN_NAME_SIZE, name);
    263         if (rc != EOK)
    264                 return rc;
    265         if (fat_dentry_is_sfn(wname)) {
     257        bool enable_lfn = true; /* We can use this variable to switch off LFN support */
     258       
     259        if (fat_valid_short_name(name)) {
    266260                /* NAME could be directly stored in dentry without creating LFN */
    267261                fat_dentry_name_set(de, name);
    268 
    269262                if (fat_directory_is_sfn_exist(di, de))
    270263                        return EEXIST;
     
    273266                        return rc;
    274267                rc = fat_directory_write_dentry(di, de);
    275                 if (rc != EOK)
    276                         return rc;
    277 
    278                 return EOK;
    279         }
    280         else
    281         {
     268                return rc;
     269        } else if (enable_lfn && fat_valid_name(name)) {
    282270                /* We should create long entries to store name */
    283                 lfn_size = wstr_length(wname);
     271                int long_entry_count;
     272                uint8_t checksum;
     273                uint16_t wname[FAT_LFN_NAME_SIZE];
     274                size_t lfn_size, lfn_offset;
     275               
     276                rc = str_to_utf16(wname, FAT_LFN_NAME_SIZE, name);
     277                if (rc != EOK)
     278                        return rc;
     279               
     280                lfn_size = utf16_length(wname);
    284281                long_entry_count = lfn_size / FAT_LFN_ENTRY_SIZE;
    285282                if (lfn_size % FAT_LFN_ENTRY_SIZE)
     
    291288
    292289                /* Write Short entry */
    293                 rc = fat_directory_create_sfn(di, de, wname);
     290                rc = fat_directory_create_sfn(di, de, name);
    294291                if (rc != EOK)
    295292                        return rc;
     
    322319
    323320                rc = fat_directory_seek(di, start_pos+long_entry_count);
    324                 if (rc != EOK)
    325                         return rc;
    326                 return EOK;
    327         }
    328 }
    329 
    330 int fat_directory_create_sfn(fat_directory_t *di, fat_dentry_t *de, const wchar_t *wname)
     321                return rc;
     322        }
     323
     324        return ENOTSUP;
     325}
     326
     327int fat_directory_create_sfn(fat_directory_t *di, fat_dentry_t *de, const char *lname)
    331328{
    332329        char name[FAT_NAME_LEN+1];
     
    337334        memset(number, FAT_PAD, FAT_NAME_LEN);
    338335
    339         size_t name_len = wstr_size(wname);
    340         wchar_t *pdot = wstr_rchr(wname, '.');
     336        size_t name_len = str_size(lname);
     337        char *pdot = str_rchr(lname, '.');
    341338        ext[FAT_EXT_LEN] = '\0';
    342339        if (pdot) {
    343340                pdot++;
    344                 wstr_to_ascii(ext, pdot, FAT_EXT_LEN, FAT_SFN_CHAR);
    345                 name_len = (pdot - wname - 1);
     341                str_to_ascii(ext, pdot, FAT_EXT_LEN, FAT_SFN_CHAR);
     342                name_len = (pdot - lname - 1);
    346343        }
    347344        if (name_len > FAT_NAME_LEN)
    348345                name_len = FAT_NAME_LEN;
    349         wstr_to_ascii(name, wname, name_len, FAT_SFN_CHAR);
     346        str_to_ascii(name, lname, name_len, FAT_SFN_CHAR);
    350347
    351348        size_t idx;
  • uspace/srv/fs/fat/fat_directory.h

    r411e9ca r3e018e45  
    6868extern int fat_directory_lookup_free(fat_directory_t *di, size_t count);
    6969extern int fat_directory_write_dentry(fat_directory_t *di, fat_dentry_t *de);
    70 extern int fat_directory_create_sfn(fat_directory_t *di, fat_dentry_t *de, const wchar_t *wname);
     70extern int fat_directory_create_sfn(fat_directory_t *di, fat_dentry_t *de, const char *lname);
    7171extern int fat_directory_expand(fat_directory_t *di);
    7272
Note: See TracChangeset for help on using the changeset viewer.