Bug 49321 - rcp to /dev/null with devfs enabled causes error
Summary: rcp to /dev/null with devfs enabled causes error
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: rsh
Version: 7.1
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Phil Knirsch
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
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:
Clone Of:
Environment:
Last Closed: 2001-07-20 17:37:46 UTC
Embargoed:


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:
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 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.