Hello community,

here is the log from the commit of package mbuffer for openSUSE:Factory checked 
in at 2014-04-22 10:06:11
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/mbuffer (Old)
 and      /work/SRC/openSUSE:Factory/.mbuffer.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "mbuffer"

Changes:
--------
--- /work/SRC/openSUSE:Factory/mbuffer/mbuffer.changes  2013-04-17 
07:24:43.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.mbuffer.new/mbuffer.changes     2014-04-22 
10:06:12.000000000 +0200
@@ -1,0 +2,18 @@
+Wed Apr 16 22:51:24 UTC 2014 - [email protected]
+
+- version 20140310
+* added memory advise for buffer memory
+* prevent buffer overflow attack via defaults file
+* ignore defaults file from other users
+* updated documentation for use with cron
+* minor bugfixes
+* new feature: set option defaults in ~/.mbuffer.rc
+* enhancement: write status to the log file
+* enhancement: added option to suppress status logging
+* fix: formatting fix for summary message
+- spec file changes:
+  * refresh patch with p1
+  * the mhash library is abandonware, this is no good
+    since we are talking about crypto software, use openSSL instead.
+
+-------------------------------------------------------------------

Old:
----
  mbuffer-20130220.tgz

New:
----
  mbuffer-20140310.tgz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ mbuffer.spec ++++++
--- /var/tmp/diff_new_pack.3Sd9iS/_old  2014-04-22 10:06:13.000000000 +0200
+++ /var/tmp/diff_new_pack.3Sd9iS/_new  2014-04-22 10:06:13.000000000 +0200
@@ -14,7 +14,7 @@
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
 
 Name:           mbuffer
-Version:        20130220
+Version:        20140310
 Release:        0
 Summary:        Replacement for "buffer" with many more Features
 Source:         
http://www.maier-komor.de/software/mbuffer/mbuffer-%{version}.tgz
@@ -23,7 +23,7 @@
 Group:          Productivity/Text/Utilities
 License:        GPL-3.0+
 BuildRoot:      %{_tmppath}/build-%{name}-%{version}
-BuildRequires:  openssl-devel make gcc glibc-devel glibc-devel mhash-devel
+BuildRequires:  openssl-devel
 BuildRequires:  libtool
 
 %description
@@ -38,7 +38,7 @@
 
 %prep
 %setup -q
-%patch1
+%patch1 -p1
 
 %build
 %configure \

++++++ mbuffer-20130220.tgz -> mbuffer-20140310.tgz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mbuffer-20130220/.hg_archival.txt 
new/mbuffer-20140310/.hg_archival.txt
--- old/mbuffer-20130220/.hg_archival.txt       2013-02-20 23:37:08.000000000 
+0100
+++ new/mbuffer-20140310/.hg_archival.txt       2014-03-10 23:41:15.000000000 
+0100
@@ -1,5 +1,5 @@
 repo: 6e3b485d74645931e2408ed1f57e659029b5639a
-node: 32d9cfa57a3c816cc7fa6dfef775615e53c20c0c
+node: d98ef1ef3a25043dbae9b29d0f6bd96d873c3934
 branch: default
-latesttag: 20130220
+latesttag: R20140310
 latesttagdistance: 1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mbuffer-20130220/.hgtags new/mbuffer-20140310/.hgtags
--- old/mbuffer-20130220/.hgtags        2013-02-20 23:37:08.000000000 +0100
+++ new/mbuffer-20140310/.hgtags        2014-03-10 23:41:15.000000000 +0100
@@ -82,3 +82,5 @@
 8ae0ca3fcabebb985e84f3306f312892e350a0b5 20130209
 6c60e788eb7a6bd22822dfc36e0f73369c4298be 20130210
 35bfc3c313d416df09cfabca9ca691b60f7816b6 20130220
+d93542af23e7750fc8e50c502f84ae7c62ec7856 R20140126
+3f18779d5fda082e6093e69de8c9c4098c67823d R20140310
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mbuffer-20130220/ChangeLog 
new/mbuffer-20140310/ChangeLog
--- old/mbuffer-20130220/ChangeLog      2013-02-20 23:37:08.000000000 +0100
+++ new/mbuffer-20140310/ChangeLog      2014-03-10 23:41:15.000000000 +0100
@@ -1,3 +1,17 @@
+20140310:
+- added memory advise for buffer memory
+- compatibility fix for Solars st driver
+- prevent buffer overflow attack via defaults file
+- ignore defaults file from other users
+- updated documentation for use with cron
+- minor bugfixes
+
+20140126:
+- new feature: set option defaults in ~/.mbuffer.rc
+- enhancement: write status to the log file
+- enhancement: added option to suppress status logging
+- fix: formatting fix for summary message
+
 20130220:
 - reverted incorrect fix for -P 100, which may lead to data corruption
 - reenable hash libraries (no correlation with data corruption)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mbuffer-20130220/configure 
new/mbuffer-20140310/configure
--- old/mbuffer-20130220/configure      2013-02-20 23:37:08.000000000 +0100
+++ new/mbuffer-20140310/configure      2014-03-10 23:41:15.000000000 +0100
@@ -2372,7 +2372,7 @@
 
 
 PACKAGE=mbuffer
-VERSION=20130220
+VERSION=20140302
 
 if test "${LD_LIBRARY_PATH}" != "" ; then
        echo ""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mbuffer-20130220/configure.in 
new/mbuffer-20140310/configure.in
--- old/mbuffer-20130220/configure.in   2013-02-20 23:37:08.000000000 +0100
+++ new/mbuffer-20140310/configure.in   2014-03-10 23:41:15.000000000 +0100
@@ -5,7 +5,7 @@
 AC_EXEEXT
 
 PACKAGE=mbuffer
-VERSION=20130220
+VERSION=20140310
 
 if test "${LD_LIBRARY_PATH}" != "" ; then
        echo ""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mbuffer-20130220/mbuffer.1.in 
new/mbuffer-20140310/mbuffer.1.in
--- old/mbuffer-20130220/mbuffer.1.in   2013-02-20 23:37:08.000000000 +0100
+++ new/mbuffer-20140310/mbuffer.1.in   2014-03-10 23:41:15.000000000 +0100
@@ -96,7 +96,11 @@
 Same as above only for setting the transfer limit for the writer.
 .TP 
 \fB\-A\fR <\fIcmd\fP>
-the device used is an autoloader which uses \fIcmd\fP to load the next volume
+the device used is an autoloader which uses \fIcmd\fP to load the next
+volume. Pass <\fI/bin/false\fP> as an autoload command to suppress the
+warning message that appears when run without controlling terminal (e.g.
+via cron). Like this the autoload will fail and mbuffer will terminate
+with an error message when reaching the end of the tape.
 .TP 
 \fB\-a\fR <\fItime\fP>
 the device used is an autoloader which takes \fItime\fP seconds to load a new 
tape
@@ -120,6 +124,9 @@
 \fB\-q\fR
 quiet \- do not display the status on the standard error output
 .TP 
+\fB\-Q\fR
+quiet \- do not log the status in the log file
+.TP 
 \fB\-\-direct\fR
 Use O_DIRECT to open file descriptors. This option is not available on
 all systems. It tells the OS to bypass the page cache to improve
@@ -159,6 +166,38 @@
 terminates mbuffer via SIGINT. Be aware that the watchdog is unaware of
 tape-change activities. So choose the watchdog timeout greater that the
 worst-case tape-change time.
+.SH "DEFAULT VALUES"
+The default values for following options can be set as \fIkey = value\fP pairs
+in the ~/.mbuffer.rc file:
+.br
+\fIblocksize\fP: block size (option -s)
+.br
+\fItimeout\fP: watchdog timeout (option -W)
+.br
+\fItotalmem\fP: total buffer size (option -m)
+.br
+\fImaxreadspeed\fP: maximum read speed (option -r)
+.br
+\fImaxwritespeed\fP: maximum write speed (option -R)
+.br
+\fIstartwrite\fP: threshold for start writing (option -P)
+.br
+\fIstartread\fP: threshold for start reading (option -p)
+.br
+\fIpause\fP: pause after writing a block (option -u)
+.br
+\fInumblocks\fP: number of blocks in buffer (option -b)
+.br
+\fImemlock\fP: lock buffer in memory (option -L)
+.br
+\fIshowstatus\fP: print transfer status on console (option -q)
+.br
+\fIlogstatus\fP: write transfer status to logfile (option -Q)
+.br
+\fItcpbuffer\fP: TCP buffer size (option --tcpbuffer)
+.br
+
+
 .SH "ENVIRONMENT VARIABLES"
 If TMPDIR is set, mbuffer allocates storage for file-based buffers in this
 directory\&. If TMPDIR is unset, \fI/var/tmp\fR will be used\&.
@@ -167,6 +206,8 @@
 \fI@prefix@/bin/mbuffer\fP 
 .br 
 \fI/var/tmp/mbuffer-*\fP 
+.br 
+\fI~/.mbuffer.rc\fP 
 .SH "EXAMPLES"
 .LP 
 To run this program with the default options just type:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mbuffer-20130220/mbuffer.c 
new/mbuffer-20140310/mbuffer.c
--- old/mbuffer-20130220/mbuffer.c      2013-02-20 23:37:08.000000000 +0100
+++ new/mbuffer-20140310/mbuffer.c      2014-03-10 23:41:15.000000000 +0100
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2000-2013, Thomas Maier-Komor
+ *  Copyright (C) 2000-2014, Thomas Maier-Komor
  *
  *  This is the source code of mbuffer.
  *
@@ -132,11 +132,10 @@
 static pthread_t
        Reader, Watchdog;
 static long
-       Tmp = -1, Pause = 0, Memmap = 0,
-       Status = 1, Outblocksize = 0,
-       Autoload_time = 0, OptSync = 0;
+       Tmp = -1,
+       OptSync = 0;
 static unsigned long
-       Outsize = 10240;
+       Outsize = 10240, Pause = 0, Timeout = 0;
 static volatile int
        Terminate = 0,  /* abort execution, because of error or signal */
        EmptyCount = 0, /* counter incremented when buffer runs empty */
@@ -145,7 +144,8 @@
        Done = 0,
        MainOutOK = 1;  /* is the main outputThread still writing or just 
coordinating senders */
 static unsigned long long
-       Blocksize = 10240, MaxReadSpeed = 0, MaxWriteSpeed = 0, OutVolsize = 0;
+       Totalmem = 0, PgSz = 0, NumP = 0, Blocksize = 10240,
+       MaxReadSpeed = 0, MaxWriteSpeed = 0, OutVolsize = 0;
 static volatile unsigned long long
        Rest = 0, Numin = 0, Numout = 0;
 static double
@@ -153,9 +153,12 @@
 static char
        *Tmpfile = 0, **Buffer;
 static const char
-       *Infile = 0, *Autoload_cmd = 0;
+       *Infile = 0, *AutoloadCmd = 0;
+static unsigned int
+       AutoloadTime = 0;
 static int
        Memlock = 0, TermQ[2],
+       Memmap = 0, Quiet = 0, Status = 1, StatusLog = 1,
        Hashers = 0, Direct = 0, SetOutsize = 0;
 static long
        NumVolumes = 1,         /* number of input volumes, 0 for interactive 
prompting */
@@ -258,18 +261,17 @@
        m = (int) (secs - h * 3600)/60;
        secs -= m * 60 + h * 3600;
        if (numthreads > 1)
-               msg += sprintf(msg,"summary: %d x ",numthreads);
+               msg += sprintf(msg,"summary: %dx ",numthreads);
        else
                msg += sprintf(msg,"summary: ");
        msg += kb2str(msg,numb);
        msg += sprintf(msg,"Byte in ");
        if (h > 0)
-               msg += sprintf(msg,"%d h %02d min ",h,m);
-       else if (m > 0) {
-               msg += sprintf(msg,"%2d min ",m);
-               msg += sprintf(msg,"%04.1f sec - average of ",secs);
-       } else
-               msg += sprintf(msg,"%4.1f sec - average of ",secs);
+               msg += sprintf(msg,"%dh %02dmin %04.1fsec - average of 
",h,m,secs);
+       else if (m > 0)
+               msg += sprintf(msg,"%2dmin %04.1fsec - average of ",m,secs);
+       else
+               msg += sprintf(msg,"%4.1fsec - average of ",secs);
        msg += kb2str(msg,av);
        msg += sprintf(msg,"B/s");
        if (EmptyCount != 0)
@@ -345,12 +347,11 @@
 
 
 
-static void *watchdogThread(void *timeout)
+static void *watchdogThread(void *ignored)
 {
        unsigned long ni = Numin, no = Numout;
-       unsigned t = (unsigned) timeout;
        for (;;) {
-               sleep(t);
+               sleep(Timeout);
                if ((ni == Numin) && (Finish == -1)) {
                        errormsg("watchdog timeout: input stalled; sending 
SIGINT\n");
                        kill(getpid(),SIGINT);
@@ -401,7 +402,7 @@
        }
        while (!Done) {
                int err,numsender;
-               ssize_t nw;
+               ssize_t nw = 0;
                char buf[256], *b = buf;
 
                timeout.tv_sec = 0;
@@ -445,17 +446,21 @@
                        b += sprintf(b,"B/s, ");
                b += kb2str(b,total);
                b += sprintf(b,"B total, buffer %3.0f%% full",fill);
+               if (Quiet == 0) {
 #ifdef NEED_IO_INTERLOCK
-               if (Log == STDERR_FILENO) {
-                       int e;
-                       e = pthread_mutex_lock(&LogMut);
-                       assert(e == 0);
-                       nw = write(STDERR_FILENO,buf,strlen(buf));
-                       e = pthread_mutex_unlock(&LogMut);
-                       assert(e == 0);
-               } else
+                       if (Log == STDERR_FILENO) {
+                               int e;
+                               e = pthread_mutex_lock(&LogMut);
+                               assert(e == 0);
+                               nw = write(STDERR_FILENO,buf,strlen(buf));
+                               e = pthread_mutex_unlock(&LogMut);
+                               assert(e == 0);
+                       } else
 #endif
-                       nw = write(STDERR_FILENO,buf,strlen(buf));
+                               nw = write(STDERR_FILENO,buf,strlen(buf));
+               }
+               if ((StatusLog != 0) && (Log != STDERR_FILENO))
+                       infomsg("%s\n",buf+1);
                err = pthread_mutex_unlock(&TermMut);
                assert(0 == err);
                if (nw == -1)   /* stop trying to print status messages after a 
write error */
@@ -606,8 +611,8 @@
        do {
                if ((Autoloader) && (Infile)) {
                        int ret;
-                       if (Autoload_cmd) {
-                               cmd = Autoload_cmd;
+                       if (AutoloadCmd) {
+                               cmd = AutoloadCmd;
                        } else {
                                (void) snprintf(cmd_buf, sizeof(cmd_buf), "mt 
-f %s offline", Infile);
                                cmd = cmd_buf;
@@ -623,9 +628,9 @@
                                Terminate = 1;
                                pthread_exit((void *) -1);
                        }
-                       if (Autoload_time) {
+                       if (AutoloadTime) {
                                infomsg("waiting for drive to get ready...\n");
-                               (void) sleep(Autoload_time);
+                               (void) sleep(AutoloadTime);
                        }
                } else {
                        if (0 == promptInteractive(at,num))
@@ -1038,7 +1043,7 @@
                if (Autoloader) {
                        const char default_cmd[] = "mt -f %s offline";
                        char cmd_buf[sizeof(default_cmd)+strlen(outfile)];
-                       const char *cmd = Autoload_cmd;
+                       const char *cmd = AutoloadCmd;
                        int err;
 
                        if (cmd == 0) {
@@ -1056,9 +1061,9 @@
                                Autoloader = 0;
                                return -1;
                        }
-                       if (Autoload_time) {
+                       if (AutoloadTime) {
                                infomsg("waiting for drive to get ready...\n");
-                               (void) sleep(Autoload_time);
+                               (void) sleep(AutoloadTime);
                        }
                } else {
                        int err;
@@ -1106,29 +1111,6 @@
 
 
 
-static int checkIncompleteOutput(int out, const char *outfile)
-{
-       static unsigned long mulretry = 0;      /* well this isn't really good 
design,
-                                          but better than a global variable */
-       
-       debugmsg("Outblocksize = %ld, mulretry = %lu\n",Outblocksize,mulretry);
-       if ((0 != mulretry) || (0 == Outblocksize)) {
-               out = requestOutputVolume(out,outfile);
-               debugmsg("resetting outputsize to normal\n");
-               if (0 != mulretry) {
-                       Outsize = mulretry;
-                       mulretry = 0;
-               }
-       } else {
-               debugmsg("setting to new outputsize (end of device)\n");
-               mulretry = Outsize;
-               Outsize = Outblocksize;
-       }
-       return out;
-}
-
-
-
 static void terminateOutputThread(dest_t *d, int status)
 {
        int err;
@@ -1278,6 +1260,7 @@
                }
                do {
                        /* use Outsize which could be the blocksize of the 
device (option -d) */
+                       unsigned long long n = rest > Outsize ? Outsize : rest;
                        int num;
                        if (haderror) {
                                if (NumSenders == 0)
@@ -1287,7 +1270,6 @@
 #ifdef HAVE_SENDFILE
                        if (sendout) {
                                off_t baddr = (off_t) (Buffer[at] + blocksize - 
rest);
-                               unsigned long long n = SetOutsize ? (rest > 
Outsize ? (rest/Outsize)*Outsize : rest) : rest;
                                num = sendfile(out,SFV_FD_SELF,&baddr,n);
                                debugiomsg("outputThread: sendfile(%d, 
SFV_FD_SELF, &(Buffer[%d] + %llu), %llu) = %d\n", out, at, blocksize - rest, n, 
num);
                                if ((num == -1) && ((errno == EOPNOTSUPP) || 
(errno == EINVAL))) {
@@ -1298,17 +1280,18 @@
                        } else
 #endif
                        {
-                               num = write(out,Buffer[at] + blocksize - rest, 
rest > Outsize ? Outsize : rest);
-                               debugiomsg("outputThread: writing %lld@0x%p: 
ret = %d\n",rest > Outsize ? Outsize : rest,Buffer[at] + blocksize - rest,num);
+                               num = write(out,Buffer[at] + blocksize - rest, 
n);
+                               debugiomsg("outputThread: writing %lld@0x%p: 
ret = %d\n", n, Buffer[at] + blocksize - rest, num);
                        }
-                       if ((-1 == num) && (Terminal||Autoloader) && ((errno == 
ENOMEM) || (errno == ENOSPC))) {
-                               /* request a new volume - but first check
-                                * whether we are really at the
-                                * end of the device */
-                               out = checkIncompleteOutput(out,dest->name);
-                               if (out == -1)
-                                       haderror = 1;
-                               continue;
+                       if (Terminal||Autoloader) {
+                               if (((-1 == num) && ((errno == ENOMEM) || 
(errno == ENOSPC)))
+                                       || (0 == num)) {
+                                       /* request a new volume */
+                                       out = 
requestOutputVolume(out,dest->name);
+                                       if (out == -1)
+                                               haderror = 1;
+                                       continue;
+                               }
                        } else if (-1 == num) {
                                dest->result = strerror(errno);
                                errormsg("outputThread: error writing to %s at 
offset 0x%llx: %s\n",dest->arg,(long 
long)Blocksize*Numout+blocksize-rest,strerror(errno));
@@ -1367,7 +1350,7 @@
 {
        (void) fprintf(stderr,
                "mbuffer version "VERSION"\n"\
-               "Copyright 2001-2011 - T. Maier-Komor\n"\
+               "Copyright 2001-2014 - T. Maier-Komor\n"\
                "License: GPLv3 - see file LICENSE\n"\
                "This program comes with ABSOLUTELY NO WARRANTY!!!\n"
                "Donations via PayPal to [email protected] are welcome and 
support this work!\n"
@@ -1422,6 +1405,7 @@
                "-A <cmd>   : issue command <cmd> to request new volume\n"
                "-v <level> : set verbose level to <level> (valid values are 
0..6)\n"
                "-q         : quiet - do not display the status on stderr\n"
+               "-Q         : quiet - do not log the status\n"
                "-c         : write with synchronous data integrity support\n"
                "-e         : stop processing on any kind of error\n"
 #ifdef O_DIRECT
@@ -1435,6 +1419,7 @@
                "-4         : force use of IPv4\n"
                "-6         : force use of IPv6\n"
                "-0         : use IPv4 or IPv6\n"
+               "--tcpbuffer: size for TCP buffer\n"
                "-V\n"
                "--version  : print version information\n"
                "Unsupported buffer options: -t -Z -B\n"
@@ -1604,12 +1589,243 @@
                fatal("unable to open all outputs\n");
 }
 
+
+
+static const char *calcval(const char *arg, unsigned long long *res)
+{
+       char ch;
+       double d;
+       
+       switch (sscanf(arg,"%lf%c",&d,&ch)) {
+       default:
+               assert(0);
+               break;
+       case 2:
+               if (d <= 0)
+                       return "negative value out of range";
+               switch (ch) {
+               case 'k':
+               case 'K':
+                       d *= 1024.0;
+                       *res = d;
+                       return 0;
+               case 'm':
+               case 'M':
+                       d *= 1024.0*1024.0;
+                       *res = d;
+                       return 0;
+               case 'g':
+               case 'G':
+                       d *= 1024.0*1024.0*1024.0;
+                       *res = d;
+                       return 0;
+               case 't':
+               case 'T':
+                       d *= 1024.0*1024.0*1024.0*1024.0;
+                       *res = d;
+                       return 0;
+               case '%':
+                       if ((d >= 90) || (d <= 0))
+                               return "invalid value for percentage (must be 
0..90)";
+                       *res = d;
+                       return 0;
+               case 'b':
+               case 'B':
+                       if (d < 128)
+                               return "invalid value for number of bytes";
+                       *res = d;
+                       return 0;
+               default:
+                       return "invalid dimension";
+               }
+       case 1:
+               if (d <= 0)
+                       return "value out of range";
+               if (d <= 100)
+                       return "value out of range";
+               *res = d;
+               return 0;
+       case 0:
+               break;
+       }
+       return "unrecognized argument";
+}
+
+
+static void initDefaults()
+{
+       char dfname[PATH_MAX+1], line[256];
+       const char *home = getenv("HOME");
+       size_t l;
+       int df;
+       FILE *dfstr;
+       struct stat st;
+
+       if (home == 0) {
+               warningmsg("HOME environment variable not set - unable to find 
defaults file\n");
+               return;
+       }
+       strncpy(dfname,home,PATH_MAX);
+       dfname[sizeof(dfname)-1] = 0;
+       l = strlen(dfname);
+       if (l + 12 > PATH_MAX) {
+               warningmsg("path to defaults file breaks PATH_MAX\n");
+               return;
+       }
+       strcat(dfname,"/.mbuffer.rc");
+       df = open(dfname,O_RDONLY);
+       if (df == -1) {
+               if (errno == ENOENT)
+                       infomsg("no defaults file ~/.mbuffer.rc\n");
+               else
+                       warningmsg("error opening defaults file %s: 
%s\n",dfname,strerror(errno));
+               return;
+       }
+       if (-1 == fstat(df,&st)) {
+               warningmsg("unable to stat defaults file %s: 
%s\n",dfname,strerror(errno));
+               close(df);
+               return;
+       }
+       if (getuid() != st.st_uid) {
+               warningmsg("ignoring defaults file from different user\n");
+               close(df);
+               return;
+       }
+       infomsg("reading defaults file %s\n",dfname);
+       dfstr = fdopen(df,"r");
+       assert(dfstr);
+       while (!feof(dfstr)) {
+               char key[64],valuestr[64];
+               fscanf(dfstr,"%255[^\n]\n",line);
+               char *pound = strchr(line,'#');
+               unsigned long long value;
+               int a;
+
+               if (pound)
+                       *pound = 0;
+               a = sscanf(line,"%63[A-Za-z]%*[ 
\t=:]%63[0-9a-zA-Z]",key,valuestr);
+               if (a != 2) {
+                       warningmsg("unable to parse line '%s' in .mbuffer.rc; 
%d arguments\n",line,a);
+                       continue;
+               }
+               debugmsg("parsing key/value pair %s=%s\n",key,valuestr);
+               if (strcasecmp(key,"numblocks") == 0) {
+                       long nb = strtol(valuestr,0,0);
+                       if ((nb == 0) && (errno == EINVAL)) {
+                               warningmsg("invalid argument for %s: 
\"%s\"\n",key,valuestr);
+                       } else {
+                               Numblocks = nb;
+                               debugmsg("Numblocks = %llu\n",Numblocks);
+                       }
+               } else if (strcasecmp(key,"pause") == 0) {
+                       long p = strtol(valuestr,0,0);
+                       if ((p == 0) && (errno == EINVAL)) {
+                               warningmsg("invalid argument for %s: 
\"%s\"\n",key,valuestr);
+                       } else {
+                               Pause = p;
+                               debugmsg("Pause = %d\n",Pause);
+                       }
+               } else if (strcasecmp(key,"autoloadtime") == 0) {
+                       long at = strtol(valuestr,0,0) - 1;
+                       if ((at == 0) && (errno == EINVAL)) 
+                               warningmsg("invalid argument for %s: 
\"%s\"\n",key,valuestr);
+                       else {
+                               AutoloadTime = at;
+                               debugmsg("Autoloader time = %d\n",AutoloadTime);
+                       }
+               } else if (strcasecmp(key,"startread") == 0) {
+                       double sr = 0;
+                       if (1 == sscanf(valuestr,"%lf",&sr))
+                               sr /= 100;
+                       if ((sr <= 1) && (sr > 0)) {
+                               StartRead = sr;
+                               debugmsg("StartRead = %1.2lf\n",StartRead);
+                       }
+               } else if (strcasecmp(key,"startwrite") == 0) {
+                       double sw = 0;
+                       if (1 == sscanf(valuestr,"%lf",&sw))
+                               sw /= 100;
+                       if ((sw <= 1) && (sw > 0)) {
+                               StartWrite = sw;
+                               debugmsg("StartWrite = %1.2lf\n",StartWrite);
+                       }
+               } else if (strcasecmp(key,"timeout") == 0) {
+                       long t = strtol(valuestr,0,0);
+                       if (((t == 0) && (errno == EINVAL)) || (t < 0)) 
+                               warningmsg("invalid argument for %s: 
\"%s\"\n",key,valuestr);
+                       else {
+                               Timeout = t;
+                               debugmsg("Timeout = %lu\n",Timeout);
+                       }
+               } else if (strcasecmp(key,"showstatus") == 0) {
+                       if ((strcasecmp(valuestr,"yes") == 0) || 
(strcasecmp(valuestr,"on") == 0) || (strcmp(valuestr,"1") == 0)) {
+                               Quiet = 0;
+                               debugmsg("showstatus = yes\n");
+                       } else if ((strcasecmp(valuestr,"no") == 0) || 
(strcasecmp(valuestr,"off") == 0) || (strcmp(valuestr,"0") == 0)) {
+                               Quiet = 1;
+                               debugmsg("showstatus = no\n");
+                       } else 
+                               warningmsg("invalid argument for %s: 
\"%s\"\n",key,valuestr);
+                       continue;
+               } else if (strcasecmp(key,"logstatus") == 0) {
+                       if ((strcasecmp(valuestr,"yes") == 0) || 
(strcasecmp(valuestr,"on") == 0) || (strcmp(valuestr,"1") == 0)) {
+                               StatusLog = 1;
+                               debugmsg("logstatus = yes\n");
+                       } else if ((strcasecmp(valuestr,"no") == 0) || 
(strcasecmp(valuestr,"off") == 0) || (strcmp(valuestr,"0") == 0)) {
+                               StatusLog = 0;
+                               debugmsg("logstatus = no\n");
+                       } else 
+                               warningmsg("invalid argument for %s: 
\"%s\"\n",key,valuestr);
+                       continue;
+               } else if (strcasecmp(key,"memlock") == 0) {
+                       if ((strcasecmp(valuestr,"yes") == 0) || 
(strcasecmp(valuestr,"on") == 0) || (strcmp(valuestr,"1") == 0)) {
+                               Memlock = 1;
+                               debugmsg("Memlock = %lu\n",Memlock);
+                       } else if ((strcasecmp(valuestr,"no") == 0) || 
(strcasecmp(valuestr,"off") == 0) || (strcmp(valuestr,"0") == 0)) {
+                               Memlock = 0;
+                               debugmsg("Memlock = %lu\n",Memlock);
+                       } else 
+                               warningmsg("invalid argument for %s: 
\"%s\"\n",key,valuestr);
+                       continue;
+               }
+               const char *argerror = calcval(valuestr,&value);
+               if (argerror) {
+                       warningmsg("ignoring key/value pair from defaults file 
(%s = %s): %s\n",key,valuestr,argerror);
+                       continue;
+               }
+               if (strcasecmp(key,"blocksize") == 0) {
+                       Blocksize = value;
+               } else if (strcasecmp(key,"maxwritespeed") == 0) {
+                       MaxWriteSpeed = value;
+               } else if (strcasecmp(key,"maxreadspeed") == 0) {
+                       MaxReadSpeed = value;
+               } else if (strcasecmp(key,"Totalmem") == 0) {
+                       if (value < 100) {
+#if defined(_SC_AVPHYS_PAGES) && defined(_SC_PAGESIZE) && !defined(__CYGWIN__) 
|| defined(__FreeBSD__)
+                               Totalmem = ((unsigned long long) NumP * PgSz * 
value) / 100 ;
+                               debugmsg("Totalmem = %lluk\n",Totalmem>>10);
+#else
+                               warningmsg("Unable to determine page size or 
amount of available memory - please specify an absolute amount of memory.\n");
+#endif
+                       }
+               } else if (strcasecmp(key,"tcpbuffer") == 0) {
+                       TCPBufSize = value;
+               } else {
+                       warningmsg("unknown key: %s\n",key);
+                       continue;
+               }
+               infomsg("setting %s to %lld\n",key,value);
+       }
+       fclose(dfstr);
+       close(df);
+}
+
+
 int main(int argc, const char **argv)
 {
-       unsigned long long totalmem = 0;
        int optMset = 0, optSset = 0, optBset = 0, optMode = O_EXCL, numOut = 0;
        int  numstdout = 0, numthreads = 0;
-       long mxnrsem, timeout = 0;
+       long mxnrsem;
        int c, fl, err;
        sigset_t       signalSet;
 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
@@ -1621,33 +1837,56 @@
        const char *outfile = 0;
        struct sigaction sig;
        dest_t *dest = 0;
-#if defined(_SC_AVPHYS_PAGES) && defined(_SC_PAGESIZE) && !defined(__CYGWIN__)
-       long long pgsz, nump;
 
+       /* setup logging prefix */
+       progname = basename(argv0);
+       PrefixLen = strlen(progname) + 2;
+       Prefix = malloc(PrefixLen);
+       (void) strcpy(Prefix,progname);
+       Prefix[PrefixLen - 2] = ':';
+       Prefix[PrefixLen - 1] = ' ';
+
+       /* set verbose level before parsing defaults and options */
+       for (c = 1; c < argc; c++) {
+               const char *arg = argv[c];
+               if ((arg[0] == '-') && (arg[1] == 'v')) {
+                       long verb;
+                       if (arg[2])
+                               verb = strtol(arg+2,0,0);
+                       else
+                               verb = strtol(argv[++c],0,0);
+                       if ((verb == 0) && (errno == EINVAL))
+                               errormsg("invalid argument to option -v: 
\"%s\"\n",argv[c]);
+                       else
+                               Verbose = verb;
+                       debugmsg("Verbose = %d\n",Verbose);
+               }
+       }
+       
+       /* gather system parameters */
        TickTime = 1000000 / sysconf(_SC_CLK_TCK);
-       pgsz = sysconf(_SC_PAGESIZE);
-       assert(pgsz > 0);
-       nump = sysconf(_SC_AVPHYS_PAGES);
-       assert(nump > 0);
-       Blocksize = pgsz;
-       Numblocks = nump/50;
+#if defined(_SC_AVPHYS_PAGES) && defined(_SC_PAGESIZE) && !defined(__CYGWIN__)
+       PgSz = sysconf(_SC_PAGESIZE);
+       assert(PgSz > 0);
+       NumP = sysconf(_SC_AVPHYS_PAGES);
+       assert(NumP > 0);
+       Blocksize = PgSz;
+       debugmsg("total # of phys pages: %li (pagesize %li)\n",NumP,PgSz);
+       Numblocks = NumP/50;
 #elif defined(__FreeBSD__)
        size_t nump_size = sizeof(nump_size);
-       unsigned long pgsz,nump;
-       sysctlbyname("hw.availpages", &nump, &nump_size, NULL, 0);
-       pgsz = sysconf(_SC_PAGESIZE);
-       assert(pgsz > 0);
+       sysctlbyname("hw.availpages", &NumP, &nump_size, NULL, 0);
+       PgSz = sysconf(_SC_PAGESIZE);
+       assert(PgSz > 0);
 #endif
 #if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK >= 0) && 
defined(CLOCK_MONOTONIC)
        if (sysconf(_SC_MONOTONIC_CLOCK) > 0)
                ClockSrc = CLOCK_MONOTONIC;
 #endif
-       progname = basename(argv0);
-       PrefixLen = strlen(progname) + 2;
-       Prefix = malloc(PrefixLen);
-       (void) strcpy(Prefix,progname);
-       Prefix[PrefixLen - 2] = ':';
-       Prefix[PrefixLen - 1] = ' ';
+
+       /* setup parameters */
+       initDefaults();
+       debugmsg("default buffer set to %d blocks of %lld 
bytes\n",Numblocks,Blocksize);
        for (c = 1; c < argc; c++) {
                if (!argcheck("-s",argv,&c,argc)) {
                        Blocksize = Outsize = calcint(argv,c,Blocksize);
@@ -1662,16 +1901,16 @@
                        optMode |= O_TRUNC;
                        debugmsg("truncate next file\n");
                } else if (!argcheck("-m",argv,&c,argc)) {
-                       totalmem = calcint(argv,c,totalmem);
+                       Totalmem = calcint(argv,c,Totalmem);
                        optMset = 1;
-                       if (totalmem < 100) {
+                       if (Totalmem < 100) {
 #if defined(_SC_AVPHYS_PAGES) && defined(_SC_PAGESIZE) && !defined(__CYGWIN__) 
|| defined(__FreeBSD__)
-                               totalmem = ((unsigned long long) nump * pgsz * 
totalmem) / 100 ;
+                               Totalmem = ((unsigned long long) NumP * PgSz * 
Totalmem) / 100 ;
 #else
                                fatal("Unable to determine page size or amount 
of available memory - please specify an absolute amount of memory.\n");
 #endif
                        }
-                       debugmsg("totalmem = %lluk\n",totalmem>>10);
+                       debugmsg("Totalmem = %lluk\n",Totalmem>>10);
                } else if (!argcheck("-b",argv,&c,argc)) {
                        long nb = strtol(argv[c],0,0);
                        if ((nb == 0) && (errno == EINVAL)) {
@@ -1692,19 +1931,7 @@
                        fatal("cannot determine blocksize of device 
(unsupported by OS)\n");
 #endif
                } else if (!argcheck("-v",argv,&c,argc)) {
-                       int verb;
-                       if (c == argc)
-                               fatal("missing argument for option -v\n");
-                       verb = strtol(argv[c],0,0);
-                       if ((verb == 0) && (errno == EINVAL))
-                               errormsg("invalid argument to option -v: 
\"%s\"\n",argv[c]);
-                       else
-                               Verbose = verb;
-                       debugmsg("Verbose = %d\n",Verbose);
-#if defined(_SC_AVPHYS_PAGES) && defined(_SC_PAGESIZE) && !defined(__CYGWIN__)
-                       debugmsg("total # of phys pages: %li (pagesize 
%li)\n",nump,pgsz);
-#endif
-                       debugmsg("default buffer set to %d blocks of %lld 
bytes\n",Numblocks,Blocksize);
+                       /* has been parsed already */
                } else if (!argcheck("-u",argv,&c,argc)) {
 
                        long p = strtol(argv[c],0,0);
@@ -1807,7 +2034,10 @@
                        debugmsg("overwrite = 1\n");
                } else if (!strcmp("-q",argv[c])) {
                        debugmsg("disabling display of status\n");
-                       Status = 0;
+                       Quiet = 1;
+               } else if (!strcmp("-Q",argv[c])) {
+                       debugmsg("disabling logging of status\n");
+                       StatusLog = 0;
                } else if (!strcmp("-c",argv[c])) {
                        debugmsg("enabling full synchronous I/O\n");
                        OptSync = O_SYNC;
@@ -1820,15 +2050,13 @@
                                errormsg("invalid argument to option -a: 
\"%s\"\n",argv[c]);
                        else {
                                Autoloader = 1;
-                               Autoload_time = at;
+                               AutoloadTime = at;
                        }
-                       if (at && timeout && timeout <= Autoload_time)
-                               fatal("autoload time must be smaller than 
watchdog timeout\n");
-                       debugmsg("Autoloader time = %d\n",Autoload_time);
+                       debugmsg("Autoloader time = %d\n",AutoloadTime);
                } else if (!argcheck("-A",argv,&c,argc)) {
                        Autoloader = 1;
-                       Autoload_cmd = argv[c];
-                       debugmsg("Autoloader command = \"%s\"\n", Autoload_cmd);
+                       AutoloadCmd = argv[c];
+                       debugmsg("Autoloader command = \"%s\"\n", AutoloadCmd);
                } else if (!argcheck("-P",argv,&c,argc)) {
                        if (1 != sscanf(argv[c],"%lf",&StartWrite))
                                StartWrite = 0;
@@ -1852,10 +2080,10 @@
                        warning("POSIX memory locking is unsupported on this 
system.\n");
 #endif
                } else if (!argcheck("-W",argv,&c,argc)) {
-                       timeout = strtol(argv[c],0,0);
-                       if (timeout <= 0)
+                       Timeout = strtol(argv[c],0,0);
+                       if (Timeout <= 0)
                                fatal("invalid argument to option -W\n");
-                       if (timeout <= Autoload_time)
+                       if (Timeout <= AutoloadTime)
                                fatal("timeout must be bigger than autoload 
time\n");
                } else if (!strcmp("--direct",argv[c])) {
 #ifdef O_DIRECT
@@ -1908,20 +2136,22 @@
        }
 
        /* consistency check for options */
+       if (AutoloadTime && Timeout && Timeout <= AutoloadTime)
+               fatal("autoload time must be smaller than watchdog timeout\n");
        if (optBset&optSset&optMset) {
-               if (Numblocks * Blocksize != totalmem)
+               if (Numblocks * Blocksize != Totalmem)
                        fatal("inconsistent options: blocksize * number of 
blocks != totalsize!\n");
        } else if (((!optBset)&optSset&optMset) || 
(optMset&(!optBset)&(!optSset))) {
-               if (totalmem <= Blocksize)
+               if (Totalmem <= Blocksize)
                        fatal("total memory must be larger than block size\n");
-               Numblocks = totalmem / Blocksize;
-               infomsg("Numblocks = %llu, Blocksize = %llu, totalmem = 
%llu\n",(unsigned long long)Numblocks,(unsigned long long)Blocksize,(unsigned 
long long)totalmem);
+               Numblocks = Totalmem / Blocksize;
+               infomsg("Numblocks = %llu, Blocksize = %llu, Totalmem = 
%llu\n",(unsigned long long)Numblocks,(unsigned long long)Blocksize,(unsigned 
long long)Totalmem);
        } else if (optBset&!optSset&optMset) {
                if (Blocksize == 0)
                        fatal("blocksize must be greater than 0\n");
-               if (totalmem <= Blocksize)
+               if (Totalmem <= Blocksize)
                        fatal("total memory must be larger than block size\n");
-               Blocksize = totalmem / Numblocks;
+               Blocksize = Totalmem / Numblocks;
                infomsg("blocksize = %llu\n",(unsigned long long)Blocksize);
        }
        if ((StartRead < 1) && (StartWrite > 0))
@@ -2021,6 +2251,10 @@
                Buffer[0] = (char *) valloc(Blocksize * Numblocks);
                if (Buffer[0] == 0)
                        fatal("Could not allocate enough memory (%lld 
requested): %s\n",(unsigned long long)Blocksize * Numblocks,strerror(errno));
+#ifdef MADV_DONTFORK
+               if (-1 == madvise(Buffer[0],Blocksize * Numblocks, 
MADV_DONTFORK))
+                       warningmsg("unable to advise memory handling of buffer: 
%s\n",strerror(errno));
+#endif
        }
        for (c = 1; c < Numblocks; c++) {
                Buffer[c] = Buffer[0] + Blocksize * c;
@@ -2092,7 +2326,7 @@
        }
 
        debugmsg("checking if we have a controlling terminal...\n");
-       sig.sa_sigaction = SIG_IGN;
+       sig.sa_handler = SIG_IGN;
        err = sigaction(SIGTTIN,&sig,0);
        assert(err == 0);
        fl = fcntl(STDERR_FILENO,F_GETFL);
@@ -2193,6 +2427,8 @@
                   "This can result in incorrect written data when\n"
                   "using multiple volumes. Continue at your own risk!\n");
 #endif
+       if (((Verbose < 4) || (StatusLog == 0)) && (Quiet != 0))
+               Status = 0;
        if (Status) {
                if (-1 == pipe(TermQ))
                        fatal("could not create termination pipe: 
%s\n",strerror(errno));
@@ -2202,8 +2438,8 @@
        }
        err = pthread_create(&dest->thread,0,&outputThread,dest);
        assert(0 == err);
-       if (timeout) {
-               err = 
pthread_create(&Watchdog,0,&watchdogThread,(void*)timeout);
+       if (Timeout) {
+               err = pthread_create(&Watchdog,0,&watchdogThread,(void*)0);
                assert(0 == err);
        }
        if (Status) {
@@ -2223,7 +2459,7 @@
                        assert(err == 1);
                }
        }
-       if (timeout) {
+       if (Timeout) {
                err = pthread_cancel(Watchdog);
                assert(err == 0);
        }

++++++ mbuffer-fix_pointer_cast.patch ++++++
--- /var/tmp/diff_new_pack.3Sd9iS/_old  2014-04-22 10:06:13.000000000 +0200
+++ /var/tmp/diff_new_pack.3Sd9iS/_new  2014-04-22 10:06:13.000000000 +0200
@@ -1,6 +1,6 @@
---- mbuffer.c.orig     2010-03-27 22:04:34.000000000 +0100
-+++ mbuffer.c  2010-03-27 22:06:14.000000000 +0100
-@@ -47,6 +47,7 @@
+--- mbuffer-20140310.orig/mbuffer.c
++++ mbuffer-20140310/mbuffer.c
+@@ -48,6 +48,7 @@ typedef int caddr_t;
  #include <sys/time.h>
  #include <termios.h>
  #include <unistd.h>
@@ -8,7 +8,7 @@
  
  
  #ifdef __FreeBSD__
-@@ -1027,7 +1028,7 @@
+@@ -1111,7 +1112,7 @@ static int requestOutputVolume(int out,
  
  
  

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to