summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/dosfs/msdos_fsunmount.c
blob: e3cef45824fb81f8f1ef932fdd90d803105f0ee6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
 * @file
 *
 * @brief Shut Down MSDOS FileSystem
 * @ingroup libfs_msdos MSDOS FileSystem
 */

/*
 *  Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
 *  Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */

#if HAVE_CONFIG_H
#include "config.h"
#endif

#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

#include <rtems.h>
#include <rtems/libio_.h>

#include "fat.h"
#include "fat_fat_operations.h"
#include "fat_file.h"

#include "msdos.h"

/* msdos_shut_down --
 *     Shut down MSDOS filesystem - free all allocated resources (don't
 *     return if deallocation of some resource failed - free as much as
 *     possible).
 *
 * PARAMETERS:
 *     temp_mt_entry - mount table entry
 *
 */
void
msdos_shut_down(rtems_filesystem_mount_table_entry_t *temp_mt_entry)
{
    msdos_fs_info_t *fs_info = temp_mt_entry->fs_info;
    fat_file_fd_t   *fat_fd = temp_mt_entry->mt_fs_root->location.node_access;
    rtems_dosfs_convert_control *converter = fs_info->converter;

    /* close fat-file which corresponds to root directory */
    fat_file_close(&fs_info->fat, fat_fd);

    fat_shutdown_drive(&fs_info->fat);

    rtems_semaphore_delete(fs_info->vol_sema);
    (*converter->handler->destroy)( converter );
    free(fs_info->cl_buf);
    free(temp_mt_entry->fs_info);
}