1 From e18d72f70e30109492e9602ace5560e0c90b4a8b Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
3 Date: Sat, 7 Mar 2015 13:23:23 +0100
4 Subject: [PATCH 11/14] Remove linux/msdos_fs.h includes
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
10 Signed-off-by: Andreas Bombe <aeb@debian.org>
12 src/file.c | 7 +------
14 src/fsck.fat.h | 8 ++------
15 src/mkfs.fat.c | 32 +++---------------------------
16 src/msdos_fs.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
17 5 files changed, 69 insertions(+), 41 deletions(-)
18 create mode 100644 src/msdos_fs.h
20 diff --git a/src/file.c b/src/file.c
21 index 0b53840..9519070 100644
28 -#define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
29 -#define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h> */
30 -#define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
32 -#include <linux/msdos_fs.h>
36 +#include "msdos_fs.h"
40 diff --git a/src/file.h b/src/file.h
41 index 3adfc96..eaaf356 100644
48 +#include "msdos_fs.h"
50 typedef enum { fdt_none, fdt_drop, fdt_undelete } FD_TYPE;
52 typedef struct _fptr {
53 diff --git a/src/fsck.fat.h b/src/fsck.fat.h
54 index 27e9d52..e5f6178 100644
61 -#define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
62 -#define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h> */
63 -#define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
65 -#include <linux/msdos_fs.h>
71 +#include "msdos_fs.h"
73 #define VFAT_LN_ATTR (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
75 #define FAT_STATE_DIRTY 0x01
76 diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c
77 index 3d1512f..76d40d8 100644
84 +#include "msdos_fs.h"
86 /* In earlier versions, an own llseek() was used, but glibc lseek() is
87 * sufficient (or even better :) for 64 bit offsets in the meantime */
89 @@ -99,21 +101,6 @@ static inline int cdiv(int a, int b)
90 return (a + b - 1) / b;
93 -/* MS-DOS filesystem structures -- I included them here instead of
94 - including linux/msdos_fs.h since that doesn't include some fields we
97 -#define ATTR_RO 1 /* read-only */
98 -#define ATTR_HIDDEN 2 /* hidden */
99 -#define ATTR_SYS 4 /* system */
100 -#define ATTR_VOLUME 8 /* volume label */
101 -#define ATTR_DIR 16 /* directory */
102 -#define ATTR_ARCH 32 /* archived */
104 -#define ATTR_NONE 0 /* no attribute bits */
105 -#define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
106 - /* attribute bits that are copied "as is" */
109 #define FAT_EOF (atari_format ? 0x0fffffff : 0x0ffffff8)
110 #define FAT_BAD 0x0ffffff7
111 @@ -200,19 +187,6 @@ struct fat32_fsinfo {
112 uint32_t reserved2[4];
115 -struct msdos_dir_entry {
116 - char name[8], ext[3]; /* name and extension */
117 - uint8_t attr; /* attribute bits */
118 - uint8_t lcase; /* Case for base and extension */
119 - uint8_t ctime_ms; /* Creation time, milliseconds */
120 - uint16_t ctime; /* Creation time */
121 - uint16_t cdate; /* Creation date */
122 - uint16_t adate; /* Last access date */
123 - uint16_t starthi; /* high 16 bits of first cl. (FAT32) */
124 - uint16_t time, date, start; /* time, date and first cluster */
125 - uint32_t size; /* file size (in bytes) */
126 -} __attribute__ ((packed));
128 /* The "boot code" we put into the filesystem... it writes a message and
129 tells the user to try again */
131 @@ -1244,7 +1218,7 @@ static void setup_tables(void)
132 htole16((unsigned short)(ctime->tm_mday +
133 ((ctime->tm_mon + 1) << 5) +
134 ((ctime->tm_year - 80) << 9)));
137 de->ctime = de->time;
138 de->cdate = de->date;
139 de->adate = de->date;
140 diff --git a/src/msdos_fs.h b/src/msdos_fs.h
142 index 0000000..54b2a34
146 +/* msdos_fs.h - MS-DOS filesystem constants/structures
148 + This program is free software: you can redistribute it and/or modify
149 + it under the terms of the GNU General Public License as published by
150 + the Free Software Foundation, either version 3 of the License, or
151 + (at your option) any later version.
153 + This program is distributed in the hope that it will be useful,
154 + but WITHOUT ANY WARRANTY; without even the implied warranty of
155 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
156 + GNU General Public License for more details.
158 + You should have received a copy of the GNU General Public License
159 + along with this program. If not, see <http://www.gnu.org/licenses/>.
161 + The complete text of the GNU General Public License
162 + can be found in /usr/share/common-licenses/GPL-3 file.
170 +#define SECTOR_SIZE 512 /* sector size (bytes) */
171 +#define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry))
172 +#define MSDOS_DPS_BITS 4 /* log2(MSDOS_DPS) */
173 +#define MSDOS_DIR_BITS 5 /* log2(sizeof(struct msdos_dir_entry)) */
175 +#define ATTR_NONE 0 /* no attribute bits */
176 +#define ATTR_RO 1 /* read-only */
177 +#define ATTR_HIDDEN 2 /* hidden */
178 +#define ATTR_SYS 4 /* system */
179 +#define ATTR_VOLUME 8 /* volume label */
180 +#define ATTR_DIR 16 /* directory */
181 +#define ATTR_ARCH 32 /* archived */
183 +/* attribute bits that are copied "as is" */
184 +#define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
186 +#define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */
187 +#define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG)
189 +#define MSDOS_NAME 11 /* maximum name length */
190 +#define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */
191 +#define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */
193 +struct msdos_dir_entry {
194 + uint8_t name[8], ext[3]; /* name and extension */
195 + uint8_t attr; /* attribute bits */
196 + uint8_t lcase; /* Case for base and extension */
197 + uint8_t ctime_cs; /* Creation time, centiseconds (0-199) */
198 + uint16_t ctime; /* Creation time */
199 + uint16_t cdate; /* Creation date */
200 + uint16_t adate; /* Last access date */
201 + uint16_t starthi; /* High 16 bits of cluster in FAT32 */
202 + uint16_t time, date, start; /* time, date and first cluster */
203 + uint32_t size; /* file size (in bytes) */
204 +} __attribute__ ((packed));
206 +#endif /* _MSDOS_FS_H */