---
name: "devname"
section: "3"
platform: "macos"
package: "Libc"
version: "1752.120.2"
release: "macOS 26.5"
platforms: ["freebsd", "macos"]
url: "https://new.carta.tech/devname"
---

# devname(3)

get device name

## NAME

**devname**, **devname\_r** – get device name

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<sys/stat.h\>**

**#include \<stdlib.h\>**

*char* *\**\

**devname**(*dev\_t dev*, *mode\_t type*);

*char* *\**\

**devname\_r**(*dev\_t dev*, *mode\_t type*, *char \*buf*, *int len*);

## DESCRIPTION

The **devname**() function returns a pointer to the name of the block or character device in “*/dev*” with a device number of *dev*, and a file type matching the one encoded in *type* which must be one of S\_IFBLK or S\_IFCHR. If no device matches the specified values, or no information is available, NULL is returned.

The **devname**() function uses a static buffer, which will be overwritten on subsequent calls. The **devname\_r**() functions takes a buffer and length as arguments to avoid this problem.

The traditional display for applications when no device is found is the string “??”.

## SEE ALSO

[stat(2)](/stat/2.md), [dev\_mkdb(8)](/dev_mkdb/8.md)

## HISTORY

The **devname**() function call appeared in 4.4BSD.
