Subject: Re: /dev/null on nfs
To: Zdenek Salvet <salvet@nyx.dcs.muni.cz>
From: Mark Treacy <mark@labtam.oz.au>
List: current-users
Date: 06/14/1994 00:52:11
>> > Is it possible to have /dev/null on NFS-mounted filesystem ?
>> > With kernel of Jun 8 it gives me: 
>> > 
>> > $ ls -l /dev/null
>> > crw-rw-rw-  1 root  daemon    2,   2 Jun  9 12:00 /dev/null
>> > $ echo >/dev/null
>> > cannot create /dev/null: error 22
>> > $ cat </dev/null
>> > $
>> > 
>> > /dev resides on filesystem NFS-mounted from Solaris 2.3.
I had the same problem a few weeks ago.
In the shell the redirection becomes
	open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666)
In the kernel the O_TRUNC portion of the open is implemented
as a VOP_SETATTR() on the size.  SVR4 returns EINVAL when this (the setattr)
is done on a device.

Of the systems I have observed, the above open results in an rpc
create operation, systems using the bsd nfs instead issued a setattr.

Since quite a few things break when you can't redirect to /dev/null,
and I had no local filesystems to worry about, I used the following
hack to vn_open() as a temporary workaround.

*** vfs_vnops.c.old	Tue Jun 14 00:17:30 1994
--- vfs_vnops.c	Tue Jun 14 00:16:11 1994
***************
*** 102,107 ****
--- 102,111 ----
  				goto bad;
  			}
  			fmode &= ~O_CREAT;
+ #ifdef	DISKLESS
+ 			if (vp->v_type != VREG)
+ 				fmode &= ~O_TRUNC;
+ #endif
  		}
  	} else {
  		ndp->ni_cnd.cn_nameiop = LOOKUP;

------------------------------------------------------------------------------