1 From 245d0cce5e77d7465d61bfde91bc79477d5e6fd6 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
3 Date: Thu, 26 Feb 2015 19:22:54 +0100
4 Subject: [PATCH 10/14] Remove non standard int types
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/boot.c | 16 +++----
15 src/fsck.fat.h | 148 ++++++++++++++++++++++++++++-----------------------------
17 src/lfn.c | 23 ++++-----
18 src/mkfs.fat.c | 95 ++++++++++++++++++------------------
19 7 files changed, 138 insertions(+), 149 deletions(-)
21 diff --git a/src/boot.c b/src/boot.c
22 index be7bfb7..0c0918f 100644
26 * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
31 -#include <sys/types.h>
36 #define FAT16_THRESHOLD 65525
44 @@ -62,7 +62,7 @@ static struct {
46 /* Unaligned fields must first be accessed byte-wise */
47 #define GET_UNALIGNED_W(f) \
48 - ( (__u16)f[0] | ((__u16)f[1]<<8) )
49 + ( (uint16_t)f[0] | ((uint16_t)f[1]<<8) )
51 static const char *get_media_descr(unsigned char media)
53 @@ -166,18 +166,18 @@ static void check_backup_boot(DOS_FS * fs, struct boot_sector *b, int lss)
54 fs_read(fs->backupboot_start, sizeof(b2), &b2);
55 if (memcmp(b, &b2, sizeof(b2)) != 0) {
56 /* there are any differences */
59 int i, pos, first = 1;
62 printf("There are differences between boot sector and its backup.\n");
63 printf("This is mostly harmless. Differences: (offset:original/backup)\n ");
65 - for (p = (__u8 *) b, q = (__u8 *) & b2, i = 0; i < sizeof(b2);
66 + for (p = (uint8_t *) b, q = (uint8_t *) & b2, i = 0; i < sizeof(b2);
69 sprintf(buf, "%s%u:%02x/%02x", first ? "" : ", ",
70 - (unsigned)(p - (__u8 *) b), *p, *q);
71 + (unsigned)(p - (uint8_t *) b), *p, *q);
72 if (pos + strlen(buf) > 78)
73 printf("\n "), pos = 2;
75 @@ -227,7 +227,7 @@ static void read_fsinfo(DOS_FS * fs, struct boot_sector *b, int lss)
76 if (interactive && get_key("12", "?") == '1') {
77 /* search for a free reserved sector (not boot sector and not
78 * backup boot sector) */
81 for (s = 1; s < le16toh(b->reserved); ++s)
82 if (s != le16toh(b->backup_boot))
84 @@ -425,7 +425,7 @@ void read_boot(DOS_FS * fs)
85 fs->eff_fat_bits = (fs->fat_bits == 32) ? 28 : fs->fat_bits;
86 fs->fat_size = fat_length * logical_sector_size;
88 - fs->label = calloc(12, sizeof(__u8));
89 + fs->label = calloc(12, sizeof(uint8_t));
90 if (fs->fat_bits == 12 || fs->fat_bits == 16) {
91 struct boot_sector_16 *b16 = (struct boot_sector_16 *)&b;
92 if (b16->extended_sig == 0x29)
93 diff --git a/src/common.h b/src/common.h
94 index b127f63..c15efb5 100644
98 can be found in /usr/share/common-licenses/GPL-3 file.
101 -#include <asm/types.h>
106 diff --git a/src/file.c b/src/file.c
107 index 30adcde..0b53840 100644
111 #define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h> */
112 #define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
114 -#include <asm/types.h>
116 #include <linux/msdos_fs.h>
119 diff --git a/src/fsck.fat.h b/src/fsck.fat.h
120 index e5ade5b..27e9d52 100644
127 -#include <sys/types.h>
128 #define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
129 #define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h> */
130 #define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
132 -#include <asm/types.h>
133 -#include <asm/byteorder.h>
135 #include <linux/msdos_fs.h>
139 /* ++roman: Use own definition of boot sector structure -- the kernel headers'
140 * name for it is msdos_boot_sector in 2.0 and fat_boot_sector in 2.1 ... */
142 - __u8 ignored[3]; /* Boot strap short or near jump */
143 - __u8 system_id[8]; /* Name - can be used to special case
144 + uint8_t ignored[3]; /* Boot strap short or near jump */
145 + uint8_t system_id[8]; /* Name - can be used to special case
146 partition manager volumes */
147 - __u8 sector_size[2]; /* bytes per logical sector */
148 - __u8 cluster_size; /* sectors/cluster */
149 - __u16 reserved; /* reserved sectors */
150 - __u8 fats; /* number of FATs */
151 - __u8 dir_entries[2]; /* root directory entries */
152 - __u8 sectors[2]; /* number of sectors */
153 - __u8 media; /* media code (unused) */
154 - __u16 fat_length; /* sectors/FAT */
155 - __u16 secs_track; /* sectors per track */
156 - __u16 heads; /* number of heads */
157 - __u32 hidden; /* hidden sectors (unused) */
158 - __u32 total_sect; /* number of sectors (if sectors == 0) */
159 + uint8_t sector_size[2]; /* bytes per logical sector */
160 + uint8_t cluster_size; /* sectors/cluster */
161 + uint16_t reserved; /* reserved sectors */
162 + uint8_t fats; /* number of FATs */
163 + uint8_t dir_entries[2]; /* root directory entries */
164 + uint8_t sectors[2]; /* number of sectors */
165 + uint8_t media; /* media code (unused) */
166 + uint16_t fat_length; /* sectors/FAT */
167 + uint16_t secs_track; /* sectors per track */
168 + uint16_t heads; /* number of heads */
169 + uint32_t hidden; /* hidden sectors (unused) */
170 + uint32_t total_sect; /* number of sectors (if sectors == 0) */
172 /* The following fields are only used by FAT32 */
173 - __u32 fat32_length; /* sectors/FAT */
174 - __u16 flags; /* bit 8: fat mirroring, low 4: active fat */
175 - __u8 version[2]; /* major, minor filesystem version */
176 - __u32 root_cluster; /* first cluster in root directory */
177 - __u16 info_sector; /* filesystem info sector */
178 - __u16 backup_boot; /* backup boot sector */
179 - __u8 reserved2[12]; /* Unused */
181 - __u8 drive_number; /* Logical Drive Number */
182 - __u8 reserved3; /* Unused */
184 - __u8 extended_sig; /* Extended Signature (0x29) */
185 - __u32 serial; /* Serial number */
186 - __u8 label[11]; /* FS label */
187 - __u8 fs_type[8]; /* FS Type */
188 + uint32_t fat32_length; /* sectors/FAT */
189 + uint16_t flags; /* bit 8: fat mirroring, low 4: active fat */
190 + uint8_t version[2]; /* major, minor filesystem version */
191 + uint32_t root_cluster; /* first cluster in root directory */
192 + uint16_t info_sector; /* filesystem info sector */
193 + uint16_t backup_boot; /* backup boot sector */
194 + uint8_t reserved2[12]; /* Unused */
196 + uint8_t drive_number; /* Logical Drive Number */
197 + uint8_t reserved3; /* Unused */
199 + uint8_t extended_sig; /* Extended Signature (0x29) */
200 + uint32_t serial; /* Serial number */
201 + uint8_t label[11]; /* FS label */
202 + uint8_t fs_type[8]; /* FS Type */
204 /* fill up to 512 bytes */
207 } __attribute__ ((packed));
209 struct boot_sector_16 {
210 - __u8 ignored[3]; /* Boot strap short or near jump */
211 - __u8 system_id[8]; /* Name - can be used to special case
212 + uint8_t ignored[3]; /* Boot strap short or near jump */
213 + uint8_t system_id[8]; /* Name - can be used to special case
214 partition manager volumes */
215 - __u8 sector_size[2]; /* bytes per logical sector */
216 - __u8 cluster_size; /* sectors/cluster */
217 - __u16 reserved; /* reserved sectors */
218 - __u8 fats; /* number of FATs */
219 - __u8 dir_entries[2]; /* root directory entries */
220 - __u8 sectors[2]; /* number of sectors */
221 - __u8 media; /* media code (unused) */
222 - __u16 fat_length; /* sectors/FAT */
223 - __u16 secs_track; /* sectors per track */
224 - __u16 heads; /* number of heads */
225 - __u32 hidden; /* hidden sectors (unused) */
226 - __u32 total_sect; /* number of sectors (if sectors == 0) */
228 - __u8 drive_number; /* Logical Drive Number */
229 - __u8 reserved2; /* Unused */
231 - __u8 extended_sig; /* Extended Signature (0x29) */
232 - __u32 serial; /* Serial number */
233 - __u8 label[11]; /* FS label */
234 - __u8 fs_type[8]; /* FS Type */
235 + uint8_t sector_size[2]; /* bytes per logical sector */
236 + uint8_t cluster_size; /* sectors/cluster */
237 + uint16_t reserved; /* reserved sectors */
238 + uint8_t fats; /* number of FATs */
239 + uint8_t dir_entries[2]; /* root directory entries */
240 + uint8_t sectors[2]; /* number of sectors */
241 + uint8_t media; /* media code (unused) */
242 + uint16_t fat_length; /* sectors/FAT */
243 + uint16_t secs_track; /* sectors per track */
244 + uint16_t heads; /* number of heads */
245 + uint32_t hidden; /* hidden sectors (unused) */
246 + uint32_t total_sect; /* number of sectors (if sectors == 0) */
248 + uint8_t drive_number; /* Logical Drive Number */
249 + uint8_t reserved2; /* Unused */
251 + uint8_t extended_sig; /* Extended Signature (0x29) */
252 + uint32_t serial; /* Serial number */
253 + uint8_t label[11]; /* FS label */
254 + uint8_t fs_type[8]; /* FS Type */
256 /* fill up to 512 bytes */
259 } __attribute__ ((packed));
262 - __u32 magic; /* Magic for info sector ('RRaA') */
264 - __u32 reserved1; /* Nothing as far as I can tell */
265 - __u32 signature; /* 0x61417272 ('rrAa') */
266 - __u32 free_clusters; /* Free cluster count. -1 if unknown */
267 - __u32 next_cluster; /* Most recently allocated cluster. */
268 - __u32 reserved2[3];
271 + uint32_t magic; /* Magic for info sector ('RRaA') */
272 + uint8_t junk[0x1dc];
273 + uint32_t reserved1; /* Nothing as far as I can tell */
274 + uint32_t signature; /* 0x61417272 ('rrAa') */
275 + uint32_t free_clusters; /* Free cluster count. -1 if unknown */
276 + uint32_t next_cluster; /* Most recently allocated cluster. */
277 + uint32_t reserved2[3];
278 + uint16_t reserved3;
279 + uint16_t boot_sign;
283 - __u8 name[8], ext[3]; /* name and extension */
284 - __u8 attr; /* attribute bits */
285 - __u8 lcase; /* Case for base and extension */
286 - __u8 ctime_ms; /* Creation time, milliseconds */
287 - __u16 ctime; /* Creation time */
288 - __u16 cdate; /* Creation date */
289 - __u16 adate; /* Last access date */
290 - __u16 starthi; /* High 16 bits of cluster in FAT32 */
291 - __u16 time, date, start; /* time, date and first cluster */
292 - __u32 size; /* file size (in bytes) */
293 + uint8_t name[8], ext[3]; /* name and extension */
294 + uint8_t attr; /* attribute bits */
295 + uint8_t lcase; /* Case for base and extension */
296 + uint8_t ctime_ms; /* Creation time, milliseconds */
297 + uint16_t ctime; /* Creation time */
298 + uint16_t cdate; /* Creation date */
299 + uint16_t adate; /* Last access date */
300 + uint16_t starthi; /* High 16 bits of cluster in FAT32 */
301 + uint16_t time, date, start; /* time, date and first cluster */
302 + uint32_t size; /* file size (in bytes) */
303 } __attribute__ ((packed)) DIR_ENT;
305 typedef struct _dos_file {
306 diff --git a/src/io.c b/src/io.c
307 index 3755ba5..450432c 100644
311 * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
313 #define _LARGEFILE64_SOURCE
314 -#include <sys/types.h>
318 diff --git a/src/lfn.c b/src/lfn.c
319 index 2e60198..2601172 100644
334 - __u8 id; /* sequence number for slot */
335 - __u8 name0_4[10]; /* first 5 characters in name */
336 - __u8 attr; /* attribute byte */
337 - __u8 reserved; /* always 0 */
338 - __u8 alias_checksum; /* checksum for 8.3 alias */
339 - __u8 name5_10[12]; /* 6 more characters in name */
340 - __u16 start; /* starting cluster number, 0 in long slots */
341 - __u8 name11_12[4]; /* last 2 characters in name */
342 + uint8_t id; /* sequence number for slot */
343 + uint8_t name0_4[10]; /* first 5 characters in name */
344 + uint8_t attr; /* attribute byte */
345 + uint8_t reserved; /* always 0 */
346 + uint8_t alias_checksum; /* checksum for 8.3 alias */
347 + uint8_t name5_10[12]; /* 6 more characters in name */
348 + uint16_t start; /* starting cluster number, 0 in long slots */
349 + uint8_t name11_12[4]; /* last 2 characters in name */
352 #define LFN_ID_START 0x40
353 @@ -173,7 +174,7 @@ static void clear_lfn_slots(int start, int end)
354 void lfn_fix_checksum(loff_t from, loff_t to, const char *short_name)
359 for (sum = 0, i = 0; i < 11; i++)
360 sum = (((sum & 1) << 7) | ((sum & 0xfe) >> 1)) + short_name[i];
362 @@ -409,7 +410,7 @@ void lfn_add_slot(DIR_ENT * de, loff_t dir_offset)
363 char *lfn_get(DIR_ENT * de, loff_t * lfn_offset)
371 @@ -453,7 +454,7 @@ char *lfn_get(DIR_ENT * de, loff_t * lfn_offset)
374 for (i = 0; i < lfn_parts; ++i) {
375 - __u8 id = (lfn_parts - i) | (i == 0 ? LFN_ID_START : 0);
376 + uint8_t id = (lfn_parts - i) | (i == 0 ? LFN_ID_START : 0);
377 fs_write(lfn_offsets[i] + offsetof(LFN_ENT, id),
380 diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c
381 index e6f9390..3d1512f 100644
385 #include <sys/ioctl.h>
386 #include <sys/stat.h>
387 #include <sys/time.h>
388 -#include <sys/types.h>
396 -#include <asm/types.h>
398 /* In earlier versions, an own llseek() was used, but glibc lseek() is
399 * sufficient (or even better :) for 64 bit offsets in the meantime */
401 @@ -148,72 +145,72 @@ static inline int cdiv(int a, int b)
404 struct msdos_volume_info {
405 - __u8 drive_number; /* BIOS drive number */
406 - __u8 RESERVED; /* Unused */
407 - __u8 ext_boot_sign; /* 0x29 if fields below exist (DOS 3.3+) */
408 - __u8 volume_id[4]; /* Volume ID number */
409 - __u8 volume_label[11]; /* Volume label */
410 - __u8 fs_type[8]; /* Typically FAT12 or FAT16 */
411 + uint8_t drive_number; /* BIOS drive number */
412 + uint8_t RESERVED; /* Unused */
413 + uint8_t ext_boot_sign; /* 0x29 if fields below exist (DOS 3.3+) */
414 + uint8_t volume_id[4]; /* Volume ID number */
415 + uint8_t volume_label[11]; /* Volume label */
416 + uint8_t fs_type[8]; /* Typically FAT12 or FAT16 */
417 } __attribute__ ((packed));
419 struct msdos_boot_sector {
420 - __u8 boot_jump[3]; /* Boot strap short or near jump */
421 - __u8 system_id[8]; /* Name - can be used to special case
422 + uint8_t boot_jump[3]; /* Boot strap short or near jump */
423 + uint8_t system_id[8]; /* Name - can be used to special case
424 partition manager volumes */
425 - __u8 sector_size[2]; /* bytes per logical sector */
426 - __u8 cluster_size; /* sectors/cluster */
427 - __u16 reserved; /* reserved sectors */
428 - __u8 fats; /* number of FATs */
429 - __u8 dir_entries[2]; /* root directory entries */
430 - __u8 sectors[2]; /* number of sectors */
431 - __u8 media; /* media code (unused) */
432 - __u16 fat_length; /* sectors/FAT */
433 - __u16 secs_track; /* sectors per track */
434 - __u16 heads; /* number of heads */
435 - __u32 hidden; /* hidden sectors (unused) */
436 - __u32 total_sect; /* number of sectors (if sectors == 0) */
437 + uint8_t sector_size[2]; /* bytes per logical sector */
438 + uint8_t cluster_size; /* sectors/cluster */
439 + uint16_t reserved; /* reserved sectors */
440 + uint8_t fats; /* number of FATs */
441 + uint8_t dir_entries[2]; /* root directory entries */
442 + uint8_t sectors[2]; /* number of sectors */
443 + uint8_t media; /* media code (unused) */
444 + uint16_t fat_length; /* sectors/FAT */
445 + uint16_t secs_track; /* sectors per track */
446 + uint16_t heads; /* number of heads */
447 + uint32_t hidden; /* hidden sectors (unused) */
448 + uint32_t total_sect; /* number of sectors (if sectors == 0) */
451 struct msdos_volume_info vi;
452 - __u8 boot_code[BOOTCODE_SIZE];
453 + uint8_t boot_code[BOOTCODE_SIZE];
454 } __attribute__ ((packed)) _oldfat;
456 - __u32 fat32_length; /* sectors/FAT */
457 - __u16 flags; /* bit 8: fat mirroring, low 4: active fat */
458 - __u8 version[2]; /* major, minor filesystem version */
459 - __u32 root_cluster; /* first cluster in root directory */
460 - __u16 info_sector; /* filesystem info sector */
461 - __u16 backup_boot; /* backup boot sector */
462 - __u16 reserved2[6]; /* Unused */
463 + uint32_t fat32_length; /* sectors/FAT */
464 + uint16_t flags; /* bit 8: fat mirroring, low 4: active fat */
465 + uint8_t version[2]; /* major, minor filesystem version */
466 + uint32_t root_cluster; /* first cluster in root directory */
467 + uint16_t info_sector; /* filesystem info sector */
468 + uint16_t backup_boot; /* backup boot sector */
469 + uint16_t reserved2[6]; /* Unused */
470 struct msdos_volume_info vi;
471 - __u8 boot_code[BOOTCODE_FAT32_SIZE];
472 + uint8_t boot_code[BOOTCODE_FAT32_SIZE];
473 } __attribute__ ((packed)) _fat32;
474 } __attribute__ ((packed)) fstype;
476 + uint16_t boot_sign;
477 } __attribute__ ((packed));
478 #define fat32 fstype._fat32
479 #define oldfat fstype._oldfat
481 struct fat32_fsinfo {
482 - __u32 reserved1; /* Nothing as far as I can tell */
483 - __u32 signature; /* 0x61417272L */
484 - __u32 free_clusters; /* Free cluster count. -1 if unknown */
485 - __u32 next_cluster; /* Most recently allocated cluster.
486 + uint32_t reserved1; /* Nothing as far as I can tell */
487 + uint32_t signature; /* 0x61417272L */
488 + uint32_t free_clusters; /* Free cluster count. -1 if unknown */
489 + uint32_t next_cluster; /* Most recently allocated cluster.
490 * Unused under Linux. */
491 - __u32 reserved2[4];
492 + uint32_t reserved2[4];
495 struct msdos_dir_entry {
496 char name[8], ext[3]; /* name and extension */
497 - __u8 attr; /* attribute bits */
498 - __u8 lcase; /* Case for base and extension */
499 - __u8 ctime_ms; /* Creation time, milliseconds */
500 - __u16 ctime; /* Creation time */
501 - __u16 cdate; /* Creation date */
502 - __u16 adate; /* Last access date */
503 - __u16 starthi; /* high 16 bits of first cl. (FAT32) */
504 - __u16 time, date, start; /* time, date and first cluster */
505 - __u32 size; /* file size (in bytes) */
506 + uint8_t attr; /* attribute bits */
507 + uint8_t lcase; /* Case for base and extension */
508 + uint8_t ctime_ms; /* Creation time, milliseconds */
509 + uint16_t ctime; /* Creation time */
510 + uint16_t cdate; /* Creation date */
511 + uint16_t adate; /* Last access date */
512 + uint16_t starthi; /* high 16 bits of first cl. (FAT32) */
513 + uint16_t time, date, start; /* time, date and first cluster */
514 + uint32_t size; /* file size (in bytes) */
515 } __attribute__ ((packed));
517 /* The "boot code" we put into the filesystem... it writes a message and
518 @@ -826,7 +823,7 @@ static void setup_tables(void)
519 bs.hidden = htole32(hidden_sectors);
521 /* In Atari format, hidden is a 16 bit field */
522 - __u16 hidden = htole16(hidden_sectors);
523 + uint16_t hidden = htole16(hidden_sectors);
524 if (hidden_sectors & ~0xffff)
525 die("#hidden doesn't fit in 16bit field of Atari format\n");
526 memcpy(&bs.hidden, &hidden, 2);
527 @@ -1279,7 +1276,7 @@ static void setup_tables(void)
528 info->next_cluster = htole32(2);
530 /* Info sector also must have boot sign */
531 - *(__u16 *) (info_sector + 0x1fe) = htole16(BOOT_SIGN);
532 + *(uint16_t *) (info_sector + 0x1fe) = htole16(BOOT_SIGN);
535 if (!(blank_sector = malloc(sector_size)))