Skip to contentSkip to conversation

convert /proc/swaps to seq_file

PATCH New Randy.Dunlap 1 participant 1 message Oct 24, 2002

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 convert /proc/swaps to seq_file

This patch to 2.5.44 make /proc/swaps use seq_file.

Question: is any locking needed here?
The previous code didn't use any locking.

Any other feedback on it?

Thanks,
~Randy
~~~

fs/proc/proc_misc.c renamed from fs/proc/proc_misc.c.swaps +13 -8
@@ -295,6 +295,18 @@
 	.release	= seq_release,
 };
 
+extern struct seq_operations swaps_op;
+static int swaps_open(struct inode *inode, struct file *file)
+{
+	return seq_open(file, &swaps_op);
+}
+static struct file_operations proc_swaps_operations = {
+	.open		= swaps_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= seq_release,
+};
+
 #ifdef CONFIG_MODULES
 extern struct seq_operations modules_op;
 static int modules_open(struct inode *inode, struct file *file)
@@ -503,13 +515,6 @@
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
-static int swaps_read_proc(char *page, char **start, off_t off,
-				 int count, int *eof, void *data)
-{
-	int len = get_swaparea_info(page);
-	return proc_calc_metrics(page, start, off, count, eof, len);
-}
-
 static int memory_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
 {
@@ -616,7 +621,6 @@
 		{"rtc",		ds1286_read_proc},
 #endif
 		{"locks",	locks_read_proc},
-		{"swaps",	swaps_read_proc},
 		{"iomem",	memory_read_proc},
 		{"execdomains",	execdomains_read_proc},
 		{NULL,}
@@ -632,6 +636,7 @@
 		entry->proc_fops = &proc_kmsg_operations;
 	create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations);
 	create_seq_entry("partitions", 0, &proc_partitions_operations);
+	create_seq_entry("swaps", 0, &proc_swaps_operations);
 #if !defined(CONFIG_ARCH_S390)
 	create_seq_entry("interrupts", 0, &proc_interrupts_operations);
 #endif
mm/swapfile.c renamed from mm/swapfile.c.swaps +73 -28

124 lines not on this page · raw message