Index: cpukit/libmisc/untar/untar.c
===================================================================
--- cpukit/libmisc/untar/untar.c	(revision 5d0f0de4aa3791b32b4b48e5f97a1e68f07641e3)
+++ cpukit/libmisc/untar/untar.c	(revision b0f08c83e23e69c7b19b04d38910f90b5f7af51b)
@@ -251,4 +251,5 @@
   const char          *bufr,
   char                *fname,
+  unsigned long       *mode,
   unsigned long       *file_size,
   unsigned long       *nblocks,
@@ -286,4 +287,6 @@
   strncpy(fname, bufr, MAX_NAME_FIELD_SIZE);
   fname[MAX_NAME_FIELD_SIZE] = '\0';
+
+  *mode = strtoul(&bufr[100], NULL, 8);
 
   *linkflag   = bufr[156];
@@ -300,5 +303,6 @@
     symlink(linkname, fname);
   } else if (*linkflag == REGTYPE) {
-    rtems_printf(printer, "untar: file: %s (%i)\n", fname, (int) *file_size);
+    rtems_printf(printer, "untar: file: %s (s:%i,m:%04o)\n",
+                 fname, (int) *file_size, (int) *mode);
     *nblocks = (((*file_size) + 511) & ~511) / 512;
     if (Make_Path(printer, fname, false) < 0) {
@@ -319,5 +323,5 @@
             r = unlink(fname);
             if (r == 0) {
-              r = mkdir(fname, S_IRWXU | S_IRWXG | S_IRWXO);
+              r = mkdir(fname, *mode);
             }
           }
@@ -363,5 +367,5 @@
 )
 {
-  FILE           *fp;
+  int            fd;
   const char     *tar_ptr = (const char *)tar_buf;
   const char     *bufr;
@@ -369,7 +373,8 @@
   int            retval = UNTAR_SUCCESSFUL;
   unsigned long  ptr;
-  unsigned long  nblocks;
-  unsigned long  file_size;
-  unsigned char  linkflag;
+  unsigned long  nblocks = 0;
+  unsigned long  file_size = 0;
+  unsigned long  mode = 0;
+  unsigned char  linkflag = 0;
 
   rtems_printf(printer, "untar: memory at %p (%zu)\n", tar_buf, size);
@@ -386,5 +391,6 @@
     ptr += 512;
 
-    retval = Untar_ProcessHeader(bufr, fname, &file_size, &nblocks, &linkflag, printer);
+    retval = Untar_ProcessHeader(bufr, fname, &mode, &file_size,
+                                 &nblocks, &linkflag, printer);
 
     if (retval != UNTAR_SUCCESSFUL)
@@ -392,12 +398,12 @@
 
     if (linkflag == REGTYPE) {
-      if ((fp = fopen(fname, "w")) == NULL) {
+      if ((fd = open(fname, O_TRUNC | O_CREAT | O_WRONLY, mode)) == -1) {
         Print_Error(printer, "open", fname);
         ptr += 512 * nblocks;
       } else {
         unsigned long sizeToGo = file_size;
-        size_t        len;
-        size_t        i;
-        size_t        n;
+        ssize_t       len;
+        ssize_t       i;
+        ssize_t       n;
 
         /*
@@ -407,5 +413,5 @@
         for (i = 0; i < nblocks; i++) {
           len = ((sizeToGo < 512L) ? (sizeToGo) : (512L));
-          n = fwrite(&tar_ptr[ptr], 1, len, fp);
+          n = write(fd, &tar_ptr[ptr], len);
           if (n != len) {
             Print_Error(printer, "write", fname);
@@ -416,5 +422,5 @@
           sizeToGo -= n;
         }
-        fclose(fp);
+        close(fd);
       }
 
@@ -486,7 +492,8 @@
   int            retval;
   unsigned long  i;
-  unsigned long  nblocks;
-  unsigned long  file_size;
-  unsigned char  linkflag;
+  unsigned long  nblocks = 0;
+  unsigned long  file_size = 0;
+  unsigned long  mode = 0;
+  unsigned char  linkflag = 0;
 
   retval = UNTAR_SUCCESSFUL;
@@ -509,5 +516,6 @@
     }
 
-    retval = Untar_ProcessHeader(bufr, fname, &file_size, &nblocks, &linkflag, printer);
+    retval = Untar_ProcessHeader(bufr, fname, &mode, &file_size,
+                                 &nblocks, &linkflag, printer);
 
     if (retval != UNTAR_SUCCESSFUL)
@@ -522,5 +530,5 @@
        */
 
-      if ((out_fd = creat(fname, 0644)) == -1) {
+      if ((out_fd = creat(fname, mode)) == -1) {
         (void) lseek(fd, SEEK_CUR, 512UL * nblocks);
       } else {
@@ -580,4 +588,5 @@
             &context->header[0],
             &context->fname[0],
+            &context->mode,
             &context->todo_bytes,
             &context->todo_blocks,
@@ -592,5 +601,5 @@
 
           if (linkflag == REGTYPE) {
-            context->out_fd = creat(&context->fname[0], 0644);
+            context->out_fd = creat(&context->fname[0], context->mode);
 
             if (context->out_fd >= 0) {
Index: cpukit/libmisc/untar/untar.h
===================================================================
--- cpukit/libmisc/untar/untar.h	(revision 5d0f0de4aa3791b32b4b48e5f97a1e68f07641e3)
+++ cpukit/libmisc/untar/untar.h	(revision b0f08c83e23e69c7b19b04d38910f90b5f7af51b)
@@ -75,7 +75,12 @@
 
   /**
+   * @brief Mode of the file.
+   */
+  unsigned long mode;
+
+  /**
    * @brief Overall amount of bytes to be processed.
    */
-  long unsigned todo_bytes;
+  unsigned long todo_bytes;
 
   /**
Index: testsuites/libtests/tar01/Makefile.am
===================================================================
--- testsuites/libtests/tar01/Makefile.am	(revision 5d0f0de4aa3791b32b4b48e5f97a1e68f07641e3)
+++ testsuites/libtests/tar01/Makefile.am	(revision b0f08c83e23e69c7b19b04d38910f90b5f7af51b)
@@ -10,5 +10,5 @@
 
 tar01_LDADD = -lrtemscpu -lz
-  
+
 BUILT_SOURCES =
 BUILT_SOURCES += initial_filesystem_tar.c
@@ -58,4 +58,7 @@
 	(echo "This is a test of loading an RTEMS filesystem from an" ; \
 	echo "initial tar image.") >initial_fs/home/test_file
+	(echo "#! joel" ; \
+	echo "ls -las /dev") >initial_fs/home/test_script
+	chmod +x initial_fs/home/test_script
 	(cd initial_fs; \
 	$(LN_S) home/test_file symlink; \
Index: testsuites/libtests/tar01/init.c
===================================================================
--- testsuites/libtests/tar01/init.c	(revision 5d0f0de4aa3791b32b4b48e5f97a1e68f07641e3)
+++ testsuites/libtests/tar01/init.c	(revision b0f08c83e23e69c7b19b04d38910f90b5f7af51b)
@@ -47,4 +47,14 @@
 );
 
+static void test_untar_check_mode(const char* file, int mode)
+{
+  struct stat sb;
+  int         fmode;
+  rtems_test_assert(stat(file, &sb) == 0);
+  fmode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+  printf(" %s: mode: %04o want: %04o\n", file, fmode, mode);
+  rtems_test_assert(fmode == mode);
+}
+
 void test_untar_from_memory(void)
 {
@@ -65,4 +75,9 @@
   printf( "========= /home/test_file =========\n" );
   test_cat( "/home/test_file", 0, 0 );
+
+  /******************/
+  printf( "========= /home/test_script =========\n" );
+  test_cat( "/home/test_script", 0, 0 );
+  test_untar_check_mode("/home/test_script", 0755);
 
   /******************/
@@ -108,4 +123,9 @@
 
   /******************/
+  printf( "========= /dest/home/test_script =========\n" );
+  test_cat( "/dest/home/test_script", 0, 0 );
+  test_untar_check_mode("/dest/home/test_script", 0755);
+
+  /******************/
   printf( "========= /dest/symlink =========\n" );
   test_cat( "/dest/symlink", 0, 0 );
@@ -145,4 +165,9 @@
 
   /******************/
+  printf( "========= /dest2/home/test_script =========\n" );
+  test_cat( "/dest2/home/test_script", 0, 0 );
+  test_untar_check_mode("/dest2/home/test_script", 0755);
+
+  /******************/
   printf( "========= /dest2/symlink =========\n" );
   test_cat( "/dest2/symlink", 0, 0 );
@@ -185,4 +210,9 @@
 
   /******************/
+  printf( "========= /dest3/home/test_script =========\n" );
+  test_cat( "/dest3/home/test_script", 0, 0 );
+  test_untar_check_mode("/dest3/home/test_script", 0755);
+
+  /******************/
   printf( "========= /dest3/symlink =========\n" );
   test_cat( "/dest3/symlink", 0, 0 );
