Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

getdevmajor(3) [netbsd man page]

GETDEVMAJOR(3)						   BSD Library Functions Manual 					    GETDEVMAJOR(3)

NAME
getdevmajor -- get block or character device major number LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdlib.h> #include <sys/stat.h> devmajor_t getdevmajor(const char *name, mode_t type); DESCRIPTION
The getdevmajor() function returns the major device number of the block or character device specified by name and a file type matching the one encoded in type which must be one of S_IFBLK or S_IFCHR. RETURN VALUES
If no device matches the specified values, no information is available, or an error occurs, NODEVMAJOR is returned and errno is set to indi- cate the error. EXAMPLES
To retrieve the major number for pty(4) slave devices (aka pts devices): #include <stdlib.h> #include <sys/stat.h> devmajor_t pts; pts = getdevmajor("pts", S_IFCHR); To retrieve the major numbers for the block and character wd(4) devices: #include <stdlib.h> #include <sys/stat.h> devmajor_t c, b; c = getdevmajor("wd", S_IFCHR); b = getdevmajor("wd", S_IFBLK); ERRORS
The getdevmajor() function may fail and set errno for any of the errors specified for the library functions malloc(3) and sysctlbyname(3). In addition, the following errors may be reported: [EINVAL] The value of the type argument is not S_IFCHR or S_IFBLK. [ENOENT] The named device is not found. SEE ALSO
stat(2), devname(3), malloc(3), sysctlbyname(3) HISTORY
The getdevmajor() function call appeared in NetBSD 3.0. BSD
January 20, 2009 BSD

Check Out this Related Man Page

MKNOD(8)						    BSD System Manager's Manual 						  MKNOD(8)

NAME
mknod -- build special file SYNOPSIS
mknod name mknod name [b | c] major minor [owner:group] DESCRIPTION
The mknod utility is deprecated on modern FreeBSD systems. The mknod utility creates device special files. To make nodes manually, the arguments are: name Device name, for example /dev/da0 for a SCSI disk or /dev/pts/0 for pseudo-terminals. b | c Type of device. If the device is a block type device such as a tape or disk drive which needs both cooked and raw special files, the type is b. All other devices are character type devices, such as terminal and pseudo devices, and are type c. major The major device number is an integer number which tells the kernel which device driver entry point to use. minor The minor device number tells the kernel which subunit the node corresponds to on the device; for example, a subunit may be a file system partition or a tty line. owner:group The owner group operand pair is optional, however, if one is specified, they both must be specified. The owner may be either a numeric user ID or a user name. If a user name is also a numeric user ID, the operand is used as a user name. The group may be either a numeric group ID or a group name. Similar to the user name, if a group name is also a numeric group ID, the operand is used as a group name. Major and minor device numbers can be given in any format acceptable to strtoul(3), so that a leading '0x' indicates a hexadecimal number, and a leading '0' will cause the number to be interpreted as octal. The mknod utility can be used to recreate deleted device nodes under a devfs(5) mount point by invoking it with only a filename as an argu- ment. Example: mknod /dev/cd0 where /dev/cd0 is the name of the deleted device node. COMPATIBILITY
The chown(8)-like functionality is specific to FreeBSD. As of FreeBSD 4.0, block devices were deprecated in favour of character devices. As of FreeBSD 5.0, device nodes are managed by the device file system devfs(5), making the mknod utility superfluous. As of FreeBSD 6.0 device nodes may be created in regular file systems but such nodes cannot be used to access devices. SEE ALSO
mkfifo(1), mknod(2), devfs(5), chown(8) HISTORY
A mknod utility appeared in Version 6 AT&T UNIX. BSD
January 31, 2010 BSD
Man Page