~youscribe/parted/3.1

« back to all changes in this revision

Viewing changes to libparted/fs/r/fat/fat.h

  • Committer: Guilhem Lettron
  • Date: 2012-10-22 14:37:59 UTC
  • Revision ID: guilhem+ubuntu@lettron.fr-20121022143759-m403kecgz13sknvp
3.1 from tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    libparted
 
3
    Copyright (C) 1998-2001, 2007, 2009-2012 Free Software Foundation, Inc.
 
4
 
 
5
    This program is free software; you can redistribute it and/or modify
 
6
    it under the terms of the GNU General Public License as published by
 
7
    the Free Software Foundation; either version 3 of the License, or
 
8
    (at your option) any later version.
 
9
 
 
10
    This program is distributed in the hope that it will be useful,
 
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
    GNU General Public License for more details.
 
14
 
 
15
    You should have received a copy of the GNU General Public License
 
16
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
*/
 
18
 
 
19
#ifndef FAT_H_INCLUDED
 
20
#define FAT_H_INCLUDED
 
21
 
 
22
#include <parted/parted.h>
 
23
#include <parted/endian.h>
 
24
#include <parted/debug.h>
 
25
 
 
26
#if ENABLE_NLS
 
27
#  include <libintl.h>
 
28
#  define _(String) dgettext (PACKAGE, String)
 
29
#else
 
30
#  define _(String) (String)
 
31
#endif /* ENABLE_NLS */
 
32
 
 
33
#include <stdlib.h>
 
34
#include <sys/types.h>
 
35
#include <sys/stat.h>
 
36
#include <fcntl.h>
 
37
 
 
38
#define BUFFER_SIZE  1024       /* buffer size in sectors (512 bytes) */
 
39
 
 
40
typedef uint32_t                FatCluster;
 
41
typedef int32_t                 FatFragment;
 
42
 
 
43
enum _FatType {
 
44
        FAT_TYPE_FAT12,
 
45
        FAT_TYPE_FAT16,
 
46
        FAT_TYPE_FAT32
 
47
};
 
48
typedef enum _FatType           FatType;
 
49
 
 
50
typedef struct _FatSpecific     FatSpecific;
 
51
typedef struct _FatDirEntry     FatDirEntry;
 
52
 
 
53
/* FIXME: YUCKY */
 
54
#include "table.h"
 
55
#include "bootsector.h"
 
56
#include "context.h"
 
57
#include "fatio.h"
 
58
#include "traverse.h"
 
59
#include "calc.h"
 
60
#include "count.h"
 
61
#include "clstdup.h"
 
62
 
 
63
struct __attribute__ ((packed)) _FatDirEntry {
 
64
        char            name[8];
 
65
        uint8_t         extension[3];
 
66
        uint8_t         attributes;
 
67
        uint8_t         is_upper_case_name;
 
68
        uint8_t         creation_time_low;      /* milliseconds */
 
69
        uint16_t        creation_time_high;
 
70
        uint16_t        creation_date;
 
71
        uint16_t        access_date;
 
72
        uint16_t        first_cluster_high;     /* for FAT32 */
 
73
        uint16_t        time;
 
74
        uint16_t        date;
 
75
        uint16_t        first_cluster;
 
76
        uint32_t        length;
 
77
};
 
78
 
 
79
struct _FatSpecific {
 
80
        FatBootSector   boot_sector;    /* structure of boot sector */
 
81
        FatInfoSector   info_sector;    /* fat32-only information sector */
 
82
 
 
83
        int             logical_sector_size;    /* illogical sector size :-) */
 
84
        PedSector       sector_count;
 
85
 
 
86
        int             sectors_per_track;      /* BIOS CHS stuff (S) */
 
87
        int             heads;                  /* BIOS CHS stuff (H) */
 
88
 
 
89
        int             cluster_size;
 
90
        PedSector       cluster_sectors;
 
91
        FatCluster      cluster_count;
 
92
        int             dir_entries_per_cluster;
 
93
 
 
94
        FatType         fat_type;
 
95
        int             fat_table_count;
 
96
        PedSector       fat_sectors;
 
97
 
 
98
        uint32_t        serial_number;
 
99
 
 
100
        PedSector       info_sector_offset;     /* FAT32 only */
 
101
        PedSector       fat_offset;
 
102
        PedSector       root_dir_offset;        /* non-FAT32 */
 
103
        PedSector       cluster_offset;
 
104
        PedSector       boot_sector_backup_offset;
 
105
 
 
106
        FatCluster      root_cluster;           /* FAT32 only */
 
107
        int             root_dir_entry_count;   /* non-FAT32 */
 
108
        PedSector       root_dir_sector_count;  /* non-FAT32 */
 
109
        FatCluster      total_dir_clusters;
 
110
 
 
111
        FatTable*       fat;
 
112
        FatClusterInfo* cluster_info;
 
113
 
 
114
        PedSector       buffer_sectors;
 
115
        char*           buffer;
 
116
 
 
117
        int             frag_size;
 
118
        PedSector       frag_sectors;
 
119
        FatFragment     frag_count;
 
120
        FatFragment     buffer_frags;
 
121
        FatFragment     cluster_frags;
 
122
};
 
123
 
 
124
#define FAT_SPECIFIC(fs)        ((FatSpecific*) fs->type_specific)
 
125
 
 
126
#define FAT_ROOT                0
 
127
 
 
128
#define DELETED_FLAG            0xe5
 
129
 
 
130
#define READONLY_ATTR           0x01
 
131
#define HIDDEN_ATTR             0x02
 
132
#define SYSTEM_ATTR             0x04
 
133
#define VOLUME_LABEL_ATTR       0x08
 
134
#define VFAT_ATTR               0x0f
 
135
#define DIRECTORY_ATTR          0x10
 
136
#define ARCH_ATTR               0x20
 
137
 
 
138
#define MAX_FAT12_CLUSTERS      4086
 
139
#define MAX_FAT16_CLUSTERS      65526
 
140
#define MAX_FAT32_CLUSTERS      2000000
 
141
 
 
142
#define FAT_ROOT_DIR_ENTRY_COUNT        512
 
143
 
 
144
extern PedFileSystemType fat16_type;
 
145
extern PedFileSystemType fat32_type;
 
146
 
 
147
extern void fat_print (const PedFileSystem* fs);
 
148
 
 
149
extern PedFileSystem* fat_alloc (const PedGeometry* geom);
 
150
extern void fat_free (PedFileSystem* fs);
 
151
extern int fat_alloc_buffers (PedFileSystem* fs);
 
152
extern void fat_free_buffers (PedFileSystem* fs);
 
153
 
 
154
extern int fat_resize (PedFileSystem* fs, PedGeometry* geom, PedTimer* timer);
 
155
 
 
156
extern int fat_set_frag_sectors (PedFileSystem* fs, PedSector frag_sectors);
 
157
 
 
158
#endif /* FAT_H_INCLUDED */