From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 12 May 2015 16:52:35 +0100 Message-ID: From: Charles Forsyth To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=f46d043c7f0aaf49220515e47ba9 Subject: Re: [9fans] on cp /fd/1 /fd/0 Topicbox-Message-UUID: 528e702c-ead9-11e9-9d60-3106f5b1d025 --f46d043c7f0aaf49220515e47ba9 Content-Type: text/plain; charset=UTF-8 On 12 May 2015 at 12:56, Daniel Bastos wrote: > % cp /fd/1 /fd/0 > cp: can't open /fd/1: '/fd/1' inappropriate use of fd > > I can't open it for reading, but I could open it for writing. Why can't I > open it for reading? > The file open on file descriptor 1 wasn't itself opened for reading, only writing. Check with ls -l /fd/1: h% ls -l /fd/0 /fd/1 --r-------- d 0 bootes bootes 0 Jul 2 2014 /fd/0 ---w------- d 0 bootes bootes 0 Jul 2 2014 /fd/1 The "bootes" is wrong, though: the driver should use up->user (not hostowner, or even the owner of the underlying file). You'll notice that someone else had /fd/1 with both r and w, in which case cp /fd/1 /fd/0 would instead have complained about /fd/0 since /fd/1 could be opened, but /fd/0 can't be written. --f46d043c7f0aaf49220515e47ba9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On 12 May 2015 at 12:56, Daniel Bastos <dbastos@toledo.com>= wrote:
% cp /fd/1 /fd/0
cp: can= 't open /fd/1: '/fd/1' inappropriate use of fd

I can't open it for reading, but I could open it for writing. = Why can't I open it for reading?

The file open on file descriptor 1 wasn't= itself opened for reading, only writing. Check with ls -l /fd/1:

h% ls -l /fd/0 /fd/1<= /div>
--r-------- d 0 bootes bootes 0 Jul =C2=A02= =C2=A02014 /fd/0
---w------- d 0 bootes bo= otes 0 Jul =C2=A02 =C2=A02014 /fd/1

The "boot= es" is wrong, though: the driver should use up->user (not hostowner= , or even the owner of the underlying file).
You'll notice th= at someone else had /fd/1 with both r and w, in which case cp /fd/1 /fd/0 w= ould instead have complained about /fd/0
since /fd/1 could be ope= ned, but /fd/0 can't be written.
--f46d043c7f0aaf49220515e47ba9--