Re: [PATCH] Allow to disable shmem.o

From: Andi Kleen
Date: Sun Aug 08 2004 - 09:29:32 EST


On Sun, Aug 08, 2004 at 09:07:05AM -0500, Matt Mackall wrote:
> +extern struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev);
> +extern struct super_block *ramfs_get_sb(struct file_system_type *fs_type,
> + int flags, const char *dev_name, void *data);
> +extern struct file_operations ramfs_file_operations;
> +extern struct vm_operations_struct generic_file_vm_ops;

This should be all in header files.

> + */
> +struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags)
> +{
> + int error;
> + struct file *file;
> + struct inode *inode;
> + struct dentry *dentry, *root;
> + struct qstr this;
> +
> + if (IS_ERR(shm_mnt))
> + return (void *)shm_mnt;

Why this strange cast?

> +
> + error = -ENOMEM;
> + this.name = name;
> + this.len = strlen(name);
> + this.hash = 0; /* will go */
> + root = shm_mnt->mnt_root;
> + dentry = d_alloc(root, &this);
> + if (!dentry)
> + goto put_memory;
> +
> + error = -ENFILE;
> + file = get_empty_filp();
> + if (!file)
> + goto put_dentry;
> +
> + error = -ENOSPC;
> + inode = ramfs_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0);

Hmm, won't this allow everybody else to open it in /proc/pid/fd/ ?
(existing shmem.c seems to use it too, but it looks a bit bogus)

-AndI
-
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/