coreutils-8.29.patchset revision fd51c417
1From 2ad10befa33d331800346cab63417bebb1db3e6f Mon Sep 17 00:00:00 2001
2From: Jerome Duval <jerome.duval@gmail.com>
3Date: Tue, 13 May 2014 17:18:52 +0000
4Subject: define __USE_GNU for wempcpy
5
6
7diff --git a/lib/fnmatch.c b/lib/fnmatch.c
8index 0a7e887..83dcaad 100644
9--- a/lib/fnmatch.c
10+++ b/lib/fnmatch.c
11@@ -21,6 +21,9 @@
12 #ifndef _GNU_SOURCE
13 # define _GNU_SOURCE    1
14 #endif
15+#ifndef __USE_GNU
16+# define __USE_GNU		1
17+#endif
18 
19 #include <fnmatch.h>
20 
21-- 
222.14.2
23
24
25From 2524d0dde2a381c8f8c76620c3fe01befb8e83fd Mon Sep 17 00:00:00 2001
26From: Jerome Duval <jerome.duval@gmail.com>
27Date: Tue, 13 May 2014 17:22:10 +0000
28Subject: force declaration of rpl_inet_ntop
29
30
31diff --git a/lib/arpa_inet.in.h b/lib/arpa_inet.in.h
32index bfe2232..4c68c5e 100644
33--- a/lib/arpa_inet.in.h
34+++ b/lib/arpa_inet.in.h
35@@ -72,7 +72,7 @@
36 
37    For more details, see the POSIX:2001 specification
38    <http://www.opengroup.org/susv3xsh/inet_ntop.html>.  */
39-# if @REPLACE_INET_NTOP@
40+# if 1
41 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
42 #   undef inet_ntop
43 #   define inet_ntop rpl_inet_ntop
44-- 
452.14.2
46
47
48From c09450fe92943d42ee78ed86944d38ebcd18726a Mon Sep 17 00:00:00 2001
49From: Jerome Duval <jerome.duval@gmail.com>
50Date: Tue, 13 May 2014 17:32:36 +0000
51Subject: Haiku defines mknod in unistd.h
52
53
54diff --git a/lib/mknod.c b/lib/mknod.c
55index d12d4fe..eee3fd3 100644
56--- a/lib/mknod.c
57+++ b/lib/mknod.c
58@@ -18,6 +18,7 @@
59 
60 #include <config.h>
61 
62+#include <unistd.h>
63 #include <sys/stat.h>
64 
65 #include <errno.h>
66-- 
672.14.2
68
69
70From ecd1f97294f01f1d3ee3d71e40601acd624ecd8a Mon Sep 17 00:00:00 2001
71From: Jerome Duval <jerome.duval@gmail.com>
72Date: Tue, 13 May 2014 17:35:25 +0000
73Subject: protect the label, not used on Haiku
74
75
76diff --git a/lib/mountlist.c b/lib/mountlist.c
77index d880450..c8772dd 100644
78--- a/lib/mountlist.c
79+++ b/lib/mountlist.c
80@@ -1109,6 +1109,7 @@ read_file_system_list (bool need_fs_type)
81   return mount_list;
82 
83 
84+#ifndef __HAIKU__
85  free_then_fail: _GL_UNUSED_LABEL
86   {
87     int saved_errno = errno;
88@@ -1124,6 +1125,7 @@ read_file_system_list (bool need_fs_type)
89     errno = saved_errno;
90     return NULL;
91   }
92+#endif
93 }
94 
95 /* Free a mount entry as returned from read_file_system_list ().  */
96-- 
972.14.2
98
99
100From 7f075f99fa7a5d78148ab5d79965a969db423c45 Mon Sep 17 00:00:00 2001
101From: Jerome Duval <jerome.duval@gmail.com>
102Date: Thu, 15 May 2014 15:40:32 +0000
103Subject: strchrnul needs __USE_GNU on Haiku
104
105
106diff --git a/lib/regex.h b/lib/regex.h
107index b236a1b..0646c86 100644
108--- a/lib/regex.h
109+++ b/lib/regex.h
110@@ -31,8 +31,10 @@ extern "C" {
111 /* Define __USE_GNU to declare GNU extensions that violate the
112    POSIX name space rules.  */
113 #ifdef _GNU_SOURCE
114+#ifndef __USE_GNU
115 # define __USE_GNU 1
116 #endif
117+#endif
118 
119 #ifdef _REGEX_LARGE_OFFSETS
120 
121diff --git a/lib/string.in.h b/lib/string.in.h
122index 0e0e0c5..60edfa5 100644
123--- a/lib/string.in.h
124+++ b/lib/string.in.h
125@@ -37,6 +37,9 @@
126 #define _GL_ALREADY_INCLUDING_STRING_H
127 
128 /* The include_next requires a split double-inclusion guard.  */
129+#ifndef __USE_GNU
130+#define __USE_GNU
131+#endif
132 #@INCLUDE_NEXT@ @NEXT_STRING_H@
133 
134 #undef _GL_ALREADY_INCLUDING_STRING_H
135-- 
1362.14.2
137
138
139From c7af057601c8fa8f0dd152c10257b44ec132c1f9 Mon Sep 17 00:00:00 2001
140From: Jerome Duval <jerome.duval@gmail.com>
141Date: Thu, 15 May 2014 20:13:58 +0000
142Subject: don't build hostid, nice, users, who
143
144
145diff --git a/Makefile.in b/Makefile.in
146index 60bb1ed..6a2c2df 100644
147--- a/Makefile.in
148+++ b/Makefile.in
149@@ -1543,16 +1543,16 @@ nodist_src_libver_a_OBJECTS = src/version.$(OBJEXT)
150 src_libver_a_OBJECTS = $(nodist_src_libver_a_OBJECTS)
151 am__EXEEXT_1 = src/arch$(EXEEXT) src/coreutils$(EXEEXT) \
152 	src/hostname$(EXEEXT)
153-am__EXEEXT_2 = src/chroot$(EXEEXT) src/df$(EXEEXT) src/hostid$(EXEEXT) \
154-	src/libstdbuf.so$(EXEEXT) src/nice$(EXEEXT) src/pinky$(EXEEXT) \
155+am__EXEEXT_2 = src/chroot$(EXEEXT) src/df$(EXEEXT) \
156+	src/libstdbuf.so$(EXEEXT) \
157 	src/stdbuf$(EXEEXT) src/stty$(EXEEXT) src/timeout$(EXEEXT) \
158-	src/uptime$(EXEEXT) src/users$(EXEEXT) src/who$(EXEEXT)
159+	src/uptime$(EXEEXT) src/users$(EXEEXT) src/who$(EXEEXT)
160 am__EXEEXT_3 = src/[$(EXEEXT) src/b2sum$(EXEEXT) src/base64$(EXEEXT) \
161 	src/base32$(EXEEXT) src/basename$(EXEEXT) src/cat$(EXEEXT) \
162 	src/chcon$(EXEEXT) src/chgrp$(EXEEXT) src/chmod$(EXEEXT) \
163 	src/chown$(EXEEXT) src/cksum$(EXEEXT) src/comm$(EXEEXT) \
164 	src/cp$(EXEEXT) src/csplit$(EXEEXT) src/cut$(EXEEXT) \
165-	src/date$(EXEEXT) src/dd$(EXEEXT) src/dir$(EXEEXT) \
166+	src/date$(EXEEXT) src/dd$(EXEEXT) src/dir$(EXEEXT) \
167 	src/dircolors$(EXEEXT) src/dirname$(EXEEXT) src/du$(EXEEXT) \
168 	src/echo$(EXEEXT) src/env$(EXEEXT) src/expand$(EXEEXT) \
169 	src/expr$(EXEEXT) src/factor$(EXEEXT) src/false$(EXEEXT) \
170@@ -4477,7 +4477,7 @@ WARN_ON_USE_H = $(top_srcdir)/lib/warn-on-use.h
171 # FIXME: once lib/ and gnulib-tests/ are also converted, hoist to Makefile.am
172 AM_CFLAGS = $(WERROR_CFLAGS)
173 no_install__progs = src/arch src/coreutils src/hostname
174-build_if_possible__progs = src/chroot src/df src/hostid \
175+build_if_possible__progs = src/chroot src/df \
176 	src/libstdbuf.so src/nice src/pinky src/stdbuf src/stty \
177 	src/timeout src/uptime src/users src/who
178 default__progs = src/[ src/b2sum src/base64 src/base32 src/basename \
179-- 
1802.14.2
181
182
183From 4215e27a5cd2f0e04547345544301b7d85aba915 Mon Sep 17 00:00:00 2001
184From: Jerome Duval <jerome.duval@gmail.com>
185Date: Fri, 6 Feb 2015 20:24:12 +0000
186Subject: import Haiku changes, fix warnings.
187
188
189diff --git a/INSTALL b/INSTALL
190index 8865734..5bc8a54 100644
191--- a/INSTALL
192+++ b/INSTALL
193@@ -245,10 +245,10 @@ directory contains several dysfunctional programs; working variants of
194 these programs are available in '/usr/bin'.  So, if you need '/usr/ucb'
195 in your 'PATH', put it _after_ '/usr/bin'.
196 
197-   On Haiku, software installed for all users goes in '/boot/common',
198+   On Haiku, software installed for all users goes in '/boot/system',
199 not '/usr/local'.  It is recommended to use the following options:
200 
201-     ./configure --prefix=/boot/common
202+     ./configure --prefix=/boot/system
203 
204 Specifying the System Type
205 ==========================
206diff --git a/lib/localcharset.c b/lib/localcharset.c
207index f16a1a1..418e2af 100644
208--- a/lib/localcharset.c
209+++ b/lib/localcharset.c
210@@ -129,7 +129,7 @@ get_charset_aliases (void)
211   cp = charset_aliases;
212   if (cp == NULL)
213     {
214-#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__ || defined OS2)
215+#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__ || defined OS2 || defined __HAIKU__)
216       char *malloc_dir = NULL;
217       const char *dir;
218       const char *base = "charset.alias";
219@@ -376,6 +376,13 @@ get_charset_aliases (void)
220            "CP1386" "\0" "GBK" "\0"
221            "CP3372" "\0" "EUC-JP" "\0";
222 # endif
223+
224+# if defined __HAIKU__
225+	/* To avoid the troubles of installing a separate file in the same
226+	  directory as the DLL and of retrieving the DLL's directory at
227+	  runtime, simply inline the aliases here.  */
228+	cp = "UTF-8" "\0";
229+# endif
230 #endif
231 
232       charset_aliases = cp;
233diff --git a/src/copy.c b/src/copy.c
234index 165c5ce..cf4f51b 100644
235--- a/src/copy.c
236+++ b/src/copy.c
237@@ -18,6 +18,7 @@
238 
239 #include <config.h>
240 #include <stdio.h>
241+#include <unistd.h>
242 #include <assert.h>
243 #include <sys/ioctl.h>
244 #include <sys/types.h>
245@@ -65,6 +66,10 @@
246 #include "yesno.h"
247 #include "selinux.h"
248 
249+#if (defined(__BEOS__) || defined(__HAIKU__))
250+#	include <fs_attr.h>
251+#endif
252+
253 #if USE_XATTR
254 # include <attr/error_context.h>
255 # include <attr/libattr.h>
256@@ -591,6 +596,92 @@ is_ancestor (const struct stat *sb, const struct dir_list *ancestors)
257   return false;
258 }
259 
260+
261+static int
262+copy_attributes(int fromFd, int toFd)
263+{
264+	struct dirent *dirent;
265+	char buffer[65536];
266+
267+	DIR *attributes = fs_fopen_attr_dir(fromFd);
268+	if (attributes == NULL)
269+		return errno == B_UNSUPPORTED ? 0 : -1;
270+
271+	while ((dirent = fs_read_attr_dir(attributes)) != NULL) {
272+		struct stat stat;
273+		off_t pos = 0;
274+		int attrFromFD = fs_fopen_attr(fromFd, dirent->d_name, 0, O_RDONLY);
275+		int attrToFD;
276+
277+		if (attrFromFD < 0)
278+			continue;
279+
280+		if (fstat(attrFromFD, &stat) != 0) {
281+			close(attrFromFD);
282+			continue;
283+		}
284+
285+		attrToFD = fs_fopen_attr(toFd, dirent->d_name, stat.st_type,
286+			O_WRONLY | O_TRUNC | O_CREAT);
287+		if (attrToFD < 0) {
288+			close(attrFromFD);
289+			continue;
290+		}
291+
292+		while (true) {
293+			ssize_t bytesRead, bytesWritten;
294+
295+			bytesRead = read_pos(attrFromFD, pos, buffer, sizeof(buffer));
296+			if (bytesRead < 0) {
297+				fprintf(stderr, "error reading attribute '%s'", dirent->d_name);
298+				break;
299+			}
300+
301+			bytesWritten = write_pos(attrToFD, pos, buffer, bytesRead);
302+			if (bytesWritten != bytesRead) {
303+				fprintf(stderr, "error writing attribute '%s'", dirent->d_name);
304+				break;
305+			}
306+
307+			pos += bytesWritten;
308+			stat.st_size -= bytesWritten;
309+
310+			if (stat.st_size <= 0)
311+				break;
312+		}
313+		close(attrToFD);
314+		close(attrFromFD);
315+	}
316+
317+	fs_close_attr_dir(attributes);
318+	return 0;
319+}
320+
321+
322+static int
323+copy_attributes_by_name(const char *from, const char *to, int resolveLinks)
324+{
325+	int fromFd, toFd, result;
326+
327+	fromFd = open(from, O_RDONLY | (resolveLinks ? 0 : O_NOTRAVERSE));
328+	if (fromFd < 0)
329+		return -1;
330+
331+	toFd = open(to, O_RDONLY | (resolveLinks ? 0 : O_NOTRAVERSE));
332+	if (toFd < 0) {
333+		close(fromFd);
334+		return -1;
335+	}
336+
337+	result = copy_attributes(fromFd, toFd);
338+
339+	close(fromFd);
340+	close(toFd);
341+
342+	return result;
343+}
344+
345+
346 static bool
347 errno_unsupported (int err)
348 {
349@@ -724,6 +815,10 @@ copy_dir (char const *src_name_in, char const *dst_name_in, bool new_dst,
350       error (0, errno, _("cannot access %s"), quoteaf (src_name_in));
351       return false;
352     }
353+    
354+  if (x->ignore_attributes == 0
355+  	&& copy_attributes_by_name(src_name_in, dst_name_in, true) != 0)
356+    fprintf(stderr, "%s: could not copy attributes\n", src_name_in);
357 
358   /* For cp's -H option, dereference command line arguments, but do not
359      dereference symlinks that are found via recursive traversal.  */
360@@ -1392,6 +1487,11 @@ preserve_metadata:
361             return_val = false;
362         }
363     }
364+    
365+  if (x->ignore_attributes == 0
366+        && copy_attributes(source_desc, dest_desc) != 0)
367+    fprintf(stderr, "%s: could not copy attributes\n", src_name);
368+
369 
370 close_src_and_dst_desc:
371   if (close (dest_desc) < 0)
372@@ -2313,6 +2413,12 @@ copy_internal (char const *src_name, char const *dst_name,
373                                   dereference))
374             goto un_backup;
375 
376+          if (x->ignore_attributes == 0
377+              && copy_attributes_by_name (earlier_file, dst_name,
378+                  false) != 0)
379+            error (0, errno, "cannot copy attributes from %s\n",
380+                earlier_file);
381+
382           return true;
383         }
384     }
385@@ -2729,6 +2835,11 @@ copy_internal (char const *src_name, char const *dst_name,
386                  preserving owner/group is a potential security problem.  */
387             }
388         }
389+
390+      if (x->ignore_attributes == 0
391+            && copy_attributes_by_name(src_name, dst_name, false) != 0)
392+        fprintf(stderr, "%s: could not copy attributes\n", src_name);
393+
394     }
395   else
396     {
397diff --git a/src/copy.h b/src/copy.h
398index eef5663..89b4322 100644
399--- a/src/copy.h
400+++ b/src/copy.h
401@@ -187,6 +187,9 @@ struct cp_options
402      must be false.  */
403   bool require_preserve;
404 
405+  /* If nonzero, attributes will be ignored when copying.  */
406+  int ignore_attributes;
407+
408   /* If true, attempt to preserve the SELinux security context, too.
409      Set this only if the kernel is SELinux enabled.  */
410   bool preserve_security_context;
411diff --git a/src/cp.c b/src/cp.c
412index 6743f10..d2f4d6c 100644
413--- a/src/cp.c
414+++ b/src/cp.c
415@@ -74,6 +74,7 @@ struct dir_attr
416 enum
417 {
418   ATTRIBUTES_ONLY_OPTION = CHAR_MAX + 1,
419+  IGNORE_ATTRIBUTES,
420   COPY_CONTENTS_OPTION,
421   NO_PRESERVE_ATTRIBUTES_OPTION,
422   PARENTS_OPTION,
423@@ -122,6 +123,7 @@ static struct option const long_opts[] =
424   {"copy-contents", no_argument, NULL, COPY_CONTENTS_OPTION},
425   {"dereference", no_argument, NULL, 'L'},
426   {"force", no_argument, NULL, 'f'},
427+  {"ignore-attributes", no_argument, NULL, IGNORE_ATTRIBUTES},
428   {"interactive", no_argument, NULL, 'i'},
429   {"link", no_argument, NULL, 'l'},
430   {"no-clobber", no_argument, NULL, 'n'},
431@@ -180,6 +182,7 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
432   -f, --force                  if an existing destination file cannot be\n\
433                                  opened, remove it and try again (this option\n\
434                                  is ignored when the -n option is also used)\n\
435+      --ignore-attributes      do not copy attributes\n\
436   -i, --interactive            prompt before overwrite (overrides a previous -n\
437 \n\
438                                   option)\n\
439@@ -809,6 +812,7 @@ cp_option_init (struct cp_options *x)
440   x->data_copy_required = true;
441   x->require_preserve = false;
442   x->recursive = false;
443+  x->ignore_attributes = false;
444   x->sparse_mode = SPARSE_AUTO;
445   x->symbolic_link = false;
446   x->set_mode = false;
447@@ -1010,6 +1014,10 @@ main (int argc, char **argv)
448           x.dereference = DEREF_COMMAND_LINE_ARGUMENTS;
449           break;
450 
451+        case IGNORE_ATTRIBUTES:
452+          x.ignore_attributes = true;
453+          break;
454+
455         case 'i':
456           x.interactive = I_ASK_USER;
457           break;
458diff --git a/src/dircolors.h b/src/dircolors.h
459index 259336d..2529504 100644
460--- a/src/dircolors.h
461+++ b/src/dircolors.h
462@@ -59,7 +59,7 @@ static char const G_line[] =
463   'S','E','T','G','I','D',' ','3','0',';','4','3',' ','#',' ','f','i','l','e',' ','t','h','a','t',' ','i','s',' ','s','e','t','g','i','d',' ','(','g','+','s',')',0,
464   'C','A','P','A','B','I','L','I','T','Y',' ','3','0',';','4','1',' ','#',' ','f','i','l','e',' ','w','i','t','h',' ','c','a','p','a','b','i','l','i','t','y',0,
465   'S','T','I','C','K','Y','_','O','T','H','E','R','_','W','R','I','T','A','B','L','E',' ','3','0',';','4','2',' ','#',' ','d','i','r',' ','t','h','a','t',' ','i','s',' ','s','t','i','c','k','y',' ','a','n','d',' ','o','t','h','e','r','-','w','r','i','t','a','b','l','e',' ','(','+','t',',','o','+','w',')',0,
466-  'O','T','H','E','R','_','W','R','I','T','A','B','L','E',' ','3','4',';','4','2',' ','#',' ','d','i','r',' ','t','h','a','t',' ','i','s',' ','o','t','h','e','r','-','w','r','i','t','a','b','l','e',' ','(','o','+','w',')',' ','a','n','d',' ','n','o','t',' ','s','t','i','c','k','y',0,
467+  'O','T','H','E','R','_','W','R','I','T','A','B','L','E',' ','3','4',';','4','3',' ','#',' ','d','i','r',' ','t','h','a','t',' ','i','s',' ','o','t','h','e','r','-','w','r','i','t','a','b','l','e',' ','(','o','+','w',')',' ','a','n','d',' ','n','o','t',' ','s','t','i','c','k','y',0,
468   'S','T','I','C','K','Y',' ','3','7',';','4','4',' ','#',' ','d','i','r',' ','w','i','t','h',' ','t','h','e',' ','s','t','i','c','k','y',' ','b','i','t',' ','s','e','t',' ','(','+','t',')',' ','a','n','d',' ','n','o','t',' ','o','t','h','e','r','-','w','r','i','t','a','b','l','e',0,
469   '#',' ','T','h','i','s',' ','i','s',' ','f','o','r',' ','f','i','l','e','s',' ','w','i','t','h',' ','e','x','e','c','u','t','e',' ','p','e','r','m','i','s','s','i','o','n',':',0,
470   'E','X','E','C',' ','0','1',';','3','2',0,
471diff --git a/src/dircolors.hin b/src/dircolors.hin
472index fca51f2..83706ba 100644
473--- a/src/dircolors.hin
474+++ b/src/dircolors.hin
475@@ -61,7 +61,7 @@ SETUID 37;41	# file that is setuid (u+s)
476 SETGID 30;43	# file that is setgid (g+s)
477 CAPABILITY 30;41	# file with capability
478 STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
479-OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
480+OTHER_WRITABLE 34;43 # dir that is other-writable (o+w) and not sticky
481 STICKY 37;44	# dir with the sticky bit set (+t) and not other-writable
482 
483 # This is for files with execute permission:
484diff --git a/src/ls.c b/src/ls.c
485index 4becd06..7641096 100644
486--- a/src/ls.c
487+++ b/src/ls.c
488@@ -708,6 +708,11 @@ static struct ignore_pattern *hide_patterns;
489    want to mess up the terminal if control chars get sent to it, and some
490    quoting methods pass through control chars as-is.  */
491 static bool qmark_funny_chars;
492+#if defined(__HAIKU__)  /* Default to show UTF8 chars in Haiku terminal. */
493+#define QMARK_FUNNY_CHARS_TTY 0
494+#else
495+#define QMARK_FUNNY_CHARS_TTY 1
496+#endif
497 
498 /* Quoting options for file and dir name output.  */
499 
500@@ -1684,7 +1689,7 @@ decode_switches (int argc, char **argv)
501   bool sort_type_specified = false;
502   bool kibibytes_specified = false;
503 
504-  qmark_funny_chars = false;
505+  qmark_funny_chars = QMARK_FUNNY_CHARS_TTY;
506 
507   /* initialize all switches to default settings */
508 
509@@ -1709,7 +1714,9 @@ decode_switches (int argc, char **argv)
510           format = many_per_line;
511           set_quoting_style (NULL, shell_escape_quoting_style);
512           /* See description of qmark_funny_chars, above.  */
513+#ifndef __HAIKU__
514           qmark_funny_chars = true;
515+#endif
516         }
517       else
518         {
519@@ -4122,6 +4129,7 @@ print_long_format (const struct fileinfo *f)
520       p = buf;
521     }
522 
523+#if !defined(__HAIKU__)
524   if (f->stat_ok
525       && (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode)))
526     {
527@@ -4138,6 +4146,7 @@ print_long_format (const struct fileinfo *f)
528       p += file_size_width + 1;
529     }
530   else
531+#endif
532     {
533       char hbuf[LONGEST_HUMAN_READABLE + 1];
534       char const *size =
535diff --git a/src/mv.c b/src/mv.c
536index 9e80193..675c803 100644
537--- a/src/mv.c
538+++ b/src/mv.c
539@@ -126,6 +126,7 @@ cp_option_init (struct cp_options *x)
540   x->reduce_diagnostics = false;
541   x->data_copy_required = true;
542   x->require_preserve = false;  /* FIXME: maybe make this an option */
543+  x->ignore_attributes = false;
544   x->require_preserve_context = false;
545   x->preserve_xattr = true;
546   x->require_preserve_xattr = false;
547diff --git a/src/remove.c b/src/remove.c
548index b2740c7..e4df0a6 100644
549--- a/src/remove.c
550+++ b/src/remove.c
551@@ -214,7 +214,7 @@ prompt (FTS const *fts, FTSENT const *ent, bool is_dir,
552       wp_errno = errno;
553     }
554 
555-  if (write_protected || x->interactive == RMI_ALWAYS)
556+  if (write_protected || errno || x->interactive == RMI_ALWAYS)
557     {
558       if (0 <= write_protected && dirent_type == DT_UNKNOWN)
559         {
560diff --git a/src/uname.c b/src/uname.c
561index 6635a6a..4187ffb 100644
562--- a/src/uname.c
563+++ b/src/uname.c
564@@ -49,6 +49,10 @@
565 # include <mach-o/arch.h>
566 #endif
567 
568+#ifdef __HAIKU__
569+# include <OS.h>
570+#endif
571+
572 #include "system.h"
573 #include "die.h"
574 #include "error.h"
575@@ -338,6 +342,30 @@ main (int argc, char **argv)
576 # endif
577         }
578 #endif
579+
580+#ifdef __HAIKU__
581+	  {
582+		cpu_topology_node_info root;
583+		uint32 count = 1;
584+		status_t error = get_cpu_topology_info(&root, &count);
585+		if (error != B_OK || count < 1)
586+			element = "unknown";
587+		else {
588+			switch (root.data.root.platform) {
589+				case B_CPU_x86:
590+					element = "x86";
591+					break;
592+				case B_CPU_x86_64:
593+					element = "x86_64";
594+					break;
595+				default:
596+					element = "other";
597+					break;
598+			}
599+		}
600+	  }
601+#endif
602+
603       if (! (toprint == UINT_MAX && element == unknown))
604         print_element (element);
605     }
606-- 
6072.14.2
608
609