Changeset eefeefd in rtems


Ignore:
Timestamp:
Jan 30, 2013, 9:31:40 AM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
524cdbbc
Parents:
1b937c6
git-author:
Sebastian Huber <sebastian.huber@…> (01/30/13 09:31:40)
git-committer:
Sebastian Huber <sebastian.huber@…> (01/30/13 16:08:04)
Message:

dosfs: Always release the buffers

Release the buffers also if this is not the last reference to the file
object since otherwise we may hold modified data indefinitely.

File:
1 edited

Legend:

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

    r1b937c6 reefeefd  
    192192{
    193193    int            rc = RC_OK;
    194     uint32_t       key = 0;
    195194
    196195    /*
    197196     * if links_num field of fat-file descriptor is greater than 1
    198      * decrement the count of links and return
     197     * decrement only the count of links
    199198     */
    200199    if (fat_fd->links_num > 1)
    201200    {
    202201        fat_fd->links_num--;
    203         return rc;
    204     }
    205 
    206     key = fat_construct_key(fs_info, &fat_fd->dir_pos.sname);
    207 
    208     if (fat_fd->flags & FAT_FILE_REMOVED)
    209     {
    210         rc = fat_file_truncate(fs_info, fat_fd, 0);
    211         if ( rc != RC_OK )
    212             return rc;
    213 
    214         _hash_delete(fs_info->rhash, key, fat_fd->ino, fat_fd);
    215 
    216         if ( fat_ino_is_unique(fs_info, fat_fd->ino) )
    217             fat_free_unique_ino(fs_info, fat_fd->ino);
    218 
    219         free(fat_fd);
    220202    }
    221203    else
    222204    {
    223         if (fat_ino_is_unique(fs_info, fat_fd->ino))
    224         {
    225             fat_fd->links_num = 0;
     205        uint32_t key = fat_construct_key(fs_info, &fat_fd->dir_pos.sname);
     206
     207        if (fat_fd->flags & FAT_FILE_REMOVED)
     208        {
     209            rc = fat_file_truncate(fs_info, fat_fd, 0);
     210            if (rc == RC_OK)
     211            {
     212                _hash_delete(fs_info->rhash, key, fat_fd->ino, fat_fd);
     213
     214                if (fat_ino_is_unique(fs_info, fat_fd->ino))
     215                    fat_free_unique_ino(fs_info, fat_fd->ino);
     216
     217                free(fat_fd);
     218            }
    226219        }
    227220        else
    228221        {
    229             _hash_delete(fs_info->vhash, key, fat_fd->ino, fat_fd);
    230             free(fat_fd);
    231         }
    232     }
     222            if (fat_ino_is_unique(fs_info, fat_fd->ino))
     223            {
     224                fat_fd->links_num = 0;
     225            }
     226            else
     227            {
     228                _hash_delete(fs_info->vhash, key, fat_fd->ino, fat_fd);
     229                free(fat_fd);
     230            }
     231        }
     232    }
     233
    233234    /*
    234235     * flush any modified "cached" buffer back to disk
Note: See TracChangeset for help on using the changeset viewer.