LLAPI_IOCTL(3)

NAME
llapi_ioctl - call ioctl() with possible command remapping

SYNOPSIS
#include <lustre/lustreapi.h>

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

DESCRIPTION
llapi_ioctl() calls the ioctl(2) system call with the supplied arguments. However, if the ioctl() returns 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
llapi_ioctl() typically returns:

0   on success in most cases

<0  a negative value on failure and sets errno. 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
#include <lustre/lustreapi.h>

int main(int argc, char *argv[])
{
        unsigned long group = 1234;
        int rc, fd;

        fd = open(argv[1], O_RDONLY);
        if (rc < 0) {
                fprintf(stderr, "error opening file '%s': %s\n",
                        argv[1], strerror(errno));
                return -1;
        }

        rc = llapi_ioctl(fd, LL_IOC_GROUP_LOCK, &group);
        if (rc < 0) {
                fprintf(stderr, "%s: ioctl error: %s\n",
                        argv[1], strerror(errno));
                return rc;
        }

        printf("%s: locked with group %lu\n", argv[1], group);
        return 0;
}

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

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