Test: coreutils-5.3.0-6 [Was: DD converts LF - CR / LF]

2005-05-13 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Sebastian Schuberth on 5/6/2005 1:19 AM:
 dd if=test_unix.txt of=text.txt
 
 create an exact copy of test_unix.txt?

If you are interested, try the coreutils-5.3.0-6 test release (in setup,
you have to specifically request the Exp radio button to see test
releases).  I changed dd to default to binary mode on regular files, and
added text and binary as valid flags to iflag= and oflag=.  Let me
know if the new behavior causes any problems.

The coreutils release is marked test because it also attempts to fix the
`mkdir -p //server/share/dir' bug, but that fix relies on snapshot
behavior and is still being ironed out before cygwin 1.5.17 can be released.

- --
Life is short - so eat dessert first!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFChKb084KuGfSFAYARAs3IAJwJ3NndRw4ByJem3grH+cYdNnORRgCff+4y
ayelPxPzjws0sZpsGHnYIyg=
=SKx4
-END PGP SIGNATURE-

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: DD converts LF - CR / LF

2005-05-12 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Christopher Faylor on 5/9/2005 8:57 AM:
 
 As one of the project leads, I am formally asking you to make dd default
 to binary behavior.

With a request like that, you've got it!  Is there any reason why
fcntl(fd, F_SETFL, O_TEXT) does not seem to change the mode if the file is
already open in binary mode?  It required me to use setmode(fd, O_TEXT)
instead.  My local patches are now tested, and default the dd files to
binary if they are not a tty (tty's remain with the underlying behavior,
this is comparable to other programs like od that default to binary).
Then it copies Paul Eggert's upstream idea of adding
[io]flag={text,binary}, but uses setmode to ensure that a user-specified
mode is applied (since fcntl did not want to do it).

Meanwhile, I'm still waiting on Pierre's latest mkdir(2) patch before
`mkdir -p //server/share' will work.  But I can go ahead and release
5.3.0-6 in test status, and bump it to current when cygwin-1.5.17 is
released.  Look for an upload request on cygwin-apps by tomorrow.

- --
Life is short - so eat dessert first!

Eric Blake [EMAIL PROTECTED]

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCg1k584KuGfSFAYARAurrAJ9Jd/QaVy7MoLiSod2MI5DfDH/2kQCfb682
EAo+ZHsW5tjy1oEnZ0rznpY=
=308L
-END PGP SIGNATURE-

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: DD converts LF - CR / LF

2005-05-12 Thread Corinna Vinschen
On May 12 07:25, Eric Blake wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 According to Christopher Faylor on 5/9/2005 8:57 AM:
  
  As one of the project leads, I am formally asking you to make dd default
  to binary behavior.
 
 With a request like that, you've got it!  Is there any reason why
 fcntl(fd, F_SETFL, O_TEXT) does not seem to change the mode if the file is

Not bad an idea, really.  Just http://cygwin.com/acronyms/#SHTDI


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: DD converts LF - CR / LF

2005-05-09 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Christopher Faylor on 5/8/2005 5:03 PM:
Hmm, overriding the explicit advice of the system administrator?  How
common is it for file systems to be mounted in text mode?  Why would
anyone do such a thing?  If it's sufficiently rare, then dd shouldn't
need to worry about it.
 
 It is not rare but, regardless, this email was the result of someone who
 was surprised by the fact that dd converted LF - CRLF.  Whether it is
 common or not, I don't think it makes sense to surprise people who use
 dd when it is trivial to make it work in a more UNIX-like fashion (i.e.,
 do not convert LF - CRLF).

The cygwin installer is being changed to more explicitly warn users that
text-mode mounts are usually a bad idea.  The problem is that the cygwin
system administrator is often the primary user, and is often naive about
the issues between text vs binary mounts (especially at the point in time
when they ran the installer).

However, Paul's arguments are starting to convince me (if only because
then I have fewer downstream patches to maintain) - respecting the
underlying mount point unless told otherwise can also be considered a
sensible behavior, and is adopted by several other utilities in coreutils.
 So long as there is command-line configurability to get both text and
binary behaviors (whether that be default binary, iflag=binary is a no-op,
and iflag=text always changes behavior; or default from underlying mount,
and both iflag=binary and iflag=text potentially change behavior), then a
cygwin FAQ can be written that tells the user how to make dd(1) meet
expectations (if it really is frequently asked).

I guess it comes down to how often is dd used in scripts vs.
interactively?  Note that this alias would give binary-only behavior in
interactive mode even when respecting the underlying mount points:

