Whamcloud - gitweb
LU-18217 build: Ensure LINUX_RELEASE is defined
[fs/lustre-release.git] / lustre / doc / llapi_ioctl.3
1 .TH LLAPI_IOCTL 3 2024-08-27 "Lustre User API" "Lustre Library Functions"
2 .SH NAME
3 llapi_ioctl \- call ioctl() with possible command remapping
4 .SH SYNOPSIS
5 .nf
6 .B #include <lustre/lustreapi.h>
7 .PP
8 .BI "int llapi_ioctl(int " fd ", unsigned int " cmd ", void *" buf ");"
9 .fi
10 .SH DESCRIPTION
11 .B llapi_ioctl()
12 calls the
13 .BR ioctl (2)
14 system call with the supplied arguments.  However, if the ioctl() returns
15 .B ENOTTY
16 (no such ioctl) then if
17 .I cmd
18 has been remapped from an older ioctl command number the ioctl() call will
19 be retried with the old ioctl command number.
20 .SH RETURN VALUES
21 .B llapi_ioctl()
22 typically returns:
23 .TP
24 0
25 on success in most cases
26 .TP
27 <0
28 a negative value on failure and sets
29 .BR errno .
30 Due to the variety of ioctl commands, it may return different values
31 and errno as appropriate for the
32 .IR fd ,
33 .I cmd
34 number, and argument
35 .I buf
36 passed.
37 .SH EXAMPLES
38 .nf
39 #include <lustre/lustreapi.h>
40 \&
41 int main(int argc, char *argv[])
42 {
43         unsigned long group = 1234;
44         int rc, fd;
45 \&
46         fd = open(argv[1], O_RDONLY);
47         if (rc < 0) {
48                 fprintf(stderr, "error opening file '%s': %s\\n",
49                         argv[1], strerror(errno));
50                 return -1;
51         }
52 \&
53         rc = llapi_ioctl(fd, LL_IOC_GROUP_LOCK, &group);
54         if (rc < 0) {
55                 fprintf(stderr, "%s: ioctl error: %s\\n",
56                         argv[1], strerror(errno));
57                 return rc;
58         }
59 \&
60         printf("%s: locked with group %lu\\n", argv[1], group);
61         return 0;
62 }
63 .fi
64 .SH AVAILABILITY
65 .B llapi_ioctl()
66 is part of the
67 .BR lustre (7)
68 user application interface library since release 2.16.0
69 .\" Added in commit v2_15_55-173-g594b780062
70 .SH SEE ALSO
71 .BR ioctl (2),
72 .BR lustre (7),
73 .BR lustreapi (7)