source: rtems/cpukit/include/rtems/untar.h @ 2afb22b

Last change on this file since 2afb22b was 2afb22b, checked in by Chris Johns <chrisj@…>, on Dec 23, 2017 at 7:18:56 AM

Remove make preinstall

A speciality of the RTEMS build system was the make preinstall step. It
copied header files from arbitrary locations into the build tree. The
header files were included via the -Bsome/build/tree/path GCC command
line option.

This has at least seven problems:

  • The make preinstall step itself needs time and disk space.
  • Errors in header files show up in the build tree copy. This makes it hard for editors to open the right file to fix the error.
  • There is no clear relationship between source and build tree header files. This makes an audit of the build process difficult.
  • The visibility of all header files in the build tree makes it difficult to enforce API barriers. For example it is discouraged to use BSP-specifics in the cpukit.
  • An introduction of a new build system is difficult.
  • Include paths specified by the -B option are system headers. This may suppress warnings.
  • The parallel build had sporadic failures on some hosts.

This patch removes the make preinstall step. All installed header
files are moved to dedicated include directories in the source tree.
Let @RTEMS_CPU@ be the target architecture, e.g. arm, powerpc, sparc,
etc. Let @RTEMS_BSP_FAMILIY@ be a BSP family base directory, e.g.
erc32, imx, qoriq, etc.

The new cpukit include directories are:

  • cpukit/include
  • cpukit/score/cpu/@RTEMS_CPU@/include
  • cpukit/libnetworking

The new BSP include directories are:

  • bsps/include
  • bsps/@RTEMS_CPU@/include
  • bsps/@RTEMS_CPU@/@RTEMS_BSP_FAMILIY@/include

There are build tree include directories for generated files.

The include directory order favours the most general header file, e.g.
it is not possible to override general header files via the include path
order.

The "bootstrap -p" option was removed. The new "bootstrap -H" option
should be used to regenerate the "headers.am" files.

Update #3254.

  • Property mode set to 100644
