Skip to contentSkip to conversation

ipv4 -- proc_net_fops_create

PATCH In review Stephen Hemminger 3 participants 5 messages Sep 11, 2003 – Sep 13, 2003 1 message not in the archive

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

PATCH 1/1 ipv4 -- proc_net_fops_create

Use proc_net_fops_create it is cleaner.

net/ipv4/proc.c +3 -11
diff -Nru a/net/ipv4/proc.c b/net/ipv4/proc.c
@@ -240,20 +240,12 @@
 	int rc = 0;
 	struct proc_dir_entry *p;
 
-	p = create_proc_entry("netstat", S_IRUGO, proc_net);
-	if (!p)
+	if (!proc_net_fops_create("netstat", S_IRUGO, &netstat_seq_fops))
 		goto out_netstat;
-	p->proc_fops = &netstat_seq_fops;
-
-	p = create_proc_entry("snmp", S_IRUGO, proc_net);
-	if (!p)
+	if (!proc_net_fops_create("snmp", S_IRUGO, &snmp_seq_fops))
 		goto out_snmp;
-	p->proc_fops = &snmp_seq_fops;
-
-	p = create_proc_entry("sockstat", S_IRUGO, proc_net);
-	if (!p)
+	if (!proc_net_fops_create("sockstat", S_IRUGO, &sockstat_seq_fops))
 		goto out_sockstat;
-	p->proc_fops = &sockstat_seq_fops;
 out:
 	return rc;
 out_sockstat:
#2 lore raw
Quoted 2 lines · On Fri, 12 Sep 2003 07:50:03 +0900 (JST) YOSHIFUJI Hideaki / _$B5HF#1QL@…

I sent this kind of patch for net/{core,ipv4,ipv6} to David / netdev on 8th Sep. David?

I'm heavily backlogged and haven't been able to apply any patches. Sorry. I'll try to do some today.

#4 lore raw

PATCH 1/1 proc_net macro's for non-proc-fs case

In reply to a message not in the archive

The following should work better. They have the desired properties that:
- return value makes sense for those that might check
- arguments fops and info don't have to be defined (ie can be #ifdef'd out)
- generate no warnings for null effect.

include/linux/proc_fs.h +4 -3
diff -Nru a/include/linux/proc_fs.h b/include/linux/proc_fs.h
@@ -185,9 +185,10 @@
 #else
 
 #define proc_root_driver NULL
-#define proc_net_fops_create(name,mode,fops) do {} while(0)
-static inline struct proc_dir_entry *proc_net_create(const char *name, mode_t mode, 
-	get_info_t *get_info) {return NULL;}
+#define proc_net NULL
+
+#define proc_net_fops_create(name, mode, fops)  ({ (void)(mode), NULL; })
+#define proc_net_create(name, mode, info)	({ (void)(mode), NULL; })
 static inline void proc_net_remove(const char *name) {}
 
 static inline struct dentry *proc_pid_unhash(struct task_struct *p) { return NULL; }
#5 lore raw

Re: [PATCH] proc_net macro's for non-proc-fs case

Quoted 4 lines · On Fri, 12 Sep 2003 11:21:20 -0700 Stephen Hemminger <[email protected]>…

The following should work better. They have the desired properties that:
- return value makes sense for those that might check
- arguments fops and info don't have to be defined (ie can be #ifdef'd out)
- generate no warnings for null effect.

Looks good, applied thanks.