$ alias dd='dd iflag=binary oflag=binary'

iflag= is already a coreutils extension beyond POSIX, so this alias relies
on parsing multiple iflag= operands in the same way that POSIX requires
support for multiple conv= operands.  But since iflag= is a POSIX
extension, portable scripts that use dd cannot assume its existance, and
they will get whichever default behavior we choose (all binary, or
underlying mount).

- --
Life is short - so eat dessert first!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCf10N84KuGfSFAYARAi9FAKCvTTD43+pDp5euzEfL9ZwWoMRd9wCeK1uM
hz2iNl2z2OJYh+me30G3qpQ=
=53KA
-END PGP SIGNATURE-

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: DD converts LF - CR / LF

2005-05-09 Thread Christopher Faylor
On Mon, May 09, 2005 at 06:52:29AM -0600, Eric Blake wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Christopher Faylor on 5/8/2005 5:03 PM:
Hmm, overriding the explicit advice of the system administrator?  How
common is it for file systems to be mounted in text mode?  Why would
anyone do such a thing?  If it's sufficiently rare, then dd shouldn't
need to worry about it.
 
 It is not rare but, regardless, this email was the result of someone who
 was surprised by the fact that dd converted LF - CRLF.  Whether it is
 common or not, I don't think it makes sense to surprise people who use
 dd when it is trivial to make it work in a more UNIX-like fashion (i.e.,
 do not convert LF - CRLF).

The cygwin installer is being changed to more explicitly warn users that
text-mode mounts are usually a bad idea.  The problem is that the cygwin
system administrator is often the primary user, and is often naive about
the issues between text vs binary mounts (especially at the point in time
when they ran the installer).

However, Paul's arguments are starting to convince me (if only because
then I have fewer downstream patches to maintain) - respecting the
underlying mount point unless told otherwise can also be considered a
sensible behavior, and is adopted by several other utilities in coreutils.

As one of the project leads, I am formally asking you to make dd default
to binary behavior.  This whole thread was kicked off by someone who was
suprised by the current behavior.  I don't think there is any reason to
force people to read the man page in order to get the behavior that
they're used to on UNIX.  If you want to make it to text mode when the
dd arguments clearly indicate that you're manipulating text, then that
would be great.  Otherwise, the current and proposed behavior will just
annoy me and prevent me from writing portable scripts.  I use text mode
mounts myself and I do not desire this behavior.

So far, that seems to be two for two desiring binmode.

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: DD converts LF - CR / LF

2005-05-08 Thread Paul Eggert
Eric Blake [EMAIL PROTECTED] writes:

 it now defaults to the underlying mount mode when the user does not
 specify binary or text.  In my opinion, dd should default to binary
 when neither text nor binary is specified

Hmm, overriding the explicit advice of the system administrator?
How common is it for file systems to be mounted in text mode?  Why
would anyone do such a thing?  If it's sufficiently rare, then dd
shouldn't need to worry about it.

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: DD converts LF - CR / LF

2005-05-08 Thread Sebastian Schuberth
Paul Eggert wrote:

 Eric Blake [EMAIL PROTECTED] writes:
 
it now defaults to the underlying mount mode when the user does not
specify binary or text.  In my opinion, dd should default to binary
when neither text nor binary is specified
 
 Hmm, overriding the explicit advice of the system administrator?
 How common is it for file systems to be mounted in text mode?  Why
 would anyone do such a thing?  If it's sufficiently rare, then dd
 shouldn't need to worry about it.

If you run Cygwin under Windows and mix usage of Cygwin's command line
CVS client and e.g. TortoiseCVS, you need to mount the file systems in
text mode. Otherwise, you get additional line feeds when checking in /
out to / from a CVS server (that runs under Unix).

-- 
Sebastian Schuberth

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: DD converts LF - CR / LF

2005-05-08 Thread Christopher Faylor
On Sun, May 08, 2005 at 08:02:30AM -0700, Paul Eggert wrote:
Eric Blake [EMAIL PROTECTED] writes:
it now defaults to the underlying mount mode when the user does not
specify binary or text.  In my opinion, dd should default to binary
when neither text nor binary is specified

Hmm, overriding the explicit advice of the system administrator?  How
common is it for file systems to be mounted in text mode?  Why would
anyone do such a thing?  If it's sufficiently rare, then dd shouldn't
need to worry about it.

