LLAPI\_IOCTL(3) Lustre Library Functions LLAPI\_IOCTL(3)

# [NAME](#NAME)

llapi\_ioctl - call ioctl() with possible command remapping

# [SYNOPSIS](#SYNOPSIS)

```
#include <lustre/lustreapi.h>
#include <linux/lustre/lustre_ioctl.h>
```

```
int llapi_ioctl(int fd, unsigned int cmd, void *buf);
```

# [DESCRIPTION](#DESCRIPTION)

**llapi\_ioctl()** calls the [**ioctl**(2)](/man/enterprise-packages/lustre/ioctl.2) system call with the supplied arguments. However, if the ioctl() fails and sets errno to **ENOTTY** (no such ioctl) then if *cmd* has been remapped from an older ioctl command number the ioctl() call will be retried with the old ioctl command number.

# [RETURN VALUES](#RETURN_VALUES)

**llapi\_ioctl()** typically returns:

&gt;=0

on success, the value returned by the [**ioctl**(2)](/man/enterprise-packages/lustre/ioctl.2).

[-EBADF](#EBADF)

if *fd* is negative, without calling [**ioctl**(2)](/man/enterprise-packages/lustre/ioctl.2). **errno** is also set to **EBADF**.

-1

on failure, with **errno** set by [**ioctl**(2)](/man/enterprise-packages/lustre/ioctl.2). Note: If ioctl command is not supported, errno will be set to ENOTTY. For this specific case, llapi\_ioctl() may retry calling ioctl again and return its result.

Due to the variety of ioctl commands, it may return different values and errno as appropriate for the *fd*, *cmd* number, and argument *buf* passed.

# [EXAMPLES](#EXAMPLES)

```
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <lustre/lustreapi.h>
#include <linux/lustre/lustre_ioctl.h>
int main(int argc, char *argv[])
{


        char lov_name[MAX_OBD_NAME];


        int rc, fd;


        if (argc != 2) {


                fprintf(stderr, "Usage: %s <filename>\n", argv[0]);


                return 1;


        }


        fd = open(argv[1], O_RDONLY);


        if (fd < 0) {


                fprintf(stderr, "error opening file '%s': %s\n",


                        argv[1], strerror(errno));


                return 1;


        }


        rc = llapi_ioctl(fd, OBD_IOC_GETDTNAME, lov_name);


        if (rc < 0) {


                fprintf(stderr, "%s: ioctl error: %s\n",


                        argv[1], strerror(errno));


                return 1;


        }


        printf("%s: LOV device name %s\n", argv[1], lov_name);


        return 0;
}
```

# [AVAILABILITY](#AVAILABILITY)

**llapi\_ioctl()** is part of the [**lustre**(7)](/man/enterprise-packages/lustre/lustre.7) user application interface library since release 2.16.0

# [SEE ALSO](#SEE_ALSO)

[**ioctl**(2)](/man/enterprise-packages/lustre/ioctl.2), [**lustre**(7)](/man/enterprise-packages/lustre/lustre.7), [**lustreapi**(7)](/man/enterprise-packages/lustre/lustreapi.7)

2026-08-23 Lustre User API

---

Document: llapi_ioctl(3) from lustre 2.17.59-r1 (Chainguard OS)
Source: https://github.com/lustre/lustre-release
