Technical article 105206

My mdevice file is disappearing.

OpenServer 5.0.0OpenServer 5.0.2

Written · Last revised

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 TMPDIR
or
# TMPDIR=[directory in root filesystem]; export TMPDIR
2. 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)

From the Xinuos technical article database, record 105206. Reproduced with permission. The original is at www.sco.com/ta/105206, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.