Bug 49321 - rcp to /dev/null with devfs enabled causes error
rcp to /dev/null with devfs enabled causes error
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: rsh (Show other bugs)
7.1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Phil Knirsch
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-07-17 19:43 EDT by Need Real Name
Modified: 2015-03-04 20:09 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-07-20 13:37:46 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2001-07-17 19:43:24 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.77 [en] (X11; U; Linux 2.4.2-2 i686)

Description of problem:
When rcp'ing a file to /dev/null, an error is caused because the devfs
implementation of /dev/null doesn't seem to allow ftruncate() to be called
on it.  rcp calls ftruncate() after the end of a transfer (on the
receiver).  This was never a problem before using a non-devfs /dev/null. 

Our batch queueing software copies the stdout and stderr files back to the
submitting host using rcp.  Many of our scripts copy these to /dev/null
when they are not needed.  Hence the problem.  Because an error is thrown,
there is a delay of ~30 at the end of every batch job.

As a quick fix, I modified rcp.c and recompiled. This worked but I'm
guessing it would be better to fix devfs to allow ftruncate calls. 



How reproducible:
Always

Steps to Reproduce:
[pedretti@foo ~]$ rcp filename foo:/dev/null




	

Actual Results:  rcp: can't truncate /dev/null: Permission denied

Expected Results:  No error messages

Additional info:

My fix, beginning line 883 in rcp.c:

if (ftruncate(ofd, size)) {
    /* fix to avoid calling ftruncate() on /dev/null */
    if (strncmp(np, "/dev/null", 9) != 0) {
        error("rcp: can't truncate %s: %s\n", 
            np, strerror(errno));
            wrerr = DISPLAYED;
    }
}
Comment 1 Phil Knirsch 2002-01-30 07:58:22 EST
I agree. On the other hand, according to the 'official' specification for
ftruncate the behaviour of it is unspecified for anything but regular files or
shared memory segments, so an app must not rely on the fact that it does
anything reasonable on anything else.

So i'll fix it a little more thoroughly than you did, but it needs to be fixed
in rcp as it is broken there.

The next version (0.17-6) will have the fix included. Should be available via
rawhide real soon now (in the next couple of days).

Read ya, Phil

Note You need to log in before you can comment on or make changes to this bug.