File size: 6.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Untar an Image
5 *
6 * This file defines the interface to methods which can untar an image.
7 */
8
9/*
10 *  Written by: Jake Janovetz <janovetz@tempest.ece.uiuc.edu>
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#ifndef _RTEMS_UNTAR_H
18#define _RTEMS_UNTAR_H
19
20#include <stdbool.h>
21#include <stddef.h>
22#include <tar.h>
23#include <zlib.h>
24#include <xz.h>
25
26#include <rtems/print.h>
27
28/**
29 *  @defgroup libmisc_untar_img Untar Image
30 *
31 *  @ingroup libmisc
32 */
33/**@{*/
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38#define UNTAR_SUCCESSFUL         0
39#define UNTAR_FAIL               1
40#define UNTAR_INVALID_CHECKSUM   2
41#define UNTAR_INVALID_HEADER     3
42
43#define UNTAR_GZ_INFLATE_FAILED 4
44#define UNTAR_GZ_INFLATE_END_FAILED 5
45
46int Untar_FromMemory(void *tar_buf, size_t size);
47int Untar_FromMemory_Print(void *tar_buf, size_t size, const rtems_printer* printer);
48int Untar_FromFile(const char *tar_name);
49int Untar_FromFile_Print(const char *tar_name, const rtems_printer* printer);
50
51typedef struct {
52  /**
53   * @brief Current context state.
54   */
55  enum {
56    UNTAR_CHUNK_HEADER,
57    UNTAR_CHUNK_SKIP,
58    UNTAR_CHUNK_WRITE,
59    UNTAR_CHUNK_ERROR
60  } state;
61
62  /**
63   * @brief Header buffer.
64   */
65  char header[512];
66
67  /**
68   * @brief Name buffer.
69   */
70  char fname[100];
71
72  /**
73   * @brief Number of bytes of overall length are already processed.
74   */
75  size_t done_bytes;
76
77  /**
78   * @brief Mode of the file.
79   */
80  unsigned long mode;
81
82  /**
83   * @brief Overall amount of bytes to be processed.
84   */
85  unsigned long todo_bytes;
86
87  /**
88   * @brief Overall amount of blocks to be processed.
89   */
90  unsigned long todo_blocks;
91
92  /**
93   * @brief File descriptor of output file.
94   */
95  int out_fd;
96} Untar_ChunkContext;
97
98typedef struct {
99  /**
100   * @brief Instance of Chunk Context needed for tar decompression.
101   */
102  Untar_ChunkContext base;
103
104  /**
105   * @brief Current zlib context.
106   */
107  z_stream strm;
108
109  /**
110   * @brief Buffer that contains the inflated data.
111   */
112  void *inflateBuffer;
113
114  /**
115   * @brief Size of buffer that contains the inflated data.
116   */
117  size_t inflateBufferSize;
118
119} Untar_GzChunkContext;
120
121typedef struct {
122  /**
123   * @brief Instance of Chunk Context needed for tar decompression.
124   */
125  Untar_ChunkContext base;
126
127  /**
128   * @brief Xz context.
129   */
130  struct xz_dec* strm;
131
132  /**
133   * @brief Xz buffer.
134   */
135  struct xz_buf buf;
136
137  /**
138   * @brief Buffer that contains the inflated data.
139   */
140  void *inflateBuffer;
141
142  /**
143   * @brief Size of buffer that contains the inflated data.
144   */
145  size_t inflateBufferSize;
146
147} Untar_XzChunkContext;
148
149/**
150 * @brief Initializes the Untar_ChunkContext files out of a part of a block of
151 * memory.
152 *
153 * @param Untar_ChunkContext *context [in] Pointer to a context structure.
154 */
155void Untar_ChunkContext_Init(Untar_ChunkContext *context);
156
157/*
158 * @brief Rips links, directories and files out of a part of a block of memory.
159 *
160 * @param Untar_ChunkContext *context [in] Pointer to a context structure.
161 * @param void *chunk [in] Pointer to a chunk of a TAR buffer.
162 * @param size_t chunk_size [in] Length of the chunk of a TAR buffer.
163 *
164 * @retval UNTAR_SUCCESSFUL (0)    on successful completion.
165 * @retval UNTAR_FAIL              for a faulty step within the process.
166 * @retval UNTAR_INVALID_CHECKSUM  for an invalid header checksum.
167 * @retval UNTAR_INVALID_HEADER    for an invalid header.
168 */
169
170int Untar_FromChunk_Print(
171  Untar_ChunkContext *context,
172  void *chunk,
173  size_t chunk_size,
174  const rtems_printer* printer
175);
176
177/**
178 * @brief Initializes the Untar_ChunkGzContext.
179 *
180 * @param Untar_ChunkGzContext *context [in] Pointer to a context structure.
181 * @param void *inflateBuffer [in] Pointer to a context structure.
182 * @param size_t inflateBufferSize [in] Size of inflateBuffer.
183 */
184int Untar_GzChunkContext_Init(
185  Untar_GzChunkContext *ctx,
186  void *inflateBuffer,
187  size_t inflateBufferSize
188);
189
190/*
191 * @brief Untars a GZ compressed POSIX TAR file.
192 *
193 * This is a subroutine used to rip links, directories, and
194 * files out of a tar.gz/tgz file.
195 *
196 * @param Untar_ChunkContext *context [in] Pointer to a context structure.
197 * @param ssize buflen [in] Size of valid bytes in input buffer.
198 * @param z_stream *strm [in] Pointer to the current zlib context.
199 */
200int Untar_FromGzChunk_Print(
201  Untar_GzChunkContext *ctx,
202  void *chunk,
203  size_t chunk_size,
204  const rtems_printer* printer
205);
206
207/**
208 * @brief Initializes the Untar_ChunkXzContext.
209 *
210 * @param Untar_ChunkXzContext *context [in] Pointer to a context structure.
211 * @param enum xz_mode mode [in] Dictionary mode.
212 * @param uint32_t dict_max [in] Maximum size of dictionary.
213 * @param void *inflateBuffer [in] Pointer to a context structure.
214 * @param size_t inflateBufferSize [in] Size of inflateBuffer.
215 */
216int Untar_XzChunkContext_Init(
217  Untar_XzChunkContext *ctx,
218  enum xz_mode mode,
219  uint32_t dict_max,
220  void *inflateBuffer,
221  size_t inflateBufferSize
222);
223
224/*
225 * @brief Untars a XZ compressed POSIX TAR file.
226 *
227 * This is a subroutine used to rip links, directories, and
228 * files out of a tar.gz/tgz file.
229 *
230 * @param Untar_ChunkContext *context [in] Pointer to a context structure.
231 * @param ssize buflen [in] Size of valid bytes in input buffer.
232 * @param z_stream *strm [in] Pointer to the current zlib context.
233 */
234int Untar_FromXzChunk_Print(
235  Untar_XzChunkContext *ctx,
236  const void *chunk,
237  size_t chunk_size,
238  const rtems_printer* printer
239);
240
241/**************************************************************************
242 * This converts octal ASCII number representations into an
243 * unsigned long.  Only support 32-bit numbers for now.
244 *************************************************************************/
245extern unsigned long
246_rtems_octal2ulong(const char *octascii, size_t len);
247
248/************************************************************************
249 * Compute the TAR checksum and check with the value in
250 * the archive.  The checksum is computed over the entire
251 * header, but the checksum field is substituted with blanks.
252 ************************************************************************/
253extern int
254_rtems_tar_header_checksum(const char *bufr);
255
256#ifdef __cplusplus
257}
258#endif
259/**@}*/
260#endif  /* _RTEMS_UNTAR_H */
Note: See TracBrowser for help on using the repository browser.