source: rtems/cpukit/libmisc/untar/untar.h @ d84e346b

5
Last change on this file since d84e346b was d84e346b, checked in by Chris Johns <chrisj@…>, on 05/18/16 at 23:18:21

libmisc/untar: Support directory create and overwrites. Share the common code.

Support creating directories for files with a path depth greater than 1. Some
tar files can have files with a path depth greater than 1 and no directory
entry in the tar file to create a directory.

Support overwriting existing files and directories failing in a similar
way to tar on common hosts. If a file is replaced with a file delete the
file and create a new file. If a directory replaces a file remove the file
and create the directory. If a file replaces a directory remove the directory,
and if the directory is not empty and cannot be removed report an error. If a
directory alreday exists do nothing leaving the contents untouched.

The untar code now shares the common header parsing and initial processing
with the actual writes still separate. No changes to the IMFS have been made.

Updates #2415.
Closes #2207.

  • Property mode set to 100644
File size: 1.8 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
24#include <rtems/print.h>
25
26/**
27 *  @defgroup libmisc_untar_img Untar Image
28 *
29 *  @ingroup libmisc
30 */
31/**@{*/
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#define UNTAR_SUCCESSFUL         0
37#define UNTAR_FAIL               1
38#define UNTAR_INVALID_CHECKSUM   2
39#define UNTAR_INVALID_HEADER     3
40
41
42int Untar_FromMemory(void *tar_buf, size_t size);
43int Untar_FromMemory_Print(void *tar_buf, size_t size, const rtems_printer* printer);
44int Untar_FromFile(const char *tar_name);
45int Untar_FromFile_Print(const char *tar_name, const rtems_printer* printer);
46
47/**************************************************************************
48 * This converts octal ASCII number representations into an
49 * unsigned long.  Only support 32-bit numbers for now.
50 *************************************************************************/
51extern unsigned long
52_rtems_octal2ulong(const char *octascii, size_t len);
53
54/************************************************************************
55 * Compute the TAR checksum and check with the value in
56 * the archive.  The checksum is computed over the entire
57 * header, but the checksum field is substituted with blanks.
58 ************************************************************************/
59extern int
60_rtems_tar_header_checksum(const char *bufr);
61
62#ifdef __cplusplus
63}
64#endif
65/**@}*/
66#endif  /* _RTEMS_UNTAR_H */
Note: See TracBrowser for help on using the repository browser.