Bug 49321 - rcp to /dev/null with devfs enabled causes error
Summary: rcp to /dev/null with devfs enabled causes error
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: rsh   
(Show other bugs)
Version: 7.1
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Phil Knirsch
QA Contact: David Lawrence
Depends On:
TreeView+ depends on / blocked
Reported: 2001-07-17 23:43 UTC by Need Real Name
Modified: 2015-03-05 01:09 UTC (History)
2 users (show)

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

Attachments (Terms of Use)

Description Need Real Name 2001-07-17 23:43:24 UTC
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:

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 12:58:22 UTC
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.