It is not rare but, regardless, this email was the result of someone who
was surprised by the fact that dd converted LF - CRLF.  Whether it is
common or not, I don't think it makes sense to surprise people who use
dd when it is trivial to make it work in a more UNIX-like fashion (i.e.,
do not convert LF - CRLF).
--
Christopher Faylor  spammer? - [EMAIL PROTECTED]
Cygwin Co-Project Leader[EMAIL PROTECTED]
TimeSys, Inc.

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: DD converts LF - CR / LF

2005-05-07 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Paul Eggert on 5/6/2005 12:01 PM:
 That looks pretty complicated.  How about if we just rely on open
 and fcntl to do the work?  If they don't work, they should.
 
 I installed this into coreutils:
 
 2005-05-06  Paul Eggert  [EMAIL PROTECTED]
 
   * NEWS: dd has new iflag= and oflag= flags binary and text.
   * doc/coreutils.texi (dd invocation): Document it.
   * src/dd.c (flags, usage): Support it.

That's okay for a start, but it now defaults to the underlying mount mode
when the user does not specify binary or text.  In my opinion, dd should
default to binary when neither text nor binary is specified (of course,
that makes iflag=binary pretty much a no-op).

- --
Life is short - so eat dessert first!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCfNtI84KuGfSFAYARAvJTAJ9qZymfD8tj84OIFBORuo1+Nyix5wCfXoqQ
R21yy4vx9YA1YIDr5oHG7MI=
=wjhL
-END PGP SIGNATURE-

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: DD converts LF - CR / LF

2005-05-07 Thread Christopher Faylor
On Sat, May 07, 2005 at 09:14:17AM -0600, Eric Blake wrote:
According to Paul Eggert on 5/6/2005 12:01 PM:
 That looks pretty complicated.  How about if we just rely on open
 and fcntl to do the work?  If they don't work, they should.
 
 I installed this into coreutils:
 
 2005-05-06  Paul Eggert  [EMAIL PROTECTED]
 
  * NEWS: dd has new iflag= and oflag= flags binary and text.
  * doc/coreutils.texi (dd invocation): Document it.
  * src/dd.c (flags, usage): Support it.

That's okay for a start, but it now defaults to the underlying mount mode
when the user does not specify binary or text.  In my opinion, dd should
default to binary when neither text nor binary is specified (of course,
that makes iflag=binary pretty much a no-op).

So, this seems to be the consensus.  It really is the only sane way for
dd to operate.

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: DD converts LF - CR / LF

2005-05-07 Thread Sebastian Schuberth
2005-05-06  Paul Eggert  [EMAIL PROTECTED]

 * NEWS: dd has new iflag= and oflag= flags binary and text.
 * doc/coreutils.texi (dd invocation): Document it.
 * src/dd.c (flags, usage): Support it.
 
 That's okay for a start, but it now defaults to the underlying mount mode
 when the user does not specify binary or text.  In my opinion, dd should
 default to binary when neither text nor binary is specified (of course,
 that makes iflag=binary pretty much a no-op).

I agree, DD should default to binary in any case. Well, I'll look
foreward to the Cywin release of coreutils-5.3.0-6 to see which patch
will make it ;-)

-- 
Sebastian Schuberth

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



DD converts LF - CR / LF

2005-05-06 Thread Sebastian Schuberth
Hello,
my mounts are all text mode, i.e. the Default Text File
Type is DOS. Nevertheless, shouldn't
dd if=test_unix.txt of=text.txt
create an exact copy of test_unix.txt? It seems DD doesn't open the
file in binary mode (like even VIM does), because
if test_unix.txt contains LF line ends, text.txt will contain CR /
LF line ends, increasing the file size. This drove me nuts when working
with DD on some binary files. How can I solve this? I already tried 
several of the conv= arguments to DD with no luck.

Thanks in advance.
--
Sebastian Schuberth

Cygwin Configuration Diagnostics
Current System Time: Fri May 06 09:13:50 2005

Windows XP Professional Ver 5.1 Build 2600 Service Pack 2

Path:   C:\cygwin\usr\local\bin
C:\cygwin\bin
C:\cygwin\bin
C:\cygwin\usr\X11R6\bin

c:\Development\Libraries\Integrated_Performance_Primitives-v4.1\ia32_itanium\bin

c:\Development\Libraries\Integrated_Performance_Primitives-v4.1\ia32_itanium\bin\win32
c:\WINDOWS
c:\WINDOWS\system32
c:\WINDOWS\System32\Wbem
c:\Program Files\Common Files\Compuware\
c:\Program Files\Common Files\Compuware\NMShared
c:\Program Files\Common Files\GTK\2.0\bin
c:\Development\Libraries\IPP\ia32_itanium\bin
c:\Development\Libraries\IPP\ia32_itanium\bin\win32
d:\Program Files\Intel C++ Compiler\Compiler80\Ia32\Bin
d:\Program Files\Intel C++ Compiler\IDB80\Bin
d:\Program Files\doxygen\bin
C:\cygwin\bin
c:\Development\Libraries\The Image Debugger
c:\Development\Libraries\DirectX SDK\Utilities
d:\Program Files\Cg Compiler\bin
d:\Program Files\doxygen\bin
d:\Program Files\SSH Secure Shell

Output from C:\cygwin\bin\id.exe (nontsec)
UID: 45386(sschuber)GID: 10545(mkgroup-l-d)
0(root) 544(Administrators) 545(Users)
10545(mkgroup-l-d)

Output from C:\cygwin\bin\id.exe (ntsec)
UID: 45386(sschuber)GID: 10545(mkgroup-l-d)
0(root) 544(Administrators) 545(Users)
10545(mkgroup-l-d)

SysDir: C:\WINDOWS\system32
WinDir: C:\WINDOWS

HOME = `C:\cygwin\home\sschuber'
MAKE_MODE = `unix'
PWD = `/d/Filing'
USER = `sschuber'

ALLUSERSPROFILE = `C:\Documents and Settings\All Users'
AMIRA_LOCAL = `C:\Development\CVS-ZIB\amira'
AMIRA_NO_LICENSE_MESSAGE = `1'
AMIRA_ROOT = `D:\Program Files\Amira'
APPDATA = `C:\Documents and Settings\sschuber\Application Data'
CG_BIN_PATH = `D:\Program Files\Cg Compiler\bin'
CG_INC_PATH = `D:\Program Files\Cg Compiler\include'
CG_LIB_PATH = `D:\Program Files\Cg Compiler\lib'
COMMONPROGRAMFILES = `C:\Program Files\Common Files'
COMPUTERNAME = `XP-LSG-BERLIN2'
COMSPEC = `C:\WINDOWS\system32\cmd.exe'
CVS_RSH = `/bin/ssh'
DXSDK_DIR = `C:\Development\Libraries\DirectX SDK\'
FP_NO_HOST_CHECK = `NO'
HOMEDRIVE = `U:'
HOMEPATH = `\'
HOMESHARE = `\\ad-fs1\sschuber'
HOSTNAME = `XP-LSG-BERLIN2'
INCLUDE = 
`C:\Development\Libraries\Integrated_Performance_Primitives-v4.1\ia32_itanium\include'
INFOPATH = 
`/usr/local/info:/usr/info:/usr/share/info:/usr/autotool/devel/info:/usr/autotool/stable/info:'
INTEL_COMPILER80 = `D:\Program Files\Intel C++ Compiler\Compiler80'
INTEL_LICENSE_FILE = `C:\Program Files\Common Files\Intel\Licenses'
LIB = 
`C:\Development\Libraries\Integrated_Performance_Primitives-v4.1\ia32_itanium\lib;C:\Development\Libraries\Integrated_Performance_Primitives-v4.1\ia32_itanium\stublib'
LOGONSERVER = `\\AD-BER1'
MANPATH = 
`/usr/local/man:/usr/man:/usr/share/man:/usr/autotool/devel/man::/usr/ssl/man'
NUMBER_OF_PROCESSORS = `2'
OLDPWD = `/home/sschuber'
OS = `Windows_NT'
PATHEXT = `.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH'
PRINTER = `FinePrint'
PROCESSOR_ARCHITECTURE = `x86'
PROCESSOR_IDENTIFIER = `x86 Family 15 Model 3 Stepping 4, GenuineIntel'
PROCESSOR_LEVEL = `15'
PROCESSOR_REVISION = `0304'
PROGRAMFILES = `C:\Program Files'
PROMPT = `$P$G'
PS1 = `\[\033]0;\w\007
[EMAIL PROTECTED] \[\033[33m\w\033[0m\]
$ '
SESSIONNAME = `Console'
SHLVL = `1'
SYSTEMDRIVE = `C:'
SYSTEMROOT = `C:\WINDOWS'
TEMP = `C:\DOCUME~1\sschuber\LOCALS~1\Temp'
TERM = `cygwin'
TMP = `C:\DOCUME~1\sschuber\LOCALS~1\Temp'
USERDNSDOMAIN = `AD.MC.COM'
USERDOMAIN = `MERCURY'
USERNAME = `sschuber'
USERPROFILE = `C:\Documents and Settings\sschuber'
VISAGE_TEXMEM = `224M'
VS71COMNTOOLS = `C:\Program Files\Microsoft Visual Studio .NET 
2003\Common7\Tools\'
WINDIR = `C:\WINDOWS'
_ = `/usr/bin/cygcheck'
POSIXLY_CORRECT = `1'

HKEY_CURRENT_USER\Software\Cygnus Solutions
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2
  (default) = `/cygdrive'
  cygdrive flags = 0x0028
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/
  (default) = `C:\cygwin'
  flags = 

Re: DD converts LF - CR / LF

2005-05-06 Thread Brian Dessent
Sebastian Schuberth wrote:

 my mounts are all text mode, i.e. the Default Text File
 Type is DOS. Nevertheless, shouldn't

Yeah, that does seem a bit broken.  You can solve that with something
like the following:

--- dd.c.orig   2005-05-06 01:03:01.12500 -0700
+++ dd.c2005-05-06 01:00:07.265625000 -0700
@@ -136,8 +136,12 @@
 static int conversions_mask = 0;
 
 /* Open flags for the input and output files.  */
-static int input_flags = 0;
-static int output_flags = 0;
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+static int input_flags = O_BINARY;
+static int output_flags = O_BINARY;
 
 /* Status flags for what is printed to stderr.  */
 static int status_flags = 0;

-

It would be up to the coreutils maintainer to decide what to do about
this.  It could be handled in a number of ways.

Brian

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: DD converts LF - CR / LF

2005-05-06 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Brian Dessent on 5/6/2005 2:06 AM:
 Sebastian Schuberth wrote:
 
my mounts are all text mode, i.e. the Default Text File
Type is DOS. Nevertheless, shouldn't

dd if=test_unix.txt of=text.txt

create an exact copy of test_unix.txt? It seems DD doesn't open the
file in binary mode

I already tried several of the conv= arguments to DD with no luck.
 
 
 Yeah, that does seem a bit broken.  You can solve that with something
 like the following:
 
 --- dd.c.orig   2005-05-06 01:03:01.12500 -0700
 +++ dd.c2005-05-06 01:00:07.265625000 -0700
 @@ -136,8 +136,12 @@
  static int conversions_mask = 0;
  
  /* Open flags for the input and output files.  */
 -static int input_flags = 0;
 -static int output_flags = 0;
 +#ifndef O_BINARY
 +#define O_BINARY 0
 +#endif
 +
 +static int input_flags = O_BINARY;
 +static int output_flags = O_BINARY;
  
  /* Status flags for what is printed to stderr.  */
  static int status_flags = 0;
 
 -
 
 It would be up to the coreutils maintainer to decide what to do about
 this.  It could be handled in a number of ways.
 
 Brian
 

Predefining O_BINARY as the default input_flags and output_flags is a
stopgap measure.  While it is fine for other programs, such as od, to
always open in binary mode, I think that dd should be more flexible as it
already can specify so many other fine-tuning details.  It would be nicer
if iflag= and oflag= supported text and binary as supported flags (no-ops
on platforms where there is no difference).  Or maybe introduce new
keywords imode= and omode=, since it is not clear whether fcntl(fd,
F_SETFL, O_BINARY) will work, or whether modes must be set with
SET_MODE(fd, O_BINARY) from system.h.  Also, since O_BINARY and O_TEXT are
mutually exclusive (when O_BINARY is defined, you can't set the mode to
O_BINARY|O_TEXT), it would add a layer of complication to parsing iflags
to ensure that an incompatible mode is not chosen.

There is still the question on cygwin whether an unspecified text/binary
mode should always default to binary, or should default to the underlying
default for that particular mount.  Meanwhile, I noticed that cygwin
permits open(foo, O_RDWR | O_BINARY | O_TEXT), although I don't know
which of the two modes it chose; I think it should instead return EINVAL
like setmode(fd, O_BINARY | O_TEXT) does.

Here's a cygwin-local patch (against the 5.3.0 tarball) that adds imode=
and omode=, and which defaults to binary mode if unspecified.  I'll try to
release coreutils-5.3.0-6 to cygwin in the next week, including this fix
and a `mkdir -p' fix.  I'm cc'ing bug-coreutils in case it is decided to
be a good idea to use as a starting point for folding in upstream (of
course, it would also need NEWS and coreutils.texi documentation, and
updated to apply against CVS HEAD).

