Changeset ccd4a7f in rtems


Ignore:
Timestamp:
Mar 14, 2017, 7:13:07 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
063eb574
Parents:
e69ee36
git-author:
Sebastian Huber <sebastian.huber@…> (03/14/17 07:13:07)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/16/17 14:33:57)
Message:

dosfs: Simplify msdos_creat_node()

Update #2929.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/src/dosfs/msdos_create.c

    re69ee36 rccd4a7f  
    180180    if (type == FAT_DIRECTORY)
    181181    {
     182        uint32_t unused;
     183
    182184        /* open new directory as fat-file */
    183185        rc = fat_file_open(&fs_info->fat, &dir_pos, &fat_fd);
     
    189191         * descritor
    190192         */
    191         fat_fd->fat_file_size = 0;
    192193        fat_fd->fat_file_type = FAT_DIRECTORY;
    193194        fat_fd->size_limit = MSDOS_MAX_DIR_LENGTH;
    194195        fat_file_set_ctime_mtime(fat_fd, now);
     196
     197        /* extend it to contain exactly one cluster */
     198        rc = fat_file_extend(&fs_info->fat,
     199                             fat_fd,
     200                             true,
     201                             fs_info->fat.vol.bpc,
     202                             &unused);
     203        if (rc != RC_OK)
     204            goto err;
    195205
    196206        /*
     
    227237        }
    228238
    229         /*
    230          * write dot and dotdot entries to new fat-file: currently fat-file
    231          * correspondes to a new node is zero length, so it will be extended
    232          * by one cluster and entries will be written
    233          */
     239        /* set up cluster num for dot entry */
     240        *MSDOS_DIR_FIRST_CLUSTER_LOW(DOT_NODE_P(dot_dotdot)) =
     241                CT_LE_W((uint16_t  )((fat_fd->cln) & 0x0000FFFF));
     242        *MSDOS_DIR_FIRST_CLUSTER_HI(DOT_NODE_P(dot_dotdot)) =
     243                CT_LE_W((uint16_t  )(((fat_fd->cln) & 0xFFFF0000) >> 16));
     244
     245        /* write dot and dotdot entries */
    234246        ret = fat_file_write(&fs_info->fat, fat_fd, 0,
    235247                             MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE * 2,
     
    241253        }
    242254
    243         /* increment fat-file size by cluster size */
    244         fat_fd->fat_file_size += fs_info->fat.vol.bpc;
    245 
    246         /* set up cluster num for dot entry */
    247         *MSDOS_DIR_FIRST_CLUSTER_LOW(DOT_NODE_P(dot_dotdot)) =
    248                 CT_LE_W((uint16_t  )((fat_fd->cln) & 0x0000FFFF));
    249         *MSDOS_DIR_FIRST_CLUSTER_HI(DOT_NODE_P(dot_dotdot)) =
    250                 CT_LE_W((uint16_t  )(((fat_fd->cln) & 0xFFFF0000) >> 16));
    251 
    252         /* rewrite dot entry */
    253         ret = fat_file_write(&fs_info->fat, fat_fd, 0,
    254                              MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE,
    255                              (uint8_t *)DOT_NODE_P(dot_dotdot));
    256         if (ret < 0)
    257         {
    258             rc = -1;
    259             goto error;
    260         }
    261 
    262255        /* write first cluster num of a new directory to disk */
    263256        rc = fat_file_write_first_cluster_num(&fs_info->fat, fat_fd);
Note: See TracChangeset for help on using the changeset viewer.