Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>1) How does virtual file system(VFS) get to know on which file system the underline file resides?</p> </blockquote> <p>You have to specify the file you're trying to open by its <strong>full</strong> pathname (or the <em>current</em> working directory).<br> So by traversing this directory path backwards, the first match (the deepest path) to a mount point will provide the mounted filesystem, type of filesystem and the device.</p> <p>Each filesystem provides this information when it is mounted and is saved in the mount tables.<br> You can view this (current state) information using the <code>mount</code> command.</p> <blockquote> <p>2) How does it then calls the file_open or open function of that particular filesystem to open file.</p> </blockquote> <p>Once the filesystem is known, the <code>ops</code> structure for that fs is retrieved, and the <code>open()</code> entrypoint can be called.</p> <blockquote> <p>1) What does actually cdev_add() do? in terms of registering a device to the kernel.</p> </blockquote> <p>Driver registration (e.g <code>cdev_init()</code> for a char device) installs the driver's <code>ops</code> structure which lists the entrypoints of functions that the driver can perform.<br> <code>cdev_add()</code> notifies the kernel that the driver can control a specific instance of that char device type. That device instance is assigned a minor number that associates the device name in <code>/dev</code> to state information in the driver.<br> Note that device types other than char (such a network or platform (bus) devices) belong to a different subsystem, and use different registration procedures. </p> <blockquote> <p>2) Registering a device to the kernel means?</p> </blockquote> <p>Access to that device is now enabled. </p> <blockquote> <p>3) How does a open(/dev/mynull, O_RONLY); called on a device file actually calls the open function of driver which is mapped while initializing the device by calling routine cdev_init(&amp;c_dev, &amp;pugs_fops); ?</p> </blockquote> <p>The driver's <code>init()</code> routine should only be called once when the driver is loaded. This routine should probe for the existence and operational state of all instances of the device. Resources such as interrupt lines, DMA channels and I/O port and/or memory space should be acquired. The driver registers its <code>ops</code> structure with kernel. The driver registers each instance of the device with kernel. </p> <p>The <code>open()</code> call in userspace is handled by the C library. The <code>/dev</code> device name is translated to the device major number (which identifies which device subsystem or class, e.g <em>tty</em> or <em>audio</em>, has to process the request) and the minor number (which identifies which device driver to use and which instance of the device is accessed). The processor is switched to supervisor mode so that the kernel driver's <code>open()</code> routine can be called, which is retrieved from the driver's <code>ops</code> structure. For a bit more on the <code>ops</code> structure see this <a href="https://stackoverflow.com/questions/12917198/linux-device-driver-program-where-the-program-starts/12923107#12923107">other answer</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload