0011-Remove-linux-msdos_fs.h-includes.patch 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
  9. Signed-off-by: Andreas Bombe <aeb@debian.org>
  10. ---
  11. src/file.c | 7 +------
  12. src/file.h | 2 ++
  13. src/fsck.fat.h | 8 ++------
  14. src/mkfs.fat.c | 32 +++---------------------------
  15. src/msdos_fs.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  16. 5 files changed, 69 insertions(+), 41 deletions(-)
  17. create mode 100644 src/msdos_fs.h
  18. diff --git a/src/file.c b/src/file.c
  19. index 0b53840..9519070 100644
  20. --- a/src/file.c
  21. +++ b/src/file.c
  22. @@ -30,14 +30,9 @@
  23. #include <ctype.h>
  24. #include <unistd.h>
  25. -#define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
  26. -#define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h> */
  27. -#define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
  28. -
  29. -#include <linux/msdos_fs.h>
  30. -
  31. #include "common.h"
  32. #include "file.h"
  33. +#include "msdos_fs.h"
  34. #include "charconv.h"
  35. FDSC *fp_root = NULL;
  36. diff --git a/src/file.h b/src/file.h
  37. index 3adfc96..eaaf356 100644
  38. --- a/src/file.h
  39. +++ b/src/file.h
  40. @@ -23,6 +23,8 @@
  41. #ifndef _FILE_H
  42. #define _FILE_H
  43. +#include "msdos_fs.h"
  44. +
  45. typedef enum { fdt_none, fdt_drop, fdt_undelete } FD_TYPE;
  46. typedef struct _fptr {
  47. diff --git a/src/fsck.fat.h b/src/fsck.fat.h
  48. index 27e9d52..e5f6178 100644
  49. --- a/src/fsck.fat.h
  50. +++ b/src/fsck.fat.h
  51. @@ -28,16 +28,12 @@
  52. #define _DOSFSCK_H
  53. #include <fcntl.h>
  54. -#define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
  55. -#define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h> */
  56. -#define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
  57. -
  58. -#include <linux/msdos_fs.h>
  59. -
  60. #include <stddef.h>
  61. #include <stdint.h>
  62. #include <endian.h>
  63. +#include "msdos_fs.h"
  64. +
  65. #define VFAT_LN_ATTR (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
  66. #define FAT_STATE_DIRTY 0x01
  67. diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c
  68. index 3d1512f..76d40d8 100644
  69. --- a/src/mkfs.fat.c
  70. +++ b/src/mkfs.fat.c
  71. @@ -67,6 +67,8 @@
  72. #include <stdint.h>
  73. #include <endian.h>
  74. +#include "msdos_fs.h"
  75. +
  76. /* In earlier versions, an own llseek() was used, but glibc lseek() is
  77. * sufficient (or even better :) for 64 bit offsets in the meantime */
  78. #define llseek lseek
  79. @@ -99,21 +101,6 @@ static inline int cdiv(int a, int b)
  80. return (a + b - 1) / b;
  81. }
  82. -/* MS-DOS filesystem structures -- I included them here instead of
  83. - including linux/msdos_fs.h since that doesn't include some fields we
  84. - need */
  85. -
  86. -#define ATTR_RO 1 /* read-only */
  87. -#define ATTR_HIDDEN 2 /* hidden */
  88. -#define ATTR_SYS 4 /* system */
  89. -#define ATTR_VOLUME 8 /* volume label */
  90. -#define ATTR_DIR 16 /* directory */
  91. -#define ATTR_ARCH 32 /* archived */
  92. -
  93. -#define ATTR_NONE 0 /* no attribute bits */
  94. -#define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
  95. - /* attribute bits that are copied "as is" */
  96. -
  97. /* FAT values */
  98. #define FAT_EOF (atari_format ? 0x0fffffff : 0x0ffffff8)
  99. #define FAT_BAD 0x0ffffff7
  100. @@ -200,19 +187,6 @@ struct fat32_fsinfo {
  101. uint32_t reserved2[4];
  102. };
  103. -struct msdos_dir_entry {
  104. - char name[8], ext[3]; /* name and extension */
  105. - uint8_t attr; /* attribute bits */
  106. - uint8_t lcase; /* Case for base and extension */
  107. - uint8_t ctime_ms; /* Creation time, milliseconds */
  108. - uint16_t ctime; /* Creation time */
  109. - uint16_t cdate; /* Creation date */
  110. - uint16_t adate; /* Last access date */
  111. - uint16_t starthi; /* high 16 bits of first cl. (FAT32) */
  112. - uint16_t time, date, start; /* time, date and first cluster */
  113. - uint32_t size; /* file size (in bytes) */
  114. -} __attribute__ ((packed));
  115. -
  116. /* The "boot code" we put into the filesystem... it writes a message and
  117. tells the user to try again */
  118. @@ -1244,7 +1218,7 @@ static void setup_tables(void)
  119. htole16((unsigned short)(ctime->tm_mday +
  120. ((ctime->tm_mon + 1) << 5) +
  121. ((ctime->tm_year - 80) << 9)));
  122. - de->ctime_ms = 0;
  123. + de->ctime_cs = 0;
  124. de->ctime = de->time;
  125. de->cdate = de->date;
  126. de->adate = de->date;
  127. diff --git a/src/msdos_fs.h b/src/msdos_fs.h
  128. new file mode 100644
  129. index 0000000..54b2a34
  130. --- /dev/null
  131. +++ b/src/msdos_fs.h
  132. @@ -0,0 +1,61 @@
  133. +/* msdos_fs.h - MS-DOS filesystem constants/structures
  134. +
  135. + This program is free software: you can redistribute it and/or modify
  136. + it under the terms of the GNU General Public License as published by
  137. + the Free Software Foundation, either version 3 of the License, or
  138. + (at your option) any later version.
  139. +
  140. + This program is distributed in the hope that it will be useful,
  141. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  142. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  143. + GNU General Public License for more details.
  144. +
  145. + You should have received a copy of the GNU General Public License
  146. + along with this program. If not, see <http://www.gnu.org/licenses/>.
  147. +
  148. + The complete text of the GNU General Public License
  149. + can be found in /usr/share/common-licenses/GPL-3 file.
  150. +*/
  151. +
  152. +#ifndef _MSDOS_FS_H
  153. +#define _MSDOS_FS_H
  154. +
  155. +#include <stdint.h>
  156. +
  157. +#define SECTOR_SIZE 512 /* sector size (bytes) */
  158. +#define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry))
  159. +#define MSDOS_DPS_BITS 4 /* log2(MSDOS_DPS) */
  160. +#define MSDOS_DIR_BITS 5 /* log2(sizeof(struct msdos_dir_entry)) */
  161. +
  162. +#define ATTR_NONE 0 /* no attribute bits */
  163. +#define ATTR_RO 1 /* read-only */
  164. +#define ATTR_HIDDEN 2 /* hidden */
  165. +#define ATTR_SYS 4 /* system */
  166. +#define ATTR_VOLUME 8 /* volume label */
  167. +#define ATTR_DIR 16 /* directory */
  168. +#define ATTR_ARCH 32 /* archived */
  169. +
  170. +/* attribute bits that are copied "as is" */
  171. +#define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
  172. +
  173. +#define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */
  174. +#define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG)
  175. +
  176. +#define MSDOS_NAME 11 /* maximum name length */
  177. +#define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */
  178. +#define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */
  179. +
  180. +struct msdos_dir_entry {
  181. + uint8_t name[8], ext[3]; /* name and extension */
  182. + uint8_t attr; /* attribute bits */
  183. + uint8_t lcase; /* Case for base and extension */
  184. + uint8_t ctime_cs; /* Creation time, centiseconds (0-199) */
  185. + uint16_t ctime; /* Creation time */
  186. + uint16_t cdate; /* Creation date */
  187. + uint16_t adate; /* Last access date */
  188. + uint16_t starthi; /* High 16 bits of cluster in FAT32 */
  189. + uint16_t time, date, start; /* time, date and first cluster */
  190. + uint32_t size; /* file size (in bytes) */
  191. +} __attribute__ ((packed));
  192. +
  193. +#endif /* _MSDOS_FS_H */
  194. --
  195. 1.9.1