From 93e450b2152325a1abfa80167284a047b9b2756f Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org.ua>
Date: Mon, 1 Nov 2010 15:04:41 +0200
Subject: [PATCH] upstream: Fix extraction of device nodes.

Cherry-picked from upstream commit
3913675640f65bb4774429d369681957b528996e:

* src/extract.c (extract_node): Do not mask out node type.
The bug was introduced in commit ea964cce.
---
 debian/changelog | 5 +++--
 src/extract.c    | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index c6250bd..19fa778 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,10 @@
 tar (1.24-2) unstable; urgency=low
 
-  * upstream patch to fix extraction of of empty directories with -C,
+  * upstream patch to fix extraction of empty directories with -C,
     closes: #602209.
+  * upstream patch to fix extraction of device nodes, closes: #602184.
 
- -- Carl Worth <cworth@cworth.org>  Sat, 06 Nov 2010 12:51:16 -0700
+ -- Carl Worth <cworth@cworth.org>  Sat, 06 Nov 2010 12:52:50 -0700
 
 tar (1.24-1) unstable; urgency=low
 
diff --git a/src/extract.c b/src/extract.c
index 98236ac..3d3eafb 100644
--- a/src/extract.c
+++ b/src/extract.c
@@ -1191,7 +1191,7 @@ static int
 extract_node (char *file_name, int typeflag)
 {
   bool interdir_made = false;
-  mode_t mode = (current_stat_info.stat.st_mode & MODE_RWX
+  mode_t mode = (current_stat_info.stat.st_mode & (MODE_RWX | S_IFBLK | S_IFCHR)
 		 & ~ (0 < same_owner_option ? S_IRWXG | S_IRWXO : 0));
 
   while (mknodat (chdir_fd, file_name, mode, current_stat_info.stat.st_rdev)
-- 
2.45.2