add chaos_calmer branch
[15.05/openwrt.git] / tools / dosfstools / patches / 0011-Remove-linux-msdos_fs.h-includes.patch
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
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
10 Signed-off-by: Andreas Bombe <aeb@debian.org>
11 ---
12  src/file.c     |  7 +------
13  src/file.h     |  2 ++
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
19
20 diff --git a/src/file.c b/src/file.c
21 index 0b53840..9519070 100644
22 --- a/src/file.c
23 +++ b/src/file.c
24 @@ -30,14 +30,9 @@
25  #include <ctype.h>
26  #include <unistd.h>
27  
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> */
31 -
32 -#include <linux/msdos_fs.h>
33 -
34  #include "common.h"
35  #include "file.h"
36 +#include "msdos_fs.h"
37  #include "charconv.h"
38  
39  FDSC *fp_root = NULL;
40 diff --git a/src/file.h b/src/file.h
41 index 3adfc96..eaaf356 100644
42 --- a/src/file.h
43 +++ b/src/file.h
44 @@ -23,6 +23,8 @@
45  #ifndef _FILE_H
46  #define _FILE_H
47  
48 +#include "msdos_fs.h"
49 +
50  typedef enum { fdt_none, fdt_drop, fdt_undelete } FD_TYPE;
51  
52  typedef struct _fptr {
53 diff --git a/src/fsck.fat.h b/src/fsck.fat.h
54 index 27e9d52..e5f6178 100644
55 --- a/src/fsck.fat.h
56 +++ b/src/fsck.fat.h
57 @@ -28,16 +28,12 @@
58  #define _DOSFSCK_H
59  
60  #include <fcntl.h>
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> */
64 -
65 -#include <linux/msdos_fs.h>
66 -
67  #include <stddef.h>
68  #include <stdint.h>
69  #include <endian.h>
70  
71 +#include "msdos_fs.h"
72 +
73  #define VFAT_LN_ATTR (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
74  
75  #define FAT_STATE_DIRTY 0x01
76 diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c
77 index 3d1512f..76d40d8 100644
78 --- a/src/mkfs.fat.c
79 +++ b/src/mkfs.fat.c
80 @@ -67,6 +67,8 @@
81  #include <stdint.h>
82  #include <endian.h>
83  
84 +#include "msdos_fs.h"
85 +
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 */
88  #define llseek lseek
89 @@ -99,21 +101,6 @@ static inline int cdiv(int a, int b)
90      return (a + b - 1) / b;
91  }
92  
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
95 -   need */
96 -
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 */
103 -
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" */
107 -
108  /* FAT values */
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];
113  };
114  
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));
127 -
128  /* The "boot code" we put into the filesystem... it writes a message and
129     tells the user to try again */
130  
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)));
135 -       de->ctime_ms = 0;
136 +       de->ctime_cs = 0;
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
141 new file mode 100644
142 index 0000000..54b2a34
143 --- /dev/null
144 +++ b/src/msdos_fs.h
145 @@ -0,0 +1,61 @@
146 +/* msdos_fs.h - MS-DOS filesystem constants/structures
147 +
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.
152 +
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.
157 +
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/>.
160 +
161 +   The complete text of the GNU General Public License
162 +   can be found in /usr/share/common-licenses/GPL-3 file.
163 +*/
164 +
165 +#ifndef _MSDOS_FS_H
166 +#define _MSDOS_FS_H
167 +
168 +#include <stdint.h>
169 +
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)) */
174 +
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 */
182 +
183 +/* attribute bits that are copied "as is" */
184 +#define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
185 +
186 +#define DELETED_FLAG 0xe5      /* marks file as deleted when in name[0] */
187 +#define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG)
188 +
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 */
192 +
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));
205 +
206 +#endif /* _MSDOS_FS_H */
207 -- 
208 1.9.1
209