Skip to contentSkip to conversation

kernel 2.6.3 writring on device ?

Question Sébastien BOMBAL 1 participant 1 message Jun 25, 2004

lore
Share & tools
lore
#0 lore raw

Hi,

I have a little problem with a module.

I am trying to write a cryptoloop like. It is working, and I crypt the I/O.

Then I had a IOCTL in order to store the algorythm and cipher used in the beginning of the backend device to a fixed offset.

I get from the user land a file descriptor, and I get the file structure from fget().

tmcrypt represents a structure of the device which crypts, and cryptonit_backing_file is the file structure for the backend device.

The problem is : the kernel freeze jut after the end of the IOCTL. (from the log..). But If I comment the line of the write operation, everythning is normal. Any ideas ?

Thanks for your help.

Regards.

/** FIXME **/

  tmpcrypt->cryptonit_backend_file->f_pos = 0;

  if(IS_RDONLY(tmpcrypt->cryptonit_backend_file->f_dentry->d_inode) 
     || (NULL == tmpcrypt->cryptonit_backend_file->f_op->write)){
    err = -EACCES;
    printk (KERN_ERR "cryptonit : Inode is readonly ?\n");
    goto out_free_tfm;
  }

  printk(KERN_DEBUG "cryptonit : not readonly\n");

  err = get_write_access(tmpcrypt->cryptonit_backend_file->f_dentry->d_inode);
  if (err){
    printk (KERN_ERR "cryptonit : cryptonit cannot get_write_access\n");
    goto out_free_tfm;
  }	

  printk(KERN_DEBUG "cryptonit : down semaphore backing file\n");  
  down(&tmpcrypt->cryptonit_backend_file->f_mapping->host->i_sem);

err =
tmpcrypt->cryptonit_backend_file->f_op->write(tmpcrypt->cryptonit_backend_file,

						      "test", 4,
						      &tmpcrypt->cryptonit_backend_file->f_pos);
  printk(KERN_DEBUG "cryptonit : up semaphore backing file\n");  
  up(&tmpcrypt->cryptonit_backend_file->f_mapping->host->i_sem);

/******** END *********/

Signature · 3 lines
Sébastien BOMBAL - IDEALX
Ingénieur Développeur
EPITA - SRS.