LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   How to pass IOCTL arguments from usespace ioctl call (https://www.linuxquestions.org/questions/linux-kernel-70/how-to-pass-ioctl-arguments-from-usespace-ioctl-call-605110/)

devkpict 12-06-2007 11:50 PM

How to pass IOCTL arguments from usespace ioctl call
 
Hi All,

I am calling ext3_ioctl, using ioctl() call in userspace,

I need guidence for passing arguments with ioctl() from

userspace.

osor 12-07-2007 06:45 PM

Have you looked at man 2 ioctl? What exactly do you want to do? Something like the following?
Code:

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

#include <sys/ioctl.h>
#include <linux/fs.h>
#include <linux/ext3_fs.h>

int main(int argc, char *argv[])
{
        int fd, flags = EXT3_SYNC_FL;
        if(argc != 2) {
                fprintf(stderr, "Usage: %s filename\n", argv[0]);
                exit(EXIT_FAILURE);
        }
        if((fd = open(argv[1], O_RDWR)) == -1) {
                perror("open");
                exit(EXIT_FAILURE);
        }
        if(ioctl(fd, EXT3_IOC_SETFLAGS, &flags) == -1) {
                perror("ioctl");
                close(fd);
                exit(EXIT_FAILURE);
        }
        exit(EXIT_SUCCESS);
}



All times are GMT -5. The time now is 08:32 PM.