OS Manuals

llapi_ioctl(3)

llapi_ioctl - call ioctl() with possible command remapping

LLAPI_IOCTL(3) Lustre Library Functions LLAPI_IOCTL(3)

llapi_ioctl - call ioctl() with possible command remapping

#include <lustre/lustreapi.h>
#include <linux/lustre/lustre_ioctl.h>
int llapi_ioctl(int fd, unsigned int cmd, void *buf);

llapi_ioctl() calls the 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.

llapi_ioctl() typically returns:

>=0
on success, the value returned by the ioctl(2).
if fd is negative, without calling ioctl(2). errno is also set to EBADF.
-1
on failure, with errno set by 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.

#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; }

llapi_ioctl() is part of the lustre(7) user application interface library since release 2.16.0

ioctl(2), lustre(7), lustreapi(7)

2026-08-23 Lustre User API

lustre 2.17.59-r1 · enterprise-packages · ingested 2026-10-02