diff --git a/sys-apps/coreutils/coreutils-6.12-haiku.diff b/sys-apps/coreutils/coreutils-6.12-haiku.diff index d73113782..27fc67b24 100644 --- a/sys-apps/coreutils/coreutils-6.12-haiku.diff +++ b/sys-apps/coreutils/coreutils-6.12-haiku.diff @@ -1,78 +1,325 @@ -diff -urN coreutils-6.12/lib/fpurge.c coreutils-6.12-haiku/lib/fpurge.c ---- coreutils-6.12/lib/fpurge.c 2008-05-14 12:53:25.000000000 +0000 -+++ coreutils-6.12-haiku/lib/fpurge.c 2008-10-02 12:28:05.000000000 +0000 -@@ -61,7 +61,7 @@ - /* Most systems provide FILE as a struct and the necessary bitmask in - , because they need it for implementing getc() and putc() as - fast macros. */ --# if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */ -+# if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 || defined __HAIKU__ /* GNU libc, BeOS, Linux libc5 */ - fp->_IO_read_end = fp->_IO_read_ptr; - fp->_IO_write_ptr = fp->_IO_write_base; - /* Avoid memory leak when there is an active ungetc buffer. */ -diff -urN coreutils-6.12/lib/freadahead.c coreutils-6.12-haiku/lib/freadahead.c ---- coreutils-6.12/lib/freadahead.c 2008-05-14 12:53:25.000000000 +0000 -+++ coreutils-6.12-haiku/lib/freadahead.c 2008-10-02 12:29:10.000000000 +0000 +diff -urN coreutils-6.12.orig/configure coreutils-6.12/configure +--- coreutils-6.12.orig/configure 2008-11-30 21:41:13.000000000 +0000 ++++ coreutils-6.12/configure 2008-11-30 22:05:25.000000000 +0000 +@@ -25272,7 +25272,7 @@ + cat >>conftest.$ac_ext <<_ACEOF + /* end confdefs.h. */ + #include +-#if defined __GLIBC__ && !defined __BEOS__ ++#if defined __GLIBC__ && !(defined(__BEOS__) || defined(__HAIKU__)) + Do not use statvfs on systems with GNU libc, because that function stats + all preceding entries in /proc/mounts, and that makes df hang if even + one of the corresponding file systems is hard-mounted, but not available. +diff -urN coreutils-6.12.orig/lib/fcntl.in.h coreutils-6.12/lib/fcntl.in.h +--- coreutils-6.12.orig/lib/fcntl.in.h 2008-11-30 21:40:44.000000000 +0000 ++++ coreutils-6.12/lib/fcntl.in.h 2008-11-30 22:05:25.000000000 +0000 +@@ -104,7 +104,7 @@ + # define O_TEXT _O_TEXT + #endif + +-#ifdef __BEOS__ ++#if (defined(__BEOS__) || defined(__HAIKU__)) + /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */ + # undef O_BINARY + # undef O_TEXT +diff -urN coreutils-6.12.orig/lib/freadahead.c coreutils-6.12/lib/freadahead.c +--- coreutils-6.12.orig/lib/freadahead.c 2008-11-30 21:40:47.000000000 +0000 ++++ coreutils-6.12/lib/freadahead.c 2008-11-30 20:57:54.000000000 +0000 @@ -24,7 +24,7 @@ size_t freadahead (FILE *fp) { -#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */ -+#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 || defined __HAIKU__ /* GNU libc, BeOS, Linux libc5 */ ++#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */ if (fp->_IO_write_ptr > fp->_IO_write_base) return 0; return (fp->_IO_read_end - fp->_IO_read_ptr) -diff -urN coreutils-6.12/lib/freading.c coreutils-6.12-haiku/lib/freading.c ---- coreutils-6.12/lib/freading.c 2008-05-14 12:53:25.000000000 +0000 -+++ coreutils-6.12-haiku/lib/freading.c 2008-10-02 12:30:41.000000000 +0000 -@@ -31,7 +31,7 @@ - /* Most systems provide FILE as a struct and the necessary bitmask in - , because they need it for implementing getc() and putc() as - fast macros. */ --#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */ -+#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 || defined __HAIKU__ /* GNU libc, BeOS, Linux libc5 */ - return ((fp->_flags & _IO_NO_WRITES) != 0 - || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0 - && fp->_IO_read_base != NULL)); -diff -urN coreutils-6.12/lib/freadptr.c coreutils-6.12-haiku/lib/freadptr.c ---- coreutils-6.12/lib/freadptr.c 2008-05-14 12:53:25.000000000 +0000 -+++ coreutils-6.12-haiku/lib/freadptr.c 2008-10-02 12:32:42.000000000 +0000 +diff -urN coreutils-6.12.orig/lib/freadptr.c coreutils-6.12/lib/freadptr.c +--- coreutils-6.12.orig/lib/freadptr.c 2008-11-30 21:40:44.000000000 +0000 ++++ coreutils-6.12/lib/freadptr.c 2008-11-30 21:13:58.000000000 +0000 @@ -29,7 +29,7 @@ size_t size; /* Keep this code in sync with freadahead! */ -#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */ -+#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 || defined __HAIKU__ /* GNU libc, BeOS, Linux libc5 */ ++#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */ if (fp->_IO_write_ptr > fp->_IO_write_base) return NULL; size = fp->_IO_read_end - fp->_IO_read_ptr; -diff -urN coreutils-6.12/lib/freadseek.c coreutils-6.12-haiku/lib/freadseek.c ---- coreutils-6.12/lib/freadseek.c 2008-05-14 12:53:25.000000000 +0000 -+++ coreutils-6.12-haiku/lib/freadseek.c 2008-10-02 12:35:31.000000000 +0000 +diff -urN coreutils-6.12.orig/lib/freadseek.c coreutils-6.12/lib/freadseek.c +--- coreutils-6.12.orig/lib/freadseek.c 2008-11-30 21:40:46.000000000 +0000 ++++ coreutils-6.12/lib/freadseek.c 2008-11-30 21:15:22.000000000 +0000 @@ -34,7 +34,7 @@ freadptrinc (FILE *fp, size_t increment) { /* Keep this code in sync with freadptr! */ -#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */ -+#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 || defined __HAIKU__ /* GNU libc, BeOS, Linux libc5 */ ++#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */ fp->_IO_read_ptr += increment; #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ fp_->_p += increment; -diff -urN coreutils-6.12/lib/fseterr.c coreutils-6.12-haiku/lib/fseterr.c ---- coreutils-6.12/lib/fseterr.c 2008-05-14 12:53:25.000000000 +0000 -+++ coreutils-6.12-haiku/lib/fseterr.c 2008-10-02 12:36:27.000000000 +0000 +diff -urN coreutils-6.12.orig/lib/fseterr.c coreutils-6.12/lib/fseterr.c +--- coreutils-6.12.orig/lib/fseterr.c 2008-11-30 21:40:48.000000000 +0000 ++++ coreutils-6.12/lib/fseterr.c 2008-11-30 21:16:48.000000000 +0000 @@ -29,7 +29,7 @@ /* Most systems provide FILE as a struct and the necessary bitmask in , because they need it for implementing getc() and putc() as fast macros. */ -#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */ -+#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 || defined __HAIKU__ /* GNU libc, BeOS, Linux libc5 */ ++#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */ fp->_flags |= _IO_ERR_SEEN; #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ fp_->_flags |= __SERR; -diff -urN coreutils-6.12/src/remove.c coreutils-6.12-haiku/src/remove.c ---- coreutils-6.12/src/remove.c 2008-05-06 09:28:24.000000000 +0000 -+++ coreutils-6.12-haiku/src/remove.c 2008-10-02 16:24:12.000000000 +0000 +diff -urN coreutils-6.12.orig/lib/physmem.c coreutils-6.12/lib/physmem.c +--- coreutils-6.12.orig/lib/physmem.c 2008-11-30 21:40:44.000000000 +0000 ++++ coreutils-6.12/lib/physmem.c 2008-11-30 22:05:25.000000000 +0000 +@@ -17,6 +17,7 @@ + along with this program. If not, see . */ + + /* Written by Paul Eggert. */ ++#undef DEBUG + + #include + +diff -urN coreutils-6.12.orig/src/copy.c coreutils-6.12/src/copy.c +--- coreutils-6.12.orig/src/copy.c 2008-11-30 21:40:58.000000000 +0000 ++++ coreutils-6.12/src/copy.c 2008-11-30 22:05:25.000000000 +0000 +@@ -55,6 +55,10 @@ + #include "areadlink.h" + #include "yesno.h" + ++#if (defined(__BEOS__) || defined(__HAIKU__)) ++# include ++#endif ++ + #ifndef HAVE_FCHOWN + # define HAVE_FCHOWN false + # define fchown(fd, uid, gid) (-1) +@@ -127,6 +131,68 @@ + return false; + } + ++ ++static int ++copy_attributes(int fromFd, int toFd) ++{ ++ struct dirent *dirent; ++ char buffer[65536]; ++ ++ DIR *attributes = fs_fopen_attr_dir(fromFd); ++ if (attributes == NULL) ++ return -1; ++ ++ while ((dirent = fs_read_attr_dir(attributes)) != NULL) { ++ attr_info info; ++ off_t pos = 0; ++ ++ if (fs_stat_attr(fromFd, dirent->d_name, &info) != 0) ++ continue; ++ ++ while (info.size > 0) { ++ ssize_t bytesRead, bytesWritten; ++ ++ bytesRead = fs_read_attr(fromFd, dirent->d_name, info.type, pos, buffer, sizeof(buffer)); ++ if (bytesRead <= 0) ++ break; ++ ++ bytesWritten = fs_write_attr(toFd, dirent->d_name, info.type, pos, buffer, bytesRead); ++ if (bytesWritten != bytesRead) ++ break; ++ ++ pos += bytesWritten; ++ info.size -= bytesWritten; ++ } ++ } ++ ++ fs_close_attr_dir(attributes); ++} ++ ++ ++static int ++copy_attributes_by_name(const char *from, const char *to, int resolveLinks) ++{ ++ int fromFd, toFd, result; ++ ++ fromFd = open(from, O_RDONLY | (resolveLinks ? 0 : O_NOTRAVERSE)); ++ if (fromFd < 0) ++ return -1; ++ ++ toFd = open(to, O_RDONLY | (resolveLinks ? 0 : O_NOTRAVERSE)); ++ if (toFd < 0) { ++ close(fromFd); ++ return -1; ++ } ++ ++ result = copy_attributes(fromFd, toFd); ++ ++ close(fromFd); ++ close(toFd); ++ ++ return result; ++} ++ ++ + /* Read the contents of the directory SRC_NAME_IN, and recursively + copy the contents to DST_NAME_IN. NEW_DST is true if + DST_NAME_IN is a directory that was created previously in the +@@ -154,6 +220,10 @@ + return false; + } + ++ if (x->ignore_attributes == 0 ++ && copy_attributes_by_name(src_name_in, dst_name_in, true) != 0) ++ fprintf(stderr, "%s: could not copy attributes\n", src_name_in); ++ + /* For cp's -H option, dereference command line arguments, but do not + dereference symlinks that are found via recursive traversal. */ + if (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS) +@@ -709,6 +779,11 @@ + } + } + ++ if (x->ignore_attributes == 0 ++ && copy_attributes(source_desc, dest_desc) != 0) ++ fprintf(stderr, "%s: could not copy attributes\n", src_name); ++ ++ + close_src_and_dst_desc: + if (close (dest_desc) < 0) + { +@@ -1516,6 +1591,19 @@ + goto un_backup; + } + ++ if (link_failed) ++ { ++ error (0, errno, _("cannot create hard link %s to %s"), ++ quote_n (0, dst_name), quote_n (1, earlier_file)); ++ goto un_backup; ++ } ++ else ++ { ++ if (x->ignore_attributes == 0 ++ && copy_attributes_by_name(earlier_file, dst_name, false) != 0) ++ fprintf(stderr, "%s: could not copy attributes\n", earlier_file); ++ } ++ + return true; + } + } +diff -urN coreutils-6.12.orig/src/copy.h coreutils-6.12/src/copy.h +--- coreutils-6.12.orig/src/copy.h 2008-11-30 21:40:53.000000000 +0000 ++++ coreutils-6.12/src/copy.h 2008-11-30 22:05:25.000000000 +0000 +@@ -174,6 +174,9 @@ + fail if it is unable to do so. */ + bool require_preserve_context; + ++ /* If nonzero, attributes will be ignored when copying. */ ++ int ignore_attributes; ++ + /* If true, copy directories recursively and copy special files + as themselves rather than copying their contents. */ + bool recursive; +diff -urN coreutils-6.12.orig/src/cp.c coreutils-6.12/src/cp.c +--- coreutils-6.12.orig/src/cp.c 2008-11-30 21:40:59.000000000 +0000 ++++ coreutils-6.12/src/cp.c 2008-11-30 22:05:25.000000000 +0000 +@@ -73,6 +73,7 @@ + enum + { + COPY_CONTENTS_OPTION = CHAR_MAX + 1, ++ IGNORE_ATTRIBUTES, + NO_PRESERVE_ATTRIBUTES_OPTION, + PARENTS_OPTION, + PRESERVE_ATTRIBUTES_OPTION, +@@ -130,6 +131,7 @@ + {"copy-contents", no_argument, NULL, COPY_CONTENTS_OPTION}, + {"dereference", no_argument, NULL, 'L'}, + {"force", no_argument, NULL, 'f'}, ++ {"ignore-attributes", no_argument, NULL, IGNORE_ATTRIBUTES}, + {"interactive", no_argument, NULL, 'i'}, + {"link", no_argument, NULL, 'l'}, + {"no-dereference", no_argument, NULL, 'P'}, +@@ -186,6 +188,7 @@ + fputs (_("\ + -f, --force if an existing destination file cannot be\n\ + opened, remove it and try again\n\ ++ --ignore-attributes do not copy attributes\n\ + -i, --interactive prompt before overwrite\n\ + -H follow command-line symbolic links in SOURCE\n\ + "), stdout); +@@ -779,6 +782,7 @@ + x->require_preserve_context = false; + + x->require_preserve = false; ++ x->ignore_attributes = false; + x->recursive = false; + x->sparse_mode = SPARSE_AUTO; + x->symbolic_link = false; +@@ -956,6 +960,10 @@ + x.dereference = DEREF_COMMAND_LINE_ARGUMENTS; + break; + ++ case IGNORE_ATTRIBUTES: ++ x.ignore_attributes = true; ++ break; ++ + case 'i': + x.interactive = I_ASK_USER; + break; +diff -urN coreutils-6.12.orig/src/ls.c coreutils-6.12/src/ls.c +--- coreutils-6.12.orig/src/ls.c 2008-11-30 21:40:54.000000000 +0000 ++++ coreutils-6.12/src/ls.c 2008-11-30 22:05:25.000000000 +0000 +@@ -635,6 +635,11 @@ + want to mess up the terminal if control chars get sent to it, and some + quoting methods pass through control chars as-is. */ + static bool qmark_funny_chars; ++#if (defined(__BEOS__) || defined(__HAIKU__)) /* Default to show UTF8 chars in BeOS terminal. */ ++#define QMARK_FUNNY_CHARS_TTY 0 ++#else ++#define QMARK_FUNNY_CHARS_TTY 1 ++#endif + + /* Quoting options for file and dir name output. */ + +@@ -1391,7 +1396,7 @@ + /* Record whether there is an option specifying sort type. */ + bool sort_type_specified = false; + +- qmark_funny_chars = false; ++ qmark_funny_chars = QMARK_FUNNY_CHARS_TTY; + + /* initialize all switches to default settings */ + +@@ -3513,6 +3518,7 @@ + p = buf; + } + ++#ifndef __BEOS__ + if (f->stat_ok + && (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode))) + { +@@ -3529,6 +3535,7 @@ + p += file_size_width + 1; + } + else ++#endif + { + char hbuf[LONGEST_HUMAN_READABLE + 1]; + char const *size = +diff -urN coreutils-6.12.orig/src/mv.c coreutils-6.12/src/mv.c +--- coreutils-6.12.orig/src/mv.c 2008-11-30 21:40:59.000000000 +0000 ++++ coreutils-6.12/src/mv.c 2008-11-30 22:05:25.000000000 +0000 +@@ -142,6 +142,7 @@ + x->preserve_security_context = selinux_enabled; + x->require_preserve = false; /* FIXME: maybe make this an option */ + x->require_preserve_context = false; ++ x->ignore_attributes = false; + x->recursive = true; + x->sparse_mode = SPARSE_AUTO; /* FIXME: maybe make this an option */ + x->symbolic_link = false; +diff -urN coreutils-6.12.orig/src/remove.c coreutils-6.12/src/remove.c +--- coreutils-6.12.orig/src/remove.c 2008-11-30 21:40:59.000000000 +0000 ++++ coreutils-6.12/src/remove.c 2008-11-30 18:25:45.000000000 +0000 @@ -264,9 +264,10 @@ { size_t n_lengths = obstack_object_size (&ds->len_stack) / sizeof (size_t); @@ -98,24 +345,7 @@ diff -urN coreutils-6.12/src/remove.c coreutils-6.12-haiku/src/remove.c if (top->unremovable) hash_free (top->unremovable); obstack_blank (&ds->Active_dir, -(int) sizeof (struct AD_ent)); -@@ -836,14 +838,13 @@ - { - int write_protected = 0; - int dirent_type = *pdirent_type; -- -+ int wp_errno = 0; -+ - *is_empty = T_UNKNOWN; - - if (x->interactive == RMI_NEVER) - return RM_OK; - -- int wp_errno = 0; -- - if (!x->ignore_missing_files - && ((x->interactive == RMI_ALWAYS) || x->stdin_tty) - && dirent_type != DT_LNK) -@@ -891,6 +892,7 @@ +@@ -891,6 +893,7 @@ break; } @@ -123,7 +353,7 @@ diff -urN coreutils-6.12/src/remove.c coreutils-6.12-haiku/src/remove.c char const *quoted_name = quote (full_filename (filename)); if (write_protected < 0) -@@ -930,6 +932,7 @@ +@@ -930,6 +933,7 @@ : _("%s: remove %s %s? ")), program_name, file_type (sbuf), quoted_name); } @@ -131,7 +361,7 @@ diff -urN coreutils-6.12/src/remove.c coreutils-6.12-haiku/src/remove.c if (!yesno ()) return RM_USER_DECLINED; -@@ -1549,6 +1552,7 @@ +@@ -1549,6 +1553,7 @@ return RM_ERROR; } @@ -139,7 +369,7 @@ diff -urN coreutils-6.12/src/remove.c coreutils-6.12-haiku/src/remove.c struct stat st; cache_stat_init (&st); cycle_check_init (&ds->cycle_check_state); -@@ -1571,6 +1575,7 @@ +@@ -1571,6 +1576,7 @@ AD_push_initial (ds); AD_INIT_OTHER_MEMBERS (); @@ -147,7 +377,7 @@ diff -urN coreutils-6.12/src/remove.c coreutils-6.12-haiku/src/remove.c enum RM_status status = remove_entry (AT_FDCWD, ds, filename, DT_UNKNOWN, &st, x); if (status == RM_NONEMPTY_DIR) -@@ -1589,6 +1594,8 @@ +@@ -1589,6 +1595,8 @@ ds_clear (ds); return status; } @@ -156,9 +386,9 @@ diff -urN coreutils-6.12/src/remove.c coreutils-6.12-haiku/src/remove.c /* Remove all files and/or directories specified by N_FILES and FILE. Apply the options in X. */ -diff -urN coreutils-6.12/src/rm.c coreutils-6.12-haiku/src/rm.c ---- coreutils-6.12/src/rm.c 2008-05-26 06:40:33.000000000 +0000 -+++ coreutils-6.12-haiku/src/rm.c 2008-10-02 14:13:30.000000000 +0000 +diff -urN coreutils-6.12.orig/src/rm.c coreutils-6.12/src/rm.c +--- coreutils-6.12.orig/src/rm.c 2008-11-30 21:40:58.000000000 +0000 ++++ coreutils-6.12/src/rm.c 2008-11-30 18:25:45.000000000 +0000 @@ -357,6 +357,7 @@ quote ("/")); } @@ -178,9 +408,9 @@ diff -urN coreutils-6.12/src/rm.c coreutils-6.12-haiku/src/rm.c + } + } } -diff -urN coreutils-6.12/src/seq.c coreutils-6.12-haiku/src/seq.c ---- coreutils-6.12/src/seq.c 2008-05-26 06:40:32.000000000 +0000 -+++ coreutils-6.12-haiku/src/seq.c 2008-10-02 16:34:10.000000000 +0000 +diff -urN coreutils-6.12.orig/src/seq.c coreutils-6.12/src/seq.c +--- coreutils-6.12.orig/src/seq.c 2008-11-30 21:40:52.000000000 +0000 ++++ coreutils-6.12/src/seq.c 2008-11-30 18:25:45.000000000 +0000 @@ -166,6 +166,7 @@ : (decimal_point == arg /* .# -> 0.# */ || ! ISDIGIT (decimal_point[-1]))); /* -.# -> 0.# */ @@ -213,26 +443,9 @@ diff -urN coreutils-6.12/src/seq.c coreutils-6.12-haiku/src/seq.c } else { -@@ -375,6 +379,7 @@ - operand step = { 1, 1, 0 }; - operand last; - struct layout layout = { 0, 0 }; -+ char const *f; - - /* The printf(3) format used for output. */ - char const *format_str = NULL; -@@ -444,7 +449,7 @@ - if (format_str) - { - validate_format (format_str); -- char const *f = long_double_format (format_str, &layout); -+ *f = long_double_format (format_str, &layout); - if (! f) - { - error (0, 0, _("invalid format string: %s"), quote (format_str)); -diff -urN coreutils-6.12/src/shred.c coreutils-6.12-haiku/src/shred.c ---- coreutils-6.12/src/shred.c 2008-05-26 06:40:33.000000000 +0000 -+++ coreutils-6.12-haiku/src/shred.c 2008-10-02 14:13:31.000000000 +0000 +diff -urN coreutils-6.12.orig/src/shred.c coreutils-6.12/src/shred.c +--- coreutils-6.12.orig/src/shred.c 2008-11-30 21:40:53.000000000 +0000 ++++ coreutils-6.12/src/shred.c 2008-11-30 18:25:45.000000000 +0000 @@ -461,7 +461,7 @@ out. Thus, it shouldn't give up on bad blocks. This code works because lim is always a multiple of