DEVFS_CLEAN(9F) Kernel Functions for Drivers DEVFS_CLEAN(9F)

devfs_cleandestroy unreferenced devfs nodes and detach devices

#include <sys/fs/dv_node.h>

int
devfs_clean(dev_info_t *dip, char *devnm, uint_t flags);

private DDI function

This is a private function that is not part of the stable DDI. It may be removed or changed at any time.

dip
A pointer to the device's dev_info structure. Clean up is rooted at this device.
devnm
An optional character string used to restrict the devfs nodes list.
flags
The following flag is supported:
force clean of referenced directories, referenced empty directories are marked as stale to facilitate DR (dynamic reconfiguration)

The () function is used to clean up and detach devices from the system. While many device drivers may have one or more minor nodes created with ddi_create_minor_node(9F), some device drivers may have children devices with different device drivers attached. Each of these entries shows up in the file system of the global zone under /devices (see devfs(4FS)). These nodes are referred to as a devfs nodes (dv_node).

devfs caches unreferenced devfs nodes to speed up the performance of ls, find, etc. The () function is used to cleanup cached nodes to reclaim memory as well as to facilitate device removal (devfs nodes reference dev_info nodes, which prevents driver from detaching).

The () function starts searching the tree rooted at dip. All directories encountered are recursed through. If devnm is not NULL, then it is used to limit the nodes that it searches. It compares the name of the node, ignoring any part of the device's name that corresponds to a minor node. If devnm has been specified, then cleanup stops immediately after a busy devfs node has been encountered.

Not all nodes may be cleaned up when a driver calls the () function. However, this is a non-fatal situation. Callers should continue trying to offline devices as many holds from userland processes may exist due to device contracts which will be released when the device is offlined.

If a shell parks in a /devices directory, the devfs node will be held, preventing the corresponding device to be detached. This would be a denial of service against DR (dynamic reconfiguration). To prevent this, DR code calls () with the DV_CLEAN_FORCE flag.

This function may be called in user or kernel context.

The devfs_clean() function always succeeds and returns zero.

devfs(4FS)

July 26, 2016 OmniOS