.TH LLAPI_IOCTL 3 2026-08-23 "Lustre User API" "Lustre Library Functions" .SH NAME llapi_ioctl \- call ioctl() with possible command remapping .SH SYNOPSIS .nf .B #include .B #include .PP .BI "int llapi_ioctl(int " fd ", unsigned int " cmd ", void *" buf ");" .fi .SH DESCRIPTION .B llapi_ioctl() calls the .BR ioctl (2) system call with the supplied arguments. However, if the ioctl() fails and sets errno to .B ENOTTY (no such ioctl) then if .I cmd has been remapped from an older ioctl command number the ioctl() call will be retried with the old ioctl command number. .SH RETURN VALUES .B llapi_ioctl() typically returns: .TP >=0 on success, the value returned by the .BR ioctl (2). .TP \-EBADF if .I fd is negative, without calling .BR ioctl (2). .B errno is also set to .BR EBADF . .TP \-1 on failure, with .B errno set by .BR ioctl (2). .BR 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. .PP Due to the variety of ioctl commands, it may return different values and errno as appropriate for the .IR fd , .I cmd number, and argument .I buf passed. .SH EXAMPLES .nf #include #include #include #include #include #include #include #include \& int main(int argc, char *argv[]) { char lov_name[MAX_OBD_NAME]; int rc, fd; \& if (argc != 2) { fprintf(stderr, "Usage: %s \\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; } .fi .SH AVAILABILITY .B llapi_ioctl() is part of the .BR lustre (7) user application interface library since release 2.16.0 .\" Added in commit v2_15_55-173-g594b780062 .SH SEE ALSO .BR ioctl (2), .BR lustre (7), .BR lustreapi (7)