man.bsd.lv manual page server

Manual Page Search Parameters

GETDEVPATH(3) Library Functions Manual GETDEVPATH(3)

getdevpathretrieve device path given name or label

library “libc”

#include <sys/types.h>
#include <fstab.h>

char *
getdevpath(const char *devname, int flags);

() takes a device name such as “da0”, a device identifier such as “V21JYQ0G”, a device path beginning with “/” or “.”, or a device label from one of the devtab files, and returns an allocated path which may be used to open the device.

Device names prefixed with “/” or “.” are assumed to be device paths and an exact allocated copy is simply returned. However, flags may modify the operation.

Device names specified with a type prefix, such as “serno:V21JYQ0G” are assumed to be typed device identifiers and are directly translated to the appropriate path in /dev, for example “/dev/serno/V21JYQ0G”.

Device labels are directly checked against /dev first, using (), and if not found will be searched for in one of the devtab files.

The following flags may be passed to ():

Normally, getdevpath() returns a high level devfs path which often winds up being a softlink in devfs. If this flag is specified and the device path represents a softlink, getdevpath() will do a readlink(2) and return the actual raw device path instead. If the device path cannot be lstat()'d this option will return NULL.

getdevpath() returns a pointer to a malloc()'d path on success and NULL on failure. If a failure occurs errno will be set appropriately.

Note that a malloc()'d path may be returned even if it does not exist in the filesystem. Callers should not assume that the device is accessible unless they can also open the device.

devfs(5), devtab(5), fstab(5)

The getdevpath function appeared in DragonFly 2.3.

July 10, 2009 DragonFly-5.6.1