mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-22 08:54:44 +08:00
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.
This commit is contained in:
+403
-192
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
* @file
|
||||
*
|
||||
* @brief Untar an Image
|
||||
*
|
||||
*
|
||||
* This file defines the interface to methods which can untar an image.
|
||||
*/
|
||||
|
||||
@@ -17,9 +17,12 @@
|
||||
#ifndef _RTEMS_UNTAR_H
|
||||
#define _RTEMS_UNTAR_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <tar.h>
|
||||
|
||||
#include <rtems/print.h>
|
||||
|
||||
/**
|
||||
* @defgroup libmisc_untar_img Untar Image
|
||||
*
|
||||
@@ -37,7 +40,9 @@ extern "C" {
|
||||
|
||||
|
||||
int Untar_FromMemory(void *tar_buf, size_t size);
|
||||
int Untar_FromMemory_Print(void *tar_buf, size_t size, const rtems_printer* printer);
|
||||
int Untar_FromFile(const char *tar_name);
|
||||
int Untar_FromFile_Print(const char *tar_name, const rtems_printer* printer);
|
||||
|
||||
/**************************************************************************
|
||||
* This converts octal ASCII number representations into an
|
||||
|
||||
@@ -44,9 +44,12 @@ void test_cat(
|
||||
void test_untar_from_memory(void)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
rtems_printer printer;
|
||||
|
||||
rtems_print_printer_printf(&printer);
|
||||
|
||||
printf("Untaring from memory - ");
|
||||
sc = Untar_FromMemory((void *)TARFILE_START, TARFILE_SIZE);
|
||||
sc = Untar_FromMemory_Print((void *)TARFILE_START, TARFILE_SIZE, &printer);
|
||||
if (sc != RTEMS_SUCCESSFUL) {
|
||||
printf ("error: untar failed: %s\n", rtems_status_text (sc));
|
||||
exit(1);
|
||||
@@ -56,7 +59,7 @@ void test_untar_from_memory(void)
|
||||
/******************/
|
||||
printf( "========= /home/test_file =========\n" );
|
||||
test_cat( "/home/test_file", 0, 0 );
|
||||
|
||||
|
||||
/******************/
|
||||
printf( "========= /symlink =========\n" );
|
||||
test_cat( "/symlink", 0, 0 );
|
||||
@@ -97,7 +100,7 @@ void test_untar_from_file(void)
|
||||
/******************/
|
||||
printf( "========= /dest/home/test_file =========\n" );
|
||||
test_cat( "/dest/home/test_file", 0, 0 );
|
||||
|
||||
|
||||
/******************/
|
||||
printf( "========= /dest/symlink =========\n" );
|
||||
test_cat( "/dest/symlink", 0, 0 );
|
||||
|
||||
Reference in New Issue
Block a user