Listing 1. Telling the Kernel to Mount the Filesystem Internally
  
static int get_mount (void)
{
   struct vfsmount *mnt;
   spin_lock (&mount_lock);
   if (pcihpfs_mount) {
       mntget(pcihpfs_mount);
       ++pcihpfs_mount_count;
       spin_unlock (&mount_lock);
       goto go_ahead;
   }
   spin_unlock (&mount_lock);
   mnt = kern_mount (&pcihpfs_fs_type);
   if (IS_ERR(mnt)) {
       err ("could not mount the fs...
            erroring out!\n");
       return -ENODEV;
   }
   spin_lock (&mount_lock);
   if (!pcihpfs_mount) {
       pcihpfs_mount = mnt;
       ++pcihpfs_mount_count;
       spin_unlock (&mount_lock);
       goto go_ahead;
   }
   mntget(pcihpfs_mount);
   ++pcihpfs_mount_count;
   spin_unlock (&mount_lock);
   mntput(mnt);
go_ahead:
   dbg("pcihpfs_mount_count = %d\n",
       pcihpfs_mount_count);
   return 0;
}
  
  
  
  
  
  
  
  
  
    Copyright © 1994 - 2018 Linux Journal.  All rights reserved.