Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 212296 - sys-fs/dd-rescue-1.14 has trouble with IRIX for O_DIRECT path
Summary: sys-fs/dd-rescue-1.14 has trouble with IRIX for O_DIRECT path
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: MIPS IRIX
: High normal (vote)
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-04 17:09 UTC by Stuart Shelton
Modified: 2011-12-15 18:03 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stuart Shelton 2008-03-04 17:09:07 UTC
The dd-rescue build fails immediately, since 'gcc' doesn't exist on the target system.

The best fix seems to be:

--- Makefile
+++ Makefile
@@ -6,9 +6,6 @@
 
 DESTDIR = 
 
-CC = gcc
-RPM_OPT_FLAGS = -O2 -Wall -g
-CFLAGS = $(RPM_OPT_FLAGS) $(EXTRA_CFLAGS)
 DEFINES = -DVERSION=\"$(VERSION)\"
 INSTALL = install
 INSTALLFLAGS = -s

... and additionally, IRIX doesn't seem to like the O_DIRECT code-path and posix_memalign() isn't very portable, so this helps:

--- dd_rescue.c
+++ dd_rescue.c
@@ -55,6 +55,10 @@
 #include <sys/time.h>
 #include <sys/stat.h>
 
+#ifdef __sgi
+#undef O_DIRECT
+#endif
+
 int softbs, hardbs, syncfreq;
 int maxerr, nrerr, reverse, dotrunc, abwrerr, sparse, nosparse;
 int verbose, quiet, interact, force;
@@ -742,7 +746,12 @@ int main(int argc, char* argv[])
                ipos = 0;
 
 #ifdef O_DIRECT
-       if (posix_memalign(mp, sysconf(_SC_PAGESIZE), softbs)) {
+#ifdef linux
+#define my_valloc(a, b, c)     posix_memalign((a), (b), (c))
+#else
+#define my_valloc(a, b, c)     (*(a) = valloc((c)))
+#endif
+       if (my_valloc(mp, sysconf(_SC_PAGESIZE), softbs)) {
                fplog(stderr, "dd_rescue: (fatal): allocation of aligned buffer failed!\n");
                cleanup(); exit(18);
        }

... finally, for IRIX-specific problems, MIPSpro doesn't like certain pointer-addition, failing with "The expression must be a pointer to a complete object type.":

--- dd_rescue.c
+++ dd_rescue.c
@@ -328,10 +328,11 @@
 
 ssize_t readblock(const int toread)
 {
-       ssize_t err, rd = 0;
+       ssize_t err, tmp, rd = 0;
        //errno = 0; /* should not be necessary */
        do {
-               rd += (err = mypread(ides, buf+rd, toread-rd, ipos+rd-reverse*toread));
+    tmp = (ssize_t)buf+rd;
+               rd += (err = mypread(ides, (void *)tmp, toread-rd, ipos+rd-reverse*toread));
                if (err == -1) 
                        rd++;
        } while ((err == -1 && (errno == EINTR || errno == EAGAIN))
@@ -342,10 +343,11 @@
 
 ssize_t writeblock(const int towrite)
 {
-       ssize_t err, wr = 0;
+       ssize_t err, tmp, wr = 0;
        //errno = 0; /* should not be necessary */
        do {
-               wr += (err = mypwrite(odes, buf+wr, towrite-wr, opos+wr-reverse*towrite));
+    tmp = (ssize_t)buf+wr;
+               wr += (err = mypwrite(odes, (void *)tmp, towrite-wr, opos+wr-reverse*towrite));
                if (err == -1) 
                        wr++;
        } while ((err == -1 && (errno == EINTR || errno == EAGAIN))

... and lastly, IRIX lacks a strsignal function, so I used this (which may be inefficient or broken, but works for me):

--- dd_rescue.c
+++ dd_rescue.c
@@ -661,6 +663,53 @@
        */
 }
 
+char * strsignal(int sig)
+{
+  const char * const sys_siglist[] = {
+      "unknown signal"
+    , "Hangup"
+    , "Interrupt"
+    , "Quit"
+    , "Illegal Instruction"
+    , "Trace, Breakpoint, Range Error, Divide by Zero, or Overflow Trap"
+    , "Abort"
+    , "Emulation Trap"
+    , "Arithmetic Exception"
+    , "Killed"
+    , "Bus Error"
+    , "Segmentation Fault"
+    , "Bad System Call"
+    , "Broken Pipe"
+    , "Alarm Clock"
+    , "Terminated"
+    , "User Signal 1"
+    , "User Signal 2"
+    , "Child Status Changed"
+    , "Power Fail/Restart"
+    , "Window Size Change"
+    , "Urgent Socket Condition"
+    , "Pollable Event"
+    , "Stopped (signal)"
+    , "Stopped (user)"
+    , "Continued"
+    , "Stopped (tty input)"
+    , "Stopped (tty output)"
+    , "Virtual Timer Expired"
+    , "Profiling Timer Expired"
+    , "CPU time limit exceeded"
+    , "File size limit exceeded"
+    , "unknown signal"
+    , "Checkpoint warning"
+    , "Restart warning"
+  };
+
+  if (sig > 0 && sig < 65 && sys_siglist[sig] != NULL) {
+    return (char*)sys_siglist[sig];
+  } else {
+    return "unknown signal";
+  };
+}
+
 void breakhandler(int sig)
 {
        fplog(stderr, "dd_rescue: (fatal): Caught signal %i \"%s\". Exiting!\n",
Comment 1 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2008-05-13 19:05:44 UTC
Stuart, 
Thanks for reporting. Can you please attach a physical patch then we can examine it and apply/commit. Thanks!
Comment 2 Fabian Groffen gentoo-dev 2009-05-20 17:03:29 UTC
we can use CC=$(tc-getCC), would that work with the current IRIX setup?
Comment 3 Stuart Shelton 2009-05-21 11:55:28 UTC
It seems to be used extensively elsewhere - so I'd think so, yes.
Comment 4 Diego Elio Pettenò (RETIRED) gentoo-dev 2010-11-17 10:22:20 UTC
Sorry for stumping in your backgarden guys; I'll fix the hardcoded gcc in 1.23, but I suppose it's still better to keep this around for the IRIX problems.
Comment 5 Fabian Groffen gentoo-dev 2011-12-15 18:03:34 UTC
We are sorry to close this bug.  We lack the man-power and devotion to support mips-irix in the tree.