[CFR] devfs improvements

Jaakko Heinonen jh at FreeBSD.org
Mon Jul 19 15:00:50 UTC 2010


I have been working on some devfs improvements and I am now posting the
patch for wider review and testing. Especially testing from people using
multiple devfs mounts and/or symbolic links would be useful.

The patch:


Notable changes:

- Automatically remove empty directories.
- Allow user created symbolic links to cover device files and
  directories if the device file appears after the link creation.
- It's now possible to report if the device file already exists or is
  invalid to make_dev_credf(9) and make_dev_p(9) callers. There
  is a new flag MAKEDEV_CHECKNAME to indicate that the caller is
  prepared to handle such error. If the flag is not specified and the
  device name is invalid, a panic will occur. This code is not yet
  enabled because there are some driver issues which need to be sorted
  out before. (See "#ifdef notyet" in make_dev_credv().) 

In addition the patch should fix these bugs:

- kern/114057
- fstat(2) could return stale information through open file descriptors.

My main motivation for these changes was erratic handling of duplicate
and invalid device names. For example currently you can crash the system
through geom_label by inserting a specially crafted CD. Driver bugs
causing duplicate device registrations weren't detected either.

Most of the ideas implemented in the patch are from Kostik Belousov.
Special thanks for him providing help and reviews during the

Additional patches:

A patch for GEOM to convert g_dev_taste() to use make_dev_p() with
MAKEDEV_CHECKNAME flag instead of make_dev().


Enable panicking on invalid device names:



More information about the freebsd-current mailing list