2005-05-06  Eric Blake  [EMAIL PROTECTED]

Add imode= and omode= to dd:
* src/dd.c (input_mode, output_mode, modes, set_fd_mode):
New variables and method.
(usage) [O_BINARY]: Document new args.
(scanargs) [O_BINARY]: Parse new imode and omode args.
(main): Set file mode.

- --
Life is short - so eat dessert first!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCe3DJ84KuGfSFAYARApZbAKCaEJJqwJ9I2UCXy5HarHMJXKHqSACdFNyN
XurPMrVxdRcFj+cqepzaSnw=
=m/hB
-END PGP SIGNATURE-
--- ../coreutils-5.3.0.orig/src/dd.c2004-11-22 07:14:44.0 -0700
+++ src/dd.c2005-05-06 07:17:15.073875000 -0600
@@ -139,6 +139,10 @@
 static int input_flags = 0;
 static int output_flags = 0;
 
+/* Mode flags for the input and output files.  */
+static int input_mode = 0;
+static int output_mode = 0;
+
 /* Status flags for what is printed to stderr.  */
 static int status_flags = 0;
 
@@ -237,6 +241,16 @@
   {, 0}
 };
 
+#if O_BINARY
+static struct symbol_value const modes[] =
+{
+  {binary,O_BINARY},
+  {text,  O_TEXT},
+  {,  0}
+};
+#endif
+
+
 /* Status, for status=  */
 static struct symbol_value const statuses[] =
 {
@@ -380,9 +394,23 @@
   fputs (_(\
   if=FILE read from FILE instead of stdin\n\
   iflag=FLAGS read as per the comma separated symbol list\n\
+), stdout);
+#if O_BINARY
+  fputs (_(\
+  imode=MODE  open input in MODE\n\
+), stdout);
+#endif
+  fputs (_(\
   obs=BYTES   write BYTES bytes at a time\n\
   of=FILE write to FILE instead of stdout\n\
   oflag=FLAGS write as per the comma separated symbol list\n\
+), stdout);
+#if O_BINARY
+  fputs (_(\
+  omode=MODE  open output in MODE\n\
+), stdout);
+#endif
+  fputs (_(\
   seek=BLOCKS skip BLOCKS obs-sized blocks at start of output\n\
   skip=BLOCKS skip BLOCKS ibs-sized blocks at start of input\n\
   status=noxfer   suppress 

Re: DD converts LF - CR / LF

2005-05-06 Thread Brian Dessent
Eric Blake wrote:

 Predefining O_BINARY as the default input_flags and output_flags is a
 stopgap measure.  While it is fine for other programs, such as od, to

Doesn't that overly complicate things?  Seems to me that whenever you
use dd you are interested in copying fixed record length data.  It just
doesn't seem very likely that you would actually ever want dd to operate
in text mode.

Brian

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: DD converts LF - CR / LF

2005-05-06 Thread Christopher Faylor
On Fri, May 06, 2005 at 07:27:39AM -0600, Eric Blake wrote:
There is still the question on cygwin whether an unspecified
text/binary mode should always default to binary, or should default to
the underlying default for that particular mount.

I think that dd should always default to binary unless directed not to
do so.  I don't think anyone would be expecting it to perform automatic
LF-CRLF translations for them since that is not a documented feature of
the utility.

Meanwhile, I noticed that cygwin permits open(foo, O_RDWR | O_BINARY
| O_TEXT), although I don't know which of the two modes it chose; I
think it should instead return EINVAL like setmode(fd, O_BINARY |
O_TEXT) does.

This behavior is consistent with windows, AFAICT.

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: DD converts LF - CR / LF

2005-05-06 Thread Christopher Faylor
On Fri, May 06, 2005 at 06:52:15AM -0700, Brian Dessent wrote:
Eric Blake wrote:

 Predefining O_BINARY as the default input_flags and output_flags is a
 stopgap measure.  While it is fine for other programs, such as od, to

Doesn't that overly complicate things?  Seems to me that whenever you
use dd you are interested in copying fixed record length data.  It just
doesn't seem very likely that you would actually ever want dd to operate
in text mode.

I was going to make the same observation but then I read the dd man page
and saw that it was already capable of padding newline-terminated records
so I guess this wouldn't be that big a stretch.

It certainly shouldn't do this by default, though, no matter what the
underlying mount says.

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/