Thread (3 messages) 3 messages, 2 authors, 2003-03-31

Re: opening files in the kernel.

From: Nir Tzachar <hidden>
Date: 2003-03-31 06:49:24

hello

well, i've written this simple solution.
it works well ( as dar as i tested it. )


static struct file *
objectfs_dentry_fopen(struct dentry *physical_dentry,int flags)
{
  int error = 0;
  int mode = (flags+1) & O_ACCMODE; /* taken from filp_open */

  struct file *filp = kmalloc(sizeof(struct file),GFP_KERNEL);
  TRACE(": entering\n");
  if (! filp){
    TRACE("could not allocate memory. ");
    filp = ERR_PTR(-ENOMEM);
    goto out;
  }

  error = init_private_file(filp, physical_dentry, mode);

  filp->f_flags = flags;
  dget(physical_dentry); /* so it wont disappear */


 out:
  TRACE(": leaving \n");
  return filp;

}



/* XXX HACK:
   * to close a file!!!
   */

static int
objectfs_file_close(struct file *filp)
{
   int error = 0;
   struct dentry *dentry;

   ASSERT(filp != NULL);
   dentry = filp->f_dentry;

   if (filp->f_op->flush){
     lock_kernel();
     error = filp->f_op->flush(filp);
     unlock_kernel();
   }

   atomic_dec(&filp->f_count);

   if (filp->f_op->release)
     error = filp->f_op->release(dentry->d_inode,filp);

   return error;

}







========================================================================
nir.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help