Problem
My mdevice file disappears after I reconfigure, remove, or update some types of drivers, whether I am using netconfig or other utilities.
Cause
The mdevice file is accidentally removed during the execution of the /etc/conf/bin/idmaster program. The removal occurs due to the combination of the following two circumstances:
1. The TMPDIR environment variable is set to a directory in a non-root filesystem.
2. The idinstall program is run to update or remove driver information from the kernel.
When the idinstall program is called (usually from a network
or smartboard installation program) it will run idmaster, a small
program that updates the mdevice file. The idmaster program will
first back up the mdevice file by executing the tempnam(S) system
call.The tempnam() system call will back up a file into a temporary directory. If the environment variable TMPDIR exists, then tempnam() will use the pathname in TMPDIR to store the file.
After the drivers are removed, the idmaster program will then
remove the original mdevice file and attempt to link(S) the saved
file back to /etc/conf/cf.d/mdevice. Since a hard link cannot
be across filesystems, the link will only succeed if the TMPDIR
variable is a directory in the root filesystem. If the TMPDIR
variable is in a non-root filesystem, the link attempt will fail
silently and the user will be left with a non-existent mdevice file. Solution
In order to prevent the above problem from occurring again, there are two separate workarounds, depending on your preference for a global resolution (which is easier, but restricts setting TMPDIR) or a local resolution (which is more complex, but allows TMPDIR to be set to a non-root filesystem):
1. Global resolution:Make sure the TMPDIR environment variable is either empty or set to a directory in the root filesystem:
# TMPDIR=; export TMPDIRor# TMPDIR=[directory in root filesystem]; export TMPDIR2. Local resolution:Change the "idmaster" program so it will temporarily unset the
TMPDIR environment variable. You can do this by moving the
idmaster binary to another file (in our example, naming the new
file "idmaster.real"), then making idmaster run a shell script
that unsets TMPDIR and then calls the original binary with the
appropriate arguments:# cd /etc/conf/bin
# mv idmaster idmaster.real--------Save the following as "idmaster"-------
:
TMPDIR=; export TMPDIR
/etc/conf/bin/idmaster.real $*
-----------------------------------------------Make sure both "idmaster" and "idmaster.real" are executable.
NOTE: Once you have experienced the problem, there is a chance that
you can bring back the deleted mdevice file. Look in the
/etc/.last_dev_del directory; the idinstall program may have
saved a copy of mdevice there before it was removed from
/etc/conf/cf.d. See also
mdevice(F), idinstall(ADM)