You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openwrt/tools/dosfstools/patches/0010-Remove-non-standard-in...

539 lines
20 KiB
Diff

From 245d0cce5e77d7465d61bfde91bc79477d5e6fd6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
Date: Thu, 26 Feb 2015 19:22:54 +0100
Subject: [PATCH 10/14] Remove non standard int types
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Signed-off-by: Andreas Bombe <aeb@debian.org>
---
src/boot.c | 16 +++----
src/common.h | 2 -
src/file.c | 2 -
src/fsck.fat.h | 148 ++++++++++++++++++++++++++++-----------------------------
src/io.c | 1 -
src/lfn.c | 23 ++++-----
src/mkfs.fat.c | 95 ++++++++++++++++++------------------
7 files changed, 138 insertions(+), 149 deletions(-)
diff --git a/src/boot.c b/src/boot.c
index be7bfb7..0c0918f 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -25,8 +25,8 @@
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
#include <stdio.h>
+#include <stdint.h>
#include <string.h>
-#include <sys/types.h>
#include <stdlib.h>
#include <time.h>
@@ -45,7 +45,7 @@
#define FAT16_THRESHOLD 65525
static struct {
- __u8 media;
+ uint8_t media;
const char *descr;
} mediabytes[] = {
{
@@ -62,7 +62,7 @@ static struct {
/* Unaligned fields must first be accessed byte-wise */
#define GET_UNALIGNED_W(f) \
- ( (__u16)f[0] | ((__u16)f[1]<<8) )
+ ( (uint16_t)f[0] | ((uint16_t)f[1]<<8) )
static const char *get_media_descr(unsigned char media)
{
@@ -166,18 +166,18 @@ static void check_backup_boot(DOS_FS * fs, struct boot_sector *b, int lss)
fs_read(fs->backupboot_start, sizeof(b2), &b2);
if (memcmp(b, &b2, sizeof(b2)) != 0) {
/* there are any differences */
- __u8 *p, *q;
+ uint8_t *p, *q;
int i, pos, first = 1;
char buf[20];
printf("There are differences between boot sector and its backup.\n");
printf("This is mostly harmless. Differences: (offset:original/backup)\n ");
pos = 2;
- for (p = (__u8 *) b, q = (__u8 *) & b2, i = 0; i < sizeof(b2);
+ for (p = (uint8_t *) b, q = (uint8_t *) & b2, i = 0; i < sizeof(b2);
++p, ++q, ++i) {
if (*p != *q) {
sprintf(buf, "%s%u:%02x/%02x", first ? "" : ", ",
- (unsigned)(p - (__u8 *) b), *p, *q);
+ (unsigned)(p - (uint8_t *) b), *p, *q);
if (pos + strlen(buf) > 78)
printf("\n "), pos = 2;
printf("%s", buf);
@@ -227,7 +227,7 @@ static void read_fsinfo(DOS_FS * fs, struct boot_sector *b, int lss)
if (interactive && get_key("12", "?") == '1') {
/* search for a free reserved sector (not boot sector and not
* backup boot sector) */
- __u32 s;
+ uint32_t s;
for (s = 1; s < le16toh(b->reserved); ++s)
if (s != le16toh(b->backup_boot))
break;
@@ -425,7 +425,7 @@ void read_boot(DOS_FS * fs)
fs->eff_fat_bits = (fs->fat_bits == 32) ? 28 : fs->fat_bits;
fs->fat_size = fat_length * logical_sector_size;
- fs->label = calloc(12, sizeof(__u8));
+ fs->label = calloc(12, sizeof(uint8_t));
if (fs->fat_bits == 12 || fs->fat_bits == 16) {
struct boot_sector_16 *b16 = (struct boot_sector_16 *)&b;
if (b16->extended_sig == 0x29)
diff --git a/src/common.h b/src/common.h
index b127f63..c15efb5 100644
--- a/src/common.h
+++ b/src/common.h
@@ -20,8 +20,6 @@
can be found in /usr/share/common-licenses/GPL-3 file.
*/
-#include <asm/types.h>
-
#ifndef _COMMON_H
#define _COMMON_H
diff --git a/src/file.c b/src/file.c
index 30adcde..0b53840 100644
--- a/src/file.c
+++ b/src/file.c
@@ -34,8 +34,6 @@
#define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h> */
#define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
-#include <asm/types.h>
-
#include <linux/msdos_fs.h>
#include "common.h"
diff --git a/src/fsck.fat.h b/src/fsck.fat.h
index e5ade5b..27e9d52 100644
--- a/src/fsck.fat.h
+++ b/src/fsck.fat.h
@@ -28,14 +28,10 @@
#define _DOSFSCK_H
#include <fcntl.h>
-#include <sys/types.h>
#define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
#define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h> */
#define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
-#include <asm/types.h>
-#include <asm/byteorder.h>
-
#include <linux/msdos_fs.h>
#include <stddef.h>
@@ -49,95 +45,95 @@
/* ++roman: Use own definition of boot sector structure -- the kernel headers'
* name for it is msdos_boot_sector in 2.0 and fat_boot_sector in 2.1 ... */
struct boot_sector {
- __u8 ignored[3]; /* Boot strap short or near jump */
- __u8 system_id[8]; /* Name - can be used to special case
+ uint8_t ignored[3]; /* Boot strap short or near jump */
+ uint8_t system_id[8]; /* Name - can be used to special case
partition manager volumes */
- __u8 sector_size[2]; /* bytes per logical sector */
- __u8 cluster_size; /* sectors/cluster */
- __u16 reserved; /* reserved sectors */
- __u8 fats; /* number of FATs */
- __u8 dir_entries[2]; /* root directory entries */
- __u8 sectors[2]; /* number of sectors */
- __u8 media; /* media code (unused) */
- __u16 fat_length; /* sectors/FAT */
- __u16 secs_track; /* sectors per track */
- __u16 heads; /* number of heads */
- __u32 hidden; /* hidden sectors (unused) */
- __u32 total_sect; /* number of sectors (if sectors == 0) */
+ uint8_t sector_size[2]; /* bytes per logical sector */
+ uint8_t cluster_size; /* sectors/cluster */
+ uint16_t reserved; /* reserved sectors */
+ uint8_t fats; /* number of FATs */
+ uint8_t dir_entries[2]; /* root directory entries */
+ uint8_t sectors[2]; /* number of sectors */
+ uint8_t media; /* media code (unused) */
+ uint16_t fat_length; /* sectors/FAT */
+ uint16_t secs_track; /* sectors per track */
+ uint16_t heads; /* number of heads */
+ uint32_t hidden; /* hidden sectors (unused) */
+ uint32_t total_sect; /* number of sectors (if sectors == 0) */
/* The following fields are only used by FAT32 */
- __u32 fat32_length; /* sectors/FAT */
- __u16 flags; /* bit 8: fat mirroring, low 4: active fat */
- __u8 version[2]; /* major, minor filesystem version */
- __u32 root_cluster; /* first cluster in root directory */
- __u16 info_sector; /* filesystem info sector */
- __u16 backup_boot; /* backup boot sector */
- __u8 reserved2[12]; /* Unused */
-
- __u8 drive_number; /* Logical Drive Number */
- __u8 reserved3; /* Unused */
-
- __u8 extended_sig; /* Extended Signature (0x29) */
- __u32 serial; /* Serial number */
- __u8 label[11]; /* FS label */
- __u8 fs_type[8]; /* FS Type */
+ uint32_t fat32_length; /* sectors/FAT */
+ uint16_t flags; /* bit 8: fat mirroring, low 4: active fat */
+ uint8_t version[2]; /* major, minor filesystem version */
+ uint32_t root_cluster; /* first cluster in root directory */
+ uint16_t info_sector; /* filesystem info sector */
+ uint16_t backup_boot; /* backup boot sector */
+ uint8_t reserved2[12]; /* Unused */
+
+ uint8_t drive_number; /* Logical Drive Number */
+ uint8_t reserved3; /* Unused */
+
+ uint8_t extended_sig; /* Extended Signature (0x29) */
+ uint32_t serial; /* Serial number */
+ uint8_t label[11]; /* FS label */
+ uint8_t fs_type[8]; /* FS Type */
/* fill up to 512 bytes */
- __u8 junk[422];
+ uint8_t junk[422];
} __attribute__ ((packed));
struct boot_sector_16 {
- __u8 ignored[3]; /* Boot strap short or near jump */
- __u8 system_id[8]; /* Name - can be used to special case
+ uint8_t ignored[3]; /* Boot strap short or near jump */
+ uint8_t system_id[8]; /* Name - can be used to special case
partition manager volumes */
- __u8 sector_size[2]; /* bytes per logical sector */
- __u8 cluster_size; /* sectors/cluster */
- __u16 reserved; /* reserved sectors */
- __u8 fats; /* number of FATs */
- __u8 dir_entries[2]; /* root directory entries */
- __u8 sectors[2]; /* number of sectors */
- __u8 media; /* media code (unused) */
- __u16 fat_length; /* sectors/FAT */
- __u16 secs_track; /* sectors per track */
- __u16 heads; /* number of heads */
- __u32 hidden; /* hidden sectors (unused) */
- __u32 total_sect; /* number of sectors (if sectors == 0) */
-
- __u8 drive_number; /* Logical Drive Number */
- __u8 reserved2; /* Unused */
-
- __u8 extended_sig; /* Extended Signature (0x29) */
- __u32 serial; /* Serial number */
- __u8 label[11]; /* FS label */
- __u8 fs_type[8]; /* FS Type */
+ uint8_t sector_size[2]; /* bytes per logical sector */
+ uint8_t cluster_size; /* sectors/cluster */
+ uint16_t reserved; /* reserved sectors */
+ uint8_t fats; /* number of FATs */
+ uint8_t dir_entries[2]; /* root directory entries */
+ uint8_t sectors[2]; /* number of sectors */
+ uint8_t media; /* media code (unused) */
+ uint16_t fat_length; /* sectors/FAT */
+ uint16_t secs_track; /* sectors per track */
+ uint16_t heads; /* number of heads */
+ uint32_t hidden; /* hidden sectors (unused) */
+ uint32_t total_sect; /* number of sectors (if sectors == 0) */
+
+ uint8_t drive_number; /* Logical Drive Number */
+ uint8_t reserved2; /* Unused */
+
+ uint8_t extended_sig; /* Extended Signature (0x29) */
+ uint32_t serial; /* Serial number */
+ uint8_t label[11]; /* FS label */
+ uint8_t fs_type[8]; /* FS Type */
/* fill up to 512 bytes */
- __u8 junk[450];
+ uint8_t junk[450];
} __attribute__ ((packed));
struct info_sector {
- __u32 magic; /* Magic for info sector ('RRaA') */
- __u8 junk[0x1dc];
- __u32 reserved1; /* Nothing as far as I can tell */
- __u32 signature; /* 0x61417272 ('rrAa') */
- __u32 free_clusters; /* Free cluster count. -1 if unknown */
- __u32 next_cluster; /* Most recently allocated cluster. */
- __u32 reserved2[3];
- __u16 reserved3;
- __u16 boot_sign;
+ uint32_t magic; /* Magic for info sector ('RRaA') */
+ uint8_t junk[0x1dc];
+ uint32_t reserved1; /* Nothing as far as I can tell */
+ uint32_t signature; /* 0x61417272 ('rrAa') */
+ uint32_t free_clusters; /* Free cluster count. -1 if unknown */
+ uint32_t next_cluster; /* Most recently allocated cluster. */
+ uint32_t reserved2[3];
+ uint16_t reserved3;
+ uint16_t boot_sign;
};
typedef struct {
- __u8 name[8], ext[3]; /* name and extension */
- __u8 attr; /* attribute bits */
- __u8 lcase; /* Case for base and extension */
- __u8 ctime_ms; /* Creation time, milliseconds */
- __u16 ctime; /* Creation time */
- __u16 cdate; /* Creation date */
- __u16 adate; /* Last access date */
- __u16 starthi; /* High 16 bits of cluster in FAT32 */
- __u16 time, date, start; /* time, date and first cluster */
- __u32 size; /* file size (in bytes) */
+ uint8_t name[8], ext[3]; /* name and extension */
+ uint8_t attr; /* attribute bits */
+ uint8_t lcase; /* Case for base and extension */
+ uint8_t ctime_ms; /* Creation time, milliseconds */
+ uint16_t ctime; /* Creation time */
+ uint16_t cdate; /* Creation date */
+ uint16_t adate; /* Last access date */
+ uint16_t starthi; /* High 16 bits of cluster in FAT32 */
+ uint16_t time, date, start; /* time, date and first cluster */
+ uint32_t size; /* file size (in bytes) */
} __attribute__ ((packed)) DIR_ENT;
typedef struct _dos_file {
diff --git a/src/io.c b/src/io.c
index 3755ba5..450432c 100644
--- a/src/io.c
+++ b/src/io.c
@@ -31,7 +31,6 @@
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
#define _LARGEFILE64_SOURCE
-#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/src/lfn.c b/src/lfn.c
index 2e60198..2601172 100644
--- a/src/lfn.c
+++ b/src/lfn.c
@@ -21,6 +21,7 @@
*/
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
@@ -33,14 +34,14 @@
#include "file.h"
typedef struct {
- __u8 id; /* sequence number for slot */
- __u8 name0_4[10]; /* first 5 characters in name */
- __u8 attr; /* attribute byte */
- __u8 reserved; /* always 0 */
- __u8 alias_checksum; /* checksum for 8.3 alias */
- __u8 name5_10[12]; /* 6 more characters in name */
- __u16 start; /* starting cluster number, 0 in long slots */
- __u8 name11_12[4]; /* last 2 characters in name */
+ uint8_t id; /* sequence number for slot */
+ uint8_t name0_4[10]; /* first 5 characters in name */
+ uint8_t attr; /* attribute byte */
+ uint8_t reserved; /* always 0 */
+ uint8_t alias_checksum; /* checksum for 8.3 alias */
+ uint8_t name5_10[12]; /* 6 more characters in name */
+ uint16_t start; /* starting cluster number, 0 in long slots */
+ uint8_t name11_12[4]; /* last 2 characters in name */
} LFN_ENT;
#define LFN_ID_START 0x40
@@ -173,7 +174,7 @@ static void clear_lfn_slots(int start, int end)
void lfn_fix_checksum(loff_t from, loff_t to, const char *short_name)
{
int i;
- __u8 sum;
+ uint8_t sum;
for (sum = 0, i = 0; i < 11; i++)
sum = (((sum & 1) << 7) | ((sum & 0xfe) >> 1)) + short_name[i];
@@ -409,7 +410,7 @@ void lfn_add_slot(DIR_ENT * de, loff_t dir_offset)
char *lfn_get(DIR_ENT * de, loff_t * lfn_offset)
{
char *lfn;
- __u8 sum;
+ uint8_t sum;
int i;
*lfn_offset = 0;
@@ -453,7 +454,7 @@ char *lfn_get(DIR_ENT * de, loff_t * lfn_offset)
return NULL;
case '3':
for (i = 0; i < lfn_parts; ++i) {
- __u8 id = (lfn_parts - i) | (i == 0 ? LFN_ID_START : 0);
+ uint8_t id = (lfn_parts - i) | (i == 0 ? LFN_ID_START : 0);
fs_write(lfn_offsets[i] + offsetof(LFN_ENT, id),
sizeof(id), &id);
}
diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c
index e6f9390..3d1512f 100644
--- a/src/mkfs.fat.c
+++ b/src/mkfs.fat.c
@@ -60,7 +60,6 @@
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/time.h>
-#include <sys/types.h>
#include <unistd.h>
#include <time.h>
#include <errno.h>
@@ -68,8 +67,6 @@
#include <stdint.h>
#include <endian.h>
-#include <asm/types.h>
-
/* In earlier versions, an own llseek() was used, but glibc lseek() is
* sufficient (or even better :) for 64 bit offsets in the meantime */
#define llseek lseek
@@ -148,72 +145,72 @@ static inline int cdiv(int a, int b)
* alignments */
struct msdos_volume_info {
- __u8 drive_number; /* BIOS drive number */
- __u8 RESERVED; /* Unused */
- __u8 ext_boot_sign; /* 0x29 if fields below exist (DOS 3.3+) */
- __u8 volume_id[4]; /* Volume ID number */
- __u8 volume_label[11]; /* Volume label */
- __u8 fs_type[8]; /* Typically FAT12 or FAT16 */
+ uint8_t drive_number; /* BIOS drive number */
+ uint8_t RESERVED; /* Unused */
+ uint8_t ext_boot_sign; /* 0x29 if fields below exist (DOS 3.3+) */
+ uint8_t volume_id[4]; /* Volume ID number */
+ uint8_t volume_label[11]; /* Volume label */
+ uint8_t fs_type[8]; /* Typically FAT12 or FAT16 */
} __attribute__ ((packed));
struct msdos_boot_sector {
- __u8 boot_jump[3]; /* Boot strap short or near jump */
- __u8 system_id[8]; /* Name - can be used to special case
+ uint8_t boot_jump[3]; /* Boot strap short or near jump */
+ uint8_t system_id[8]; /* Name - can be used to special case
partition manager volumes */
- __u8 sector_size[2]; /* bytes per logical sector */
- __u8 cluster_size; /* sectors/cluster */
- __u16 reserved; /* reserved sectors */
- __u8 fats; /* number of FATs */
- __u8 dir_entries[2]; /* root directory entries */
- __u8 sectors[2]; /* number of sectors */
- __u8 media; /* media code (unused) */
- __u16 fat_length; /* sectors/FAT */
- __u16 secs_track; /* sectors per track */
- __u16 heads; /* number of heads */
- __u32 hidden; /* hidden sectors (unused) */
- __u32 total_sect; /* number of sectors (if sectors == 0) */
+ uint8_t sector_size[2]; /* bytes per logical sector */
+ uint8_t cluster_size; /* sectors/cluster */
+ uint16_t reserved; /* reserved sectors */
+ uint8_t fats; /* number of FATs */
+ uint8_t dir_entries[2]; /* root directory entries */
+ uint8_t sectors[2]; /* number of sectors */
+ uint8_t media; /* media code (unused) */
+ uint16_t fat_length; /* sectors/FAT */
+ uint16_t secs_track; /* sectors per track */
+ uint16_t heads; /* number of heads */
+ uint32_t hidden; /* hidden sectors (unused) */
+ uint32_t total_sect; /* number of sectors (if sectors == 0) */
union {
struct {
struct msdos_volume_info vi;
- __u8 boot_code[BOOTCODE_SIZE];
+ uint8_t boot_code[BOOTCODE_SIZE];
} __attribute__ ((packed)) _oldfat;
struct {
- __u32 fat32_length; /* sectors/FAT */
- __u16 flags; /* bit 8: fat mirroring, low 4: active fat */
- __u8 version[2]; /* major, minor filesystem version */
- __u32 root_cluster; /* first cluster in root directory */
- __u16 info_sector; /* filesystem info sector */
- __u16 backup_boot; /* backup boot sector */
- __u16 reserved2[6]; /* Unused */
+ uint32_t fat32_length; /* sectors/FAT */
+ uint16_t flags; /* bit 8: fat mirroring, low 4: active fat */
+ uint8_t version[2]; /* major, minor filesystem version */
+ uint32_t root_cluster; /* first cluster in root directory */
+ uint16_t info_sector; /* filesystem info sector */
+ uint16_t backup_boot; /* backup boot sector */
+ uint16_t reserved2[6]; /* Unused */
struct msdos_volume_info vi;
- __u8 boot_code[BOOTCODE_FAT32_SIZE];
+ uint8_t boot_code[BOOTCODE_FAT32_SIZE];
} __attribute__ ((packed)) _fat32;
} __attribute__ ((packed)) fstype;
- __u16 boot_sign;
+ uint16_t boot_sign;
} __attribute__ ((packed));
#define fat32 fstype._fat32
#define oldfat fstype._oldfat
struct fat32_fsinfo {
- __u32 reserved1; /* Nothing as far as I can tell */
- __u32 signature; /* 0x61417272L */
- __u32 free_clusters; /* Free cluster count. -1 if unknown */
- __u32 next_cluster; /* Most recently allocated cluster.
+ uint32_t reserved1; /* Nothing as far as I can tell */
+ uint32_t signature; /* 0x61417272L */
+ uint32_t free_clusters; /* Free cluster count. -1 if unknown */
+ uint32_t next_cluster; /* Most recently allocated cluster.
* Unused under Linux. */
- __u32 reserved2[4];
+ uint32_t reserved2[4];
};
struct msdos_dir_entry {
char name[8], ext[3]; /* name and extension */
- __u8 attr; /* attribute bits */
- __u8 lcase; /* Case for base and extension */
- __u8 ctime_ms; /* Creation time, milliseconds */
- __u16 ctime; /* Creation time */
- __u16 cdate; /* Creation date */
- __u16 adate; /* Last access date */
- __u16 starthi; /* high 16 bits of first cl. (FAT32) */
- __u16 time, date, start; /* time, date and first cluster */
- __u32 size; /* file size (in bytes) */
+ uint8_t attr; /* attribute bits */
+ uint8_t lcase; /* Case for base and extension */
+ uint8_t ctime_ms; /* Creation time, milliseconds */
+ uint16_t ctime; /* Creation time */
+ uint16_t cdate; /* Creation date */
+ uint16_t adate; /* Last access date */
+ uint16_t starthi; /* high 16 bits of first cl. (FAT32) */
+ uint16_t time, date, start; /* time, date and first cluster */
+ uint32_t size; /* file size (in bytes) */
} __attribute__ ((packed));
/* The "boot code" we put into the filesystem... it writes a message and
@@ -826,7 +823,7 @@ static void setup_tables(void)
bs.hidden = htole32(hidden_sectors);
else {
/* In Atari format, hidden is a 16 bit field */
- __u16 hidden = htole16(hidden_sectors);
+ uint16_t hidden = htole16(hidden_sectors);
if (hidden_sectors & ~0xffff)
die("#hidden doesn't fit in 16bit field of Atari format\n");
memcpy(&bs.hidden, &hidden, 2);
@@ -1279,7 +1276,7 @@ static void setup_tables(void)
info->next_cluster = htole32(2);
/* Info sector also must have boot sign */
- *(__u16 *) (info_sector + 0x1fe) = htole16(BOOT_SIGN);
+ *(uint16_t *) (info_sector + 0x1fe) = htole16(BOOT_SIGN);
}
if (!(blank_sector = malloc(sector_size)))
--
1.9.1