Re: [PATCH] /dev/crypto for Linux

From: Michal Ludvig
Date: Wed Aug 25 2004 - 10:47:18 EST


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Christoph Hellwig told me that:

>>+static int
>>+clonefd(struct file *filp)
>>+{
>>+ struct files_struct * files = current->files;
>>+ int fd;
>>+
>>+ fd = get_unused_fd();
>>+ if (fd >= 0) {
>>+ get_file(filp);
>>+ FD_SET(fd, files->open_fds);
>>+ fd_install(fd, filp);
>>+ }
>>+
>>+ return fd;
>>+}
>
>
> Yikes.
>
>
>>+static int
>>+cryptodev_ioctl(struct inode *inode, struct file *filp,
>>+ unsigned int cmd, unsigned long arg)
>>+{
>>+ struct session_op sop;
>>+ struct crypt_op cop;
>>+ struct fcrypt *fcr = filp->private_data;
>>+ uint32_t ses;
>>+ int ret, fd;
>>+
>>+ if (!fcr)
>>+ BUG();
>>+
>>+ switch (cmd) {
>>+ case CRIOGET:
>>+ fd = clonefd(filp);
>>+ put_user(fd, (int*)arg);
>>+ return 0;
>
>
> Extremly bad API. Just allow opening the device multiple times,
> and get a new context each time (can be stored in file->private_data

As I already said - these are relicts from the OpenBSD API. Will be
redesigned and rewritten.

Michal Ludvig
- --
SUSE Labs mludvig@xxxxxxx
(+420) 296.542.396 http://www.suse.cz
Personal homepage http://www.logix.cz/michal
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBLLPQDDolCcRbIhgRAvglAJ48SiKsO2NymzGqsn9x8EYZSoMoMQCfWqsC
t8E+AdtAgZc9Wi2Ta0xz1bs=
=emM8
-----END PGP SIGNATURE-----
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/