missing get_empty_inode()

Ralf Oehler (R.Oehler@GDAmbH.com)
Fri, 09 May 2003 11:27:03 +0200 (MEST)


This message is in MIME format
--_=XFMail.1.5.0.Linux:20030509112703:13450=_
Content-Type: text/plain; charset=iso-8859-1

Hello, list

Currently I'm porting my driver sources from 2.4.18 to 2.4.20 an I noticed
the absence of get_empty_inode().
I didn't find an exported function to get a sb-less inode.
My goal is to open sd- and an sg- devices in order to do
ioctl(send_scsi_cmd) on them. As my driver acts as a block device driver
(layered pseudo block device), there is no sb assigned to it.

What is, according to the current philosophy, the cleanest code-sniplet to

- open
- ioctl
- close

an sd-device ?
an sg-device ?

Currently (2.4.18), I do it like

open-sd:
dummy_inode = get_empty_inode();
init_special_inode( dummy_inode,
S_IFBLK | 0600,
kdev );
dummy_inode->i_bdev = bdev;
dummy_inode->i_dev = dummy_inode->i_rdev;
insert_inode_hash(dummy_inode);

close-sd:
def_blk_fops.release(dummy_inode, &dummy_filp);

ioctl-sd:
ioctl_by_bdev(dummy_inode->i_bdev, cmd, arg);

open-sg:
dummy_inode = get_empty_inode();
init_special_inode( dummy_inode,
S_IFCHR | 0600,
kdev );
dummy_inode->i_dev = dummy_inode->i_rdev;
dummy_dentry.d_inode = dummy_inode;
ret = init_private_file( dummy_file,
dummy_dentry,
FMODE_READ|FMODE_WRITE ); /* calls open() */
insert_inode_hash(dummy_inode);

close-sg:
dummy_file->f_op->release(dummy_inode, dummy_file);
fops_put(filp->f_op);
filp->f_dentry = NULL;
dummy_inode->i_state |= I_FREEING;
clear_inode(dummy_inode);
dummy_inode = NULL;

ioctl-sg:
filp->f_op->ioctl( dummy_inode, filp, cmd, arg );

Regards,
Ralf

--
 --------------------------------------------------------------------------
|  Ralf Oehler                          
|                                       
|  GDA - Gesellschaft fuer Digitale                              _/
|        Archivierungstechnik mbH & CoKG                        _/
|  Ein Unternehmen der Bechtle AG               #/_/_/_/ _/_/_/_/ _/_/_/_/
|                                              _/    _/ _/    _/       _/
|  E-Mail:      R.Oehler@GDAmbH.com           _/    _/ _/    _/ _/    _/
|  Tel.:        +49 6182-9271-23             _/_/_/_/ _/_/_/#/ _/_/_/#/
|  Fax.:        +49 6182-25035                    _/
|  Mail:        GDA, Bensbruchstra_e 11,   _/_/_/_/
|               D-63533 Mainhausen      
|  HTTP:        www.GDAmbH.com         
 --------------------------------------------------------------------------

time is a funny concept

--_=XFMail.1.5.0.Linux:20030509112703:13450=_ Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org

iD8DBQE+u3RmxdAnPawJED4RAjUuAJ9rZyinuMQRrI0PV05LFI+E7U2PgwCdG1wE mAhzbI9s1ptg4d3ZWzDNDCk= =yphs -----END PGP SIGNATURE-----

--_=XFMail.1.5.0.Linux:20030509112703:13450=_-- End of MIME message - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/