Index: cpukit/libmisc/Makefile.am
===================================================================
--- cpukit/libmisc/Makefile.am	(revision 1a8fe67acf5903caacc6da2854a074ed0c4b2743)
+++ cpukit/libmisc/Makefile.am	(revision 6a174c024aa878e72386f811f28d880449fc264d)
@@ -156,5 +156,5 @@
 ## libuntar
 noinst_LIBRARIES += libuntar.a
-libuntar_a_SOURCES = untar/untar.c untar/untar.h
+libuntar_a_SOURCES = untar/untar.c untar/untar_tgz.c untar/untar.h
 
 EXTRA_DIST += untar/README
Index: cpukit/libmisc/untar/untar.h
===================================================================
--- cpukit/libmisc/untar/untar.h	(revision 1a8fe67acf5903caacc6da2854a074ed0c4b2743)
+++ cpukit/libmisc/untar/untar.h	(revision 6a174c024aa878e72386f811f28d880449fc264d)
@@ -21,4 +21,5 @@
 #include <stddef.h>
 #include <tar.h>
+#include <zlib.h>
 
 #include <rtems/print.h>
@@ -39,4 +40,6 @@
 #define UNTAR_INVALID_HEADER     3
 
+#define UNTAR_GZ_INFLATE_FAILED 4
+#define UNTAR_GZ_INFLATE_END_FAILED 5
 
 int Untar_FromMemory(void *tar_buf, size_t size);
@@ -138,4 +141,34 @@
 );
 
+/**
+ * @brief Initializes the Untar_ChunkGzContext.
+ *
+ * @param Untar_ChunkGzContext *context [in] Pointer to a context structure.
+ * @param void *inflateBuffer [in] Pointer to a context structure.
+ * @param size_t inflateBufferSize [in] Size of inflateBuffer.
+ */
+int Untar_GzChunkContext_Init(
+  Untar_GzChunkContext *ctx,
+  void *inflateBuffer,
+  size_t inflateBufferSize
+);
+
+/*
+ * @brief Untars a GZ compressed POSIX TAR file.
+ *
+ * This is a subroutine used to rip links, directories, and
+ * files out of a tar.gz/tgz file.
+ *
+ * @param Untar_ChunkContext *context [in] Pointer to a context structure.
+ * @param ssize buflen [in] Size of valid bytes in input buffer.
+ * @param z_stream *strm [in] Pointer to the current zlib context.
+ */
+int Untar_FromGzChunk_Print(
+  Untar_GzChunkContext *ctx,
+  void *chunk,
+  size_t chunk_size,
+  const rtems_printer* printer
+);
+
 /**************************************************************************
  * This converts octal ASCII number representations into an
Index: cpukit/libmisc/untar/untar_tgz.c
===================================================================
--- cpukit/libmisc/untar/untar_tgz.c	(revision 6a174c024aa878e72386f811f28d880449fc264d)
+++ cpukit/libmisc/untar/untar_tgz.c	(revision 6a174c024aa878e72386f811f28d880449fc264d)
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2016 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <info@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/untar.h>
+
+int Untar_GzChunkContext_Init(
+  Untar_GzChunkContext *ctx,
+  void *inflateBuffer,
+  size_t inflateBufferSize
+)
+{
+  int ret;
+  int status = UNTAR_SUCCESSFUL;
+
+  Untar_ChunkContext_Init(&ctx->base);
+  ctx->inflateBuffer = inflateBuffer;
+  ctx->inflateBufferSize = inflateBufferSize;
+  memset(&ctx->strm, 0, sizeof(ctx->strm));
+  ret = inflateInit2(&ctx->strm, 32 + MAX_WBITS);
+  if (ret != Z_OK){
+    status = UNTAR_FAIL;
+  }
+  return status;
+}
+
+int Untar_FromGzChunk_Print(
+  Untar_GzChunkContext *ctx,
+  void *chunk,
+  size_t chunk_size,
+  const rtems_printer *printer
+)
+{
+  int untar_succesful;
+  int status;
+
+  ctx->strm.next_in = (Bytef *)chunk;
+  ctx->strm.avail_in = (size_t)chunk_size;
+
+    /* Inflate until output buffer is not full */
+  do {
+    ctx->strm.next_out = (Bytef *) ctx->inflateBuffer;
+    ctx->strm.avail_out = ctx->inflateBufferSize;
+
+    status = inflate(&ctx->strm, Z_NO_FLUSH);
+    if (status == Z_OK || status == Z_STREAM_END) {
+      size_t inflated_size =
+        ctx->inflateBufferSize - ctx->strm.avail_out;
+      untar_succesful = Untar_FromChunk_Print(&ctx->base,
+        ctx->inflateBuffer, inflated_size, NULL);
+      if (untar_succesful != UNTAR_SUCCESSFUL){
+        return untar_succesful;
+      }
+    }
+  } while (ctx->strm.avail_out == 0 && ctx->strm.avail_in > 0
+      && status == Z_OK);
+
+  if (status != Z_OK) {
+    if (untar_succesful != UNTAR_SUCCESSFUL){
+      rtems_printf(printer, "Untar not successful\n");
+    }
+
+    if (status != Z_STREAM_END) {
+      rtems_printf(printer, "Zlib inflate failed\n");
+    }
+
+    status = inflateEnd(&ctx->strm);
+    if (status != Z_OK) {
+      rtems_printf(printer, "Zlib inflate end failed\n");
+    }
+  }
+  return untar_succesful;
+}
+
+
Index: testsuites/libtests/configure.ac
===================================================================
--- testsuites/libtests/configure.ac	(revision 1a8fe67acf5903caacc6da2854a074ed0c4b2743)
+++ testsuites/libtests/configure.ac	(revision 6a174c024aa878e72386f811f28d880449fc264d)
@@ -32,4 +32,5 @@
 AC_PROG_LN_S
 AC_PATH_PROG([PAX],[pax],no)
+AC_PATH_PROG([GZIP],[gzip],no)
 
 AS_IF([test "x$PAX" = "xno"],[
@@ -39,5 +40,5 @@
 AC_CHECK_HEADERS([complex.h])
 
-AM_CONDITIONAL(TARTESTS,test "$as_ln_s" = "ln -s" && test -n "$PAX")
+AM_CONDITIONAL(TARTESTS,test "$as_ln_s" = "ln -s" && test -n "$PAX" && test -n "$GZIP")
 
 AM_CONDITIONAL(HAS_CXX,test "$rtems_cv_HAS_CPLUSPLUS" = "yes")
Index: testsuites/libtests/tar01/Makefile.am
===================================================================
--- testsuites/libtests/tar01/Makefile.am	(revision 1a8fe67acf5903caacc6da2854a074ed0c4b2743)
+++ testsuites/libtests/tar01/Makefile.am	(revision 6a174c024aa878e72386f811f28d880449fc264d)
@@ -1,8 +1,19 @@
 if TARTESTS
 rtems_tests_PROGRAMS = tar01
-tar01_SOURCES = init.c ../../psxtests/psxfile01/test_cat.c \
-  initial_filesystem_tar.c initial_filesystem_tar.h
+tar01_SOURCES =
+tar01_SOURCES += init.c
+tar01_SOURCES += ../../psxtests/psxfile01/test_cat.c
+tar01_SOURCES += initial_filesystem_tar.c
+tar01_SOURCES += initial_filesystem_tar.h
+tar01_SOURCES += initial_filesystem_tar_gz.c
+tar01_SOURCES += initial_filesystem_tar_gz.h
+
+tar01_LDADD = -lrtemscpu -lz
   
-BUILT_SOURCES = initial_filesystem_tar.c initial_filesystem_tar.h
+BUILT_SOURCES =
+BUILT_SOURCES += initial_filesystem_tar.c
+BUILT_SOURCES += initial_filesystem_tar.h
+BUILT_SOURCES += initial_filesystem_tar_gz.c
+BUILT_SOURCES += initial_filesystem_tar_gz.h
 
 dist_rtems_tests_DATA = tar01.scn
@@ -19,5 +30,5 @@
 AM_CPPFLAGS += -I$(top_srcdir)/../psxtests/include
 
-LINK_OBJS = $(tar01_OBJECTS)
+LINK_OBJS = $(tar01_OBJECTS) $(tar01_LDADD)
 LINK_LIBS = $(tar01_LDLIBS)
 
@@ -34,4 +45,12 @@
 CLEANFILES += initial_filesystem_tar.h
 
+initial_filesystem_tar_gz.c: initial_filesystem.tar.gz
+	$(BIN2C) -C initial_filesystem.tar.gz initial_filesystem_tar_gz
+CLEANFILES += initial_filesystem_tar_gz.h
+
+initial_filesystem_tar_gz.h: initial_filesystem.tar.gz
+	$(BIN2C) -H initial_filesystem.tar.gz initial_filesystem_tar_gz
+CLEANFILES += initial_filesystem_tar_gz.h
+
 initial_filesystem.tar:
 	rm -rf initial_fs
@@ -43,4 +62,9 @@
 	$(PAX) -w -f ../initial_filesystem.tar home symlink)
 CLEANFILES += initial_filesystem.tar
+
+initial_filesystem.tar.gz: initial_filesystem.tar
+	$(GZIP) < initial_filesystem.tar > initial_filesystem.tar.gz
+CLEANFILES += initial_filesystem.tar.gz
+
 endif TARTESTS
 
Index: testsuites/libtests/tar01/init.c
===================================================================
--- testsuites/libtests/tar01/init.c	(revision 1a8fe67acf5903caacc6da2854a074ed0c4b2743)
+++ testsuites/libtests/tar01/init.c	(revision 6a174c024aa878e72386f811f28d880449fc264d)
@@ -25,4 +25,5 @@
 
 #include "initial_filesystem_tar.h"
+#include "initial_filesystem_tar_gz.h"
 
 const char rtems_test_name[] = "TAR 1";
@@ -33,7 +34,10 @@
 void test_untar_from_file(void);
 void test_untar_chunks_from_memory(void);
+void test_untar_unzip_tgz(void);
 
 #define TARFILE_START initial_filesystem_tar
 #define TARFILE_SIZE  initial_filesystem_tar_size
+#define TARFILE_GZ_START initial_filesystem_tar_gz
+#define TARFILE_GZ_SIZE  initial_filesystem_tar_gz_size
 
 void test_cat(
@@ -146,4 +150,43 @@
 }
 
+void test_untar_unzip_tgz(void)
+{
+  int status;
+  rtems_printer     printer;
+  int rv;
+  Untar_GzChunkContext ctx;
+  size_t i = 0;
+  char *buffer = (char *)TARFILE_GZ_START;
+  size_t buflen = TARFILE_GZ_SIZE;
+  char inflate_buffer;
+
+  rtems_print_printer_printf(&printer);
+
+  /* make a directory to untar it into */
+  rv = mkdir( "/dest3", 0777 );
+  rtems_test_assert( rv == 0 );
+
+  rv = chdir( "/dest3" );
+  rtems_test_assert( rv == 0 );
+
+  printf( "Untaring chunks from tgz - " );
+
+  status = Untar_GzChunkContext_Init(&ctx, &inflate_buffer, 1);
+  rtems_test_assert(status == UNTAR_SUCCESSFUL);
+  for(i = 0; i < buflen; i++) {
+    status = Untar_FromGzChunk_Print(&ctx, &buffer[i], 1, &printer);
+    rtems_test_assert(status == UNTAR_SUCCESSFUL);
+  }
+  printf( "successful\n" );
+
+  /******************/
+  printf( "========= /dest3/home/test_file =========\n" );
+  test_cat( "/dest3/home/test_file", 0, 0 );
+
+  /******************/
+  printf( "========= /dest3/symlink =========\n" );
+  test_cat( "/dest3/symlink", 0, 0 );
+}
+
 rtems_task Init(
   rtems_task_argument ignored
@@ -157,4 +200,6 @@
   puts( "" );
   test_untar_chunks_from_memory();
+  puts( "" );
+  test_untar_unzip_tgz();
 
   TEST_END();
Index: testsuites/libtests/tar01/tar01.scn
===================================================================
--- testsuites/libtests/tar01/tar01.scn	(revision 1a8fe67acf5903caacc6da2854a074ed0c4b2743)
+++ testsuites/libtests/tar01/tar01.scn	(revision 6a174c024aa878e72386f811f28d880449fc264d)
@@ -32,3 +32,14 @@
 initial tar image.
 
+
+Untaring chunks from tgz- untar: dir: home
+untar: file: home/test_file (73)
+successful
+========= /dest3/home/test_file =========
+(0)This is a test of loading an RTEMS filesystem from an
+initial tar image.
+
+========= /dest3/symlink =========
+(0)This is a test of loading an RTEMS filesystem from an
+initial tar image.
 *** END OF TAR01 TEST ***
