mm: use non-racy method for /proc/swaps creation

Use proc_create() to make sure that ->proc_fops be setup before gluing PDE to
main tree.

Signed-off-by: Denis V. Lunev <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Denis V. Lunev 2008-04-29 01:02:13 -07:00 • committed by Linus Torvalds
commit 3d71f86f4d

View file

@ -1426,11 +1426,7 @@ static const struct file_operations proc_swaps_operations = {
static int __init procswaps_init(void)
{
struct proc_dir_entry *entry;
entry = create_proc_entry("swaps", 0, NULL);
if (entry)
entry->proc_fops = &proc_swaps_operations;
proc_create("swaps", 0, NULL, &proc_swaps_operations);
return 0;
}
__initcall(procswaps_init);