Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Regarding cahrecter devices driver

    Hi i am new to the driver domain i went through basic book The Linux Kernel Module Programming Guide by Peter Jay Salzman ,Michael Burian ,Ori Pomerantz and i got struck in one place that is cherecter device driver.

    can any one explain me why i need to do this for all driver programming.please guide me for writing a driver program.

    4.1.1. The file_operations Structure
    The file_operations structure is defined in linux/fs.h, and holds pointers to functions defined by the
    driver that perform various operations on the device. Each field of the structure corresponds to the address of
    some function defined by the driver to handle a requested operation.
    For example, every character driver needs to define a function that reads from the device. The file_operations
    structure holds the address of the module's function that performs that operation. Here is what the definition
    looks like for kernel 2.6.5:
    struct file_operations {
    struct module *owner;
    loff_t(*llseek) (struct file *, loff_t, int);
    ssize_t(*read) (struct file *, char __user *, size_t, loff_t *);
    ssize_t(*aio_read) (struct kiocb *, char __user *, size_t, loff_t);
    ssize_t(*write) (struct file *, const char __user *, size_t, loff_t *);
    ssize_t(*aio_write) (struct kiocb *, const char __user *, size_t,
    int (*readdir) (struct file *, void *, filldir_t);
    unsigned int (*poll) (struct file *, struct poll_table_struct *);
    int (*ioctl) (struct inode *, struct file *, unsigned int,
    unsigned long);
    int (*mmap) (struct file *, struct vm_area_struct *);
    int (*open) (struct inode *, struct file *);
    int (*flush) (struct file *);
    int (*release) (struct inode *, struct file *);
    int (*fsync) (struct file *, struct dentry *, int datasync);
    int (*aio_fsync) (struct kiocb *, int datasync);
    int (*fasync) (int, struct file *, int);
    int (*lock) (struct file *, int, struct file_lock *);
    ssize_t(*readv) (struct file *, const struct iovec *, unsigned long,
    loff_t *);
    ssize_t(*writev) (struct file *, const struct iovec *, unsigned long,
    loff_t *);
    ssize_t(*sendfile) (struct file *, loff_t *, size_t, read_actor_t,
    void __user *);
    ssize_t(*sendpage) (struct file *, struct page *, int, size_t,
    loff_t *, int);
    unsigned long (*get_unmapped_area) (struct file *, unsigned long,
    unsigned long, unsigned long,
    unsigned long);
    Some operations are not implemented by a driver. For example, a driver that handles a video card won't need
    to read from a directory structure. The corresponding entries in the file_operations structure should be set to
    There is a gcc extension that makes assigning to this structure more convenient. You'll see it in modern
    drivers, and may catch you by surprise. This is what the new way of assigning to the structure looks like:


  2. #2
    Linux Newbie
    Join Date
    Mar 2008
    This is a good book for studying device driver programming.
    Linux Device Drivers, Third Edition []

  3. #3
    please give me a solution

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts