Skip to content

Commit

Permalink
[PATCH] mark struct file_operations const 7
Browse files Browse the repository at this point in the history
Many struct file_operations in the kernel can be "const".  Marking them const
moves these to the .rodata section, which avoids false sharing with potential
dirty data.  In addition it'll catch accidental writes at compile time to
these shared resources.

Signed-off-by: Arjan van de Ven <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
fenrus75 authored and Linus Torvalds committed Feb 12, 2007
1 parent 00977a5 commit 9a32144
Show file tree
Hide file tree
Showing 53 changed files with 86 additions and 86 deletions.
4 changes: 2 additions & 2 deletions ipc/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct mqueue_inode_info {
};

static struct inode_operations mqueue_dir_inode_operations;
static struct file_operations mqueue_file_operations;
static const struct file_operations mqueue_file_operations;
static struct super_operations mqueue_super_ops;
static void remove_notification(struct mqueue_inode_info *info);

Expand Down Expand Up @@ -1166,7 +1166,7 @@ static struct inode_operations mqueue_dir_inode_operations = {
.unlink = mqueue_unlink,
};

static struct file_operations mqueue_file_operations = {
static const struct file_operations mqueue_file_operations = {
.flush = mqueue_flush_file,
.poll = mqueue_poll_file,
.read = mqueue_read_file,
Expand Down
4 changes: 2 additions & 2 deletions ipc/shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

#include "util.h"

static struct file_operations shm_file_operations;
static const struct file_operations shm_file_operations;
static struct vm_operations_struct shm_vm_ops;

static struct ipc_ids init_shm_ids;
Expand Down Expand Up @@ -249,7 +249,7 @@ static int shm_release(struct inode *ino, struct file *file)
return 0;
}

static struct file_operations shm_file_operations = {
static const struct file_operations shm_file_operations = {
.mmap = shm_mmap,
.release = shm_release,
#ifndef CONFIG_MMU
Expand Down
4 changes: 2 additions & 2 deletions ipc/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void __ipc_init ipc_init_ids(struct ipc_ids* ids, int size)
}

#ifdef CONFIG_PROC_FS
static struct file_operations sysvipc_proc_fops;
static const struct file_operations sysvipc_proc_fops;
/**
* ipc_init_proc_interface - Create a proc interface for sysipc types using a seq_file interface.
* @path: Path in procfs
Expand Down Expand Up @@ -879,7 +879,7 @@ static int sysvipc_proc_release(struct inode *inode, struct file *file)
return seq_release_private(inode, file);
}

static struct file_operations sysvipc_proc_fops = {
static const struct file_operations sysvipc_proc_fops = {
.open = sysvipc_proc_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down
2 changes: 1 addition & 1 deletion kernel/cpuset.c
Original file line number Diff line number Diff line change
Expand Up @@ -2656,7 +2656,7 @@ static int cpuset_open(struct inode *inode, struct file *file)
return single_open(file, proc_cpuset_show, pid);
}

struct file_operations proc_cpuset_operations = {
const struct file_operations proc_cpuset_operations = {
.open = cpuset_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down
2 changes: 1 addition & 1 deletion net/802/tr.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ static int rif_seq_open(struct inode *inode, struct file *file)
return seq_open(file, &rif_seq_ops);
}

static struct file_operations rif_seq_fops = {
static const struct file_operations rif_seq_fops = {
.owner = THIS_MODULE,
.open = rif_seq_open,
.read = seq_read,
Expand Down
4 changes: 2 additions & 2 deletions net/8021q/vlanproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static int vlan_seq_open(struct inode *inode, struct file *file)
return seq_open(file, &vlan_seq_ops);
}

static struct file_operations vlan_fops = {
static const struct file_operations vlan_fops = {
.owner = THIS_MODULE,
.open = vlan_seq_open,
.read = seq_read,
Expand All @@ -98,7 +98,7 @@ static int vlandev_seq_open(struct inode *inode, struct file *file)
return single_open(file, vlandev_seq_show, PDE(inode)->data);
}

static struct file_operations vlandev_fops = {
static const struct file_operations vlandev_fops = {
.owner = THIS_MODULE,
.open = vlandev_seq_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/appletalk/aarp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ static int aarp_seq_open(struct inode *inode, struct file *file)
goto out;
}

struct file_operations atalk_seq_arp_fops = {
const struct file_operations atalk_seq_arp_fops = {
.owner = THIS_MODULE,
.open = aarp_seq_open,
.read = seq_read,
Expand Down
6 changes: 3 additions & 3 deletions net/appletalk/atalk_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,23 +240,23 @@ static int atalk_seq_socket_open(struct inode *inode, struct file *file)
return seq_open(file, &atalk_seq_socket_ops);
}

static struct file_operations atalk_seq_interface_fops = {
static const struct file_operations atalk_seq_interface_fops = {
.owner = THIS_MODULE,
.open = atalk_seq_interface_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

static struct file_operations atalk_seq_route_fops = {
static const struct file_operations atalk_seq_route_fops = {
.owner = THIS_MODULE,
.open = atalk_seq_route_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

static struct file_operations atalk_seq_socket_fops = {
static const struct file_operations atalk_seq_socket_fops = {
.owner = THIS_MODULE,
.open = atalk_seq_socket_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/atm/br2684.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ static int br2684_proc_open(struct inode *inode, struct file *file)
return seq_open(file, &br2684_seq_ops);
}

static struct file_operations br2684_proc_ops = {
static const struct file_operations br2684_proc_ops = {
.owner = THIS_MODULE,
.open = br2684_proc_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/atm/clip.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ static int arp_seq_open(struct inode *inode, struct file *file)
goto out;
}

static struct file_operations arp_seq_fops = {
static const struct file_operations arp_seq_fops = {
.open = arp_seq_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down
2 changes: 1 addition & 1 deletion net/atm/lec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ static int lec_seq_release(struct inode *inode, struct file *file)
return seq_release_private(inode, file);
}

static struct file_operations lec_seq_fops = {
static const struct file_operations lec_seq_fops = {
.owner = THIS_MODULE,
.open = lec_seq_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/atm/mpoa_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static int parse_qos(const char *buff);
/*
* Define allowed FILE OPERATIONS
*/
static struct file_operations mpc_file_operations = {
static const struct file_operations mpc_file_operations = {
.owner = THIS_MODULE,
.open = proc_mpc_open,
.read = seq_read,
Expand Down
12 changes: 6 additions & 6 deletions net/atm/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
static ssize_t proc_dev_atm_read(struct file *file,char __user *buf,size_t count,
loff_t *pos);

static struct file_operations proc_atm_dev_ops = {
static const struct file_operations proc_atm_dev_ops = {
.owner = THIS_MODULE,
.read = proc_dev_atm_read,
};
Expand Down Expand Up @@ -272,7 +272,7 @@ static int atm_dev_seq_open(struct inode *inode, struct file *file)
return seq_open(file, &atm_dev_seq_ops);
}

static struct file_operations devices_seq_fops = {
static const struct file_operations devices_seq_fops = {
.open = atm_dev_seq_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down Expand Up @@ -307,7 +307,7 @@ static int pvc_seq_open(struct inode *inode, struct file *file)
return __vcc_seq_open(inode, file, PF_ATMPVC, &pvc_seq_ops);
}

static struct file_operations pvc_seq_fops = {
static const struct file_operations pvc_seq_fops = {
.open = pvc_seq_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down Expand Up @@ -341,7 +341,7 @@ static int vcc_seq_open(struct inode *inode, struct file *file)
return __vcc_seq_open(inode, file, 0, &vcc_seq_ops);
}

static struct file_operations vcc_seq_fops = {
static const struct file_operations vcc_seq_fops = {
.open = vcc_seq_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down Expand Up @@ -376,7 +376,7 @@ static int svc_seq_open(struct inode *inode, struct file *file)
return __vcc_seq_open(inode, file, PF_ATMSVC, &svc_seq_ops);
}

static struct file_operations svc_seq_fops = {
static const struct file_operations svc_seq_fops = {
.open = svc_seq_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down Expand Up @@ -457,7 +457,7 @@ void atm_proc_dev_deregister(struct atm_dev *dev)

static struct atm_proc_entry {
char *name;
struct file_operations *proc_fops;
const struct file_operations *proc_fops;
struct proc_dir_entry *dirent;
} atm_proc_ents[] = {
{ .name = "devices", .proc_fops = &devices_seq_fops },
Expand Down
2 changes: 1 addition & 1 deletion net/ax25/af_ax25.c
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ static int ax25_info_open(struct inode *inode, struct file *file)
return seq_open(file, &ax25_info_seqops);
}

static struct file_operations ax25_info_fops = {
static const struct file_operations ax25_info_fops = {
.owner = THIS_MODULE,
.open = ax25_info_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/ax25/ax25_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ static int ax25_rt_info_open(struct inode *inode, struct file *file)
return seq_open(file, &ax25_rt_seqops);
}

struct file_operations ax25_route_fops = {
const struct file_operations ax25_route_fops = {
.owner = THIS_MODULE,
.open = ax25_rt_info_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/ax25/ax25_uid.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ static int ax25_uid_info_open(struct inode *inode, struct file *file)
return seq_open(file, &ax25_uid_seqops);
}

struct file_operations ax25_uid_fops = {
const struct file_operations ax25_uid_fops = {
.owner = THIS_MODULE,
.open = ax25_uid_info_open,
.read = seq_read,
Expand Down
4 changes: 2 additions & 2 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2200,7 +2200,7 @@ static int dev_seq_open(struct inode *inode, struct file *file)
return seq_open(file, &dev_seq_ops);
}

static struct file_operations dev_seq_fops = {
static const struct file_operations dev_seq_fops = {
.owner = THIS_MODULE,
.open = dev_seq_open,
.read = seq_read,
Expand All @@ -2220,7 +2220,7 @@ static int softnet_seq_open(struct inode *inode, struct file *file)
return seq_open(file, &softnet_seq_ops);
}

static struct file_operations softnet_seq_fops = {
static const struct file_operations softnet_seq_fops = {
.owner = THIS_MODULE,
.open = softnet_seq_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/core/dev_mcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ static int dev_mc_seq_open(struct inode *inode, struct file *file)
return seq_open(file, &dev_mc_seq_ops);
}

static struct file_operations dev_mc_seq_fops = {
static const struct file_operations dev_mc_seq_fops = {
.owner = THIS_MODULE,
.open = dev_mc_seq_open,
.read = seq_read,
Expand Down
4 changes: 2 additions & 2 deletions net/core/neighbour.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev);

static struct neigh_table *neigh_tables;
#ifdef CONFIG_PROC_FS
static struct file_operations neigh_stat_seq_fops;
static const struct file_operations neigh_stat_seq_fops;
#endif

/*
Expand Down Expand Up @@ -2403,7 +2403,7 @@ static int neigh_stat_seq_open(struct inode *inode, struct file *file)
return ret;
};

static struct file_operations neigh_stat_seq_fops = {
static const struct file_operations neigh_stat_seq_fops = {
.owner = THIS_MODULE,
.open = neigh_stat_seq_open,
.read = seq_read,
Expand Down
6 changes: 3 additions & 3 deletions net/core/pktgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ static int pgctrl_open(struct inode *inode, struct file *file)
return single_open(file, pgctrl_show, PDE(inode)->data);
}

static struct file_operations pktgen_fops = {
static const struct file_operations pktgen_fops = {
.owner = THIS_MODULE,
.open = pgctrl_open,
.read = seq_read,
Expand Down Expand Up @@ -1672,7 +1672,7 @@ static int pktgen_if_open(struct inode *inode, struct file *file)
return single_open(file, pktgen_if_show, PDE(inode)->data);
}

static struct file_operations pktgen_if_fops = {
static const struct file_operations pktgen_if_fops = {
.owner = THIS_MODULE,
.open = pktgen_if_open,
.read = seq_read,
Expand Down Expand Up @@ -1815,7 +1815,7 @@ static int pktgen_thread_open(struct inode *inode, struct file *file)
return single_open(file, pktgen_thread_show, PDE(inode)->data);
}

static struct file_operations pktgen_thread_fops = {
static const struct file_operations pktgen_thread_fops = {
.owner = THIS_MODULE,
.open = pktgen_thread_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,7 @@ static int proto_seq_open(struct inode *inode, struct file *file)
return seq_open(file, &proto_seq_ops);
}

static struct file_operations proto_seq_fops = {
static const struct file_operations proto_seq_fops = {
.owner = THIS_MODULE,
.open = proto_seq_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/core/wireless.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ static int wireless_seq_open(struct inode *inode, struct file *file)
return seq_open(file, &wireless_seq_ops);
}

static struct file_operations wireless_seq_fops = {
static const struct file_operations wireless_seq_fops = {
.owner = THIS_MODULE,
.open = wireless_seq_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/dccp/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static ssize_t dccpprobe_read(struct file *file, char __user *buf,
return error ? error : cnt;
}

static struct file_operations dccpprobe_fops = {
static const struct file_operations dccpprobe_fops = {
.owner = THIS_MODULE,
.open = dccpprobe_open,
.read = dccpprobe_read,
Expand Down
2 changes: 1 addition & 1 deletion net/decnet/af_decnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -2331,7 +2331,7 @@ static int dn_socket_seq_open(struct inode *inode, struct file *file)
goto out;
}

static struct file_operations dn_socket_seq_fops = {
static const struct file_operations dn_socket_seq_fops = {
.owner = THIS_MODULE,
.open = dn_socket_seq_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/decnet/dn_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ static int dn_dev_seq_open(struct inode *inode, struct file *file)
return seq_open(file, &dn_dev_seq_ops);
}

static struct file_operations dn_dev_seq_fops = {
static const struct file_operations dn_dev_seq_fops = {
.owner = THIS_MODULE,
.open = dn_dev_seq_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/decnet/dn_neigh.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ static int dn_neigh_seq_open(struct inode *inode, struct file *file)
goto out;
}

static struct file_operations dn_neigh_seq_fops = {
static const struct file_operations dn_neigh_seq_fops = {
.owner = THIS_MODULE,
.open = dn_neigh_seq_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/decnet/dn_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ static int dn_rt_cache_seq_open(struct inode *inode, struct file *file)
goto out;
}

static struct file_operations dn_rt_cache_seq_fops = {
static const struct file_operations dn_rt_cache_seq_fops = {
.owner = THIS_MODULE,
.open = dn_rt_cache_seq_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/arp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ static int arp_seq_open(struct inode *inode, struct file *file)
goto out;
}

static struct file_operations arp_seq_fops = {
static const struct file_operations arp_seq_fops = {
.owner = THIS_MODULE,
.open = arp_seq_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/fib_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ static int fib_seq_open(struct inode *inode, struct file *file)
goto out;
}

static struct file_operations fib_seq_fops = {
static const struct file_operations fib_seq_fops = {
.owner = THIS_MODULE,
.open = fib_seq_open,
.read = seq_read,
Expand Down
Loading

0 comments on commit 9a32144

Please sign in to comment.